bug-make
[Top][All Lists]
Advanced

[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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]