]> git.ipfire.org Git - thirdparty/make.git/commitdiff
Clean up expand.c
authorPaul Smith <psmith@gnu.org>
Sat, 25 Mar 2023 21:53:19 +0000 (17:53 -0400)
committerPaul Smith <psmith@gnu.org>
Sun, 26 Mar 2023 20:48:48 +0000 (16:48 -0400)
Clarify the naming and documentation on functions in src/expand.c:
- variable_expand -> expand_string
- variable_expand_string -> expand_string_buf
- variable_expand_for_file -> expand_string_for_file
- allocated_variable_expand -> allocated_expand_string
- allocated_variable_expand_for_file ->
  allocated_expand_string_for_file
Change all callers to use the new names.

* src/variable.h: Rename the functions and macros.
* src/expand.c: Ditto.
* src/file.c: Use the new function names.
* src/function.c: Ditto.
* src/implicit.c: Ditto.
* src/job.c: Ditto.
* src/loadapi.c: Ditto.
* src/main.c: Ditto.
* src/read.c: Ditto.
* src/remake.c: Ditto.
* src/variable.c: Ditto.
* src/vpath.c: Ditto.
* src/w32/subproc/sub_proc.c: Ditto.

14 files changed:
src/expand.c
src/file.c
src/function.c
src/implicit.c
src/job.c
src/loadapi.c
src/main.c
src/makeint.h
src/read.c
src/remake.c
src/variable.c
src/variable.h
src/vpath.c
src/w32/subproc/sub_proc.c

index b2d5074894b90d63fe70ca858da9c85e34e11408..25c711535f927c1ad6b11d3fe30c99e7173ec194 100644 (file)
@@ -207,7 +207,7 @@ recursively_expand_for_file (struct variable *v, struct file *file)
   if (v->append)
     value = allocated_variable_append (v);
   else
-    value = allocated_variable_expand (v->value);
+    value = allocated_expand_string (v->value);
   v->expanding = 0;
 
   if (set_reading)
@@ -252,16 +252,17 @@ reference_variable (char *o, const char *name, size_t length)
 }
 \f
 /* Scan STRING for variable references and expansion-function calls.  Only
-   LENGTH bytes of STRING are actually scanned.  If LENGTH is -1, scan until
-   a null byte is found.
+   LENGTH bytes of STRING are actually scanned.
+   If LENGTH is SIZE_MAX, scan until a null byte is found.
 
-   Write the results to LINE, which must point into 'variable_buffer'.  If
-   LINE is NULL, start at the beginning of the buffer.
-   Return a pointer to LINE, or to the beginning of the buffer if LINE is
+   Write the results to BUF, which must point into 'variable_buffer'.  If
+   BUF is NULL, start at the beginning of the current 'variable_buffer'.
+
+   Return a pointer to BUF, or to the beginning of the new buffer if BUF is
    NULL.
  */
 char *
-variable_expand_string (char *line, const char *string, size_t length)
+expand_string_buf (char *buf, const char *string, size_t length)
 {
   struct variable *v;
   const char *p, *p1;
@@ -269,10 +270,10 @@ variable_expand_string (char *line, const char *string, size_t length)
   char *o;
   size_t line_offset;
 
-  if (!line)
-    line = initialize_variable_output ();
-  o = line;
-  line_offset = line - variable_buffer;
+  if (!buf)
+    buf = initialize_variable_output ();
+  o = buf;
+  line_offset = buf - variable_buffer;
 
   if (length == 0)
     return variable_buffer;
@@ -472,17 +473,7 @@ variable_expand_string (char *line, const char *string, size_t length)
   return (variable_buffer + line_offset);
 }
 \f
-/* Scan LINE for variable references and expansion-function calls.
-   Build in 'variable_buffer' the result of expanding the references and calls.
-   Return the address of the resulting string, which is null-terminated
-   and is valid only until the next time this function is called.  */
 
