From b6a779d262cc9246da3c159065c4e865214a9a3e Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Mon, 17 Jan 2022 17:15:00 -0500 Subject: [PATCH] Ensure that loaded functions increment the command count 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 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/function.c b/src/function.c index c107a387..1120ad21 100644 --- a/src/function.c +++ b/src/function.c @@ -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);