zsh-workers
 help / color / mirror / code / Atom feed
* dead code in subst_parse_str
@ 2015-01-06  0:55 Mikael Magnusson
  2015-01-06  5:25 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Mikael Magnusson @ 2015-01-06  0:55 UTC (permalink / raw)
  To: zsh workers

A while ago, this was committed,
https://sourceforge.net/p/zsh/code/ci/5fdcd3a2b468

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.

-- 
Mikael Magnusson


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: dead code in subst_parse_str
  2015-01-06  0:55 dead code in subst_parse_str Mikael Magnusson
@ 2015-01-06  5:25 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2015-01-06  5:25 UTC (permalink / raw)
  To: zsh workers

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-01-06  5:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-06  0:55 dead code in subst_parse_str Mikael Magnusson
2015-01-06  5:25 ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).