about summary refs log tree commit diff
diff options
context:
space:
mode:
authorWayne Davison <wayned@users.sourceforge.net>2000-07-18 07:49:16 +0000
committerWayne Davison <wayned@users.sourceforge.net>2000-07-18 07:49:16 +0000
commit2e96c8f0742c9b759495226b8b20e3a8363e6d50 (patch)
treefce300172368ae68eb6339ea332aedfeeb843a4d
parentb33c464a706358e0c6e1202aee686fee95572abe (diff)
downloadzsh-2e96c8f0742c9b759495226b8b20e3a8363e6d50.tar.gz
zsh-2e96c8f0742c9b759495226b8b20e3a8363e6d50.tar.xz
zsh-2e96c8f0742c9b759495226b8b20e3a8363e6d50.zip
Removed the spaceflag variable.
-rw-r--r--Src/input.c70
-rw-r--r--Src/lex.c3
2 files changed, 41 insertions, 32 deletions
diff --git a/Src/input.c b/Src/input.c
index 576341a7c..8f33e3631 100644
--- a/Src/input.c
+++ b/Src/input.c
@@ -88,7 +88,7 @@ int strin;
 /* total # of characters waiting to be read. */
 
 /**/
-int inbufct;
+mod_export int inbufct;
 
 /* the flags controlling the input routines in input.c: see INP_* in zsh.h */
 
@@ -128,7 +128,7 @@ static int instacksz = INSTACK_INITIAL;
  * null characters to Meta c^32 character pairs. */
 
 /**/
-char *
+mod_export char *
 shingetline(void)
 {
     char *line = NULL;
@@ -176,7 +176,7 @@ shingetline(void)
 int
 ingetc(void)
 {
-    char lastc;
+    int lastc;
 
     if (lexstop)
 	return ' ';
@@ -186,6 +186,8 @@ ingetc(void)
 	    inbufct--;
 	    if (itok(lastc = STOUC(*inbufptr++)))
 		continue;
+	    if (((inbufflags & INP_LINENO) || !strin) && lastc == '\n')
+		lineno++;
 	    return lastc;
 	}
 
@@ -219,7 +221,7 @@ inputline(void)
     char *ingetcline, *ingetcpmptl = NULL, *ingetcpmptr = NULL;
 
     /* If reading code interactively, work out the prompts. */
-    if (interact && isset(SHINSTDIN))
+    if (interact && isset(SHINSTDIN)) {
 	if (!isfirstln)
 	    ingetcpmptl = prompt2;
 	else {
@@ -227,6 +229,7 @@ inputline(void)
 	    if (rprompt)
 		ingetcpmptr = rprompt;
 	}
+    }
     if (!(interact && isset(SHINSTDIN) && SHTTY != -1 && isset(USEZLE))) {
 	/*
 	 * If not using zle, read the line straight from the input file.
@@ -248,8 +251,21 @@ inputline(void)
 	    free(pptbuf);
 	}
 	ingetcline = shingetline();
-    } else
-	ingetcline = (char *)zleread(ingetcpmptl, ingetcpmptr, 1);
+    } else {
+	/*
+	 * Since we may have to read multiple lines before getting
+	 * a complete piece of input, we tell zle not to restore the
+	 * original tty settings after reading each chunk.  Instead,
+	 * this is done when the history mechanism for the current input
+	 * terminates, which is not until we have the whole input.
+	 * This is supposed to minimise problems on systems that clobber
+	 * typeahead when the terminal settings are altered.
+	 *                     pws 1998/03/12
+	 */
+	ingetcline = (char *)zleread(ingetcpmptl, ingetcpmptr,
+				     ZLRF_HISTORY|ZLRF_NOSETTY);
+	histdone |= HISTFLAG_SETTY;
+    }
     if (!ingetcline) {
 	return lexstop = 1;
     }
@@ -257,31 +273,25 @@ inputline(void)
 	free(ingetcline);
 	return lexstop = errflag = 1;
     }
