summaryrefslogtreecommitdiff
path: root/function.c
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2003-11-04 07:40:29 +0000
committerPaul Smith <psmith@gnu.org>2003-11-04 07:40:29 +0000
commitee3d37a591cf2db3dd1444b2c1e2fcb041f68d33 (patch)
tree0cedbb4ac47a4a0dcd49bd80c4b0ceadf8bed80d /function.c
parent76f034acaadf081fd589cc5409bb4c2c138570e0 (diff)
downloadgunmake-ee3d37a591cf2db3dd1444b2c1e2fcb041f68d33.tar.gz
Fix bugs 5798 and 6195.
Diffstat (limited to 'function.c')
-rw-r--r--function.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/function.c b/function.c
index d05a5bb..8100a8f 100644
--- a/function.c
+++ b/function.c
@@ -678,6 +678,11 @@ func_words (char *o, char **argv, const char *funcname)
return o;
}
+/* Set begpp to point to the first non-whitespace character of the string,
+ * and endpp to point to the last non-whitespace character of the string.
+ * If the string is empty or contains nothing but whitespace, endpp will be
+ * begpp-1.
+ */
static char *
strip_whitespace (const char **begpp, const char **endpp)
{
@@ -1134,7 +1139,7 @@ static char *
func_if (char *o, char **argv, const char *funcname)
{
const char *begp = argv[0];
- const char *endp = begp + strlen (argv[0]);
+ const char *endp = begp + strlen (argv[0]) - 1;
int result = 0;
/* Find the result of the condition: if we have a value, and it's not
@@ -1143,9 +1148,9 @@ func_if (char *o, char **argv, const char *funcname)
strip_whitespace (&begp, &endp);
- if (begp < endp)
+ if (begp <= endp)
{
- char *expansion = expand_argument (begp, NULL);
+ char *expansion = expand_argument (begp, endp+1);
result = strlen (expansion);
free (expansion);