onetrueawk/awk

Redundant Variable?

ldo opened this issue · 2 comments

ldo commented

In tran.c, the qstring function assigns its argument is to a local variable os which is only used in an error message report. Not sure why this is done, since is is not modified and so could be used directly.

diff --git a/tran.c b/tran.c
index c396db4..e1496cd 100644
--- a/tran.c
+++ b/tran.c
@@ -563,7 +563,6 @@ Cell *catstr(Cell *a, Cell *b) /* concatenate a and b */

 char *qstring(const char *is, int delim)   /* collect string up to next delim */
 {
-   const char *os = is;
    int c, n;
    const uschar *s = (const uschar *) is;
    uschar *buf, *bp;
@@ -572,7 +571,7 @@ char *qstring(const char *is, int delim)    /* collect string up to next delim */
        FATAL( "out of space in qstring(%s)", s);
    for (bp = buf; (c = *s) != delim; s++) {
        if (c == '\n')
-           SYNTAX( "newline in string %.20s...", os );
+           SYNTAX( "newline in string %.20s...", is );
        else if (c != '\\')
            *bp++ = c;
        else {  /* \something */

Agreed, there is no need for the os variable.

plan9 commented

removed.