onetrueawk / awk

One true awk
Other
1.98k stars 159 forks source link

Redundant Variable? #158

Closed ldo closed 1 year ago

ldo commented 2 years ago

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 */
millert commented 2 years ago

Agreed, there is no need for the os variable.

plan9 commented 1 year ago

removed.