summaryrefslogtreecommitdiff
path: root/modules/gnu.c
diff options
context:
space:
mode:
authorEric Blake <ebb9@byu.net>2009-02-18 13:36:15 -0700
committerEric Blake <ebb9@byu.net>2009-02-18 15:36:03 -0700
commitd8726aac7acd47435ad3e4dedef44d01cd828dc1 (patch)
tree9d48713e84c90ea15df2e12811ae37d53d7e21fa /modules/gnu.c
parent028f5c5976a35256f5fa3804f33292a75ba56c6e (diff)
downloadm4-d8726aac7acd47435ad3e4dedef44d01cd828dc1.tar.gz
Prefer buffer over byte operations.
* modules/format.c (format): Use memchr for speed. * modules/gnu.c (substitute): Likewise. * m4/macro.c (locate_dollar): Inline into only caller... (process_macro): ...and rearrange for readability. * m4/input.c (consume_buffer): Allow C++ compilation. * doc/m4.texinfo (Changesyntax): Enhance test. Signed-off-by: Eric Blake <ebb9@byu.net> (cherry picked from commit 45a154e6d70517bf1b837715aae2fe366c9c1116)
Diffstat (limited to 'modules/gnu.c')
-rw-r--r--modules/gnu.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/modules/gnu.c b/modules/gnu.c
index e6c7691e..53a3ecb8 100644
--- a/modules/gnu.c
+++ b/modules/gnu.c
@@ -238,22 +238,23 @@ substitute (m4 *context, m4_obstack *obs, const m4_call_info *caller,
m4_pattern_buffer *buf)
{
int ch;
-
- while (repl_len--)
+ while (1)
{
- ch = *repl++;
- if (ch != '\\')
+ const char *backslash = (char *) memchr (repl, '\\', repl_len);
+ if (!backslash)
{
- obstack_1grow (obs, ch);
- continue;
+ obstack_grow (obs, repl, repl_len);
+ return;
}
+ obstack_grow (obs, repl, backslash - repl);
+ repl_len -= backslash - repl + 1;
if (!repl_len)
{
m4_warn (context, 0, caller,
_("trailing \\ ignored in replacement"));
return;
}
-
+ repl = backslash + 1;
ch = *repl++;
repl_len--;
switch (ch)