Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: regexparse



In article <rsqiu1nj1i3.fsf@xxxxxxxxxxxxxxxxx>,
  Tanaka Akira <akr@xxxxxxxxxxx> writes:

> Finally, I re-implemented most of `_regex_arguments' in C.
> This should accelerate `_apt'.

Oops.  I found that `apt-config shell <TAB>' prints `no more
arguments'.  This is caused by regexparse doesnot execute completion
actions since `apt-config shell ' is already valid command line.

This patch make regexparse to call completion actions even if command
line is valid.

Index: Completion/Base/_regex_arguments
===================================================================
RCS file: /projects/zsh/zsh/Completion/Base/_regex_arguments,v
retrieving revision 1.1.1.11
diff -u -r1.1.1.11 _regex_arguments
--- Completion/Base/_regex_arguments	1999/12/25 00:41:47	1.1.1.11
+++ Completion/Base/_regex_arguments	1999/12/25 11:31:19
@@ -70,7 +70,7 @@
   "$funcname"' () {
     local _ra_p1 _ra_p2 _ra_left _ra_right _ra_com
     local _ra_actions _ra_line="${(pj:\0:)${(@)words[1,CURRENT - 1]:Q}}"$'\''\0'\''"$PREFIX"
-    regexparse _ra_p1 _ra_p2 "$_ra_line" '"${(j: :)${(qqqq)regex[@]}}"'
+    regexparse -c _ra_p1 _ra_p2 "$_ra_line" '"${(j: :)${(qqqq)regex[@]}}"'
     case "$?" in
     0|2) _message "no more arguments";;
     1) 
Index: Src/Modules/zutil.c
===================================================================
RCS file: /projects/zsh/zsh/Src/Modules/zutil.c,v
retrieving revision 1.1.1.5
diff -u -r1.1.1.5 zutil.c
--- Src/Modules/zutil.c	1999/12/25 00:42:05	1.1.1.5
+++ Src/Modules/zutil.c	1999/12/25 11:31:22
@@ -992,7 +992,7 @@
 }
 
 static int
-rmatch(RParseResult *sm, char *subj, char *var1, char *var2)
+rmatch(RParseResult *sm, char *subj, char *var1, char *var2, int comp)
 {
     LinkNode ln, lnn;
     LinkList nexts;
@@ -1080,8 +1080,8 @@
 	}
     } while(ln);
 
-    if(!*subj)
-        for(ln = firstnode(sm->out); ln; ln = nextnode(ln)) {
+    if(!comp && !*subj)
+	for(ln = firstnode(sm->out); ln; ln = nextnode(ln)) {
 	    br = getdata(ln);
 	    if(br->state == st) {
 		for(ln = firstnode(br->actions); ln; ln = nextnode(ln)) {
@@ -1141,7 +1141,7 @@
 	    ret = 0;
 
 	if(!ret)
-	    ret = rmatch(&result, subj, var1, var2);
+	    ret = rmatch(&result, subj, var1, var2, ops['c']);
         popheap();
     } LASTALLOC;
 
@@ -1152,7 +1152,7 @@
 static struct builtin bintab[] = {
     BUILTIN("zstyle", 0, bin_zstyle, 0, -1, 0, NULL, NULL),
     BUILTIN("zformat", 0, bin_zformat, 3, -1, 0, NULL, NULL),
-    BUILTIN("regexparse", 0, bin_regexparse, 3, -1, 0, NULL, NULL),
+    BUILTIN("regexparse", 0, bin_regexparse, 3, -1, 0, "c", NULL),
 };
 
 
-- 
Tanaka Akira



Messages sorted by: Reverse Date, Date, Thread, Author