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

Re: Bad optimisations: (Was: Test version zsh-3.1.6-test-1)



Peter Stephenson wrote:

> Sven Wischnowsky wrote:
> > Playing some more: both
> > 
> >     firstarg = (*args && **args == '?' ? *args++ : *args);
> > 
> > and
> > 
> >     if (*args && **args == '?')
> >     	firstarg = *args++;
> >     else
> >         firstarg = *args;
> > 
> > work around the bug, too. Should I send a patch for one of these? They 
> > probably keep the code better readable (although they don't look much
> > less silly).
> 
> That might look a bit neater.  You'd better send it relative to the altered
> code, so I don't have to spend all of 30 seconds backing that off.

Yup.

Bye
 Sven

--- os/builtin.c	Fri Jul 16 08:35:14 1999
+++ Src/builtin.c	Fri Jul 16 11:19:35 1999
@@ -3261,16 +3261,10 @@
 	    nchars = 1;
 	args++;
     }
-
-    firstarg = *args;
-    if (*args && **args == '?') {
-    	args++;
-	/* default result parameter */
-	reply = *args ? *args++ : ops['A'] ? "reply" : "REPLY";
-	/* (If we put this reply=... after the `if' gcc-2.8.1 under
-	   Digital Unix 4.0 generates incorrect code.) */
-    } else
-	reply = *args ? *args++ : ops['A'] ? "reply" : "REPLY";
+    /* This `*args++ : *args' looks a bit weird, but it works around a bug
+     * in gcc-2.8.1 under DU 4.0. */
+    firstarg = (*args && **args == '?' ? *args++ : *args);
+    reply = *args ? *args++ : ops['A'] ? "reply" : "REPLY";
 
     if (ops['A'] && *args) {
 	zwarnnam(name, "only one array argument allowed", NULL, 0);

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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