Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: dead code in subst_parse_str



On Jan 6,  1:55am, Mikael Magnusson wrote:
}
} If you look carefully (or at coverity), you'll notice that qt is set
} to 0 initially, and then only toggled to 1 if it is already 1, ie
} never. This is again a case of I have no idea what's happening here,
} so I'll let you guys look at it.

Hmm, looks like it should have been this:

diff --git a/Src/subst.c b/Src/subst.c
index 4100803..610d71e 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -1333,14 +1333,16 @@ subst_parse_str(char **sp, int single, int err)
 	if (!single) {
             int qt = 0;
 
-	    for (; *s; s++)
+	    for (; *s; s++) {
 		if (!qt) {
 		    if (*s == Qstring)
 			*s = String;
 		    else if (*s == Qtick)
 			*s = Tick;
-                } else if (*s == Dnull)
+                }
+		if (*s == Dnull)
                     qt = !qt;
+	    }
 	}
 	return 0;
     }


However, I have no idea in what circumstances that matters.  Obviously
it has been doing something indistinguishable from the right thing with
the dead code for a long time.

-- 
Barton E. Schaefer



Messages sorted by: Reverse Date, Date, Thread, Author