-char *
-variable_expand (const char *line)
-{
-  return variable_expand_string (NULL, line, SIZE_MAX);
-}
-\f
 /* Expand an argument for an expansion function.
    The text starting at STR and ending at END is variable-expanded
    into a null-terminated string that is returned as the value.
@@ -499,7 +490,7 @@ expand_argument (const char *str, const char *end)
     return xstrdup ("");
 
   if (!end || *end == '\0')
-    return allocated_variable_expand (str);
+    return allocated_expand_string (str);
 
   if (end - str + 1 > 1000)
     tmp = alloc = xmalloc (end - str + 1);
@@ -509,25 +500,27 @@ expand_argument (const char *str, const char *end)
   memcpy (tmp, str, end - str);
   tmp[end - str] = '\0';
 
-  r = allocated_variable_expand (tmp);
+  r = allocated_expand_string (tmp);
 
   free (alloc);
 
   return r;
 }
 \f
-/* Expand LINE for FILE.  Error messages refer to the file and line where
-   FILE's commands were found.  Expansion uses FILE's variable set list.  */
+
+/* Expand STRING for FILE, into the current variable_buffer.
+   Error messages refer to the file and line where FILE's commands were found.
+   Expansion uses FILE's variable set list.  */
 
 char *
-variable_expand_for_file (const char *line, struct file *file)
+expand_string_for_file (const char *string, struct file *file)
 {
   char *result;
   struct variable_set_list *savev;
   const floc *savef;
 
-  if (file == 0)
-    return variable_expand (line);
+  if (!file)
+    return expand_string (string);
 
   savev = current_variable_set_list;
   current_variable_set_list = file->variables;
@@ -536,17 +529,32 @@ variable_expand_for_file (const char *line, struct file *file)
   if (file->cmds && file->cmds->fileinfo.filenm)
     reading_file = &file->cmds->fileinfo;
   else
-    reading_file = 0;
+    reading_file = NULL;
 
-  result = variable_expand (line);
+  result = expand_string (string);
 
   current_variable_set_list = savev;
   reading_file = savef;
 
   return result;
 }
+
+/* Like expand_string_for_file, but the returned string is malloc'd.  */
+
+char *
+allocated_expand_string_for_file (const char *string, struct file *file)
+{
+  char *obuf;
+  size_t olen;
+
+  install_variable_buffer (&obuf, &olen);
+
+  expand_string_for_file (string, file);
+
+  return swap_variable_buffer (obuf, olen);
+}
 \f
-/* Like allocated_variable_expand, but for += target-specific variables.
+/* Like allocated_expand_string, but for += target-specific variables.
    First recursively construct the variable value from its appended parts in
    any upper variable sets.  Then expand the resulting value.  */
 
@@ -588,7 +596,7 @@ variable_append (const char *name, size_t length,
   if (! v->recursive)
     return variable_buffer_output (buf, v->value, strlen (v->value));
 
-  buf = variable_expand_string (buf, v->value, strlen (v->value));
+  buf = expand_string_buf (buf, v->value, strlen (v->value));
   return (buf + strlen (buf));
 }
 
@@ -606,19 +614,3 @@ allocated_variable_append (const struct variable *v)
 
   return swap_variable_buffer (obuf, olen);
 }
-
-/* Like variable_expand_for_file, but the returned string is malloc'd.
-   This function is called a lot.  It wants to be efficient.  */
-
-char *
-allocated_variable_expand_for_file (const char *line, struct file *file)
-{
-  char *obuf;
-  size_t olen;
-
-  install_variable_buffer (&obuf, &olen);
-
-  variable_expand_for_file (line, file);
-
-  return swap_variable_buffer (obuf, olen);
-}
index 510f7d4a6eaa20aaf7b03d3be09ae182f86d2f3a..9828d2837e34d2c845b2c6d51ded2f58cf87f87b 100644 (file)
@@ -636,7 +636,7 @@ expand_deps (struct file *f)
       set_file_variables (f, d->stem ? d->stem : f->stem);
 
       /* Perform second expansion.  */
-      p = variable_expand_for_file (d->name, f);
+      p = expand_string_for_file (d->name, f);
 
       /* Free the un-expanded name.  */
       free ((char*)d->name);
