tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: make: sysV subst with variables



On Thu, 2 Jun 2011 17:51:01 +0000, David Holland writes:
>Or... hmm, maybe, since we already insist that a variable reference in
>the modifier position is a complete modifier, the right answer is to
>demand that it be followed by : or }, and if it isn't, treat it as
>plain text rather than a modifier block and therefore part of a svr4
>substitution. I believe this is grammatically sound, and it solves
>your problem. It does prohibit the case

I just took a *quick* look at this...
At the expense of a goto, its not too bad...

The important tests cases work and the corner cases you mention 
(which we don't need to support) fail as expected.

Index: var.c
===================================================================
RCS file: /cvsroot/src/usr.bin/make/var.c,v
retrieving revision 1.166
diff -u -p -r1.166 var.c
--- var.c       21 May 2011 07:30:42 -0000      1.166
+++ var.c       2 Jun 2011 19:45:06 -0000
@@ -2498,14 +2498,28 @@ ApplyModifiers(char *nstr, const char *t
 
        if (*tstr == '$') {
            /*
-            * We have some complex modifiers in a variable.
+            * We may have some complex modifiers in a variable.
             */
            void *freeIt;
            char *rval;
            int rlen;
+           int c;
 
            rval = Var_Parse(tstr, ctxt, errnum, &rlen, &freeIt);
 
+           /*
+            * If we have not parsed up to endc or ':',
+            * we are not interested.
+            */
+           if (rval != NULL && *rval &&
+               (c = tstr[rlen]) != '\0' &&
+               c != ':' &&
+               c != endc) {
+               if (freeIt)
+                   free(freeIt);
+               goto apply_mods;
+           }
+
            if (DEBUG(VAR)) {
                fprintf(debug_file, "Got '%s' from '%.*s'%.*s\n",
                       rval, rlen, tstr, rlen, tstr + rlen);
@@ -2537,6 +2551,7 @@ ApplyModifiers(char *nstr, const char *t
            }
            continue;
        }
+    apply_mods:
        if (DEBUG(VAR)) {
            fprintf(debug_file, "Applying :%c to \"%s\"\n", *tstr, nstr);
        }


Home | Main Index | Thread Index | Old Index