summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>1994-03-04 05:36:26 +0000
committerRoland McGrath <roland@redhat.com>1994-03-04 05:36:26 +0000
commit227cffec2baa1919eb4f62a5537fddb94c1e9a4b (patch)
tree18ab36698f416d7ee7c90193783623f8a944c5be
parent5d3189c952993f244470910d0ad208d4d6866166 (diff)
downloadgunmake-227cffec2baa1919eb4f62a5537fddb94c1e9a4b.tar.gz
entered into RCS
-rw-r--r--function.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/function.c b/function.c
index e543a91..9353a91 100644
--- a/function.c
+++ b/function.c
@@ -1,5 +1,5 @@
/* Variable function expansion for GNU Make.
-Copyright (C) 1988, 1989, 1991, 1992, 1993 Free Software Foundation, Inc.
+Copyright (C) 1988, 1989, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify
@@ -51,8 +51,23 @@ subst_expand (o, text, subst, replace, slen, rlen, by_word, suffix_only)
return o;
}
- while ((p = sindex (t, 0, subst, slen)) != 0)
+ do
{
+ if ((by_word | suffix_only) && slen == 0)
+ /* When matching by words, the empty string should match
+ the end of each word, rather than the end of the whole text. */
+ p = end_of_token (next_token (t));
+ else
+ {
+ p = sindex (t, 0, subst, slen);
+ if (p == 0)
+ {
+ /* No more matches. Output everything left on the end. */
+ o = variable_buffer_output (o, t, strlen (t));
+ return o;
+ }
+ }
+
/* Output everything before this occurrence of the string to replace. */
if (p > t)
o = variable_buffer_output (o, t, p - t);
@@ -73,11 +88,7 @@ subst_expand (o, text, subst, replace, slen, rlen, by_word, suffix_only)
/* Advance T past the string to be replaced. */
t = p + slen;
- }
-
- /* Output everything left on the end. */
- if (*t != '\0')
- o = variable_buffer_output (o, t, strlen (t));
+ } while (*t != '\0');
return o;
}