zsh-workers
 help / color / mirror / code / Atom feed
* Re: playing with backreferences in list-colors
@ 2000-01-24  9:54 Sven Wischnowsky
  2000-01-24 15:07 ` Alexandre Duret-Lutz
  2000-01-28  6:14 ` Bart Schaefer
  0 siblings, 2 replies; 8+ messages in thread
From: Sven Wischnowsky @ 2000-01-24  9:54 UTC (permalink / raw)
  To: zsh-workers


Alexandre Duret-Lutz wrote:

> ...
> 
> Does string="./aafoo" in frame #1 means that `(#b)(a)#*' is matched
> over "./aafoo" instead of only "aafoo"?

Yes, it was indeed using the path, which was wrong in this case.

The rest of the patch makes the complist module be loaded if the
list-colors style is used and it isn't already loaded and it makes the 
reported position of -1 be used correctly.

Bye
 Sven

diff -ru ../z.old/Completion/Core/_setup Completion/Core/_setup
--- ../z.old/Completion/Core/_setup	Mon Jan 24 09:58:02 2000
+++ Completion/Core/_setup	Mon Jan 24 10:35:30 2000
@@ -3,6 +3,7 @@
 local val nm="$compstate[nmatches]"
 
 if zstyle -a ":completion${curcontext}:$1" list-colors val; then
+  zmodload -e zsh/complist || zmodload -i zsh/complist
   if [[ "$1" = default ]]; then
     ZLS_COLORS="${(j.:.)${(@)val:gs/:/\\\:}}"
   else
diff -ru ../z.old/Src/Zle/complist.c Src/Zle/complist.c
--- ../z.old/Src/Zle/complist.c	Mon Jan 24 09:57:32 2000
+++ Src/Zle/complist.c	Mon Jan 24 10:44:16 2000
@@ -453,13 +453,13 @@
     curisbeg = curisend = 0;
 
     for (i = nrefs;  i < MAX_POS; i++)
-	begpos[i] = -1, endpos[i] = 0xfffffff;
+	begpos[i] = endpos[i] = -1;
 }
 
 static void
 doiscol(Listcols c, int pos)
 {
-    if (pos > endpos[curisend]) {
+    if (endpos[curisend] >= 0 && pos > endpos[curisend]) {
 	curisend++;
 	if (curiscol) {
 	    zcputs(c, NULL, COL_NO);
@@ -700,7 +700,7 @@
 	else if (mselect >= 0 && (m->flags & (CMF_MULT | CMF_FMULT)))
 	    zcputs(&mcolors, g->name, COL_DU);
 	else if (buf)
-	    subcols = putfilecol(&mcolors, g->name, path, buf->st_mode);
+	    subcols = putfilecol(&mcolors, g->name, m->str, buf->st_mode);
 	else
 	    subcols = putmatchcol(&mcolors, g->name, (m->disp ? m->disp : m->str));
 

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 8+ messages in thread
* Re: playing with backreferences in list-colors
@ 2000-01-28  8:14 Sven Wischnowsky
  0 siblings, 0 replies; 8+ messages in thread
From: Sven Wischnowsky @ 2000-01-28  8:14 UTC (permalink / raw)
  To: zsh-workers


Bart Schaefer wrote:

> On Jan 28,  6:14am, Bart Schaefer wrote:
> } Subject: Re: playing with backreferences in list-colors
> }
> } makes "path" be an unused parameter of clprintm.  Should it be removed
> } entirely, or is there a case in which it ought to be getting used?
> 
> To clarify:  The "path" parameter of iprintm, the only other function that
> is passed by pointer to printlist(), also is never used.

( ten out of ten points for seeing this... ;-) 

I was tempted to remove the argument, but: printlist() builds the path 
anyway and needs to do it to make the ztat(), so I thought I'd just
leave it in if anyone ever wants to write yet another lising module
which may want to have a look at it.

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 8+ messages in thread
* Re: playing with backreferences in list-colors
@ 2000-01-24  9:14 Sven Wischnowsky
  0 siblings, 0 replies; 8+ messages in thread
From: Sven Wischnowsky @ 2000-01-24  9:14 UTC (permalink / raw)
  To: zsh-workers


Peter Stephenson wrote:

