[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 4/5] remove MAP_PERCENT
From: |
Paolo Bonzini |
Subject: |
[PATCH 4/5] remove MAP_PERCENT |
Date: |
Wed, 2 Nov 2016 17:24:17 +0100 |
This is needed to free a stopchar_map bit for the next patch.
* 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 4b3cf1d..7f34199 100644
--- a/main.c
+++ b/main.c
@@ -642,7 +642,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 ef66312..15a69a8 100644
--- a/makeint.h
+++ b/makeint.h
@@ -389,7 +389,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 c2d42d2..64e7887 100644
--- a/read.c
+++ b/read.c
@@ -2432,10 +2432,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. */
@@ -2481,11 +2480,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.7.4
- [PATCH 0/5] Miscellaneous speed up patches, Paolo Bonzini, 2016/11/02
- [PATCH 1/5] optimize checking for globs, Paolo Bonzini, 2016/11/02
- [PATCH 3/5] use jhash for STRING_N_HASH, Paolo Bonzini, 2016/11/02
- [PATCH 5/5] speedup parsing of functions, Paolo Bonzini, 2016/11/02
- [PATCH 4/5] remove MAP_PERCENT,
Paolo Bonzini <=
- [PATCH 2/5] use strchr for simple case of find_char_unquote, Paolo Bonzini, 2016/11/02
- Re: [PATCH 0/5] Miscellaneous speed up patches, Paolo Bonzini, 2016/11/11