about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--Src/parse.c1
-rw-r--r--Src/prompt.c25
-rw-r--r--Src/zsh.h14
4 files changed, 28 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index d035302fe..89a740e48 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-07-09  Peter Stephenson  <p.w.stephenson@ntlworld.com>
+
+	* 22542: Src/parse.c, Src/prompt.c, Src/zsh.h: 22516 was
+	overentusiastic about popping the command stack; turn cmdpop()
+	and cmdpush() into functions for better maintainability.
+
 2006-07-03  Peter Stephenson  <pws@csr.com>
 
 	* 22537: Makefile.in: rm -rf autom4te.cache on distclean.
diff --git a/Src/parse.c b/Src/parse.c
index c67561be2..61ef9dcdc 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -1672,7 +1672,6 @@ par_simple(int *complex, int nr)
 		    lineno += oldlineno;
 		    ecnpats = onp;
 		    ecssub = oecssub;
-		    cmdpop();
 		    YYERROR(oecused);
 		}
 		yylex();
diff --git a/Src/prompt.c b/Src/prompt.c
index be7dc672c..facf777f0 100644
--- a/Src/prompt.c
+++ b/Src/prompt.c
@@ -31,7 +31,7 @@
 #include "prompt.pro"
 
 /* text attribute mask */
- 
+
 /**/
 unsigned txtattrmask;
 
@@ -41,7 +41,7 @@ unsigned txtattrmask;
 mod_export unsigned txtchange;
 
 /* the command stack for use with %_ in prompts */
- 
+
 /**/
 unsigned char *cmdstack;
 /**/
@@ -59,7 +59,7 @@ static char *cmdnames[CS_COUNT] = {
     "cmdsubst", "mathsubst", "elif-then", "heredoc",
     "heredocd", "brace",     "braceparam", "always",
 };
- 
+
 /* The buffer into which an expanded and metafied prompt is being written, *
  * and its size.                                                           */
 
@@ -1304,3 +1304,22 @@ prompttrunc(int arg, int truncchar, int doprint, int endchar)
     }
     return 1;
 }
+
+/**/
+void
+cmdpush(int cmdtok)
+{
+    if (cmdsp >= 0 && cmdsp < CMDSTACKSZ)
+	cmdstack[cmdsp++] = (unsigned char)cmdtok;
+}
+
+/**/
+void
+cmdpop(void)
+{
+    if (cmdsp <= 0) {
+	DPUTS(1, "BUG: cmdstack empty");
+	fflush(stderr);
+    } else
+	cmdsp--;
+}
diff --git a/Src/zsh.h b/Src/zsh.h
index b0962574a..8554b5c96 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -1768,20 +1768,6 @@ struct ttyinfo {
 /****************************************/
 
 #define CMDSTACKSZ 256
-#define cmdpush(X) do { \
-                       if (cmdsp >= 0 && cmdsp < CMDSTACKSZ) \
-                           cmdstack[cmdsp++]=(X); \
-                   } while (0)
-#ifdef DEBUG
-# define cmdpop()  do { \
-                       if (cmdsp <= 0) { \
-			   fputs("BUG: cmdstack empty\n", stderr); \
-			   fflush(stderr); \
-		       } else cmdsp--; \
-                   } while (0)
-#else
-# define cmdpop()   do { if (cmdsp > 0) cmdsp--; } while (0)
-#endif
 
 #define CS_FOR          0
 #define CS_WHILE        1