]> git.ipfire.org Git - thirdparty/make.git/commitdiff
Fix core dump on malformed variable line (Debian bug #81656)
authorPaul Smith <psmith@gnu.org>
Sat, 5 Oct 2002 13:45:47 +0000 (13:45 +0000)
committerPaul Smith <psmith@gnu.org>
Sat, 5 Oct 2002 13:45:47 +0000 (13:45 +0000)
Allow SysV-style variable references to use {} in addition to ().
Add variable.h to the POTFILES.in since it has a translatable string.

ChangeLog
expand.c
po/ChangeLog
po/POTFILES.in
read.c
tests/ChangeLog
tests/scripts/variables/automatic

index 2ca872ba3a82770f1b662327695aa018412a4a77..ee0936b936a5ccfefd90915a0824b6eedfde23da 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2002-10-04  Paul D. Smith  <psmith@gnu.org>
+
+       * read.c (eval): Allow SysV $$@ variables to use {} braces as well
+       as () braces.
+       (record_files): Ditto.
+
+       * expand.c (variable_expand_string): In $(A:x=y) expansion limit
+       the search for the '=' to only within the enclosing parens.
+
 2002-10-03  Paul D. Smith  <psmith@gnu.org>
 
        Version 3.80 released.
index 6722e1b38aa9a6a844f3555f1e3bec0104357b3f..3027f4728c28be39a496780e4af1bb035526da81 100644 (file)
--- a/expand.c
+++ b/expand.c
@@ -286,7 +286,7 @@ variable_expand_string (line, string, length)
                char *subst_beg, *subst_end, *replace_beg, *replace_end;
 
                subst_beg = colon + 1;
-               subst_end = strchr (subst_beg, '=');
+               subst_end = lindex (subst_beg, end, '=');
                if (subst_end == 0)
                  /* There is no = in sight.  Punt on the substitution
                     reference and treat this as a variable name containing
index a362db7e380b4f9eed393d551ef4c84ca1105ac4..5c5fe1d1f58b0ff9d17edca4c760b92655b99458 100644 (file)
@@ -1,3 +1,7 @@
+2002-10-05  Paul D. Smith  <psmith@gnu.org>
+
+       * POTFILES.in: Add variable.h as it has a translatable string.
+
 2002-08-08  Paul D. Smith  <psmith@gnu.org>
 
        * LINGUAS: Add a new translation for Chinese (simplified) (zh_CN).
index 3c9e849d5834bb92e27411cbb096e6b02919ff5f..30b7864b245a594b7135a1d23d23a323487260fc 100644 (file)
@@ -20,5 +20,6 @@ remote-cstms.c
 rule.c
 signame.c
 variable.c
+variable.h
 vmsfunctions.c
 vpath.c
diff --git a/read.c b/read.c
index 9a4c609dfc05fb4b8114bdd48704ed99ff87602f..07bb11a333f3713d9c4c305329accc4cfe046cb4 100644 (file)
--- a/read.c
+++ b/read.c
@@ -1081,7 +1081,7 @@ eval (ebuf, set_default)
         have_sysv_atvar = 0;
         if (!posix_pedantic)
           for (p = strchr (p2, '$'); p != 0; p = strchr (p+1, '$'))
-            if (p[1] == '@' || (p[1] == '(' && p[2] == '@'))
+            if (p[1] == '@' || ((p[1] == '(' || p[1] == '{') && p[2] == '@'))
               {
                 have_sysv_atvar = 1;
                 break;
@@ -1862,7 +1862,7 @@ record_files (filenames, pattern, pattern_percent, deps, cmds_started,
          since we're just emulating a SysV function, and if we do that then
          why not emulate it completely (that's what SysV make does: it
          re-expands the entire prerequisite list, all the time, with $@
-         etc. in scope.  But, it would be a pain indeed to document this
+         etc. in scope).  But, it would be a pain indeed to document this
          ("iff you use $$@, your prerequisite lists is expanded twice...")
          Ouch.  Maybe better to make the code more complex.  */
 
@@ -1895,20 +1895,23 @@ record_files (filenames, pattern, pattern_percent, deps, cmds_started,
                 char *at;
                 int atlen;
 
-                /* If it's a '$@' or '$(@', it's escaped */
+                /* If it's '$@', '$(@', or '${@', it's escaped */
                 if ((++p)[0] == '$'
-                    && (p[1] == '@' || (p[1] == '(' && p[2] == '@')))
+                    && (p[1] == '@'
+                        || ((p[1] == '(' || p[1] == '{') && p[2] == '@')))
                   {
                     bcopy (p, s, strlen (p)+1);
                     continue;
                   }
 
-                /* Maybe found one.  Check.  p will point to '@' [for $@] or
-                   ')' [for $(@)] or 'D' [for $(@D)] or 'F' [for $(@F)].  */
-                if (p[0] != '@'
-                    && (p[0] != '(' || (++p)[0] != '@'
-                        || ((++p)[0] != ')'
-                            && (p[1] != ')' || (p[0] != 'D' && p[0] != 'F')))))
+                /* Maybe found one.  We like anything of any form matching @,
+                   [({]@[}):], or [({]@[DF][}):].  */
+
+                if (! (p[0] == '@'
+                       || ((p[0] == '(' || p[0] == '{') && (++p)[0] == '@'
+                           && (((++p)[0] == ')' || p[0] == '}' || p[0] == ':')
+                               || ((p[1] == ')' || p[1] == '}' || p[1] == ':')
+                                   && (p[0] == 'D' || p[0] == 'F'))))))
                   continue;
 
                 /* Found one.  Compute the length and string ptr.  Move p
index 6f42eae58c5c5e73d5366f1cc8d5467657c0664a..2c399999f2da0d06d7bebc6e7299e31c213cfc74 100644 (file)
@@ -1,3 +1,8 @@
+2002-10-05  Paul D. Smith  <psmith@gnu.org>
+
+       * scripts/variables/automatic: Add tests for $$(@), $${@}, $${@D},
+       and $${@F}.
+
 2002-09-23  Paul D. Smith  <psmith@gnu.org>
 
        * scripts/features/escape: Test handling of escaped comment
index 42e8cba9834cb98f9d203194dda0207d909f7109..2919960b86cc4eee4fe13f2b596ebe381c3bf0b5 100644 (file)
@@ -60,6 +60,8 @@ print MAKEFILE <<'EOF';
 $(dir)/foo $(dir)/bar: $@.x $$@.x $$$@.x $$$$@.x $$(@D).x $$(@F).x
 
 $(dir)/x.z $(dir)/y.z: $(dir)/%.z : $@.% $$@.% $$$@.% $$$$@.% $$(@D).% $$(@F).%
+
+$(dir)/biz: $$(@).x $${@}.x $${@D}.x $${@F}.x
 EOF
 
 close(MAKEFILE);
@@ -72,4 +74,8 @@ $answer = ".x\n$dir/foo.x\n\$.x\n\$@.x\n$dir.x\nfoo.x\n$dir/bar.x\nbar.x\n";
 $answer = ".x\n$dir/x.z.x\n\$.x\n\$@.x\n$dir.x\nx.z.x\n.y\n$dir/y.z.y\n\$.y\n\$@.y\n$dir.y\ny.z.y\n";
 &compare_output($answer, &get_logfile(1));
 
+&run_make_with_options($makefile2, "$dir/biz", &get_logfile);
+$answer = "$dir/biz.x\n$dir.x\nbiz.x\n";
+&compare_output($answer, &get_logfile(1));
+
 1;