]> git.ipfire.org Git - thirdparty/make.git/commitdiff
Ensure that loaded functions increment the command count
authorPaul Smith <psmith@gnu.org>
Mon, 17 Jan 2022 22:15:00 +0000 (17:15 -0500)
committerPaul Smith <psmith@gnu.org>
Mon, 17 Jan 2022 23:45:47 +0000 (18:45 -0500)
Since we don't know what a loaded function (via Guile or load) may
do, increment the command count just in case.

* src/function.c (struct file_table_entry): New adds_command bool.
(FT_ENTRY): Initialize it to 0 for built-in functions.
(expand_builtin_function): If adds_command, increment the count.
(define_new_function): Set adds_command for loaded functions.

src/function.c

index c107a387aa1cddd60ce352da94f4865d94ffe555..1120ad212f4c1d73537636771f6086555f0265de 100644 (file)
@@ -40,6 +40,7 @@ struct function_table_entry
     unsigned char maximum_args;
     unsigned int expand_args:1;
     unsigned int alloc_fn:1;
+    unsigned int adds_command:1;
   };
 
 static unsigned long
@@ -2515,7 +2516,7 @@ func_abspath (char *o, char **argv, const char *funcname UNUSED)
 static char *func_call (char *o, char **argv, const char *funcname);
 
 #define FT_ENTRY(_name, _min, _max, _exp, _func) \
-  { { (_func) }, STRING_SIZE_TUPLE(_name), (_min), (_max), (_exp), 0 }
+  { { (_func) }, STRING_SIZE_TUPLE(_name), (_min), (_max), (_exp), 0, 0 }
 
 static struct function_table_entry function_table_init[] =
 {
@@ -2591,6 +2592,9 @@ expand_builtin_function (char *o, int argc, char **argv,
     OS (fatal, *expanding_var,
         _("unimplemented on this platform: function '%s'"), entry_p->name);
 
+  if (entry_p->adds_command)
+    ++command_count;
+
   if (!entry_p->alloc_fn)
     return entry_p->fptr.func_ptr (o, argv, entry_p->name);
 
@@ -2858,6 +2862,8 @@ define_new_function (const floc *flocp, const char *name,
   ent->maximum_args = (unsigned char) max;
   ent->expand_args = ANY_SET(flags, GMK_FUNC_NOEXPAND) ? 0 : 1;
   ent->alloc_fn = 1;
+  /* We don't know what this function will do.  */
+  ent->adds_command = 1;
   ent->fptr.alloc_func_ptr = func;
 
   hash_insert (&function_table, ent);