-    /* Look for a space, to see if this shouldn't be put into history */
-    if (isfirstln)
-	spaceflag = *ingetcline == ' ';
     if (isset(VERBOSE)) {
 	/* Output the whole line read so far. */
 	zputs(ingetcline, stderr);
 	fflush(stderr);
     }
-    if (*ingetcline && ingetcline[strlen(ingetcline) - 1] == '\n') {
-	/* We've now read a complete line. */
-	lineno++;
-	if (interact && isset(SUNKEYBOARDHACK) && isset(SHINSTDIN) &&
-	    SHTTY != -1 && *ingetcline && ingetcline[1] &&
-	    ingetcline[strlen(ingetcline) - 2] == '`') {
-	    /* Junk an unmatched "`" at the end of the line. */
-	    int ct;
-	    char *ptr;
-
-	    for (ct = 0, ptr = ingetcline; *ptr; ptr++)
-		if (*ptr == '`')
-		    ct++;
-	    if (ct & 1) {
-		ptr[-2] = '\n';
-		ptr[-1] = '\0';
-	    }
+    if (*ingetcline && ingetcline[strlen(ingetcline) - 1] == '\n' &&
+	interact && isset(SUNKEYBOARDHACK) && isset(SHINSTDIN) &&
+	SHTTY != -1 && *ingetcline && ingetcline[1] &&
+	ingetcline[strlen(ingetcline) - 2] == '`') {
+	/* Junk an unmatched "`" at the end of the line. */
+	int ct;
+	char *ptr;
+
+	for (ct = 0, ptr = ingetcline; *ptr; ptr++)
+	    if (*ptr == '`')
+		ct++;
+	if (ct & 1) {
+	    ptr[-2] = '\n';
+	    ptr[-1] = '\0';
 	}
     }
     isfirstch = 1;
@@ -345,6 +355,8 @@ inungetc(int c)
 	    inbufptr--;
 	    inbufct++;
 	    inbufleft++;
+	    if (((inbufflags & INP_LINENO) || !strin) && c == '\n')
+		lineno--;
 	}
 #ifdef DEBUG
         else if (!(inbufflags & INP_CONT)) {
@@ -392,7 +404,7 @@ stuff(char *fn)
 {
     FILE *in;
     char *buf;
-    int len;
+    off_t len;
 
     if (!(in = fopen(unmeta(fn), "r"))) {
 	zerr("can't open %s", fn, 0);
@@ -429,7 +441,7 @@ inerrflush(void)
 /* Set some new input onto a new element of the input stack */
 
 /**/
-void
+mod_export void
 inpush(char *str, int flags, Alias inalias)
 {
     if (!instack) {
@@ -517,7 +529,7 @@ inpoptop(void)
 /* Remove the top element of the stack and all its continuations. */
 
 /**/
-void
+mod_export void
 inpop(void)
 {
     int remcont;
diff --git a/Src/lex.c b/Src/lex.c
index db2c2c8bd..2aec25678 100644
--- a/Src/lex.c
+++ b/Src/lex.c
@@ -177,7 +177,6 @@ struct lexstack {
     int isfirstch;
     int histactive;
     int histdone;
-    int spaceflag;
     int stophist;
     int hlinesz;
     char *hline;
@@ -233,7 +232,6 @@ lexsave(void)
     ls->isfirstch = isfirstch;
     ls->histactive = histactive;
     ls->histdone = histdone;
-    ls->spaceflag = spaceflag;
     ls->stophist = stophist;
     ls->hline = chline;
     ls->hptr = hptr;
@@ -294,7 +292,6 @@ lexrestore(void)
     isfirstch = lstack->isfirstch;
     histactive = lstack->histactive;
     histdone = lstack->histdone;
-    spaceflag = lstack->spaceflag;
     stophist = lstack->stophist;
     chline = lstack->hline;
     hptr = lstack->hptr;