summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2007-12-27 13:54:16 +1100
committerHerbert Xu <herbert@gondor.apana.org.au>2007-12-27 13:54:16 +1100
commit8f01c3796f0fc3bc616125288a2aa7058c442292 (patch)
treeaf130dfcced302fb067cd10de102f5ffdbbd6374 /src
parent[ARITH] If imaxdiv() isn't available, use / and % operators (diff)
downloaddash-8f01c3796f0fc3bc616125288a2aa7058c442292.tar.gz
dash-8f01c3796f0fc3bc616125288a2aa7058c442292.zip
[PARSER] Add FAKEEOFMARK for expandstr
Previously expandstr used the string "" to indicate that it needs to be
treated just like a here-doc except that there is no terminator.  However,
the string "" is in fact a valid here-doc terminator so now that we deal
with it correctly expandstr no longer works in the presence of new-lines
in the prompt.

This patch introduces the FAKEEOFMARK macro which does not equal any
real EOF marker but is distinct from the NULL pointer which is used to
indicate non-here-doc contexts.

Thanks to Markus Triska for reporting this regression.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to '')
-rw-r--r--src/parser.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/parser.c b/src/parser.c
index 2d20b00..3206328 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -64,6 +64,11 @@
 
 
 
+/* Used by expandstr to get here-doc like behaviour. */
+#define FAKEEOFMARK (char *)1
+
+
+
 struct heredoc {
 	struct heredoc *next;	/* next here document in list */
 	union node *here;		/* redirection node */
@@ -113,6 +118,11 @@ isassignment(const char *p)
 	return *q == '=';
 }
 
+static inline int realeofmark(const char *eofmark)
+{
+	return eofmark && eofmark != FAKEEOFMARK;
+}
+
 
 /*
  * Read and parse a command.  Returns NEOF on end of file.  (NULL is a
@@ -1030,7 +1040,7 @@ endword:
  */
 
 checkend: {
-	if (eofmark) {
+	if (realeofmark(eofmark)) {
 		int markloc;
 		char *p;
 
@@ -1492,7 +1502,7 @@ expandstr(const char *ps)
 
 	/* XXX Fix (char *) cast. */
 	setinputstring((char *)ps);
-	readtoken1(pgetc(), DQSYNTAX, nullstr, 0);
+	readtoken1(pgetc(), DQSYNTAX, FAKEEOFMARK, 0);
 	popfile();
 
 	n.narg.type = NARG;
title='2021-02-07 22:41:06 -0500'>2021-02-07Swap root window coloursJune McEnroe 2021-02-07Add -X flag to install X stuff on OpenBSDJune McEnroe 2021-02-07Adjust brightness by smaller incrementsJune McEnroe 2021-02-07Fix cwm window cycling, move big by defaultJune McEnroe 2021-02-07Use class names for Foreground, Background, BorderColorJune McEnroe 2021-02-07Add simple battery status and clock to xsessionJune McEnroe 2021-02-07Set cursor theme and sizeJune McEnroe 2021-02-07Use scrot for up -s if no screencaptureJune McEnroe 2021-02-07Enable mouse acceleration in XJune McEnroe 2021-02-07Set colours for Xt and cwmJune McEnroe 2021-02-07Set urgency on bell in xtermJune McEnroe 2021-02-07Add bindings for brightness controlJune McEnroe 2021-02-07Set X key repeat rateJune McEnroe 2021-02-07Bump font size to 12June McEnroe 2021-02-07Fully configure and rebind cwmJune McEnroe 2021-02-07Add BintiJune McEnroe 2021-02-07Finish configuring xtermJune McEnroe 2021-02-06Enable tapping, reverse scroll, set scaling in wsconsctlJune McEnroe 2021-02-06Set root window to black on purple snowJune McEnroe 2021-02-06Add xmodmap configurationJune McEnroe 2021-02-06Add initial OpenBSD X configurationJune McEnroe 2021-02-06Add xterm output to schemeJune McEnroe