summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/parser.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/parser.c b/src/parser.c
index 8e40781..8bd3db4 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -853,6 +853,11 @@ static int pgetc_eatbnl(void)
 	return c;
 }
 
+static int pgetc_top(struct synstack *stack)
+{
+	return stack->syntax == SQSYNTAX ? pgetc() : pgetc_eatbnl();
+}
+
 static void synstack_push(struct synstack **stack, struct synstack *next,
 			  const char *syntax)
 {
@@ -915,7 +920,7 @@ readtoken1(int firstc, char const *syntax, char *eofmark, int striptabs)
 			attyline();
 			if (synstack->syntax == BASESYNTAX)
 				return readtoken();
-			c = syntax == SQSYNTAX ? pgetc() : pgetc_eatbnl();
+			c = pgetc_top(synstack);
 			goto loop;
 		}
 #endif
@@ -929,7 +934,7 @@ readtoken1(int firstc, char const *syntax, char *eofmark, int striptabs)
 					goto endword;	/* exit outer loop */
 				USTPUTC(c, out);
 				nlprompt();
-				c = syntax == SQSYNTAX ? pgetc() : pgetc_eatbnl();
+				c = pgetc_top(synstack);
 				goto loop;		/* continue outer loop */
 			case CWORD:
 				USTPUTC(c, out);
@@ -1056,7 +1061,7 @@ toggledq:
 					USTPUTC(c, out);
 				}
 			}
-			c = syntax == SQSYNTAX ? pgetc() : pgetc_eatbnl();
+			c = pgetc_top(synstack);
 		}
 	}
 endword: