[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 4/6] remove MAP_PERCENT
From: |
Paolo Bonzini |
Subject: |
[PATCH 4/6] remove MAP_PERCENT |
Date: |
Fri, 11 Aug 2017 13:44:31 +0200 |
* read.c (find_percent_cached): Use strchr instead of STOP_SET
to find % or nul.
* makeint.h (MAP_PERCENT): Remove.
* main.c (initialize_stopchar_map): Remove.
---
main.c | 1 -
makeint.h | 1 -
read.c | 10 +++++-----
3 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/main.c b/main.c
index 226b26b..81ad3cd 100644
--- a/main.c
+++ b/main.c
@@ -632,7 +632,6 @@ initialize_stopchar_map (void)
stopchar_map[(int)';'] = MAP_SEMI;
stopchar_map[(int)'='] = MAP_EQUALS;
stopchar_map[(int)':'] = MAP_COLON;
- stopchar_map[(int)'%'] = MAP_PERCENT;
stopchar_map[(int)'|'] = MAP_PIPE;
stopchar_map[(int)'.'] = MAP_DOT | MAP_USERFUNC;
stopchar_map[(int)','] = MAP_COMMA;
diff --git a/makeint.h b/makeint.h
index c79d0b4..d71c043 100644
--- a/makeint.h
+++ b/makeint.h
@@ -397,7 +397,6 @@ extern int unixy_shell;
#define MAP_SEMI 0x0010
#define MAP_EQUALS 0x0020
#define MAP_COLON 0x0040
-#define MAP_PERCENT 0x0080
#define MAP_PIPE 0x0100
#define MAP_DOT 0x0200
#define MAP_COMMA 0x0400
diff --git a/read.c b/read.c
index a597488..2cd497a 100644
--- a/read.c
+++ b/read.c
@@ -2429,10 +2429,9 @@ find_percent_cached (const char **string)
while (1)
{
- while (! STOP_SET (*p, MAP_PERCENT|MAP_NUL))
- ++p;
+ p = strchr(p, '%');
- if (*p == '\0')
+ if (!p)
break;
/* See if this % is escaped with a backslash; if not we're done. */
@@ -2478,11 +2477,12 @@ find_percent_cached (const char **string)
if (new)
{
*string = strcache_add (*string);
- p = *string + (p - new);
+ if (p)
+ p = *string + (p - new);
}
/* If we didn't find a %, return NULL. Otherwise return a ptr to it. */
- return (*p == '\0') ? NULL : p;
+ return p;
}
/* Find the next line of text in an eval buffer, combining continuation lines
--
2.13.3
- [PATCH v2 0/6] Miscellaneous speedup patches, Paolo Bonzini, 2017/08/11
- [PATCH 1/6] use Jenkins hash, Paolo Bonzini, 2017/08/11
- [PATCH 5/6] speedup parsing of functions, Paolo Bonzini, 2017/08/11
- [PATCH 6/6] do not use STOP_SET for singleton sets, Paolo Bonzini, 2017/08/11
- [PATCH 3/6] use strchr/memmove in collapse_continuations, Paolo Bonzini, 2017/08/11
- [PATCH 2/6] use strchr for simple case of find_char_unquote, Paolo Bonzini, 2017/08/11
- [PATCH 4/6] remove MAP_PERCENT,
Paolo Bonzini <=