zsh-workers
 help / color / mirror / code / Atom feed
* Bug with _perl_builtin_funcs
@ 2003-04-01 15:16 Felix Rosencrantz
  2003-04-23 10:17 ` PATCH: " Oliver Kiddle
  0 siblings, 1 reply; 4+ messages in thread
From: Felix Rosencrantz @ 2003-04-01 15:16 UTC (permalink / raw)
  To: zw

There is a bug in the function _perl_builtin_funcs.  This function attempts to
build a list of perl builtin funcs by parsing the man page for perlfunc.  When
it parses the man page it assume it is plain text.  However, on RH the man page
is compressed with gzip.

Though I could see man pages being possiblly compressed with some other
compression tools(e.g. bzip2) on other platforms or in the future.

-FR.

__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more
http://platinum.yahoo.com


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

* PATCH: Re: Bug with _perl_builtin_funcs
  2003-04-01 15:16 Bug with _perl_builtin_funcs Felix Rosencrantz
@ 2003-04-23 10:17 ` Oliver Kiddle
  2003-04-23 16:53   ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Oliver Kiddle @ 2003-04-23 10:17 UTC (permalink / raw)
  To: Felix Rosencrantz; +Cc: zw

On 1 Apr, Felix Rosencrantz wrote:
> There is a bug in the function _perl_builtin_funcs.  This function attempts to
> build a list of perl builtin funcs by parsing the man page for perlfunc.  When
> it parses the man page it assume it is plain text.  However, on RH the man page
> is compressed with gzip.

This should make it use bzip2 or gzip as appropriate. I also had
problems with the lines starting .IP instead of .Ip so I fixed that so
it now works on my system.

Oliver

Index: _perl_builtin_funcs
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_perl_builtin_funcs,v
retrieving revision 1.1
diff -u -r1.1 _perl_builtin_funcs
--- _perl_builtin_funcs	2 Apr 2001 11:40:15 -0000	1.1
+++ _perl_builtin_funcs	23 Apr 2003 10:10:22 -0000
@@ -8,24 +8,31 @@
 # for future use.
 #
 
-if [[ ${+_perl_builtin_funcs} -eq 0 ]]; then
+if (( ! $+_perl_builtin_funcs )); then
   typeset -agU _perl_builtin_funcs
   local perlfunc
 
-  if [[ -n "${perlfunc:=$(man -w perlfunc 2>/dev/null; print -l ${^manpath}/man1/perlfunc.1(N) {/usr/man,/usr/share/man,/usr/local/man}/man1/perlfunc.1(N))}" ]]; then
-    _perl_builtin_funcs=( `perl -lne '
-                             $in_funcs++, next if /Alphabetical/;     \
-                             next unless $in_funcs;                   \
-                             if (/^\.Ip "(\w+)/) {                    \
-                               print $1 unless $func{$1}; $func{$1}++ \
-                             }' $=perlfunc`
-               )
+  if [[ -n "${perlfunc:=$(man -w perlfunc 2>/dev/null; print -l ${^manpath:-${(s.:.)$(manpath)}}/man1/perlfunc.1(|[zZ]|gz|bz2)(N) {/usr/man,/usr/share/man,/usr/local/man}/man1/perlfunc.1(|[zZ]|gz|bz2)(N))}" ]]; then
+    case $perlfunc in
+      *.bz2) perlfunc="bzip2 -cd $perlfunc" ;;
+      *[zZ]) perlfunc="gzip -cd $perlfunc" ;;
+      *) perlfunc="cat $perlfunc" ;;
+    esac
+    _perl_builtin_funcs=(
+      $($=perlfunc | perl -lne '
+      $in_funcs++, next if /Alphabetical/;
+      next unless $in_funcs;
+      if (/^\.I[pP] "(\w+)/) {
+        print $1 unless $func{$1}; $func{$1}++
+      }')
+    )
   else
-    echo "Couldn't find perlfunc man page; giving up."
+    _message "can't find perlfunc man page; giving up"
     return 1
   fi
 fi
 
 local expl
 
-_wanted functions expl 'Perl built-in functions' compadd -a _perl_builtin_funcs
+_wanted functions expl 'perl built-in function' compadd "$@" -a - \
+    _perl_builtin_funcs


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

* Re: PATCH: Re: Bug with _perl_builtin_funcs
  2003-04-23 10:17 ` PATCH: " Oliver Kiddle
@ 2003-04-23 16:53   ` Bart Schaefer
  2003-04-24  9:06     ` Oliver Kiddle
  0 siblings, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2003-04-23 16:53 UTC (permalink / raw)
  To: zsh-workers

On Apr 23, 12:17pm, Oliver Kiddle wrote:
} Subject: PATCH: Re: Bug with _perl_builtin_funcs
}
} On 1 Apr, Felix Rosencrantz wrote:
} > it parses the man page it assume it is plain text.  However, on RH
} > the man page is compressed with gzip.
} 
} This should make it use bzip2 or gzip as appropriate.

Why not parse the output of "perldoc perlfunc" instead?


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

* Re: PATCH: Re: Bug with _perl_builtin_funcs
  2003-04-23 16:53   ` Bart Schaefer
@ 2003-04-24  9:06     ` Oliver Kiddle
  0 siblings, 0 replies; 4+ messages in thread
From: Oliver Kiddle @ 2003-04-24  9:06 UTC (permalink / raw)
  To: zsh-workers

Bart wrote:
> On Apr 23, 12:17pm, Oliver Kiddle wrote:
> } Subject: PATCH: Re: Bug with _perl_builtin_funcs
> }
> } On 1 Apr, Felix Rosencrantz wrote:
> } > it parses the man page it assume it is plain text.  However, on RH
> } > the man page is compressed with gzip.
> } 
> } This should make it use bzip2 or gzip as appropriate.
> 
> Why not parse the output of "perldoc perlfunc" instead?

As I don't ever use perldoc, I was just looking for the minimal easy fix
and throwing in a case statement to run gzcat/bzcat/cat on a file seemed
easier than anything which would involve rewriting the parsing.

And it seemed to make sense that parsing troff source is easier than
the formatted output so I didn't think much about it. However, I just
looked at the perldoc man page and it seems that I can get POD source
by using perldoc -u (so _perldoc is clearly very minimal). That's nice
and easy to parse and yields this, much shorter function:

#autoload

local expl

: ${(A)_perl_builtin_funcs:=${(u)${${(M)${(f)"$(_call_program functions \
    perldoc -u perlfunc)"}:#\=item [a-z]*}#* }%%[^a-z]*}}

_wanted functions expl 'perl built-in function' compadd "$@" -a - \
    _perl_builtin_funcs


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

end of thread, other threads:[~2003-04-24  9:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-01 15:16 Bug with _perl_builtin_funcs Felix Rosencrantz
2003-04-23 10:17 ` PATCH: " Oliver Kiddle
2003-04-23 16:53   ` Bart Schaefer
2003-04-24  9:06     ` Oliver Kiddle

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).