@@ -688,7 +688,7 @@ struct dep *
 expand_extra_prereqs (const struct variable *extra)
 {
   struct dep *d;
-  struct dep *prereqs = extra ? split_prereqs (variable_expand (extra->value)) : NULL;
+  struct dep *prereqs = extra ? split_prereqs (expand_string (extra->value)) : NULL;
 
   for (d = prereqs; d; d = d->next)
     {
index 62b13f52dbf00959debe6d285197637aa7294085..8f46ec60dd4e9c903b5a81ac8a20e71df3fdcf23 100644 (file)
@@ -885,7 +885,7 @@ func_foreach (char *o, char **argv, const char *funcname UNUSED)
       free (var->value);
       var->value = xstrndup (p, len);
 
-      result = allocated_variable_expand (body);
+      result = allocated_expand_string (body);
 
       o = variable_buffer_output (o, result, strlen (result));
       o = variable_buffer_output (o, " ", 1);
@@ -945,7 +945,7 @@ func_let (char *o, char **argv, const char *funcname UNUSED)
   /* Expand the body in the context of the arguments, adding the result to
      the variable buffer.  */
 
-  o = variable_expand_string (o, body, SIZE_MAX);
+  o = expand_string_buf (o, body, SIZE_MAX);
 
   pop_variable_scope ();
   free (varnames);
@@ -2690,7 +2690,7 @@ func_call (char *o, char **argv, const char *funcname UNUSED)
 
   saved_args = max_args;
   max_args = i;
-  o = variable_expand_string (o, body, flen+3);
+  o = expand_string_buf (o, body, flen+3);
   max_args = saved_args;
 
   v->exp_count = 0;
index c40a50f4a5a58805c38eae845d597cf525570a1e..cd7445fdb32bfa53fce3ad8f475e36ddd32c30e3 100644 (file)
@@ -706,7 +706,7 @@ pattern_search (struct file *file, int archive,
                     }
 
                   /* Perform the 2nd expansion.  */
-                  p = variable_expand_for_file (depname, file);
+                  p = expand_string_for_file (depname, file);
                   dptr = &dl;
 
                   /* Parse the results into a deps list.  */
index 9cbdd2be979827b9de3869269d1cce4b9708da68..c7313fdb6562793f5e67b610042a2b123da5fa6f 100644 (file)
--- a/src/job.c
+++ b/src/job.c
@@ -1782,8 +1782,8 @@ new_job (struct file *file)
 
       /* Finally, expand the line.  */
       cmds->fileinfo.offset = i;
-      lines[i] = allocated_variable_expand_for_file (cmds->command_lines[i],
-                                                     file);
+      lines[i] = allocated_expand_string_for_file (cmds->command_lines[i],
+                                                   file);
     }
 
   cmds->fileinfo.offset = 0;
@@ -1882,7 +1882,7 @@ new_job (struct file *file)
              nm, c->file->name);
       else
         {
-          char *newer = allocated_variable_expand_for_file ("$?", c->file);
+          char *newer = allocated_expand_string_for_file ("$?", c->file);
           if (newer[0] != '\0')
             {
               OSSS (message, 0, _("%s: update target '%s' due to: %s"),
@@ -3637,7 +3637,7 @@ construct_command_argv (char *line, char **restp, struct file *file,
     int save = warn_undefined_variables_flag;
     warn_undefined_variables_flag = 0;
 
-    shell = allocated_variable_expand_for_file ("$(SHELL)", file);
+    shell = allocated_expand_string_for_file ("$(SHELL)", file);
 #if MK_OS_W32
     /*
      * Convert to forward slashes so that construct_command_argv_internal()
@@ -3700,9 +3700,9 @@ construct_command_argv (char *line, char **restp, struct file *file,
       /* In POSIX mode we default to -ec, unless we're ignoring errors.  */
       shellflags = xstrdup (ANY_SET (cmd_flags, COMMANDS_NOERROR) ? "-c" : "-ec");
     else
-      shellflags = allocated_variable_expand_for_file (var->value, file);
+      shellflags = allocated_expand_string_for_file (var->value, file);
 
-    ifs = allocated_variable_expand_for_file ("$(IFS)", file);
+    ifs = allocated_expand_string_for_file ("$(IFS)", file);
 
     warn_undefined_variables_flag = save;
   }
index 06277668ef10e4d37d1375e57c19a7d946da589d..6e9611db489afbc7e4c505b8ef13e300487cedf7 100644 (file)
@@ -70,7 +70,7 @@ gmk_eval (const char *buffer, const gmk_floc *gfloc)
 char *
 gmk_expand (const char *ref)
 {
-  return allocated_variable_expand (ref);
+  return allocated_expand_string (ref);
 }
 
 /* Register a function to be called from makefiles.  */
index c673cb70ba12eb31d680d79e36e2ebde5b3c0e0d..86497e70944f66944ef523ee4d429055c377bbb0 100644 (file)
@@ -179,6 +179,10 @@ int question_flag = 0;
 int no_builtin_rules_flag = 0;
 int no_builtin_variables_flag = 0;
 
+/* Nonzero means all variables are automatically exported.  */
+
+int export_all_variables = 0;
+
 /* Nonzero means keep going even if remaking some file fails (-k).  */
 
 int keep_going_flag;
@@ -2797,7 +2801,7 @@ main (int argc, char **argv, char **envp)
       char *p;
 
       if (default_goal_var->recursive)
-        p = variable_expand (default_goal_var->value);
+        p = expand_string (default_goal_var->value);
       else
         {
           p = variable_buffer_output (variable_buffer, default_goal_var->value,
@@ -3336,7 +3340,7 @@ decode_env_switches (const char *envar, size_t len, enum variable_origin origin)
   p = mempcpy (p, envar, len);
   *(p++) = ')';
   *p = '\0';
-  value = variable_expand (varref);
+  value = expand_string (varref);
 
   /* Skip whitespace, and check for an empty value.  */
   NEXT_TOKEN (value);
index edac5ba25e8e34aed67c2e3c49c62b5aa3e10847..00f72190604dc40cab32fee1d711baaeadd3dc5c 100644 (file)
@@ -738,7 +738,7 @@ extern unsigned short stopchar_map[];
 extern int just_print_flag, run_silent, ignore_errors_flag, keep_going_flag;
 extern int print_data_base_flag, question_flag, touch_flag, always_make_flag;
 extern int env_overrides, no_builtin_rules_flag, no_builtin_variables_flag;
-extern int print_version_flag, check_symlink_flag;
+extern int print_version_flag, check_symlink_flag, export_all_variables;
 extern int warn_undefined_variables_flag, posix_pedantic;
 extern int not_parallel, second_expansion, clock_skew_detected;
 extern int rebuilding_makefiles, one_shell, output_sync, verify_flag;
@@ -752,6 +752,9 @@ extern int batch_mode_shell;
 #define GNUMAKEFLAGS_NAME       "GNUMAKEFLAGS"
 #define MAKEFLAGS_NAME          "MAKEFLAGS"
 
+#define MAKELEVEL_NAME "MAKELEVEL"
+#define MAKELEVEL_LENGTH (CSTRLEN (MAKELEVEL_NAME))
+
 /* Resetting the command script introduction prefix character.  */
 #define RECIPEPREFIX_NAME       ".RECIPEPREFIX"
 #define RECIPEPREFIX_DEFAULT    '\t'
index a8539c3e796c8e3b4a68950b67b1f922f345d0c2..14f9dcee4294728d1745fcdf59ab5b2416a3c4f8 100644 (file)
@@ -186,7 +186,7 @@ read_all_makefiles (const char **makefiles)
     char *name, *p;
     size_t length;
 
-    value = allocated_variable_expand ("$(MAKEFILES)");
+    value = allocated_expand_string ("$(MAKEFILES)");
 
     /* Set NAME to the start of next token and LENGTH to its length.
        MAKEFILES is updated for finding remaining tokens.  */
@@ -807,7 +807,7 @@ eval (struct ebuffer *ebuf, int set_default)
 
               /* Expand the line so we can use indirect and constructed
                  variable names in an (un)export command.  */
-              cp = ap = allocated_variable_expand (p2);
+              cp = ap = allocated_expand_string (p2);
 
               for (p = find_next_token (&cp, &l); p != 0;
                    p = find_next_token (&cp, &l))
@@ -833,7 +833,7 @@ eval (struct ebuffer *ebuf, int set_default)
           /* vpath ends the previous rule.  */
           record_waiting_files ();
 
-          cp = variable_expand (p2);
+          cp = expand_string (p2);
           p = find_next_token (&cp, &l);
           if (p != 0)
             {
@@ -866,7 +866,7 @@ eval (struct ebuffer *ebuf, int set_default)
           /* Include ends the previous rule.  */
           record_waiting_files ();
 
-          p = allocated_variable_expand (p2);
+          p = allocated_expand_string (p2);
 
           /* If no filenames, it's a no-op.  */
           if (*p == '\0')
@@ -920,7 +920,7 @@ eval (struct ebuffer *ebuf, int set_default)
           /* Load ends the previous rule.  */
           record_waiting_files ();
 
-          p = allocated_variable_expand (p2);
+          p = allocated_expand_string (p2);
 
           /* If no filenames, it's a no-op.  */
           if (*p == '\0')
@@ -1052,7 +1052,7 @@ eval (struct ebuffer *ebuf, int set_default)
             break;
           }
 
-        p2 = variable_expand_string (NULL, lb_next, wlen);
+        p2 = expand_string_buf (NULL, lb_next, wlen);
 
         while (1)
           {
@@ -1080,7 +1080,7 @@ eval (struct ebuffer *ebuf, int set_default)
                        entirely consistent, since we do an unconditional
                        expand below once we know we don't have a
                        target-specific variable. */
-                    variable_expand_string (pend, lb_next, SIZE_MAX);
+                    expand_string_buf (pend, lb_next, SIZE_MAX);
                     lb_next += strlen (lb_next);
                     p2 = variable_buffer + p2_off;
                     cmdleft = variable_buffer + cmd_off + 1;
@@ -1116,7 +1116,7 @@ eval (struct ebuffer *ebuf, int set_default)
 
             p2 += strlen (p2);
             *(p2++) = ' ';
-            p2 = variable_expand_string (p2, lb_next, wlen);
+            p2 = expand_string_buf (p2, lb_next, wlen);
             /* We don't need to worry about cmdleft here, because if it was
                found in the variable_buffer the entire buffer has already
                been expanded... we'll never get here.  */
@@ -1228,7 +1228,7 @@ eval (struct ebuffer *ebuf, int set_default)
         if (*lb_next != '\0')
           {
             size_t l = p2 - variable_buffer;
-            variable_expand_string (p2 + plen, lb_next, SIZE_MAX);
+            expand_string_buf (p2 + plen, lb_next, SIZE_MAX);
             p2 = variable_buffer + l;
 
             /* Look for a semicolon in the expanded line.  */
@@ -1359,7 +1359,7 @@ do_undefine (char *name, enum variable_origin origin, struct ebuffer *ebuf)
   char *p, *var;
 
   /* Expand the variable name and find the beginning (NAME) and end.  */
-  var = allocated_variable_expand (name);
+  var = allocated_expand_string (name);
   name = next_token (var);
   if (*name == '\0')
     O (fatal, &ebuf->floc, _("empty variable name"));
@@ -1404,7 +1404,7 @@ do_define (char *name, enum variable_origin origin, struct ebuffer *ebuf)
     }
 
   /* Expand the variable name and find the beginning (NAME) and end.  */
-  n = allocated_variable_expand (name);
+  n = allocated_expand_string (name);
   name = next_token (n);
   if (name[0] == '\0')
     O (fatal, &defstart, _("empty variable name"));
@@ -1637,7 +1637,7 @@ conditional_line (char *line, size_t len, const floc *flocp)
 
       /* Expand the thing we're looking up, so we can use indirect and
          constructed variable names.  */
-      var = allocated_variable_expand (line);
+      var = allocated_expand_string (line);
 
       /* Make sure there's only one variable name to test.  */
       p = end_of_token (var);
@@ -1695,9 +1695,9 @@ conditional_line (char *line, size_t len, const floc *flocp)
       else
         *line++ = '\0';
 
-      s2 = variable_expand (s1);
+      s2 = expand_string (s1);
       /* We must allocate a new copy of the expanded string because
-         variable_expand re-uses the same buffer.  */
+         expand_string re-uses the same buffer.  */
       l = strlen (s2);
       s1 = alloca (l + 1);
       memcpy (s1, s2, l + 1);
@@ -1744,7 +1744,7 @@ conditional_line (char *line, size_t len, const floc *flocp)
       if (*line != '\0')
         EXTRATEXT ();
 
-      s2 = variable_expand (s2);
+      s2 = expand_string (s2);
       conditionals->ignoring[o] = (streq (s1, s2) == (cmdtype == c_ifneq));
     }
 
@@ -1804,7 +1804,7 @@ record_target_var (struct nameseq *filenames, char *defn,
 
           v->origin = origin;
           if (v->flavor == f_simple)
-            v->value = allocated_variable_expand (v->value);
+            v->value = allocated_expand_string (v->value);
           else
             v->value = xstrdup (v->value);
         }
@@ -3071,7 +3071,7 @@ tilde_expand (const char *name)
         int save = warn_undefined_variables_flag;
         warn_undefined_variables_flag = 0;
 
-        home_dir = allocated_variable_expand ("$(HOME)");
+        home_dir = allocated_expand_string ("$(HOME)");
 
         warn_undefined_variables_flag = save;
       }
index b8aaab936e449e826b61a67e9c8960771946d439..7c841f5d25e43986e651f1db5af9fc79619376d8 100644 (file)
@@ -1717,7 +1717,7 @@ library_search (const char *lib, FILE_TIMESTAMP *mtime_ptr)
 
   const char **dp;
 
-  libpatterns = xstrdup (variable_expand ("$(.LIBPATTERNS)"));
+  libpatterns = xstrdup (expand_string ("$(.LIBPATTERNS)"));
 
   /* Skip the '-l'.  */
   lib += 2;
index d472c03d32601f2c51ac783c4667361466db9daf..6d87390c2264aa0f2bb86f4b28a8cc67700eea9a 100644 (file)
@@ -1005,7 +1005,6 @@ define_automatic_variables (void)
   define_variable_cname ("+F", "$(notdir $+)", o_automatic, 1);
 }
 \f
-int export_all_variables;
 
 static int
 should_export (const struct variable *v)
@@ -1305,14 +1304,14 @@ do_variable_definition (const floc *flocp, const char *varname,
          We have to allocate memory since otherwise it'll clobber the
          variable buffer, and we may still need that if we're looking at a
          target-specific variable.  */
-      newval = alloc_value = allocated_variable_expand (value);
+      newval = alloc_value = allocated_expand_string (value);
       break;
     case f_expand:
       {
         /* A POSIX "var :::= value" assignment.  Expand the value, then it
            becomes a recursive variable.  After expansion convert all '$'
            tokens to '$$' to resolve to '$' when recursively expanded.  */
-        char *t = allocated_variable_expand (value);
+        char *t = allocated_expand_string (value);
         char *np = alloc_value = xmalloc (strlen (t) * 2 + 1);
         char *op = t;
         while (op[0] != '\0')
@@ -1330,7 +1329,7 @@ do_variable_definition (const floc *flocp, const char *varname,
       {
         /* A shell definition "var != value".  Expand value, pass it to
            the shell, and store the result in recursively-expanded var. */
-        char *q = allocated_variable_expand (value);
+        char *q = allocated_expand_string (value);
         alloc_value = shell_result (q);
         free (q);
         flavor = f_recursive;
@@ -1398,7 +1397,7 @@ do_variable_definition (const floc *flocp, const char *varname,
                  when it was set; and from the expanded new value.  Allocate
                  memory for the expansion as we may still need the rest of the
                  buffer if we're looking at a target-specific variable.  */
-              val = tp = allocated_variable_expand (val);
+              val = tp = allocated_expand_string (val);
 
             /* If the new value is empty, nothing to do.  */
             vallen = strlen (val);
@@ -1544,7 +1543,7 @@ do_variable_definition (const floc *flocp, const char *varname,
         {
           char *tp = alloc_value;
 
-          alloc_value = allocated_variable_expand (newval);
+          alloc_value = allocated_expand_string (newval);
 
           if (find_and_set_default_shell (alloc_value))
             {
@@ -1767,7 +1766,7 @@ assign_variable_definition (struct variable *v, const char *line)
   name = alloca (v->length + 1);
   memcpy (name, v->name, v->length);
   name[v->length] = '\0';
-  v->name = allocated_variable_expand (name);
+  v->name = allocated_expand_string (name);
 
   if (v->name[0] == '\0')
     O (fatal, &v->fileinfo, _("empty variable name"));
@@ -2020,7 +2019,7 @@ sync_Path_environment ()
 {
   static char *environ_path = NULL;
   char *oldpath = environ_path;
-  char *path = allocated_variable_expand ("PATH=$(PATH)");
+  char *path = allocated_expand_string ("PATH=$(PATH)");
 
   if (!path)
     return;
index 218c9964766e184d6cd3448f36fc9d5464a68c8a..195cc360f8e98588983f353bdf9e596b9f0c37dd 100644 (file)
@@ -127,15 +127,14 @@ void install_variable_buffer (char **bufp, size_t *lenp);
 void restore_variable_buffer (char *buf, size_t len);
 char *swap_variable_buffer (char *buf, size_t len);
 
-char *variable_expand_string (char *line, const char *string, size_t length);
-char *variable_expand (const char *line);
-char *variable_expand_for_file (const char *line, struct file *file);
-char *allocated_variable_expand_for_file (const char *line, struct file *file);
-#define allocated_variable_expand(line) \
-  allocated_variable_expand_for_file (line, (struct file *) 0)
+char *expand_string_buf (char *buf, const char *string, size_t length);
+#define expand_string(s) expand_string_buf (NULL, (s), SIZE_MAX)
+char *expand_string_for_file (const char *string, struct file *file);
+char *allocated_expand_string_for_file (const char *line, struct file *file);
+#define allocated_expand_string(s) allocated_expand_string_for_file ((s), NULL)
 char *expand_argument (const char *str, const char *end);
 char *recursively_expand_for_file (struct variable *v, struct file *file);
-#define recursively_expand(v)   recursively_expand_for_file (v, NULL)
+#define recursively_expand(v) recursively_expand_for_file ((v), NULL)
 
 /* function.c */
 int handle_function (char **op, const char **stringp);
@@ -232,8 +231,3 @@ char **target_environment (struct file *file, int recursive);
 
 struct pattern_var *create_pattern_var (const char *target,
                                         const char *suffix);
-
-extern int export_all_variables;
-
-#define MAKELEVEL_NAME "MAKELEVEL"
-#define MAKELEVEL_LENGTH (CSTRLEN (MAKELEVEL_NAME))
index bb3694551e63020e07790ea9d9d0a5f635b34345..873a9c94ebc01ae80c1f15a0bbf5c1f85f2784c9 100644 (file)
@@ -71,7 +71,7 @@ build_vpath_lists (void)
   /* If there is a VPATH variable with a nonnull expanded value, construct the
      general VPATH list from it.  */
 
-  p = variable_expand ("$(strip $(VPATH))");
+  p = expand_string ("$(strip $(VPATH))");
 
   if (*p != '\0')
     {
@@ -95,7 +95,7 @@ build_vpath_lists (void)
   /* If there is a GPATH variable with a nonnull expanded value, construct the
      GPATH list from it.  */
 
-  p = variable_expand ("$(strip $(GPATH))");
+  p = expand_string ("$(strip $(GPATH))");
 
   if (*p != '\0')
     {
index 4331973a249e7dc5cb1db397766ecb768da062c2..be32d9efa36cd6d1697324163057ccb999d8e72f 100644 (file)
@@ -615,7 +615,7 @@ process_begin(
                         char **argvi = argv;
                         size_t arglen = 0;
 
-                        strcpy(buf, variable_expand ("$(SHELL)"));
+                        strcpy(buf, expand_string ("$(SHELL)"));
                         shell_name = &buf[0];
                         strcpy(exec_fname, "-c");
                         /* Construct a single command string in argv[0].  */