> By the way:
> 
>        All three forms of name may be preceded by  a  pattern  in
>        parentheses. If such a pattern is given, the value will be
>        used only for matches in groups whose names are matched by
>        the  pattern  given  in the parentheses. E.g. `(g*)~m*=43'
>        says to highlight all matches beginning with `m' in groups
>        whose  names  begin with `g' using the color code `43'. In
>        case of the `lc', `rc', and `ec' codes, the group  pattern
>        is ignored.
> 
> What does the `~' in the example mean here?   Is that a misprint?

Yes.

Bye
 Sven

diff -ru ../z.old/Doc/Zsh/mod_complist.yo Doc/Zsh/mod_complist.yo
--- ../z.old/Doc/Zsh/mod_complist.yo	Mon Jan 24 09:57:40 2000
+++ Doc/Zsh/mod_complist.yo	Mon Jan 24 10:12:00 2000
@@ -100,7 +100,7 @@
 All three forms of var(name) may be preceded by a pattern in
 parentheses. If such a pattern is given, the var(value) will be used
 only for matches in groups whose names are matched by the pattern
-given in the parentheses. E.g. `tt((g*)~m*=43)' says to highlight all
+given in the parentheses. E.g. `tt((g*)m*=43)' says to highlight all
 matches beginning with `tt(m)' in groups whose names  begin with
 `tt(g)' using the color code `tt(43)'. In case of the `tt(lc)',
 `tt(rc)', and `tt(ec)' codes, the group pattern is ignored.

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 8+ messages in thread
* playing with backreferences in list-colors
@ 2000-01-22 17:17 Alexandre Duret-Lutz
  2000-01-22 19:53 ` Peter Stephenson
  0 siblings, 1 reply; 8+ messages in thread
From: Alexandre Duret-Lutz @ 2000-01-22 17:17 UTC (permalink / raw)
  To: zsh-workers


I have been playing with list-colors to colorize 
process listing and so on.  This is quite fun.
The snipsets below show two problems I had
1) patterns containing letters don't seems to match;
2) backreferences when (x)# style patterns don't match make zsh segfault.


% zsh -f
phobos% unset {,Z}LS_COLO{,U}RS          
phobos% autoload -U compinit; compinit; zmodload zsh/complist
phobos% zstyle ':completion:*' group-name ''
phobos% zstyle ':completion:*:files' list-colors '=(#b)(a)*=0=1'
phobos% setopt extendedglob 
phobos% touch a{a,b,c}foo
phobos% ls a<TAB>
aafoo   abfoo   acfoo                 # nothing is highlighted
phobos% zstyle ':completion:*:files' list-colors '=(#b)(?)*=0=1'
phobos% ls a<TAB>          
aafoo   abfoo   acfoo                 # first letters are highlighted
phobos% zstyle ':completion:*:files' list-colors '=(#b)a(*)=1=0'
phobos% ls a<TAB>
aafoo   abfoo   acfoo                 # nothing is highlighted

Can't I put letters in those patterns?

And now :

phobos% zstyle ':completion:*:files' list-colors '=(#b)(a)#*=1=0'  
phobos% ls a<TAB>
zsh: segmentation fault (core dumped)  zsh -f

(I know, `(a)#' is weird, but actualy I would like to be able
to write something like `(*/)#([^ ]*)*' at the end of the pattern
for my processes listings, to colorize only basename of processes)

(gdb) bt
#0  0x80a7a37 in ztrsub (t=0x40014c50 "", 
    s=0x40018001 <Address 0x40018001 out of bounds>)
    at ../../last/Src/utils.c:2594
#1  0x8094d5c in pattryrefs (prog=0x40014a98, string=0x40014c58 "./aafoo", 
    nump=0x401e2150, begp=0x401e2160, endp=0x401e21a0)
    at ../../last/Src/pattern.c:1382
#2  0x401de36e in putfilecol (c=0x401e2100, group=0x814d470 "files", 
    n=0x40014c58 "./aafoo", m=33204) at ../../../last/Src/Zle/complist.c:585
#3  0x401de92c in clprintm (g=0x814d670, mp=0x814d6e0, mc=0, ml=0, lastc=0, 
    width=8, path=0x40014c58 "./aafoo", buf=0xbffff308)
    at ../../../last/Src/Zle/complist.c:703

[...]

Does string="./aafoo" in frame #1 means that `(#b)(a)#*' is matched
over "./aafoo" instead of only "aafoo"?

BTW zsh seems to go into troubles when such a pattern don't match :

~ % zsh -f
phobos% setopt extendedglob
phobos% [[ ab = (#b)(a)#* ]] 
phobos% echo $match
a
phobos% [[ .ab = (#b)(a)#* ]] 
phobos% echo $match          
zsh: bad pattern: (
phobos% [[ ./ab = (#b)(a)#* ]] 
phobos% echo $match           
zsh: bad pattern: (
phobos% [[ ab = (#b)(a)#* ]] 
phobos% echo $match         
a
phobos% [[ aafoo = (#b)(a)#* ]] 
phobos% echo $match            
a
phobos% [[ .aafoo = (#b)(a)#* ]] 
phobos% echo $match             
O
phobos% [[ ./aafoo = (#b)(a)#* ]] 
phobos% echo $match              
O
phobos% [[ ./aaffffffffffffffffffffoo = (#b)(a)#* ]] 
phobos% echo $match                                 
f
phobos% [[ .ab = (#b)(a)#* ]] 
zsh: segmentation fault (core dumped)  zsh -f

(sometime it's faster to coredump)

(gdb) bt
#0  0x80a7a37 in ztrsub (t=0x40014fc1 "O\001@", 
    s=0x40018001 <Address 0x40018001 out of bounds>)
    at ../../last/Src/utils.c:2594
#1  0x8094ed7 in pattryrefs (prog=0x810b650, string=0x400153f8 ".ab", 
    nump=0x0, begp=0x0, endp=0x0) at ../../last/Src/pattern.c:1417
#2  0x80949f0 in pattry (prog=0x810b650, string=0x400153f8 ".ab")
    at ../../last/Src/pattern.c:1286
#3  0x805c025 in evalcond (state=0xbffff6c0) at ../../last/Src/cond.c:206
#4  0x8064407 in execcond (state=0xbffff6c0, do_exec=0)
    at ../../last/Src/exec.c:2856

[...]

-- 
Alexandre Duret-Lutz


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2000-01-28  8:14 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-01-24  9:54 playing with backreferences in list-colors Sven Wischnowsky
2000-01-24 15:07 ` Alexandre Duret-Lutz
2000-01-28  6:14 ` Bart Schaefer
2000-01-28  6:18   ` Bart Schaefer
  -- strict thread matches above, loose matches on Subject: below --
2000-01-28  8:14 Sven Wischnowsky
2000-01-24  9:14 Sven Wischnowsky
2000-01-22 17:17 Alexandre Duret-Lutz
2000-01-22 19:53 ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).