The following test case can be used to demonstrate the bug:
a:
@echo $(addprefix foo_,)
The bug is in the handle_function() func in function.c. Specifically, in the
following loop:
p=beg; <<< FYI this is redundant! It is initialized in the 'for'
nargs = 0;
for (p=beg, nargs=0; p < end; ++argvp)
{
char *next;
++nargs;
if (nargs == entry_p->maximum_args
|| (! (next = find_next_argument (openparen, closeparen, p, end))))
next = end;
if (entry_p->expand_args)
*argvp = expand_argument (p, next);
else
{
*argvp = p;
*next = '\0';
}
p = next + 1;
}
>From my analysis, I find:
* On entry to the loop:
end = ")"
p = "foo_,)"
nargs = 0
* At bottom of loop BEFORE 'p = next + 1' is done:
end = ")"
p = ",)"
nargs = 1
* At bottom of loop AFTER 'p = next + 1' is done:
end = ")"
p = ")"
nargs = 1
* Loop then terminates prematurely because 'p < end' is false. As a result,
'nargs' is one less than it should be.
If the test at the top of the loop is changed from:
for (p=beg, nargs=0; p < end; ++argvp)
to:
for (p=beg, nargs=0; p <= end; ++argvp)
then everything works fine and the loop then terminates when:
if (nargs == entry_p->maximum_args ...
evaluates to true.
Regards
Reid
> Date: 17 Jun 2000 01:33:43 -0500
> From: Reid Madsen <[EMAIL PROTECTED]>
> Reply-to: [EMAIL PROTECTED]
>
>
> I just downloaded the new version...
>
> None of my pre-existing Makefiles work with the new version. They all die
> with the following error:
>
> *** Insufficient number of arguments (1) to function `addprefix'. Stop.
>
> The error is caused by the following usage:
>
> $(addprefix all__,$(SUBDIRS))::$(addprefix all__,)
>
> If I add some whitespace in the last argument of the second addprefix,
>
> $(addprefix all__,$(SUBDIRS))::$(addprefix all__, )
>
> then things work fine. It appears that the function processing code is not
> handling empty parameters correctly.
>
>
> FYI, we use Imake to generate our makefiles, and the above is generated by a
> rule like:
>
> #define SubdirDeps(dirs,dep_dirs) @@\
> $(addprefix all__,dirs)::$(addprefix all__,dep_dirs) @@\
> commands for dirs
>
> which can be instantiated in an Imakefile as
>
> SubdirDeps($(SUBDIRS),) # No dependencies
> or
> SubdirDeps($(SUBDIRS),$(DEP_DIRS)) # Has dependencies
>
> In the first form, since the 'dep_dirs' argument is nil, an empty argument is
> presented to addprefix. This used to work -- I surely hope you can fix this.
>
> Reid
--
Reid Madsen [EMAIL PROTECTED]
Senior Member, Tech. Staff (972) 536-3261 (Desk)
I2 Technologies (214) 850-9613 (Cellular)
--
If one synchronized swimmer drowns, do they all have to drown?