summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2007-08-14 11:51:16 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2007-08-14 11:51:16 +0000
commit83cbc075ac169570427879fc34200367c149ca96 (patch)
treefa83e51d87bcc5608288ca7a476d99fd509f60ac
parent649d87c8cb45fdcd1fe39560b04a1dd22c417bbb (diff)
downloadzsh-83cbc075ac169570427879fc34200367c149ca96.tar.gz
zsh-83cbc075ac169570427879fc34200367c149ca96.tar.xz
zsh-83cbc075ac169570427879fc34200367c149ca96.zip
23757: suppress correction of command words followed by ()
-rw-r--r--ChangeLog6
-rw-r--r--Src/lex.c20
2 files changed, 23 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index c467050e8..0748f6710 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-08-14  Peter Stephenson  <pws@csr.com>
+
+	* 23757: Src/lex.c: suppression correction of command
+	words immediately followed by () or something that looks
+	like it's going to be one.
+
 2007-08-12  Andrey Borzenkov <bor@zsh.org>
 
 	* 23751: Completion/Linux/Command/_modutils: support for
diff --git a/Src/lex.c b/Src/lex.c
index 776eaf95a..8bf90847a 100644
--- a/Src/lex.c
+++ b/Src/lex.c
@@ -66,7 +66,12 @@ int isfirstch;
 /**/
 int inalmore;
 
-/* don't do spelling correction */
+/*
+ * Don't do spelling correction.
+ * Bit 1 is only valid for the current word.  It's
+ * set when we detect a lookahead that stops the word from
+ * needing correction.
+ */
  
 /**/
 int nocorrect;
@@ -344,6 +349,7 @@ yylex(void)
     do
 	tok = gettok();
     while (tok != ENDINPUT && exalias());
+    nocorrect &= 1;
     if (tok == NEWLIN || tok == ENDINPUT) {
 	while (hdocs) {
 	    struct heredocs *next = hdocs->next;
@@ -629,7 +635,7 @@ isnumglob(void)
 }
 
 /**/
-int
+static int
 gettok(void)
 {
     int c, d;
@@ -1036,8 +1042,16 @@ gettokstr(int c, int sub)
 		     *   pws 1999/6/14
 		     */
 		    if (e == ')' || (isset(SHGLOB) && inblank(e) && !bct &&
-				     !brct && !intpos && incmdpos))
+				     !brct && !intpos && incmdpos)) {
+			/*
+			 * Either a () token, or a command word with
+			 * something suspiciously like a ksh function
+			 * definition.
+			 * The current word isn't spellcheckable.
+			 */
+			nocorrect |= 2;
 			goto brk;
+		    }
 		}
 		/*
 		 * This also handles the [k]sh `foo( )' function definition.