home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume43 / zsh / part16 < prev    next >
Encoding:
Internet Message Format  |  1994-07-14  |  86.4 KB

  1. From: zsh-list@sterling.com (Bas de Bakker)
  2. Newsgroups: comp.sources.misc
  3. Subject: v43i105:  zsh - The Z shell, version 2.5.0, Part16/18
  4. Date: 13 Jul 1994 23:07:50 -0500
  5. Organization: Sterling Software
  6. Sender: kent@sparky.sterling.com
  7. Approved: kent@sparky.sterling.com
  8. Message-ID: <302dmm$8l@sparky.sterling.com>
  9. X-Md4-Signature: 79d99170e76afbcda48a0e0dccd70948
  10.  
  11. Submitted-by: zsh-list@sterling.com (Bas de Bakker)
  12. Posting-number: Volume 43, Issue 105
  13. Archive-name: zsh/part16
  14. Environment: UNIX
  15. Supersedes: zsh: Volume 35, Issue 51-72
  16.  
  17. #! /bin/sh
  18. # This is a shell archive.  Remove anything before this line, then feed it
  19. # into a shell via "sh file" or similar.  To overwrite existing files,
  20. # type "sh file -c".
  21. # Contents:  zsh-2.5.0/README zsh-2.5.0/help/fg
  22. #   zsh-2.5.0/scripts/lete2ctl zsh-2.5.0/src/config/bz.Makefile
  23. #   zsh-2.5.0/src/config/bz.help zsh-2.5.0/src/config/config.README
  24. #   zsh-2.5.0/src/table.c zsh-2.5.0/src/text.c zsh-2.5.0/src/watch.c
  25. #   zsh-2.5.0/src/zle.h zsh-2.5.0/src/zle_word.c
  26. # Wrapped by kent@sparky on Tue Jul 12 16:47:27 1994
  27. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin:$PATH ; export PATH
  28. echo If this archive is complete, you will see the following message:
  29. echo '          "shar: End of archive 16 (of 18)."'
  30. if test -f 'zsh-2.5.0/README' -a "${1}" != "-c" ; then 
  31.   echo shar: Will not clobber existing file \"'zsh-2.5.0/README'\"
  32. else
  33.   echo shar: Extracting \"'zsh-2.5.0/README'\" \(6375 characters\)
  34.   sed "s/^X//" >'zsh-2.5.0/README' <<'END_OF_FILE'
  35. XThis is zsh version 2.5.0.  Zsh is a shell with lots of features.  For
  36. Xa list of these, see the FEATURES file.  For more details, see the
  37. Xdocumentation.
  38. X
  39. X
  40. XInstalling zsh
  41. X--------------
  42. XTo compile zsh, cd into the src directory and type "./buildzsh".  The
  43. Xbuildzsh script takes various options that are useful if you want to
  44. Xuse a nonstandard compiler, build on several architectures, etc.  Do a
  45. X"./buildzsh help" for details.  If no errors occur, you can install
  46. Xzsh by typing "make install".  This will install the executable and
  47. Xthe manpage.
  48. X
  49. XThe compilation procedure has recently been tested and found to work
  50. Xon the machines listed below.  It might work on others, too,
  51. Xparticularly if they're small variations of these.  If so, please tell
  52. Xus about it.
  53. X
  54. XSunOS 4.1.1 and 4.1.3
  55. XSunOS 5.1 and 5.2
  56. XSolaris 2.3
  57. XLinux (various versions), but can't use USE_ZSH_MALLOC
  58. XAIX 3.2
  59. XHP9000/700, after manually telling buildzsh to use setpgid
  60. XHP9000/827, but only with GCC
  61. XHP9000/847
  62. XHPUX 9.04
  63. XNeXT with NS3.0 and NS3.1
  64. XIRIX 5.1.1.1 and 5.2
  65. XAlpha with OSF/1 1.2, 1.3 and 2.0
  66. XAlpha with Ultrix (unspecified)
  67. XDECstation with Ultrix (unspecified)
  68. XDECstation 5000/240 with Ultrix 4.2A
  69. XDECstation 5000/25 with Mach 3.0
  70. XNetBSD 0.9b
  71. XDYNIX/ptx 1.4 and 2.0.4 with X11
  72. XSony NWS with NEWS-OS 3.3
  73. XMac with MiNT after redefining the zgetwd() function as getwd()
  74. X
  75. XIf you have used zsh before, please be sure to read the section
  76. X"Important changes" below.
  77. X
  78. XIncluded in this release are alternative malloc and associated
  79. Xfunctions which reduce memory usage on some systems.  You can use
  80. Xthese by defining USE_ZSH_MALLOC in config.h.
  81. X
  82. X
  83. XDocumentation
  84. X-------------
  85. XThere are a number of documents about zsh in this distribution:
  86. X
  87. Xman/zsh.1    A manpage in nroff format.  This will be installed in
  88. X        /usr/man/man1 by "make install".
  89. X
  90. Xdoc/intro.ms    An introduction to zsh in troff format using the ms
  91. X        macros.  This document explains many of the features
  92. X        that make zsh more equal than other shells.
  93. X
  94. Xdoc/zsh.texi    Everything the manpage has, but in texinfo format.
  95. X
  96. XIf you do not have the necessary tools to process these documents,
  97. Xpostscript, ascii and info versions are available in a separate file
  98. Xat the distribution sites:
  99. X
  100. Xcarlo.phys.uva.nl:/pub/bas/zsh/zsh-2.5.0doc.tar.gz
  101. Xftp.sterling.com:/zsh/zsh-2.5.0doc.tar.gz
  102. X
  103. XThe distribution also contains a help directory with descriptions of
  104. Xbuiltin commands taken from the manpage.  The example function
  105. Xfunc/run-help will view the appropriate file from the help directory,
  106. Xset in the HELPDIR variable, or run 'man' if such a file is not
  107. Xavailable.
  108. X
  109. X
  110. XImportant changes
  111. X-----------------
  112. XThis is a list of changes in zsh compared to version 2.3.1 which might
  113. Xforce you to change your old initialization files.
  114. X
  115. XThe -h option to compctl for host completion no longer exists.  Define
  116. Xa hosts variable and use compctl -k hosts instead.  Example: change
  117. Xcompctl -h ping
  118. Xto
  119. Xcompctl -k hosts ping
  120. X
  121. XThe hostcmds, bindcmds, optcmds and varcmds special arrays no longer
  122. Xexist.  Use compctl -k hosts, -b, -o and -v respectively.
  123. X
  124. XThe NO_UNSET option applies to the positional parameters (usually the
  125. Xarguments to a script) as well as to all other parameters.
  126. X
  127. XThere is a new option CSH_JUNKIE_PAREN which has to be set to allow
  128. Xthe csh-syntax "if (test) { foo }" to work.  This has been done to
  129. Xenhance sh compatibility, where "if (test)" might be used to run
  130. X"test" in a subshell.
  131. X
  132. X
  133. XFeedback
  134. X--------
  135. XZsh is currently maintained by the members of the zsh mailing list:
  136. X
  137. X    zsh-list@sterling.com
  138. X
  139. XIf you wish to subscribe to the mailing list, send an email message to
  140. X    Majordomo@sterling.com
  141. X(this is an automated server) containing
  142. X    subscribe zsh-list <optional-address>
  143. Xwhere <optional-address> can be blank if you want to subscribe from
  144. Xyour current email address.  Send the message `help' to the same
  145. Xaddress for help on the list server; `unsubscribe zsh-list' also
  146. Xworks. (Don't send this to the list!). The list manager, Rick Ohnemus,
  147. Xcan be reached at
  148. X    owner-zsh-list@sterling.com
  149. X
  150. XYou can send bug reports, compliments and the like to the mailing
  151. Xlist.  If are not a subscriber and would like to receive an answer,
  152. Xplease mention so in your message.
  153. X
  154. X
  155. XAuthors
  156. X-------
  157. XZsh was originally written by Paul Falstad, people who have supplied
  158. Xpatches for this release are (in lexical order):
  159. X
  160. XChris.Moore@src.bae.co.uk (Chris Moore)
  161. XHarald.Eikrem@delab.sintef.no
  162. XIrving_Wolfe@happy-man.com (Irving Wolfe)
  163. XJarkko.Hietaniemi@hut.fi (Jarkko Hietanimi)
  164. XP.Stephenson@swansea.ac.uk (Peter Stephenson)
  165. XRichard.Sharman@software.mitel.com (Richard Sharman)
  166. XTero_Kivinen@hut.FI (Tero Kivinen)
  167. Xarf@maths.nott.ac.uk (Anthony Iano-Fletcher)
  168. Xbas@phys.uva.nl (Bas de Bakker)
  169. Xbenson@odi.com (Benson Margulies)
  170. Xbillb@bedford.progress.com (Bill Burton)
  171. Xbrown@wi.extrel.com (M. Brown)
  172. Xcarlos@snfep1.if.usp.br (Carlos Carvalho)
  173. Xcedman@capitalist.princeton.edu (Carl Edman)
  174. Xchip%fin@myrddin.sybus.com (Chip Salzenberg)
  175. Xchs@apu.fi (Hannu Strang)
  176. Xcross@eng.umd.edu (Chris Ross)
  177. Xdm@cs.brown.edu (Dimitris Michailidis)
  178. Xdmm0t@rincewind.mech.virginia.edu (David M. Meyer)
  179. Xesky@CS.UCLA.EDU (Eskandar Ensafi)
  180. Xfranl@centerline.com (Fran Litterio)
  181. Xgansevle@cs.utwente.nl (Fred Gansevles)
  182. Xgnohmon@ssiny.com (Ralph Betza)
  183. Xguillaum@clipper.ens.fr (Florent Guillaume)
  184. Xguthrie@math.upenn.edu (John Guthrie)
  185. Xhegedus@celeste.eng.yale.edu (Peter Hegedus)
  186. Xhoh@approve.se (Goran Larsson)
  187. Xhooft@chem.ruu.nl (Rob Hooft)
  188. Xhsw1@papa.attmail.com (Stephen Harris)
  189. Xirving@happy-man.com (Irving Wolfe)
  190. Xjch@cs.cmu.edu (Jonathan Hardwick)
  191. Xjhi@dol-guldur.hut.fi (Jarkko Hietaniemi)
  192. Xjos@oce.nl (Jos Backus)
  193. Xliblit@cs.psu.edu (Benjamin Liblit)
  194. Xmarc@cam.org (Marc Boucher)
  195. Xmason@werple.apana.org.au (Geoff Wing)
  196. Xmycroft@gnu.ai.mit.edu (Charles Hannum)
  197. Xmystic@axposf.pa.dec.com (D. Hall)
  198. Xnorbert@i3.informatik.rwth-aachen.de (Norbert Kiesel)
  199. Xoberon@cs.tu-berlin.de (Sven Wischnowsky)
  200. Xpclink@qld.tne.oz.au (Rick)
  201. Xpem@aaii.oz.au (Paul Maisano)
  202. Xper@efd.lth.se (Per Foreby)
  203. Xpf@z-code.com (Paul Falstad)
  204. Xroderick@ibcinc.com (Roderick Schertler)
  205. Xschaefer@z-code.com (Bart Schaefer)
  206. Xschlangm@informatik.uni-muenchen.de (Harald Schlangmann)
  207. Xseniorr@teleport.com (Russell Senior)
  208. Xsinclair@dcs.gla.ac.uk (Duncan Sinclair)
  209. Xsterling@oldcolo.com (Bruce Sterling Woodcock)
  210. Xsuzuki@otsl.oki.co.jp (Hisao Suzuki)
  211. Xtsm@cs.brown.edu (Timothy Miller)
  212. Xwacker@physik.uni-dortmund.de (Klaus Wacker)
  213. Xwacren@cis10.ens-cachan.fr (Laurent Wacrenier)
  214. END_OF_FILE
  215.   if test 6375 -ne `wc -c <'zsh-2.5.0/README'`; then
  216.     echo shar: \"'zsh-2.5.0/README'\" unpacked with wrong size!
  217.   fi
  218.   # end of 'zsh-2.5.0/README'
  219. fi
  220. if test -f 'zsh-2.5.0/help/fg' -a "${1}" != "-c" ; then 
  221.   echo shar: Will not clobber existing file \"'zsh-2.5.0/help/fg'\"
  222. else
  223.   echo shar: Extracting \"'zsh-2.5.0/help/fg'\" \(156 characters\)
  224.   sed "s/^X//" >'zsh-2.5.0/help/fg' <<'END_OF_FILE'
  225. X       fg [ job ... ]
  226. X       job ...
  227. X              Bring the specified jobs to the foreground.  If  no
  228. X              job is specified, use the current job.
  229. END_OF_FILE
  230.   if test 156 -ne `wc -c <'zsh-2.5.0/help/fg'`; then
  231.     echo shar: \"'zsh-2.5.0/help/fg'\" unpacked with wrong size!
  232.   fi
  233.   # end of 'zsh-2.5.0/help/fg'
  234. fi
  235. if test -f 'zsh-2.5.0/scripts/lete2ctl' -a "${1}" != "-c" ; then 
  236.   echo shar: Will not clobber existing file \"'zsh-2.5.0/scripts/lete2ctl'\"
  237. else
  238.   echo shar: Extracting \"'zsh-2.5.0/scripts/lete2ctl'\" \(9250 characters\)
  239.   sed "s/^X//" >'zsh-2.5.0/scripts/lete2ctl' <<'END_OF_FILE'
  240. X#!/usr/local/bin/perl -- -*-perl-*-
  241. X#
  242. X#   ``Wee have also Shelles, thee Lyke of whych you knowe not, wherein
  243. X#     thee User may with thee merest Presse of thee Tabbe-Keye expande
  244. X#     or compleat al Maner of Wordes and such-like Diversities.''
  245. X#            - Francis Bacon, `New Atlantis' (or not).
  246. X#
  247. X# Convert tcsh "complete" statements to zsh "compctl" statements.
  248. X# Runs as a filter.  Should ignore anything which isn't a "complete".
  249. X# It expects each "complete" statement to be the first thing on a line.
  250. X# All the examples in the tcsh manual give sensible results.
  251. X# Author:  Peter Stephenson <pws@s-a.amtp.liv.ac.uk>
  252. X#
  253. X# Option:
  254. X# -x (exact): only applies in the case of command disambiguation (is
  255. X#    that really a word?)  If you have lines like
  256. X#       complete '-co*' 'p/0/(compress)'
  257. X#    (which makes co<TAB> always complete to `compress') then the
  258. X#    resulting "compctl" statements will produce one of two behaviours:
  259. X#    (1) By default (like tcsh), com<TAB> etc. will also complete to
  260. X#        "compress" and nothing else.
  261. X#    (2) With -x, com<TAB> does ordinary command completion: this is
  262. X#        more flexible.
  263. X#    I don't understand what the hyphen in complete does and I've ignored it.
  264. X#
  265. X# Notes:
  266. X# (1) The -s option is the way to do backquote expansion.  In zsh,
  267. X#     "compctl -s '`users`' talk" works (duplicates are removed).
  268. X# (2) Complicated backquote completions should definitely be rewritten as
  269. X#     shell functions (compctl's "-K func" option).  Although most of
  270. X#     these will be translated correctly, differences in shell syntax
  271. X#     are not handled.
  272. X# (3) Replacement of $:n with the n'th word on the current line with
  273. X#     backquote expansion now works; it is not necessarily the most
  274. X#     efficient way of doing it in any given case, however.
  275. X# (4) I have made use of zsh's more sophisticated globbing to change
  276. X#     things like ^foo.{a,b,c,d} to ^foo.(a|b|c|d), which works better.
  277. X#     It's just possible in some cases you may want to change it back.
  278. X# (5) Make sure all command names with wildcards are processed together --
  279. X#     they need to be lumped into one "compctl -C" or "compctl -D"
  280. X#     statement for zsh.
  281. X
  282. X# Handle options
  283. X($ARGV[0] eq '-x') && shift && ($opt_x = 1);
  284. X($ARGV[0] =~ /^-+$/) && shift;
  285. X
  286. X# Function names used (via magic autoincrement) when cmdline words are needed
  287. X$funcnam = 'compfn001';
  288. X
  289. X# Read next word on command line
  290. Xsub getword {
  291. X    local($word, $word2, $ret);
  292. X    ($_) = /^\s*(.*)$/;
  293. X    while ($_ =~ /^\S/) {
  294. X    if (/^[\']/) {
  295. X        ($word, $_) = /^\'([^\']*).(.*)$/;
  296. X    } elsif (/^[\"]/) {
  297. X        ($word, $_) = /^\"([^\"]*).(.*)$/;
  298. X        while ($word =~ /\\$/) {
  299. X        chop($word);
  300. X        ($word2, $_) = /^([^\"]*).(.*)$/;
  301. X        $word .= '"' . $word2;
  302. X        }
  303. X    } elsif (/\S/) {
  304. X        ($word, $_) = /^([^\s\\\'\"#;]*)(.*)$/;
  305. X        # Backslash: literal next character
  306. X        /^\\(.)/ && (($word .= substr($_,1,1)),
  307. X             ($_ = substr($_,2)));
  308. X        # Rest of line quoted or end of command
  309. X        /^[#;]/ && ($_ = '');
  310. X    } else {
  311. X        return undef;
  312. X    }
  313. X    length($word) && ($ret = $ret . $word);
  314. X    }
  315. X    $ret;
  316. X}
  317. X
  318. X# Interpret the x and arg in 'x/arg/type/'
  319. Xsub getpat {
  320. X    local($pat,$arg) = @_;
  321. X    local($ret,$i);
  322. X    if ($pat eq 'p') {
  323. X    $ret = "p[$arg]";
  324. X    } elsif ($pat eq 'n' || $pat eq 'N') {
  325. X    $let = ($arg =~ /[*?|]/) ? 'C' : 'c';
  326. X    $num = ($pat eq 'N') ? 2 : 1;
  327. X    $ret = "${let}[-${num},$arg]";
  328. X    } elsif ($pat eq 'c' || $pat eq 'C') {
  329. X    # A few tricks to get zsh to ignore up to the end of
  330. X    # any matched pattern.
  331. X    if (($pat eq 'c' && $arg =~ /^\*([^*?]*)$/)) {
  332. X        $ret = "n[-1,$1]";
  333. X    } elsif ($arg =~ /[*?]([^*?]*)$/) {
  334. X        length($1) && ($ret = " n[-1,$1]");
  335. X        $ret = "C[0,$arg] $ret";
  336. X    } else {
  337. X        $let = ($pat eq 'c') ? 's' : 'S';
  338. X        $ret = "${let}[$arg]";
  339. X    }
  340. X    }
  341. X    $ret =~ s/'/'\\''/g;
  342. X    $ret;
  343. X}
  344. X
  345. X# Interpret the type in 'x/arg/type/'
  346. Xsub gettype {
  347. X    local ($_) = @_;
  348. X    local($qual,$c,$glob,$ret,$b,$m,$e,@m);
  349. X    $c = substr($_,0,1);
  350. X    ($c =~ /\w/) && (substr($_,1,1) eq ':') && ($glob = substr($_,2));
  351. X# Nothing (n) can be handled by returning nothing.  (C.f. King Lear, I.i.)
  352. X    if ($c =~ /[abcjuv]/) {
  353. X    $ret = "-$c";
  354. X    } elsif ($c eq 'S') {
  355. X    $ret = '-k signals';
  356. X    } elsif ($c eq 'd') {
  357. X    $qual = '/';
  358. X    } elsif ($c eq 'e') {
  359. X    $ret = '-E';
  360. X    } elsif ($c eq 'f' && !$glob) {
  361. X    $ret = '-f';
  362. X    } elsif ($c eq 'l') {
  363. X    $ret = qq
  364. X-k  '(cputime filesize datasize stacksize coredumpsize resident descriptors)'
  365. X    ;
  366. X    } elsif ($c eq 'p') {
  367. X    # Use globbing, but make sure there's a star at the end
  368. X    ($glob =~ /\*$/) || ($glob .= '*');
  369. X    } elsif ($c eq 's') {
  370. X    $ret = '-p';
  371. X    } elsif ($c eq 't') {
  372. X    $qual = '.';
  373. X    } elsif ($c eq 'x') {
  374. X    $glob =~ s/'/'\\''/g;
  375. X    $ret = "-X '$glob'";
  376. X    undef($glob);
  377. X    } elsif ($c eq '$') {     # '{
  378. X    $ret = "-k " . substr($_,1);
  379. X    } elsif ($c eq '(') {
  380. X    s/'/'\\''/g;
  381. X    $ret = "-k '$_'";
  382. X    } elsif ($c eq '`') {
  383. X    # this took some working out...
  384. X    if (s/\$:(\d+)/$foo=$1+1,"\${word[$foo]}"/ge) {
  385. X        $ret = "-K $funcnam";
  386. X        $genfunc .= <<"HERE";
  387. Xfunction $funcnam {
  388. X    local word
  389. X    read -cA word
  390. X    reply=($_)
  391. X}
  392. XHERE
  393. X        $funcnam++;
  394. X    } else {
  395. X        s/'/'\\''/g;
  396. X        $ret = "-s '$_'";
  397. X    }
  398. X    }
  399. X
  400. X    # foo{bar,ba,blak,sheap} -> foo(bar|ba|blak|sheap).
  401. X    # This saves a lot of mess, since in zsh brace expansion occurs
  402. X    # before globbing.  I'm sorry, but I don't trust $` and $'.
  403. X    while ((($b,$m,$e) = ($glob =~ /^(.*)\{(.*)\}(.*)$/))
  404. X       && ($m =~ /,/)) {
  405. X    @m = split(/,/, $m);
  406. X    for ($i = 0; $i < @m; $i++) {
  407. X        while ($m[$i] =~ /\\$/) {
  408. X        substr($m[$i],-1,1) = "";
  409. X        splice(@m,$i,2,"$m[$i]\\,$m[$i+1]");
  410. X        }
  411. X    }
  412. X    $glob = $b . "(" . join('|',@m) . ")" . $e;
  413. X    }
  414. X
  415. X    if ($qual) {
  416. X    $glob || ($glob = '*');
  417. X    $glob .= "($qual)";
  418. X    }
  419. X    $glob && (($glob =~ s/'/'\\''/g),($glob = "-g '$glob'"));
  420. X
  421. X    defined($ret) && defined($glob) && ($ret .= " $glob");
  422. X    defined($ret) ? $ret : $glob;
  423. X}
  424. X
  425. X# Quoted array separator for extended completions
  426. X$" = " - ";
  427. X
  428. Xwhile (<>) {
  429. X    if (/^\s*complete\s/) {
  430. X    $wc = 0;
  431. X    undef(@stuff); undef($default);
  432. X    $_ = $';
  433. X    while (/\\$/) {
  434. X        # Remove backslashed newlines: in principle these should become
  435. X        # real newlines inside quotes, but what the hell.
  436. X        ($_) = /^(.*)\\$/;
  437. X        $_ .= <>;
  438. X    }
  439. X    $command = &getword;
  440. X    if ($command =~ /^-/ || $command =~ /[*?]/) {
  441. X        # E.g. complete -co* ...
  442. X        $defmatch = $command;
  443. X        ($defmatch =~ /^-/) && ($defmatch = substr($defmatch,1));
  444. X    } else {
  445. X        undef($defmatch);
  446. X    }
  447. X    while (defined($word = &getword)) {
  448. X        # Loop over remaining arguments to "complete".
  449. X        $sep = substr($word,1,1);
  450. X        $sep =~ s/(\W)/\\$1/g;
  451. X        @split = split(/$sep/,$word);
  452. X        for ($i = 0; $i < 3; $i++) {
  453. X        while ($split[i] =~ /\\$/) {
  454. X            substr($split[i],-1,1) = "";
  455. X            splice(@split,$i,2,"$split[i]\\$sep$split[i+1]");
  456. X        }
  457. X        }
  458. X        ($pat,$arg,$type,$suffix,$crap) = @split;
  459. X        ($suffix =~ /^\s*$/) && undef($suffix);
  460. X        if (($word =~ /^n${sep}\*${sep}/) &&
  461. X         (!defined($defmatch))) {
  462. X         # The "complete" catch-all:  treat this as compctl\'s
  463. X         # default (requiring no pattern matching).
  464. X        $default .= &gettype($type) . ' ';
  465. X        defined($suffix) && ($defsuf .= $suffix);
  466. X        } else {
  467. X        $pat = &getpat($pat,$arg);
  468. X        $type = &gettype($type);
  469. X        if (defined($defmatch)) {
  470. X            # The command is a pattern: use either -C or -D option.
  471. X            if ($pat eq 'p[0]') {
  472. X            # Command word (-C): 'p[0]' is redundant.
  473. X            if ($defmatch eq '*') {
  474. X                $defcommand = $type;
  475. X            } else {
  476. X                ($defmatch =~ /\*$/) && chop($defmatch);
  477. X                if ($opt_x) {
  478. X                $c = ($defmatch =~ /[*?]/) ? 'C' : c;
  479. X                $pat = "${c}[0,${defmatch}]";
  480. X                } else {
  481. X                $pat = ($defmatch =~ /[*?]/) ?
  482. X                    "C[0,${defmatch}]" : "S[${defmatch}]";
  483. X                }
  484. X                push(@commandword,defined($suffix) ?
  485. X                 "'$pat' $type -S '$suffix'" : "'$pat' $type");
  486. X            }
  487. X            } elsif ($pat eq "C[-1,*]") {
  488. X            # Not command word completion, but match
  489. X            # command word (only)
  490. X            if ($defmatch eq "*") {
  491. X                # any word of any command
  492. X                $defaultdefault .= " $type";
  493. X            } else {
  494. X                $pat = "W[0,$defmatch]";
  495. X                push(@defaultword,defined($suffix) ?
  496. X                 "'$pat' $type -S '$suffix'" : "'$pat' $type");
  497. X            }
  498. X            } else {
  499. X                # Not command word completion, but still command
  500. X            # word with pattern
  501. X            ($defmatch = '*') || ($pat = "W[0,$defmatch] $pat");
  502. X            push(@defaultword,defined($suffix) ?
  503. X                 "'$pat' $type -S '$suffix'" : "'$pat' $type");
  504. X            }
  505. X        } else {
  506. X            # Ordinary command
  507. X            push(@stuff,defined($suffix) ?
  508. X             "'$pat' $type -S '$suffix'" : "'$pat' $type");
  509. X        }
  510. X        }
  511. X    }
  512. X        if (!defined($defmatch)) {
  513. X        # Ordinary commands with no pattern
  514. X        print("compctl $default");
  515. X        defined($defsuf) && print("-S '$defsuf' ") && undef($defsuf);
  516. X        defined(@stuff) && print("-x @stuff -- ");
  517. X        print("$command\n");
  518. X    }
  519. X    if (defined($genfunc)) {
  520. X        print $genfunc;
  521. X        undef($genfunc);
  522. X    }
  523. X    }
  524. X}
  525. X
  526. X(defined(@commandword) || defined($defcommand)) &&
  527. X    print("compctl -C ",
  528. X      defined($defcommand) ? $defcommand : '-c',
  529. X      defined(@commandword) ? " -x @commandword\n" : "\n");
  530. X
  531. Xif (defined($defaultdefault) || defined(@defaultword)) {
  532. X    defined($defaultdefault) || ($defaultdefault = "-f");
  533. X    print "compctl -D $defaultdefault";
  534. X    defined(@defaultword) && print(" -x @defaultword");
  535. X    print "\n";
  536. X}
  537. X
  538. X__END__
  539. END_OF_FILE
  540.   if test 9250 -ne `wc -c <'zsh-2.5.0/scripts/lete2ctl'`; then
  541.     echo shar: \"'zsh-2.5.0/scripts/lete2ctl'\" unpacked with wrong size!
  542.   fi
  543.   # end of 'zsh-2.5.0/scripts/lete2ctl'
  544. fi
  545. if test -f 'zsh-2.5.0/src/config/bz.Makefile' -a "${1}" != "-c" ; then 
  546.   echo shar: Will not clobber existing file \"'zsh-2.5.0/src/config/bz.Makefile'\"
  547. else
  548.   echo shar: Extracting \"'zsh-2.5.0/src/config/bz.Makefile'\" \(7495 characters\)
  549.   sed "s/^X//" >'zsh-2.5.0/src/config/bz.Makefile' <<'END_OF_FILE'
  550. X# --- ${C_BLDDIR}Makefile
  551. X
  552. Xif test -n "$B_Makefile"
  553. Xthen
  554. X
  555. XF_define=
  556. XF_using=yep
  557. X
  558. Xcat <<foo
  559. X
  560. XBuilding $MAKEFILE...
  561. X
  562. Xfoo
  563. X
  564. X# configure the needed variables
  565. X
  566. Xtest -z "$make_probe_done" && . ./config/bz.makeprobe
  567. X
  568. X# just build it!
  569. X
  570. X(exec >$MAKEFILE
  571. Xcat <<foo
  572. X#! /bin/make -f
  573. X# Makefile
  574. X# architecture-customized Makefile for $VERSION
  575. X# for architecture "$arch",
  576. X# automagically generated by buildzsh -- do not edit
  577. X
  578. XMAKE=make
  579. X
  580. XAUX=buildzsh
  581. X
  582. XSRC=$SRC
  583. X
  584. XHEADER=$HEADER
  585. X
  586. XPROTO=$PROTO
  587. X
  588. XOBJS=$OBJS
  589. X
  590. XBINDIR=$C_BINDIR
  591. XMANDIR=$C_MANDIR
  592. X
  593. X# Debugging flags
  594. XDFLAGS=$DFLAGS
  595. X
  596. XCC=$CC
  597. X
  598. XCFLAGS=$CFLAGS
  599. X
  600. XCFLAGS_WO_O=$CFLAGS_WO_O
  601. X
  602. XLD=$LD
  603. X
  604. XLDFLAGS=$LDFLAGS
  605. X
  606. XLIBS=$LIBS
  607. X
  608. XZSHPATH=${C_BLDDIR}zsh
  609. X
  610. Xall: \$(PROTO) \$(ZSHPATH)
  611. X
  612. X.SUFFIXES: .c .o .pro
  613. X
  614. Xfoo
  615. X
  616. Xecho '    ...possible notes' 1>&2
  617. X
  618. Xecho '    ...special rules' 1>&2
  619. X
  620. X# --- notes for various environments (and compilers)
  621. X
  622. X# Past problems: (PLEASE COLLECT PAST PROBLEMS WITH COMPILERS
  623. X# HERE: NOT ERRORS/WARNINGS BUT STUFF ABOUT COMPILER CRASHES AND SUCH)
  624. X#
  625. X# AIX c89 -O -c builtin.c/2.4.60...2.4.2xx used to dump core,
  626. X# AIX 3.2.4 fixes the situation, harass your IBM rep until you get the patches.
  627. X# (the temporary patch is to use cc on builtin.c)
  628. X#
  629. X# IRIX cc -ansiposix -O zle_misc.c/2.4.75..2.4.2xx used to dump core,
  630. X# later zsh patchlevels do not have this problem
  631. X# (the temporary patch was to drop -O on zle_misc.c)
  632. X#
  633. X
  634. Xif test -n "$AIX"
  635. Xthen
  636. Xcat <<foo
  637. X#    --- AIX notes
  638. X#    Note 1:    Pre-3.2.4 AIX c89 -O -c builtin.c dumps core,
  639. X#        the temporary cure is to use cc on builtin.c.
  640. X#
  641. X#    Note 2: 3.2.4-onwards AIX cc -O builtin.c gets stuck (optimizer
  642. X#        tries too hard), the temporary cure is to drop -O.
  643. X#
  644. X# @@@ NOTE: won't work if srcdir != blddir
  645. X${C_BLDDIR}builtin.o:     ${C_SRCDIR}builtin.c
  646. X    cc \$(CFLAGS_WO_O) \$(DFLAGS) -o builtin.o -c builtin.c
  647. X
  648. Xfoo
  649. Xelif test -n "$HPUX"
  650. Xthen
  651. Xcat <<'foo'
  652. X#    --- HPUX notes
  653. X#    With c89 you will get warnings ftom
  654. X#    from zle_tricky.c: warning 530: Casting from loose to strict alignment.
  655. X#    this problem is caused by casting "char *"s to e.g. Cmdnam-
  656. X#    structures and then immediately accessing the elements, like this: 
  657. X#    char *s;
  658. X#    char *cn;
  659. X#    {
  660. X#        if (((Cmdnam) cn)->type != DISABLED)
  661. X#
  662. Xfoo
  663. Xelif test -n "$CONVEX"
  664. Xthen
  665. Xcat <<'foo'
  666. X#    --- CONVEX notes
  667. X#    cc options NOT used:
  668. X#    -std (strict ANSI + POSIX, non-POSIX not recognized, e.g. long long)
  669. X#    -str (strict ANSI, UNIX functions not recognized)
  670. X#    diagnostics not used (zsh code too "hopeless"):
  671. X#    assign_in_condition metrics_file metrics_off
  672. X#    negative_to_uns pointer_alignment_efficiency skip_to_char skip_to_eof
  673. X#    Note 1: man cc lies that ptr_cvt_truncates is ptr_convert_truncates
  674. X#    Note 2: cc notices that init.c:main() never returns
  675. X#    Note 3: utils.c:intr() and holdintr() sigvec initializations
  676. X#            are somehow suspicious
  677. X#
  678. Xfoo
  679. Xelif test -n "$SOLARIS"
  680. Xthen
  681. Xcat <<'foo'
  682. X#    --- SOLARIS notes
  683. X#    SunSoft cc assumed (CFLAGS derived from this assumption),
  684. X#    if you want to use gcc, try 'buildzsh gcc'
  685. Xfoo
  686. Xelif test -n "$NEXT"
  687. Xthen
  688. Xcat <<'foo'
  689. X#    --- NEXT notes
  690. X#    You will get two warnings for each file because
  691. X#    /NextDeveloper/Headers/bsd/memory.h:23 contains
  692. X#    ANSI-illegal trash after #endif.
  693. X#
  694. Xfoo
  695. Xelif test -n "$UNICOS"
  696. Xthen
  697. Xcat <<'foo'
  698. X#    --- UNICOS notes
  699. X#    Note 1: you will get five WARNINGs for each file because of
  700. X#            a) <sys/param.h>, <sys/ioctl.h>:
  701. X#           there is something else than just newline after
  702. X#           directives #endif or #else (Cray's fault)
  703. X#    It *is* possible to get more picky by adding '-h port=insx'
  704. X#    to the CFLAGS but then a horde of complaints will jump at you:
  705. X#    Note 2: a) <stdio.h>:
  706. X#           use bit fields other than signed int or unsigned int
  707. X#            b) <sys/file.h>:
  708. X#           union members have different types
  709. X#            b1) f_uinode and f_udata
  710. X#            b2) f_unext and f_udata
  711. X#            (both of these Cray's fault)
  712. X#    Note 3: zsh.h: union members have different types
  713. X#            a1) nam and binnum    a5) arr and val
  714. X#            a2) nam and list        a6) str and val
  715. X#            a3) binnum and list    a7) cfn and ifn
  716. X#            a4) arr and str        a8) ifn and afn
  717. X#            b) cond.c:
  718. X#            pointer is cast to a pointer of another type
  719. X#    Note 4: from most of the zsh source files LOTS of:
  720. X#            a) an assignment to a shorter integral type may cause truncation
  721. X#            b) an integral type is cast to  pointer
  722. X#            c) a character pointer cast may result in improprer alignment
  723. X#            d) a "char" assigned to a larger "int" may sign-extend incorrectly
  724. X#
  725. Xfoo
  726. X# IRIX5 test before IRIX test because IRIX5 is also IRIX but we
  727. X# want IRIX5-specific stuff here
  728. Xelif test -n "$IRIX5"
  729. Xthen
  730. Xcat <<'foo'
  731. X#    -- IRIX5 notes
  732. X#    Warnings turned off:
  733. X#    799: /usr/include/sgidefs.h, line 141: 'long long' is not standard ANSI. (3.1.1)
  734. X#
  735. Xfoo
  736. Xelif test -n "$IRIX"
  737. Xthen
  738. Xcat <<'foo'
  739. X#    --- IRIX notes
  740. X#    Warnings turned off:
  741. X#      2: %s redefinition hides earlier one
  742. X#         (all the static-global c's, sigh...)
  743. X#    183: Previous declaration had prototype, this declaration does not(prototype declaration kept)
  744. X#         (ANSI *.pro vs K&R *.c)
  745. X#    262: Previous declaration had prototype, this definition does not
  746. X#         (ditto)
  747. X#    269: Evaluation gives an intermediate result type difference in ANSI versus K&R C;   int  versus   unsigned int
  748. X#         (all the unsigned staff vs char and int literals, ugh)
  749. X#    302: bodyless for statement
  750. X#         (not bad at all, just suspicious)
  751. X#    303: bodyless while statement
  752. X#         (not bad at all, just suspicious)
  753. X#    309: Only int, signed int, unsigned int bit-fields defined in ANSI C. char, short, and long versions are allowed as an extension (ANSI C 3.5.2.1)
  754. X#         (one of IRIX' own header files is bad in this way...)
  755. X#
  756. Xfoo
  757. Xelif test -n "$TITAN"
  758. Xthen
  759. Xcat <<'foo'
  760. X#    --- TITAN notes
  761. X#    Note 1: lots of (about 125) of "argument xxx is not used"
  762. X#    Note 2: LOTS of (about 420) of "conversion of xxx (0xyy) loses precision
  763. X#    Note 3: couple of (3) of "implied return [blah blah]"
  764. X#        (caused by poor flow analysis, not by poor code)
  765. X#
  766. Xfoo
  767. Xfi
  768. X
  769. Xecho '    ...general rules' 1>&2
  770. X
  771. Xif test -n "$ccseparate"
  772. Xthen
  773. X  if test -n "$make_groks_VPATH"
  774. X  then
  775. X    for _b in $BSRC
  776. X    do
  777. Xcat <<foo
  778. X$_b.o:    $_b.c
  779. X    $ccit -c \$?
  780. X
  781. Xfoo
  782. X    done
  783. X  else
  784. X    for _b in $BSRC
  785. X    do
  786. Xcat <<foo
  787. X$_b.o:    $C_SRCDIR/$_b.c
  788. X    $ccit -c \$?
  789. X
  790. Xfoo
  791. X     done
  792. X  fi
  793. Xelse    # the simple case
  794. Xcat <<foo
  795. X.c.o:
  796. X    $ccit $ccdotc
  797. X
  798. Xfoo
  799. Xfi
  800. X
  801. Xif test -z "$make_groks_VPATH"
  802. Xthen
  803. X  for _proto in $PROTO
  804. X  do
  805. X    _c=`basename $_proto|sed 's/pro$/c/`
  806. Xcat <<foo
  807. X$_proto:
  808. X    sed -n -f makepro.sed $_c > $_proto
  809. X
  810. Xfoo
  811. X  done
  812. Xelse
  813. X
  814. Xcat <<foo
  815. X
  816. X.c.pro:
  817. X    sed -n -f makepro.sed ${C_SRCDIR}$< > \`basename ${C_BLDDIR}\$@\`
  818. X
  819. Xfoo
  820. Xfi
  821. X
  822. Xcat <<foo
  823. X\$(ZSHPATH): \$(OBJS)
  824. X    \$(LD) \$(LDFLAGS) -o \$(ZSHPATH) \$(OBJS) \$(LIBS)
  825. X    
  826. X\$(PROTO): ${C_SRCDIR}makepro.sed
  827. X
  828. Xtags: /tmp
  829. Xfoo
  830. Xtest -z "$F_bld_eq_src" -a -n "$C_SRCDIR" && echo "    cd $C_SRCDIR"
  831. Xcat <<foo
  832. X    ctags *.[cy]
  833. X
  834. X# I hate this next line
  835. X\$(OBJS): ${C_BLDDIR}config.h ${C_BLDDIR}signals.h ${C_SRCDIR}zsh.h ${C_SRCDIR}zle.h ${C_SRCDIR}ztype.h ${C_SRCDIR}funcs.h
  836. X
  837. X${C_BLDDIR}params.o: ${C_SRCDIR}version.h
  838. X
  839. X${C_SRCDIR}makepro.sed:
  840. X    \$(CO) \$(COFLAGS) ${C_SRCDIR}makepro.sed
  841. X
  842. Xclean:
  843. Xfoo
  844. Xtest $C_SRCDIR && echo "    cd $C_SRCDIR"
  845. Xcat <<'foo'
  846. X    rm -f $(OBJS) $(ZSHPATH) core
  847. X
  848. Xspotless:    clean
  849. Xfoo
  850. Xtest -z "$F_bld_eq_src" -a -n "$C_SRCDIR" && echo "    cd $C_SRCDIR"
  851. Xcat <<foo
  852. X    rm -f \$(PROTO) Makefile ${C_BLDDIR}signals.h ${C_BLDDIR}config.h
  853. X
  854. Xinstall: ${C_BLDDIR}zsh
  855. Xfoo
  856. Xtest -z "$F_bld_eq_src" -a -n "$C_SRCDIR" && echo "    cd $C_SRCDIR"
  857. Xcat <<foo
  858. X    cp ${C_BLDDIR}zsh \$(BINDIR)
  859. X    chmod 755 \$(BINDIR)/zsh
  860. X    cp ${C_SRCDIR}../man/zsh.1 \$(MANDIR)
  861. X    chmod 644 \$(MANDIR)/zsh.1
  862. Xfoo
  863. X)
  864. Xfi
  865. X
  866. X###
  867. END_OF_FILE
  868.   if test 7495 -ne `wc -c <'zsh-2.5.0/src/config/bz.Makefile'`; then
  869.     echo shar: \"'zsh-2.5.0/src/config/bz.Makefile'\" unpacked with wrong size!
  870.   fi
  871.   # end of 'zsh-2.5.0/src/config/bz.Makefile'
  872. fi
  873. if test -f 'zsh-2.5.0/src/config/bz.help' -a "${1}" != "-c" ; then 
  874.   echo shar: Will not clobber existing file \"'zsh-2.5.0/src/config/bz.help'\"
  875. else
  876.   echo shar: Extracting \"'zsh-2.5.0/src/config/bz.help'\" \(7059 characters\)
  877.   sed "s/^X//" >'zsh-2.5.0/src/config/bz.help' <<'END_OF_FILE'
  878. Xcat <<EOH | $PAGER
  879. XNAME
  880. X
  881. X    buildzsh -- zsh configuration tool
  882. X
  883. XSYNOPSIS
  884. X
  885. X    buildzsh [parameters]
  886. X
  887. X    buildzsh builds all or some of the files config.h, signals.h,
  888. X    and Makefile.  These files are necessary for building zsh.
  889. X    For more detailed explanation, see FILES below.
  890. X
  891. X    By default it builds them all, this can be done by simply saying
  892. X
  893. X        ./buildzsh
  894. X
  895. X    from the shell level while in the same directory with buildzsh.
  896. X    For not building all of the abovementioned files, see note 3)
  897. X    under BOOLEAN PARAMETERS.
  898. X
  899. X    buildzsh supports building zsh for several architectures
  900. X    from the same, untouched, source tree.  See MULTIARCHITECTURE
  901. X    SUPPORT below.
  902. X
  903. XPARAMETERS
  904. X
  905. X    buildzsh knows about two kinds of parameters:
  906. X
  907. X    CONFIGURABLE and BOOLEAN
  908. X
  909. XCONFIGURABLE PARAMETERS
  910. X
  911. X    configurable might also be called assignable: they can be
  912. X    assigned some value by using the form
  913. X
  914. X        param=value
  915. X
  916. X    For example
  917. X
  918. X        ./buildzsh LIBS=-ltermcap
  919. X
  920. X    sets the configurable parameters "LIBS" to the value "-ltermcap"
  921. X
  922. X    param        explanation            default
  923. X    -----        -----------            -------
  924. X    CC        C compiler            $DEFAULT_C_CC
  925. X    CFLAGS        C compiler flags    for example    $DEFAULT_C_CFLAGS
  926. X    CFLAGS_D    C preprocessor flags (-Dfoo)    $DEFAULT_C_CFLAGS_D
  927. X    CFLAGS_W    C warning flags         (-ansi)    $DEFAULT_C_CFLAGS_W
  928. X    CFLAGS_X    C extra flags        (-m486)    $DEFAULT_C_CFLAGS_X
  929. X    CFLAGS_O    C optimizer flags    (-O)    $DEFAULT_C_CFLAGS_O
  930. X    CFLAGS_g    C debugger flags     (-g)    $DEFAULT_C_CFLAGS_g
  931. X    CFLAGS_z    zsh debugging flags  (-DQDEBUG)    $DEFAULT_C_CFLAGS_z
  932. X    LDFLAGS        linking flags         (-x)    \$(CFLAGS)
  933. X    LIBS        libraries to link with    (-lnet)    $DEFAULT_C_LIBS
  934. X    SRCDIR        source directory        $DEFAULT_C_SRCDIR
  935. X    BLDDIR        building directory        $DEFAULT_C_BLDDIR
  936. X    ARCH        architecture            (zsh HOSTTYPE)
  937. X    ARCHPATT    ARCH pattern 2)            $DEFAULT_C_ARCHPATT
  938. X    INSTDIR        installation directory 3)    $DEFAULT_C_INSTDIR
  939. X    BINDIR        binary INSTDIR            $DEFAULT_C_BINDIR
  940. X    MANDIR        manual page INSTDIR        $DEFAULT_C_MANDIR
  941. X    ETCDIR        global init file directory    $DEFAULT_C_ETCDIR
  942. X    MAKE        the "make" to use        $DEFAULT_C_MAKE
  943. X
  944. X    1) CFLAGS overrides all CFLAGS_... parameters, each CFLAGS_...
  945. X       overrides any guesses done by buildzsh.
  946. X
  947. X    2) For each instance of ARCHPATT in the parameters
  948. X       $ARCH_PARMS,
  949. X       ARCH will be substituted.
  950. X
  951. X    3) If INSTDIR is set, it will be a prefix for BINDIR (=INSTDIR/bin)
  952. X       and MANDIR (=INSTDIR/man/man1), BINDIR and MANDIR cannot then be
  953. X       set on their own.
  954. X
  955. XBOOLEAN PARAMETERS
  956. X
  957. X    These parameters are either present or not.
  958. X
  959. X    param        explanation            default
  960. X    -----        -----------            -------
  961. X    config.h    build config.h            $DEFAULT_B_config_h 1)
  962. X    signals.h    build signals.h            $DEFAULT_B_signals_h 1)
  963. X    hs        build config.h and signals.h    $DEFAULT_B_hs 1)
  964. X    Makefile    build Makefile            $DEFAULT_B_mf 1)
  965. X    mf        -"-                $DEFAULT_B_mf 1)
  966. X    gcc        use gcc instead of default cc    $DEFAULT_B_gcc
  967. X    mediumgcc    as "gcc" but with stricter    $DEFAULT_B_mediumgcc
  968. X            flags, requires ANSI clean
  969. X            zsh code _and_ system headers
  970. X    strictgcc    as "gcc" but with very, VERY,    $DEFAULT_B_strictgcc
  971. X            strict flags
  972. X    ksh        run builzsh with ksh        $DEFAULT_B_ksh 2)
  973. X            instead of default sh
  974. X    help        show this help            $DEFAULT_B_help
  975. X    query        ask configurer's judgement    $DEFAULT_B_query
  976. X    auto        do not ask the initial question    $DEFAULT_B_auto 3)
  977. X            about "query", start probing
  978. X            immediately
  979. X    noopt        no optimizing compilation (-O)    $DEFAULT_B_optimize 4)
  980. X    debug        debugging compilation (-g)    $DEFAULT_B_debug 4)
  981. X    zshdebug    zsh internal debugging used    $DEFAULT_B_zshdebug
  982. X    nomake        no make at the end of buildzsh    $DEFAULT_B_nomake
  983. X
  984. X    For example
  985. X
  986. X        ./buildzsh gcc
  987. X
  988. X    will customize Makefile so that gcc and the appropriate
  989. X    flags will be used.
  990. X
  991. X    1) Normally all of config.h, signals.h, and Makefile
  992. X       will be built.  If, however, only certain of these are
  993. X       specified at the command line, only those specified will
  994. X           be built.  For example "buildzsh mf" will build only the
  995. X       Makefile.
  996. X
  997. X    2) The default is to use sh.  ksh is needed sometimes if sh
  998. X       cannot for some reason handle buildzsh (e.g. Cray's UNICOS),
  999. X       in such cases buildzsh normally runs itself automatically
  1000. X       with ksh and "ksh" option is not needed in the command line.
  1001. X
  1002. X    3) Meant either for the extremely optimistic first-timers or
  1003. X       for the battle-scarred zsh hackers.
  1004. X    
  1005. X    4) These can cancel each other out: if both are present
  1006. X       but the C compiler cannot handle both of them, optimization
  1007. X       is turned off and debugging stays.  Only certain compilation
  1008. X       environments support optimization and debugging simultaneously.
  1009. X
  1010. XMULTIARCHITECTURE SUPPORT
  1011. X
  1012. X    *** CURRENTLY UNSUPPORTED (=SOMEWHAT BROKEN) FEATURE    ***
  1013. X    *** FOR DESPERATE USE ONLY                ***
  1014. X    *** IF IT WORKS FOR YOU, FINE, BUT DON'T RELY ON IT.    ***
  1015. X    *** IF IT DOESN'T WORK FOR YOU, TOUGH.            ***
  1016. X    *** IF YOU DO THE BUILDING HONOURING THE TRADITION      ***
  1017. X    *** COMPILING AMONG THE SOURCES, EVERYTHING SHOULD GO    ***
  1018. X    *** JUST FINE, IGNORE THIS FEATURE.            ***
  1019. X
  1020. X    buildzsh understands using a common source code pool
  1021. X    for building and installing zsh for several different
  1022. X    architectures.   The configurable parameters
  1023. X
  1024. X        $ARCH_PARMS
  1025. X
  1026. X    are special: if these contain the pattern
  1027. X
  1028. X        $DEFAULT_C_ARCHPATT
  1029. X
  1030. X    this pattern will be replaced with a string describing
  1031. X    the particular architecture.  By default this string is
  1032. X    determined by buildzsh itself -- but all of these can be
  1033. X    changed from the command line, see CONFIGURABLE PARAMETERS above.
  1034. X    For example
  1035. X
  1036. X        ./buildzsh BLDDIR=/var/tmp/zsh/hp48sx
  1037. X
  1038. X    will build Makefile so that by simply saying
  1039. X
  1040. X        make -f /var/tmp/zsh/hp48sx/Makefile
  1041. X
  1042. X    the whole zsh building process will happen in the directory
  1043. X    "/var/tmp/zsh/hp48sx".
  1044. X
  1045. XFILES
  1046. X
  1047. X    buildzsh builds three files:
  1048. X
  1049. X        config.h and signals.h are normal C source files:
  1050. X        config.h contains the definitions that depend on
  1051. X        the particular features of the operating system variant,
  1052. X        signals.h contains the signal definitions.
  1053. X
  1054. X        A makefile called Makefile customized for
  1055. X        the particular architecture will be built to
  1056. X        the building directory (by default the building directory
  1057. X        is the current directory).
  1058. X
  1059. X    There are fail-safe versions of config.h, signals.h and Makefile
  1060. X    called config.h.sample, signals.h.sample and Makefile.sample
  1061. X    that can be used either as-is or as raw material if buildzsh fails.
  1062. X
  1063. X    buildzsh itself is just a top-level script that uses the bz.*
  1064. X    scripts in the directory src/config.
  1065. X
  1066. XENVIRONMENT VARIABLES
  1067. X
  1068. X    All of the configurable parameters (see above) (for example
  1069. X    CFLAGS and LIBS) are taken intact from the environment.
  1070. X
  1071. XBUGS
  1072. X
  1073. X    Nothing is perfect and buildzsh is bound to have its
  1074. X    share of bugs.  If and when modifying buildzsh becomes
  1075. X    a necessity, please read the file src/config/config.README.
  1076. X    It lists the role of each module of buildzsh and warns about
  1077. X    the most common pitfalls.
  1078. X
  1079. XWARNINGS
  1080. X
  1081. X    buildzsh is quite large piece of serious shell scripting
  1082. X    which is supposed to work under any Bourne shell (sh) AND
  1083. X    Korn shell (ksh).  Achieving this goal requires sometimes
  1084. X    dirty and/or obscure tricks to for example negotiate past
  1085. X    some bugs that appear only in some vendors' environments.
  1086. X
  1087. X    Fiddling with buildzsh is not for the faint at heart.
  1088. XEOH
  1089. Xexit 1    
  1090. END_OF_FILE
  1091.   if test 7059 -ne `wc -c <'zsh-2.5.0/src/config/bz.help'`; then
  1092.     echo shar: \"'zsh-2.5.0/src/config/bz.help'\" unpacked with wrong size!
  1093.   fi
  1094.   # end of 'zsh-2.5.0/src/config/bz.help'
  1095. fi
  1096. if test -f 'zsh-2.5.0/src/config/config.README' -a "${1}" != "-c" ; then 
  1097.   echo shar: Will not clobber existing file \"'zsh-2.5.0/src/config/config.README'\"
  1098. else
  1099.   echo shar: Extracting \"'zsh-2.5.0/src/config/config.README'\" \(6655 characters\)
  1100.   sed "s/^X//" >'zsh-2.5.0/src/config/config.README' <<'END_OF_FILE'
  1101. XPURPOSE
  1102. X
  1103. X    This directory contains shell scripts that are used by
  1104. X    src/buildzsh.
  1105. X
  1106. XFILES
  1107. X
  1108. X    Hierarchical list    Function of
  1109. X    of scripts called by    the particular
  1110. X    buildzsh.        script.
  1111. X    --------------------    --------------
  1112. X
  1113. X    bz.init            Initialization...
  1114. X        bz.saveargv        saving argv
  1115. X        bz.defaults        for parameters
  1116. X        bz.ifksh        for ksh-must
  1117. X    bz.argh            Argument handling...
  1118. X        bz.help            showing help
  1119. X    bz.check        Argument checking...
  1120. X        bz.doksh        do ksh if necessary
  1121. X        bz.sanity        fix up some parameters
  1122. X    bz.hs            Header building...
  1123. X        bz.config.h        config.h
  1124. X        bz.signals.h        signals.h
  1125. X    bz.Makefile        Architecture-specific Makefile building...
  1126. X    bz.finale        Shall we $MAKE?
  1127. X    
  1128. XNOTES
  1129. X
  1130. X    The following notes are meant for buildzsh hackers,
  1131. X    for others it will be a healthy example about the
  1132. X    problems of writing large and portable shell scripts.
  1133. X
  1134. X    The notes are indicated by a '*' in the left margin and
  1135. X    they are are followed by (some of) the names of the bz.* files
  1136. X    that are affected by the particular note.
  1137. X
  1138. X* all the sh-constructs must be also "Korn-compliant"
  1139. X  so that ksh also can munch this script.  This is normally not
  1140. X  a big headache because ksh should be superset of Bourne sh.
  1141. X
  1142. X  some miserable Bourne shells fail for some reason or another
  1143. X  while executing buildzsh, we will try for those wrecthes whether
  1144. X  ksh comes to rescue.
  1145. X
  1146. X    bz.ifksh
  1147. X    bz.doksh
  1148. X    bz.Makefiles
  1149. X
  1150. X* because the Makefiles are built by <<eof method *inside* buildzsh,
  1151. X  they have to be BOTH "Bourne-compliant" AND "Korn-compliant".
  1152. X  Therefore, certain measures have to be taken as certain
  1153. X  constructs are understood differently amongst sh/ksh/make.
  1154. X  These constructs are
  1155. X        
  1156. X        $@              (sh and make)
  1157. X        $(foo)          (ksh and make)
  1158. X
  1159. X  If these constructs are to be as "make" them understands, they MUST
  1160. X  be escaped with a leading backlash as follows
  1161. X
  1162. X        \$@
  1163. X        \$(foo)
  1164. X
  1165. X  All the "here-document" (<<EOF) situations cannot be handled with
  1166. X  <<'quoted-eof' trick, which would cure both the above problems,
  1167. X  because the expansion of $bar by sh/ksh is extensively used by
  1168. X  for example
  1169. X
  1170. X        CC=$CC
  1171. X
  1172. X  where $CC has been resolved by sh/ksh.  Note, however, that when
  1173. X  no $bar style expansions are needed during <<, the <<'quoted-eof'
  1174. X  method is viable and the \ escaping is not needed.
  1175. X
  1176. X    bz.Makefiles
  1177. X
  1178. X* do NOT even think about using the <<trick as
  1179. X
  1180. X  if test ...
  1181. X  then
  1182. X  exec >somefile
  1183. X  cat <<eof
  1184. X  ...
  1185. X  eof
  1186. X  fi
  1187. X  
  1188. X  thanks to Sun.  In ScumOS, you will get error messages like
  1189. X  buildzsh: /tmp/sh1708429: No such file or directory
  1190. X  after each 'cat' for each exec-cat pair.
  1191. X  One must resort to the work-around: using subshells
  1192. X
  1193. X  if test ...
  1194. X  then
  1195. X  (exec >somefile
  1196. X  cat >>eof
  1197. X  ...
  1198. X  eof
  1199. X  )
  1200. X  fi
  1201. X  
  1202. X  Note that one must be careful about the closing (: it can come
  1203. X  many lines after the initial cat <<'s eof, in buildzsh normally
  1204. X  just before the 'fi' that closes down the building of some file
  1205. X
  1206. X  if test ...doing-some-file
  1207. X  then
  1208. X  (exec >some-file
  1209. X  ...
  1210. X  )
  1211. X  fi
  1212. X
  1213. X    bz.Makefile
  1214. X    bz.config.h
  1215. X
  1216. X* do not use "test -x" because some braindead (but wide-spread)
  1217. X  tests do not know such a flag, use "-f" instead, that *should* work
  1218. X  everywhere.
  1219. X
  1220. X    bz.Makefile
  1221. X    bz.config.h
  1222. X    bz.doksh
  1223. X    bz.help
  1224. X    bz.hosttype
  1225. X
  1226. X* do not use "tr -s", either, use sed for that.
  1227. X
  1228. X* the argument list of the buildzsh is saved by bz.init/bz.saveargv
  1229. X  in to a variable called _argv that can be used in constructs like
  1230. X
  1231. X  for i in $_argv
  1232. X  do
  1233. X    ...
  1234. X
  1235. X  Whitespace is correctly saved in _argv.
  1236. X  (but exotic quoting might get fatal?)
  1237. X
  1238. X* there are a couple of subroutinish scripts that are used to automatize
  1239. X  the chores of asking/looking for different kinds of questions.
  1240. X
  1241. X  The calling sequence is as follows
  1242. X
  1243. X    set arg1 arg2 arg3 arg4 ...
  1244. X    . bz.foo
  1245. X  
  1246. X  Worrying about $@?  Saved in $_argv, see above.
  1247. X
  1248. X  bz.define:
  1249. X
  1250. X    Usage:
  1251. X
  1252. X    set symbol_name default_value description [ empty_ok [ quote_it ] ]
  1253. X    . bz.define
  1254. X
  1255. X    Used to #define FOO, the definition is output to stdout.
  1256. X
  1257. X    If empty answer is ok, the 4th argument should be non-empty.
  1258. X    
  1259. X    If the 5th argument is either " or ', the whole answer is
  1260. X    quoted with that particular character (on both sides, of course).
  1261. X
  1262. X  bz.ifdef:
  1263. X
  1264. X    Usage:
  1265. X
  1266. X    set test symbol_name default_value yea_feature \
  1267. X            [ nay_feature [ feature_name ] ]
  1268. X
  1269. X    Used to #define but only iff some condition holdsds,
  1270. X    the definition is output to stdout.
  1271. X
  1272. X    In query mode the question is normally paraphrased as
  1273. X    "Do you have YEA_FEATURE?".  These can be (and are)
  1274. X    customized: Do is G_verb1_, you is G_subj_, have is G_verb2_.
  1275. X    See for example the "suspended"/"stopped" question in
  1276. X    bz.config.h, there the "have" is changed into "prefer".
  1277. X
  1278. X    This is the subroutine that says "using foo..." or
  1279. X    "not using foo...".  Also the "using" can be customized,
  1280. X    it is G_verb3a_ and G_verb3b_, corresponding to the positive
  1281. X    and negative senses.
  1282. X
  1283. X    All the G_{verb,subject}X customizations are temporary:
  1284. X    each bz.ifdef call resets the defaults.
  1285. X
  1286. X    You can test the variables _yea and _nay after the
  1287. X    bz.ifdef call to know which alternative was chosen.
  1288. X
  1289. X  bz.walk:
  1290. X
  1291. X    set variable_name "file ..." "dir ..." default
  1292. X    . bz.walk
  1293. X
  1294. X      Searches PATH-like for multiple files from multiple directories.
  1295. X      The first existing dir/file is set as the value of variable_name.
  1296. X      If no such exists, the default is used as the value.
  1297. X      The outer loop steps through files and the inner through directories.
  1298. X      For example:
  1299. X
  1300. X    set gorp "cc gcc" "/usr/local/bin /usr/bin /bin" /bin/echo
  1301. X    . bz.walk
  1302. X
  1303. X      This will try /usr/local/bin/cc, /usr/bin/cc, /bin/cc,
  1304. X    /usr/local/bin/gcc, /usr/bin/gcc, and /bin/gcc, in that order.
  1305. X    If none of these exist, gorp will have the value /bin/echo.
  1306. X
  1307. X* As soon as you know for certain whether your C compiler groks -c and -o
  1308. X  simultaneously or not, add the correct variable to test to
  1309. X  either CC_GROK_c_o or CC_LOSE_c_o in bz.defaults, respectively.
  1310. X  Neither matching means running $CC *each and every* time buildzsh is run.
  1311. X
  1312. X    bz.Makefile
  1313. X    bz.defaults
  1314. X
  1315. X* As soon as you know for certain whether your C compiler groks -g and -O
  1316. X  simultaneously or not, add the correct variable to test to
  1317. X  either CC_GROK_g_O or CC_LOSE_g_O in bz.defaults, respectively.
  1318. X  Neither matching means running $CC *each and every* time buildzsh is run.
  1319. X  Variables like test:foo:bar mean testing for variable "test",
  1320. X  if that succeeds, setting CC_gFLAGS to "foo" and CC_OFLAGS to "bar".
  1321. X
  1322. X    For example: CC_GROK_g_O="AIX CC_MIPS_STYLE:-g3:-O GCC:-g:-O6"
  1323. X
  1324. X  Use 'quotes' to protect whitespace.
  1325. X
  1326. X    bz.Makefile
  1327. X    bz.defaults
  1328. X
  1329. X* if you want to display something to "stdin" while building
  1330. X  Makefile, you must "1>&2" it
  1331. X
  1332. X    bz.Makefile
  1333. X
  1334. X* the naming of the various sh variables is a total mess.
  1335. X
  1336. X---
  1337. END_OF_FILE
  1338.   if test 6655 -ne `wc -c <'zsh-2.5.0/src/config/config.README'`; then
  1339.     echo shar: \"'zsh-2.5.0/src/config/config.README'\" unpacked with wrong size!
  1340.   fi
  1341.   # end of 'zsh-2.5.0/src/config/config.README'
  1342. fi
  1343. if test -f 'zsh-2.5.0/src/table.c' -a "${1}" != "-c" ; then 
  1344.   echo shar: Will not clobber existing file \"'zsh-2.5.0/src/table.c'\"
  1345. else
  1346.   echo shar: Extracting \"'zsh-2.5.0/src/table.c'\" \(7518 characters\)
  1347.   sed "s/^X//" >'zsh-2.5.0/src/table.c' <<'END_OF_FILE'
  1348. X/*
  1349. X *
  1350. X * table.c - linked lists and hash tables
  1351. X *
  1352. X * This file is part of zsh, the Z shell.
  1353. X *
  1354. X * This software is Copyright 1992 by Paul Falstad
  1355. X *
  1356. X * Permission is hereby granted to copy, reproduce, redistribute or otherwise
  1357. X * use this software as long as: there is no monetary profit gained
  1358. X * specifically from the use or reproduction of this software, it is not
  1359. X * sold, rented, traded or otherwise marketed, and this copyright notice is
  1360. X * included prominently in any copy made.
  1361. X *
  1362. X * The author make no claims as to the fitness or correctness of this software
  1363. X * for any use whatsoever, and it is provided as is. Any use of this software
  1364. X * is at the user's own risk.
  1365. X *
  1366. X */
  1367. X
  1368. X#define TABLE_C
  1369. X#include "zsh.h"
  1370. X
  1371. X/* get an empty linked list header */
  1372. X
  1373. XLklist newlist()
  1374. X{                /**/
  1375. X    Lklist list;
  1376. X
  1377. X    list = (Lklist) alloc(sizeof *list);
  1378. X    list->first = 0;
  1379. X    list->last = (Lknode) list;
  1380. X    return list;
  1381. X}
  1382. X
  1383. X/* get an empty hash table */
  1384. X
  1385. XHashtab newhtable(size)        /**/
  1386. Xint size;
  1387. X{
  1388. X    Hashtab ret;
  1389. X
  1390. X    ret = (Hashtab) zcalloc(sizeof *ret);
  1391. X    ret->hsize = size;
  1392. X    ret->nodes = (Hashnode *) zcalloc(size * sizeof(Hashnode));
  1393. X    return ret;
  1394. X}
  1395. X
  1396. X/* the hash function used by Chris Torek */
  1397. X/* The Peter J. Weinberger hash function from the Dragon Book
  1398. X * used to be here but it
  1399. X * a) was slower than this
  1400. X * b) took 32-bit integers for granted
  1401. X *    b1) there are other integer widths
  1402. X *    b2) integer constant like 0xf0000000 is unsigned in ANSI C,
  1403. X *        signed with pcc
  1404. X * c) I _believe_ after some testing that this hashes better
  1405. X *    Jarkko Hietaniemi <Jarkko.Hietaniemi@hut.fi>
  1406. X */
  1407. X
  1408. Xunsigned hasher(s)        /**/
  1409. Xchar *s;
  1410. X{
  1411. X    unsigned hash;
  1412. X
  1413. X    for (hash = 0; *s; s++)
  1414. X    hash = hash + (hash << 5) + *s;
  1415. X /* if hashing counted strings: (size_t, char *) pairs,
  1416. X     * "+ 1" should be appended to the above line */
  1417. X
  1418. X    return hash;
  1419. X}
  1420. X
  1421. X/* add a node to a hash table */
  1422. X
  1423. Xvoid addhnode(nam, dat, ht, freefunc)    /**/
  1424. Xchar *nam;
  1425. Xvptr dat;
  1426. XHashtab ht;
  1427. XFFunc freefunc;
  1428. X{
  1429. X    int hval = hasher(nam) % ht->hsize;
  1430. X    struct hashnode **hp = ht->nodes + hval, *hn;
  1431. X
  1432. X    for (; *hp; hp = &(*hp)->next)
  1433. X    if (!strcmp((*hp)->nam, nam)) {
  1434. X        zsfree((*hp)->nam);
  1435. X        hn = (struct hashnode *)dat;
  1436. X        hn->next = (*hp)->next;
  1437. X        if (!freefunc)
  1438. X        zerr("attempt to call NULL freefunc", NULL, 0);
  1439. X        else
  1440. X        freefunc(*hp);
  1441. X        *hp = hn;
  1442. X        hn->nam = nam;
  1443. X        return;
  1444. X    }
  1445. X    hn = (Hashnode) dat;
  1446. X    hn->nam = nam;
  1447. X    hn->next = ht->nodes[hval];
  1448. X    ht->nodes[hval] = hn;
  1449. X    if (++ht->ct == ht->hsize * 4)
  1450. X    expandhtab(ht);
  1451. X}
  1452. X
  1453. X/* add a node to command hash table */
  1454. X
  1455. Xvoid addhcmdnode(nam, pnam)    /**/
  1456. Xchar *nam;
  1457. Xchar **pnam;
  1458. X{
  1459. X    int hval = hasher(nam) % cmdnamtab->hsize;
  1460. X    struct hashnode *hp = cmdnamtab->nodes[hval], *hn;
  1461. X    Cmdnam cc;
  1462. X
  1463. X    for (; hp; hp = hp->next)
  1464. X    if (!strcmp(hp->nam, nam))
  1465. X        return;
  1466. X    cc = (Cmdnam) zcalloc(sizeof *cc);
  1467. X    cc->flags = EXCMD;
  1468. X    cc->u.name = pnam;
  1469. X    hn = (Hashnode) cc;
  1470. X    hn->nam = ztrdup(nam);
  1471. X    hn->next = cmdnamtab->nodes[hval];
  1472. X    cmdnamtab->nodes[hval] = hn;
  1473. X    if (++cmdnamtab->ct == cmdnamtab->hsize * 4)
  1474. X    expandhtab(cmdnamtab);
  1475. X}
  1476. X
  1477. X/* expand hash tables when they get too many entries */
  1478. X
  1479. Xvoid expandhtab(ht)        /**/
  1480. XHashtab ht;
  1481. X{
  1482. X    struct hashnode **arr, **ha, *hn, *hp;
  1483. X    int osize = ht->hsize, nsize = osize * 8, os = osize;
  1484. X
  1485. X    ht->hsize = nsize;
  1486. X    arr = ht->nodes;
  1487. X    ht->nodes = (Hashnode *) zcalloc(nsize * sizeof(struct hashnode *));
  1488. X
  1489. X    ht->ct = 0;
  1490. X
  1491. X    for (ha = arr; osize; osize--, ha++)
  1492. X    for (hn = *ha; hn;) {
  1493. X        hp = hn->next;
  1494. X        addhnode(hn->nam, (vptr) hn, ht, (FFunc) 0);
  1495. X        hn = hp;
  1496. X    }
  1497. X    zfree(arr, os * sizeof(struct hashnode *));
  1498. X}
  1499. X
  1500. X/* get an entry in a hash table */
  1501. X
  1502. Xvptr gethnode(nam, ht)        /**/
  1503. Xchar *nam;
  1504. XHashtab ht;
  1505. X{
  1506. X    int hval = hasher(nam) % ht->hsize;
  1507. X    struct hashnode *hn = ht->nodes[hval];
  1508. X
  1509. X    for (; hn; hn = hn->next)
  1510. X    if (!strcmp(hn->nam, nam))
  1511. X        return (vptr) hn;
  1512. X    return NULL;
  1513. X}
  1514. X
  1515. Xvoid freehtab(ht, freefunc)    /**/
  1516. XHashtab ht;
  1517. XFFunc freefunc;
  1518. X{
  1519. X    int val;
  1520. X    struct hashnode *hn, **hp = &ht->nodes[0], *next;
  1521. X
  1522. X    for (val = ht->hsize; val; val--, hp++)
  1523. X    for (hn = *hp; hn;) {
  1524. X        next = hn->next;
  1525. X        zsfree(hn->nam);
  1526. X        freefunc(hn);
  1527. X        hn = next;
  1528. X    }
  1529. X    zfree(ht->nodes, ht->hsize * sizeof(struct hashnode *));
  1530. X    zfree(ht, sizeof(struct hashtab));
  1531. X}
  1532. X
  1533. X/* remove a hash table entry and return a pointer to it */
  1534. X
  1535. Xvptr remhnode(nam, ht)        /**/
  1536. Xchar *nam;
  1537. XHashtab ht;
  1538. X{
  1539. X    int hval = hasher(nam) % ht->hsize;
  1540. X    struct hashnode *hn = ht->nodes[hval], *hp;
  1541. X
  1542. X    if (!hn)
  1543. X    return NULL;
  1544. X    if (!strcmp(hn->nam, nam)) {
  1545. X    ht->nodes[hval] = hn->next;
  1546. X    zsfree(hn->nam);
  1547. X    ht->ct--;
  1548. X    return (vptr) hn;
  1549. X    }
  1550. X    for (hp = hn, hn = hn->next; hn; hn = (hp = hn)->next)
  1551. X    if (!strcmp(hn->nam, nam)) {
  1552. X        hp->next = hn->next;
  1553. X        zsfree(hn->nam);
  1554. X        ht->ct--;
  1555. X        return (vptr) hn;
  1556. X    }
  1557. X    return NULL;
  1558. X}
  1559. X
  1560. X/* insert a node in a linked list after 'llast' */
  1561. X
  1562. Xvoid insnode(list, llast, dat)    /**/
  1563. XLklist list;
  1564. XLknode llast;
  1565. Xvptr dat;
  1566. X{
  1567. X    Lknode tmp;
  1568. X
  1569. X    tmp = llast->next;
  1570. X    llast->next = (Lknode) alloc(sizeof *tmp);
  1571. X    llast->next->last = llast;
  1572. X    llast->next->dat = dat;
  1573. X    llast->next->next = tmp;
  1574. X    if (tmp)
  1575. X    tmp->last = llast->next;
  1576. X    else
  1577. X    list->last = llast->next;
  1578. X}
  1579. X
  1580. X/* remove a node from a linked list */
  1581. X
  1582. Xvptr remnode(list, nd)        /**/
  1583. XLklist list;
  1584. XLknode nd;
  1585. X{
  1586. X    vptr dat;
  1587. X
  1588. X    nd->last->next = nd->next;
  1589. X    if (nd->next)
  1590. X    nd->next->last = nd->last;
  1591. X    else
  1592. X    list->last = nd->last;
  1593. X    dat = nd->dat;
  1594. X    zfree(nd, sizeof(struct lknode));
  1595. X
  1596. X    return dat;
  1597. X}
  1598. X
  1599. X/* remove a node from a linked list */
  1600. X
  1601. Xvptr uremnode(list, nd)        /**/
  1602. XLklist list;
  1603. XLknode nd;
  1604. X{
  1605. X    vptr dat;
  1606. X
  1607. X    nd->last->next = nd->next;
  1608. X    if (nd->next)
  1609. X    nd->next->last = nd->last;
  1610. X    else
  1611. X    list->last = nd->last;
  1612. X    dat = nd->dat;
  1613. X    return dat;
  1614. X}
  1615. X
  1616. X/* delete a character in a string */
  1617. X
  1618. Xvoid chuck(str)            /**/
  1619. Xchar *str;
  1620. X{
  1621. X    while ((str[0] = str[1]))
  1622. X    str++;
  1623. X}
  1624. X
  1625. X/* get top node in a linked list */
  1626. X
  1627. Xvptr getnode(list)        /**/
  1628. XLklist list;
  1629. X{
  1630. X    vptr dat;
  1631. X    Lknode node = list->first;
  1632. X
  1633. X    if (!node)
  1634. X    return NULL;
  1635. X    dat = node->dat;
  1636. X    list->first = node->next;
  1637. X    if (node->next)
  1638. X    node->next->last = (Lknode) list;
  1639. X    else
  1640. X    list->last = (Lknode) list;
  1641. X    zfree(node, sizeof(struct lknode));
  1642. X
  1643. X    return dat;
  1644. X}
  1645. X
  1646. X/* get top node in a linked list without freeing */
  1647. X
  1648. Xvptr ugetnode(list)        /**/
  1649. XLklist list;
  1650. X{
  1651. X    vptr dat;
  1652. X    Lknode node = list->first;
  1653. X
  1654. X    if (!node)
  1655. X    return NULL;
  1656. X    dat = node->dat;
  1657. X    list->first = node->next;
  1658. X    if (node->next)
  1659. X    node->next->last = (Lknode) list;
  1660. X    else
  1661. X    list->last = (Lknode) list;
  1662. X    return dat;
  1663. X}
  1664. X
  1665. Xvoid freetable(tab, freefunc)    /**/
  1666. XLklist tab;
  1667. XFFunc freefunc;
  1668. X{
  1669. X    Lknode node = tab->first, next;
  1670. X
  1671. X    while (node) {
  1672. X    next = node->next;
  1673. X    if (freefunc)
  1674. X        freefunc(node->dat);
  1675. X    zfree(node, sizeof(struct lknode));
  1676. X
  1677. X    node = next;
  1678. X    }
  1679. X    zfree(tab, sizeof(struct lklist));
  1680. X}
  1681. X
  1682. Xchar *ztrstr(s, t)        /**/
  1683. Xchar *s;
  1684. Xchar *t;
  1685. X{
  1686. X    char *p1, *p2;
  1687. X
  1688. X    for (; *s; s++) {
  1689. X    for (p1 = s, p2 = t; *p2; p1++, p2++)
  1690. X        if (*p1 != *p2)
  1691. X        break;
  1692. X    if (!*p2)
  1693. X        return (char *)s;
  1694. X    }
  1695. X    return NULL;
  1696. X}
  1697. X
  1698. X/* insert a list in another list */
  1699. X
  1700. Xvoid inslist(l, where, x)    /**/
  1701. XLklist l;
  1702. XLknode where;
  1703. XLklist x;
  1704. X{
  1705. X    Lknode nx = where->next;
  1706. X
  1707. X    if (!l->first)
  1708. X    return;
  1709. X    where->next = l->first;
  1710. X    l->last->next = nx;
  1711. X    l->first->last = where;
  1712. X    if (nx)
  1713. X    nx->last = l->last;
  1714. X    else
  1715. X    x->last = l->last;
  1716. X}
  1717. X
  1718. Xint countnodes(x)        /**/
  1719. XLklist x;
  1720. X{
  1721. X    Lknode y;
  1722. X    int ct = 0;
  1723. X
  1724. X    for (y = firstnode(x); y; incnode(y), ct++);
  1725. X    return ct;
  1726. X}
  1727. END_OF_FILE
  1728.   if test 7518 -ne `wc -c <'zsh-2.5.0/src/table.c'`; then
  1729.     echo shar: \"'zsh-2.5.0/src/table.c'\" unpacked with wrong size!
  1730.   fi
  1731.   # end of 'zsh-2.5.0/src/table.c'
  1732. fi
  1733. if test -f 'zsh-2.5.0/src/text.c' -a "${1}" != "-c" ; then 
  1734.   echo shar: Will not clobber existing file \"'zsh-2.5.0/src/text.c'\"
  1735. else
  1736.   echo shar: Extracting \"'zsh-2.5.0/src/text.c'\" \(8918 characters\)
  1737.   sed "s/^X//" >'zsh-2.5.0/src/text.c' <<'END_OF_FILE'
  1738. X
  1739. X/*
  1740. X *
  1741. X * text.c - textual representations of syntax trees
  1742. X *
  1743. X * This file is part of zsh, the Z shell.
  1744. X *
  1745. X * This software is Copyright 1992 by Paul Falstad
  1746. X *
  1747. X * Permission is hereby granted to copy, reproduce, redistribute or otherwise
  1748. X * use this software as long as: there is no monetary profit gained
  1749. X * specifically from the use or reproduction of this software, it is not
  1750. X * sold, rented, traded or otherwise marketed, and this copyright notice is
  1751. X * included prominently in any copy made.
  1752. X *
  1753. X * The author make no claims as to the fitness or correctness of this software
  1754. X * for any use whatsoever, and it is provided as is. Any use of this software
  1755. X * is at the user's own risk.
  1756. X *
  1757. X */
  1758. X
  1759. X#include "zsh.h"
  1760. X
  1761. Xstatic char *tptr, *tbuf, *tlim;
  1762. Xstatic int tsiz, tindent, tnewlins;
  1763. X
  1764. X/* add a character to the text buffer */
  1765. X
  1766. Xvoid taddchr(c)            /**/
  1767. Xint c;
  1768. X{
  1769. X    *tptr++ = c;
  1770. X    if (tptr == tlim) {
  1771. X    if (!tbuf) {
  1772. X        tptr--;
  1773. X        return;
  1774. X    }
  1775. X    tbuf = realloc(tbuf, tsiz *= 2);
  1776. X    tlim = tbuf + tsiz;
  1777. X    tptr = tbuf + tsiz / 2;
  1778. X    }
  1779. X}
  1780. X
  1781. X/* add a string to the text buffer */
  1782. X
  1783. Xvoid taddstr(s)            /**/
  1784. Xchar *s;
  1785. X{
  1786. X    int sl = strlen(s);
  1787. X
  1788. X    while (tptr + sl >= tlim) {
  1789. X    int x = tptr - tbuf;
  1790. X
  1791. X    if (!tbuf)
  1792. X        return;
  1793. X    tbuf = realloc(tbuf, tsiz *= 2);
  1794. X    tlim = tbuf + tsiz;
  1795. X    tptr = tbuf + x;
  1796. X    }
  1797. X    strcpy(tptr, s);
  1798. X    tptr += sl;
  1799. X}
  1800. X
  1801. X/* add an integer to the text buffer */
  1802. X
  1803. Xvoid taddint(x)            /**/
  1804. Xint x;
  1805. X{
  1806. X    char buf[10];
  1807. X
  1808. X    sprintf(buf, "%d", x);
  1809. X    taddstr(buf);
  1810. X}
  1811. X
  1812. X/* add a newline, or something equivalent, to the text buffer */
  1813. X
  1814. Xvoid taddnl()
  1815. X{                /**/
  1816. X    int t0;
  1817. X
  1818. X    if (tnewlins) {
  1819. X    taddchr('\n');
  1820. X    for (t0 = 0; t0 != tindent; t0++)
  1821. X        taddchr('\t');
  1822. X    } else
  1823. X    taddstr("; ");
  1824. X}
  1825. X
  1826. X/* get a permanent textual representation of n */
  1827. X
  1828. Xchar *getpermtext(n)        /**/
  1829. Xstruct node *n;
  1830. X{
  1831. X    tnewlins = 1;
  1832. X    tbuf = (char *)zalloc(tsiz = 32);
  1833. X    tptr = tbuf;
  1834. X    tlim = tbuf + tsiz;
  1835. X    tindent = 1;
  1836. X    gettext2(n);
  1837. X    *tptr = '\0';
  1838. X    untokenize(tbuf);
  1839. X    return tbuf;
  1840. X}
  1841. X
  1842. X/* get a representation of n in a job text buffer */
  1843. X
  1844. Xchar *getjobtext(n)        /**/
  1845. Xstruct node *n;
  1846. X{
  1847. X    static char jbuf[JOBTEXTSIZE];
  1848. X
  1849. X    tnewlins = 0;
  1850. X    tbuf = NULL;
  1851. X    tptr = jbuf;
  1852. X    tlim = tptr + JOBTEXTSIZE - 1;
  1853. X    tindent = 1;
  1854. X    gettext2(n);
  1855. X    *tptr = '\0';
  1856. X    untokenize(jbuf);
  1857. X    return jbuf;
  1858. X}
  1859. X
  1860. X#define gt2(X) gettext2((struct node *) (X))
  1861. X
  1862. X/*
  1863. X    "gettext2" or "type checking and how to avoid it"
  1864. X    an epic function by Paul Falstad
  1865. X*/
  1866. X
  1867. X#define _Cond(X) ((Cond) (X))
  1868. X#define _Cmd(X) ((Cmd) (X))
  1869. X#define _Pline(X) ((Pline) (X))
  1870. X#define _Sublist(X) ((Sublist) (X))
  1871. X#define _List(X) ((List) (X))
  1872. X#define _casecmd(X) ((struct casecmd *) (X))
  1873. X#define _ifcmd(X) ((struct ifcmd *) (X))
  1874. X#define _whilecmd(X) ((struct whilecmd *) (X))
  1875. X
  1876. Xvoid gettext2(n)        /**/
  1877. Xstruct node *n;
  1878. X{
  1879. X    Cmd nn;
  1880. X    Cond nm;
  1881. X
  1882. X    if (!n || ((List) n) == &dummy_list)
  1883. X    return;
  1884. X    switch (NT_TYPE(n->type)) {
  1885. X    case N_LIST:
  1886. X    gt2(_List(n)->left);
  1887. X    if (_List(n)->type == ASYNC)
  1888. X        taddstr(" &");
  1889. X    simplifyright(_List(n));
  1890. X    if (_List(n)->right) {
  1891. X        if (tnewlins)
  1892. X        taddnl();
  1893. X        else
  1894. X        taddstr((_List(n)->type == ASYNC) ? " " : "; ");
  1895. X        gt2(_List(n)->right);
  1896. X    }
  1897. X    break;
  1898. X    case N_SUBLIST:
  1899. X    if (_Sublist(n)->flags & PFLAG_NOT)
  1900. X        taddstr("! ");
  1901. X    if (_Sublist(n)->flags & PFLAG_COPROC)
  1902. X        taddstr("coproc ");
  1903. X    gt2(_Sublist(n)->left);
  1904. X    if (_Sublist(n)->right) {
  1905. X        taddstr((_Sublist(n)->type == ORNEXT) ? " || " : " && ");
  1906. X        gt2(_Sublist(n)->right);
  1907. X    }
  1908. X    break;
  1909. X    case N_PLINE:
  1910. X    gt2(_Pline(n)->left);
  1911. X    if (_Pline(n)->type == PIPE) {
  1912. X        taddstr(" | ");
  1913. X        gt2(_Pline(n)->right);
  1914. X    }
  1915. X    break;
  1916. X    case N_CMD:
  1917. X    nn = _Cmd(n);
  1918. X    if (nn->flags & CFLAG_EXEC)
  1919. X        taddstr("exec ");
  1920. X    if (nn->flags & CFLAG_COMMAND)
  1921. X        taddstr("command ");
  1922. X    switch (nn->type) {
  1923. X    case SIMPLE:
  1924. X        getsimptext(nn);
  1925. X        break;
  1926. X    case SUBSH:
  1927. X        taddstr("( ");
  1928. X        tindent++;
  1929. X        gt2(nn->u.list);
  1930. X        tindent--;
  1931. X        taddstr(" )");
  1932. X        break;
  1933. X    case ZCTIME:
  1934. X        taddstr("time ");
  1935. X        tindent++;
  1936. X        gt2(nn->u.pline);
  1937. X        tindent--;
  1938. X        break;
  1939. X    case FUNCDEF:
  1940. X        taddlist(nn->args);
  1941. X        taddstr(" () {");
  1942. X        tindent++;
  1943. X        taddnl();
  1944. X        gt2(nn->u.list);
  1945. X        tindent--;
  1946. X        taddnl();
  1947. X        taddstr("}");
  1948. X        break;
  1949. X    case CURSH:
  1950. X        taddstr("{ ");
  1951. X        tindent++;
  1952. X        gt2(nn->u.list);
  1953. X        tindent--;
  1954. X        taddstr(" }");
  1955. X        break;
  1956. X    case CFOR:
  1957. X    case CSELECT:
  1958. X        taddstr((nn->type == CFOR) ? "for " : "select ");
  1959. X        taddstr(nn->u.forcmd->name);
  1960. X        if (nn->u.forcmd->inflag) {
  1961. X        taddstr(" in ");
  1962. X        taddlist(nn->args);
  1963. X        }
  1964. X        taddnl();
  1965. X        taddstr("do");
  1966. X        tindent++;
  1967. X        taddnl();
  1968. X        gt2(nn->u.forcmd->list);
  1969. X        tindent--;
  1970. X        taddnl();
  1971. X        taddstr("done");
  1972. X        break;
  1973. X    case CIF:
  1974. X        gt2(nn->u.ifcmd);
  1975. X        taddstr("fi");
  1976. X        break;
  1977. X    case CCASE:
  1978. X        taddstr("case ");
  1979. X        taddlist(nn->args);
  1980. X        taddstr(" in");
  1981. X        tindent++;
  1982. X        taddnl();
  1983. X        gt2(nn->u.casecmd);
  1984. X        tindent--;
  1985. X        if (tnewlins)
  1986. X        taddnl();
  1987. X        else
  1988. X        taddchr(' ');
  1989. X        taddstr("esac");
  1990. X        break;
  1991. X    case COND:
  1992. X        taddstr("[[ ");
  1993. X        gt2(nn->u.cond);
  1994. X        taddstr(" ]]");
  1995. X        break;
  1996. X    case CREPEAT:
  1997. X        taddstr("repeat ");
  1998. X        taddlist(nn->args);
  1999. X        taddnl();
  2000. X        taddstr("do");
  2001. X        tindent++;
  2002. X        taddnl();
  2003. X        gt2(nn->u.list);
  2004. X        tindent--;
  2005. X        taddnl();
  2006. X        taddstr("done");
  2007. X        break;
  2008. X    case CWHILE:
  2009. X        gt2(nn->u.whilecmd);
  2010. X        break;
  2011. X    }
  2012. X    getredirs(nn);
  2013. X    break;
  2014. X    case N_COND:
  2015. X    nm = _Cond(n);
  2016. X    switch (nm->type) {
  2017. X    case COND_NOT:
  2018. X        taddstr("! ");
  2019. X        gt2(nm->left);
  2020. X        break;
  2021. X    case COND_AND:
  2022. X        taddstr("( ");
  2023. X        gt2(nm->left);
  2024. X        taddstr(" && ");
  2025. X        gt2(nm->right);
  2026. X        taddstr(" )");
  2027. X        break;
  2028. X    case COND_OR:
  2029. X        taddstr("( ");
  2030. X        gt2(nm->left);
  2031. X        taddstr(" || ");
  2032. X        gt2(nm->right);
  2033. X        taddstr(" )");
  2034. X        break;
  2035. X    default:
  2036. X        {
  2037. X        static char *c1[] =
  2038. X        {
  2039. X            " = ", " != ", " < ", " > ", " -nt ", " -ot ", " -ef ", " -eq ",
  2040. X            " -ne ", " -lt ", " -gt ", " -le ", " -ge "
  2041. X        };
  2042. X
  2043. X        if (nm->right)
  2044. X            taddstr(nm->left);
  2045. X        if (nm->type <= COND_GE)
  2046. X            taddstr(c1[nm->type - COND_STREQ]);
  2047. X        else {
  2048. X            char c2[5];
  2049. X
  2050. X            c2[0] = ' ';
  2051. X            c2[1] = '-';
  2052. X            c2[2] = nm->type;
  2053. X            c2[3] = ' ';
  2054. X            c2[4] = '\0';
  2055. X            taddstr(c2);
  2056. X        }
  2057. X        taddstr((nm->right) ? nm->right : nm->left);
  2058. X        }
  2059. X        break;
  2060. X    }
  2061. X    break;
  2062. X    case N_CASE:
  2063. X    {
  2064. X        List *l;
  2065. X        char **p;
  2066. X
  2067. X        l = _casecmd(n)->lists;
  2068. X        p = _casecmd(n)->pats;
  2069. X
  2070. X        for (; *l; p++, l++) {
  2071. X        taddstr(*p);
  2072. X        taddstr(") ");
  2073. X        tindent++;
  2074. X        gt2(*l);
  2075. X        tindent--;
  2076. X        taddstr(";;");
  2077. X        if (tnewlins)
  2078. X            taddnl();
  2079. X        else
  2080. X            taddchr(' ');
  2081. X        }
  2082. X        break;
  2083. X    }
  2084. X    case N_IF:
  2085. X    {
  2086. X        List *i, *t;
  2087. X
  2088. X        taddstr("if ");
  2089. X        for (i = _ifcmd(n)->ifls, t = _ifcmd(n)->thenls; *i; i++, t++) {
  2090. X        tindent++;
  2091. X        gt2(*i);
  2092. X        tindent--;
  2093. X        taddnl();
  2094. X        taddstr("then");
  2095. X        tindent++;
  2096. X        taddnl();
  2097. X        gt2(*t);
  2098. X        tindent--;
  2099. X        taddnl();
  2100. X        if (i[1]) {
  2101. X            taddstr("elif ");
  2102. X        }
  2103. X        }
  2104. X        if (*t) {
  2105. X        taddstr("else");
  2106. X        tindent++;
  2107. X        taddnl();
  2108. X        gt2(*t);
  2109. X        tindent--;
  2110. X        taddnl();
  2111. X        }
  2112. X        break;
  2113. X    }
  2114. X    case N_WHILE:
  2115. X    taddstr((_whilecmd(n)->cond) ? "until " : "while ");
  2116. X    tindent++;
  2117. X    gt2(_whilecmd(n)->cont);
  2118. X    tindent--;
  2119. X    taddnl();
  2120. X    taddstr("do");
  2121. X    tindent++;
  2122. X    taddnl();
  2123. X    gt2(_whilecmd(n)->loop);
  2124. X    tindent--;
  2125. X    taddnl();
  2126. X    taddstr("done");
  2127. X    break;
  2128. X    }
  2129. X}
  2130. X
  2131. Xvoid getsimptext(cmd)        /**/
  2132. XCmd cmd;
  2133. X{
  2134. X    Lknode n;
  2135. X
  2136. X    for (n = firstnode(cmd->vars); n; incnode(n)) {
  2137. X    struct varasg *v = (struct varasg *)getdata(n);
  2138. X
  2139. X    taddstr(v->name);
  2140. X    taddchr('=');
  2141. X    if ((v->type & PMTYPE) == PMFLAG_A) {
  2142. X        taddchr('(');
  2143. X        taddlist(v->arr);
  2144. X        taddstr(") ");
  2145. X    } else {
  2146. X        taddstr(v->str);
  2147. X        taddchr(' ');
  2148. X    }
  2149. X    }
  2150. X    taddlist(cmd->args);
  2151. X}
  2152. X
  2153. Xvoid getredirs(cmd)        /**/
  2154. XCmd cmd;
  2155. X{
  2156. X    Lknode n;
  2157. X    static char *fstr[] =
  2158. X    {
  2159. X    ">", ">!", ">>", ">>!", ">&", ">&!", ">>&", ">>&!", "<", "<<",
  2160. X    "<<-", "<<<", "<&", ">&-", "..", ".."
  2161. X    };
  2162. X
  2163. X    taddchr(' ');
  2164. X    for (n = firstnode(cmd->redir); n; incnode(n)) {
  2165. X    struct redir *f = (struct redir *)getdata(n);
  2166. X
  2167. X    switch (f->type) {
  2168. X    case WRITE:
  2169. X    case WRITENOW:
  2170. X    case APP:
  2171. X    case APPNOW:
  2172. X    case READ:
  2173. X    case HERESTR:
  2174. X        if (f->fd1 != ((f->type == READ) ? 0 : 1))
  2175. X        taddchr('0' + f->fd1);
  2176. X        taddstr(fstr[f->type]);
  2177. X        taddchr(' ');
  2178. X        taddstr(f->name);
  2179. X        taddchr(' ');
  2180. X        break;
  2181. X    case MERGE:
  2182. X    case MERGEOUT:
  2183. X        if (f->fd1 != ((f->type == MERGEOUT) ? 1 : 0))
  2184. X        taddchr('0' + f->fd1);
  2185. X        taddstr(fstr[f->type]);
  2186. X        if (f->fd2 == FD_COPROC)
  2187. X        taddchr('p');
  2188. X        else
  2189. X        taddint(f->fd2);
  2190. X        taddchr(' ');
  2191. X        break;
  2192. X    case CLOSE:
  2193. X        taddchr(f->fd1 + '0');
  2194. X        taddstr(">&- ");
  2195. X        break;
  2196. X    case INPIPE:
  2197. X    case OUTPIPE:
  2198. X        if (f->fd1 != ((f->type == INPIPE) ? 0 : 1))
  2199. X        taddchr('0' + f->fd1);
  2200. X        taddstr((f->type == INPIPE) ? "< " : "> ");
  2201. X        taddstr(f->name);
  2202. X        taddchr(' ');
  2203. X        break;
  2204. X    }
  2205. X    }
  2206. X    tptr--;
  2207. X}
  2208. X
  2209. Xvoid taddlist(l)        /**/
  2210. XLklist l;
  2211. X{
  2212. X    Lknode n;
  2213. X
  2214. X    if (!(n = firstnode(l)))
  2215. X    return;
  2216. X    for (; n; incnode(n)) {
  2217. X    taddstr(getdata(n));
  2218. X    taddchr(' ');
  2219. X    }
  2220. X    tptr--;
  2221. X}
  2222. END_OF_FILE
  2223.   if test 8918 -ne `wc -c <'zsh-2.5.0/src/text.c'`; then
  2224.     echo shar: \"'zsh-2.5.0/src/text.c'\" unpacked with wrong size!
  2225.   fi
  2226.   # end of 'zsh-2.5.0/src/text.c'
  2227. fi
  2228. if test -f 'zsh-2.5.0/src/watch.c' -a "${1}" != "-c" ; then 
  2229.   echo shar: Will not clobber existing file \"'zsh-2.5.0/src/watch.c'\"
  2230. else
  2231.   echo shar: Extracting \"'zsh-2.5.0/src/watch.c'\" \(8877 characters\)
  2232.   sed "s/^X//" >'zsh-2.5.0/src/watch.c' <<'END_OF_FILE'
  2233. X
  2234. X/*
  2235. X *
  2236. X * watch.c - login/logout watching
  2237. X *
  2238. X * This file is part of zsh, the Z shell.
  2239. X *
  2240. X * This software is Copyright 1992 by Paul Falstad
  2241. X *
  2242. X * Permission is hereby granted to copy, reproduce, redistribute or otherwise
  2243. X * use this software as long as: there is no monetary profit gained
  2244. X * specifically from the use or reproduction of this software, it is not
  2245. X * sold, rented, traded or otherwise marketed, and this copyright notice is
  2246. X * included prominently in any copy made.
  2247. X *
  2248. X * The author make no claims as to the fitness or correctness of this software
  2249. X * for any use whatsoever, and it is provided as is. Any use of this software
  2250. X * is at the user's own risk.
  2251. X *
  2252. X */
  2253. X
  2254. X#include "zsh.h"
  2255. X
  2256. Xstatic int wtabsz;
  2257. Xstruct utmp *wtab;
  2258. Xstatic time_t lastutmpcheck;
  2259. X
  2260. X/* get the time of login/logout for WATCH */
  2261. X
  2262. Xtime_t getlogtime(u, inout)    /**/
  2263. Xstruct utmp *u;
  2264. Xint inout;
  2265. X{
  2266. X    FILE *in;
  2267. X    struct utmp uu;
  2268. X    int first = 1;
  2269. X    int srchlimit = 50;        /* max number of wtmp records to search */
  2270. X
  2271. X    if (inout)
  2272. X    return u->ut_time;
  2273. X    if (!(in = fopen(WTMP_FILE, "r")))
  2274. X    return time(NULL);
  2275. X    fseek(in, 0, 2);
  2276. X    do {
  2277. X    if (fseek(in, ((first) ? -1 : -2) * sizeof(struct utmp), 1)) {
  2278. X        fclose(in);
  2279. X        return time(NULL);
  2280. X    }
  2281. X    first = 0;
  2282. X    if (!fread(&uu, sizeof(struct utmp), 1, in)) {
  2283. X        fclose(in);
  2284. X        return time(NULL);
  2285. X    }
  2286. X    if (uu.ut_time < lastwatch || !srchlimit--) {
  2287. X        fclose(in);
  2288. X        return time(NULL);
  2289. X    }
  2290. X    }
  2291. X    while (memcmp(&uu, u, sizeof(uu)));
  2292. X
  2293. X    do
  2294. X    if (!fread(&uu, sizeof(struct utmp), 1, in)) {
  2295. X        fclose(in);
  2296. X        return time(NULL);
  2297. X    }
  2298. X    while (strncmp(uu.ut_line, u->ut_line, sizeof(u->ut_line)));
  2299. X    fclose(in);
  2300. X    return uu.ut_time;
  2301. X}
  2302. X
  2303. X/* Mutually recursive call to handle ternaries in watchfmt */
  2304. X
  2305. X#define BEGIN3    '('
  2306. X#define END3    ')'
  2307. X
  2308. Xchar *watch3ary(inout, u, fmt, prnt)    /**/
  2309. Xint inout;
  2310. Xstruct utmp *u;
  2311. Xchar *fmt;
  2312. Xint prnt;
  2313. X{
  2314. X    int truth = 1, sep;
  2315. X
  2316. X    switch (*fmt++) {
  2317. X    case 'n':
  2318. X    truth = (u->ut_name[0] != 0);
  2319. X    break;
  2320. X    case 'a':
  2321. X    truth = inout;
  2322. X    break;
  2323. X    case 'l':
  2324. X    if (!strncmp(u->ut_line, "tty", 3))
  2325. X        truth = (u->ut_line[3] != 0);
  2326. X    else
  2327. X        truth = (u->ut_line[0] != 0);
  2328. X    break;
  2329. X#ifdef UTMP_HOST
  2330. X    case 'm':
  2331. X    case 'M':
  2332. X    truth = (u->ut_host[0] != 0);
  2333. X    break;
  2334. X#endif
  2335. X    default:
  2336. X    prnt = 0;        /* Skip unknown conditionals entirely */
  2337. X    break;
  2338. X    }
  2339. X    sep = *fmt++;
  2340. X    fmt = watchlog2(inout, u, fmt, (truth && prnt), sep);
  2341. X    return watchlog2(inout, u, fmt, (!truth && prnt), END3);
  2342. X}
  2343. X
  2344. X/* print a login/logout event */
  2345. X
  2346. Xchar *watchlog2(inout, u, fmt, prnt, fini)    /**/
  2347. Xint inout;
  2348. Xstruct utmp *u;
  2349. Xchar *fmt;
  2350. Xint prnt;
  2351. Xint fini;
  2352. X{
  2353. X    char *p, buf[40], *bf;
  2354. X    int i;
  2355. X    time_t timet;
  2356. X    struct tm *tm;
  2357. X    char *fm2;
  2358. X
  2359. X    while (*fmt)
  2360. X    if (*fmt == '\\')
  2361. X        if (*++fmt) {
  2362. X        if (prnt)
  2363. X            putchar(*fmt);
  2364. X        ++fmt;
  2365. X        } else if (fini)
  2366. X        return fmt;
  2367. X        else
  2368. X        break;
  2369. X    else if (*fmt == fini)
  2370. X        return ++fmt;
  2371. X    else if (*fmt != '%') {
  2372. X        if (prnt)
  2373. X        putchar(*fmt);
  2374. X        ++fmt;
  2375. X    } else {
  2376. X        if (*++fmt == BEGIN3)
  2377. X        fmt = watch3ary(inout, u, ++fmt, prnt);
  2378. X        else if (!prnt)
  2379. X        ++fmt;
  2380. X        else
  2381. X        switch (*(fm2 = fmt++)) {
  2382. X        case 'n':
  2383. X            printf("%.*s", (int)sizeof(u->ut_name), u->ut_name);
  2384. X            break;
  2385. X        case 'a':
  2386. X            printf("%s", (!inout) ? "logged off" : "logged on");
  2387. X            break;
  2388. X        case 'l':
  2389. X            if (!strncmp(u->ut_line, "tty", 3))
  2390. X            printf("%.*s", (int)sizeof(u->ut_line) - 3, u->ut_line + 3);
  2391. X            else
  2392. X            printf("%.*s", (int)sizeof(u->ut_line), u->ut_line);
  2393. X            break;
  2394. X#ifdef UTMP_HOST
  2395. X        case 'm':
  2396. X            for (p = u->ut_host, i = sizeof(u->ut_host); i && *p; i--, p++) {
  2397. X            if (*p == '.' && !idigit(p[1]))
  2398. X                break;
  2399. X            putchar(*p);
  2400. X            }
  2401. X            break;
  2402. X        case 'M':
  2403. X            printf("%.*s", (int)sizeof(u->ut_host), u->ut_host);
  2404. X            break;
  2405. X#endif
  2406. X        case 'T':
  2407. X        case 't':
  2408. X        case '@':
  2409. X        case 'W':
  2410. X        case 'w':
  2411. X        case 'D':
  2412. X            switch (*fm2) {
  2413. X            case '@':
  2414. X            case 't':
  2415. X            fm2 = "%l:%M%p";
  2416. X            break;
  2417. X            case 'T':
  2418. X            fm2 = "%k:%M";
  2419. X            break;
  2420. X            case 'w':
  2421. X            fm2 = "%a %e";
  2422. X            break;
  2423. X            case 'W':
  2424. X            fm2 = "%m/%d/%y";
  2425. X            break;
  2426. X            case 'D':
  2427. X            fm2 = "%y-%m-%d";
  2428. X            break;
  2429. X            }
  2430. X            timet = getlogtime(u, inout);
  2431. X            tm = localtime(&timet);
  2432. X            ztrftime(buf, 40, fm2, tm);
  2433. X            printf("%s", (*buf == ' ') ? buf + 1 : buf);
  2434. X            break;
  2435. X        case '%':
  2436. X            putchar('%');
  2437. X            break;
  2438. X        case 'S':
  2439. X        case 's':
  2440. X        case 'B':
  2441. X        case 'b':
  2442. X        case 'U':
  2443. X        case 'u':
  2444. X            switch (*fm2) {
  2445. X            case 'S':
  2446. X            fm2 = "so";
  2447. X            break;
  2448. X            case 's':
  2449. X            fm2 = "se";
  2450. X            break;
  2451. X            case 'B':
  2452. X            fm2 = "md";
  2453. X            break;
  2454. X            case 'b':
  2455. X            fm2 = "me";
  2456. X            break;
  2457. X            case 'U':
  2458. X            fm2 = "us";
  2459. X            break;
  2460. X            case 'u':
  2461. X            fm2 = "ue";
  2462. X            break;
  2463. X            }
  2464. X            bf = buf;
  2465. X            if (tgetstr(fm2, &bf))
  2466. X            tputs(buf, 1, putraw);
  2467. X            break;
  2468. X        default:
  2469. X            putchar('%');
  2470. X            putchar(*fm2);
  2471. X            break;
  2472. X        }
  2473. X    }
  2474. X    if (prnt)
  2475. X    putchar('\n');
  2476. X
  2477. X    return fmt;
  2478. X}
  2479. X
  2480. X/* check the List for login/logouts */
  2481. X
  2482. Xvoid watchlog(inout, u, w, fmt)    /**/
  2483. Xint inout;
  2484. Xstruct utmp *u;
  2485. Xchar **w;
  2486. Xchar *fmt;
  2487. X{
  2488. X    char *v, *vv, sav;
  2489. X    int bad;
  2490. X
  2491. X    if (*w && !strcmp(*w, "all")) {
  2492. X    (void)watchlog2(inout, u, fmt, 1, 0);
  2493. X    return;
  2494. X    }
  2495. X    if (*w && !strcmp(*w, "notme") &&
  2496. X    strncmp(u->ut_name, username, sizeof(u->ut_name))) {
  2497. X    (void)watchlog2(inout, u, fmt, 1, 0);
  2498. X    return;
  2499. X    }
  2500. X    for (; *w; w++) {
  2501. X    bad = 0;
  2502. X    v = *w;
  2503. X    if (*v != '@' && *v != '%') {
  2504. X        for (vv = v; *vv && *vv != '@' && *vv != '%'; vv++);
  2505. X        sav = *vv;
  2506. X        *vv = '\0';
  2507. X        if (strncmp(u->ut_name, v, sizeof(u->ut_name)))
  2508. X        bad = 1;
  2509. X        *vv = sav;
  2510. X        v = vv;
  2511. X    }
  2512. X    for (;;)
  2513. X        if (*v == '%') {
  2514. X        for (vv = ++v; *vv && *vv != '@'; vv++);
  2515. X        sav = *vv;
  2516. X        *vv = '\0';
  2517. X        if (strncmp(u->ut_line, v, sizeof(u->ut_line)))
  2518. X            bad = 1;
  2519. X        *vv = sav;
  2520. X        v = vv;
  2521. X        }
  2522. X#ifdef UTMP_HOST
  2523. X        else if (*v == '@') {
  2524. X        for (vv = ++v; *vv && *vv != '%'; vv++);
  2525. X        sav = *vv;
  2526. X        *vv = '\0';
  2527. X        if (strncmp(u->ut_host, v, strlen(v)))
  2528. X            bad = 1;
  2529. X        *vv = sav;
  2530. X        v = vv;
  2531. X        }
  2532. X#endif
  2533. X        else
  2534. X        break;
  2535. X    if (!bad) {
  2536. X        (void)watchlog2(inout, u, fmt, 1, 0);
  2537. X        return;
  2538. X    }
  2539. X    }
  2540. X}
  2541. X
  2542. X/* compare 2 utmp entries */
  2543. X
  2544. Xint ucmp(u, v)            /**/
  2545. Xstruct utmp *u;
  2546. Xstruct utmp *v;
  2547. X{
  2548. X    if (u->ut_time == v->ut_time)
  2549. X    return strncmp(u->ut_line, v->ut_line, sizeof(u->ut_line));
  2550. X    return u->ut_time - v->ut_time;
  2551. X}
  2552. X
  2553. X/* initialize the user List */
  2554. X
  2555. Xvoid readwtab()
  2556. X{                /**/
  2557. X    struct utmp *uptr;
  2558. X    int wtabmax = 32;
  2559. X    FILE *in;
  2560. X
  2561. X    wtabsz = 0;
  2562. X    if (!(in = fopen(UTMP_FILE, "r")))
  2563. X    return;
  2564. X    uptr = wtab = (struct utmp *)zalloc(wtabmax * sizeof(struct utmp));
  2565. X    while (fread(uptr, sizeof(struct utmp), 1, in))
  2566. X#ifdef USER_PROCESS
  2567. X    if   (uptr->ut_type == USER_PROCESS)
  2568. X#else
  2569. X    if   (uptr->ut_name[0])
  2570. X#endif
  2571. X    {
  2572. X        uptr++;
  2573. X        if (++wtabsz == wtabmax)
  2574. X        uptr = (wtab = (struct utmp *)realloc((vptr) wtab, (wtabmax *= 2) *
  2575. X                              sizeof(struct utmp))) + wtabsz;
  2576. X    }
  2577. X    fclose(in);
  2578. X
  2579. X    if (wtabsz)
  2580. X    qsort((vptr) wtab, wtabsz, sizeof(struct utmp),
  2581. X               (int (*)DCLPROTO((const void *, const void *)))ucmp);
  2582. X}
  2583. X
  2584. X/* check for login/logout events; executed before each prompt
  2585. X    if WATCH is set */
  2586. X
  2587. Xvoid dowatch()
  2588. X{                /**/
  2589. X    char **s = watch;
  2590. X    char *fmt = (watchfmt) ? watchfmt : DEFWATCHFMT;
  2591. X    FILE *in;
  2592. X    int utabsz = 0, utabmax = wtabsz + 4, uct, wct;
  2593. X    struct utmp *utab, *uptr, *wptr;
  2594. X    struct stat st;
  2595. X
  2596. X    holdintr();
  2597. X    if (!fmt)
  2598. X    fmt = "%n has %a %l from %m.";
  2599. X    if (!wtab) {
  2600. X    readwtab();
  2601. X    noholdintr();
  2602. X    return;
  2603. X    }
  2604. X    if ((stat(UTMP_FILE, &st) == -1) || (st.st_mtime <= lastutmpcheck)) {
  2605. X    noholdintr();
  2606. X    return;
  2607. X    }
  2608. X    lastutmpcheck = st.st_mtime;
  2609. X    uptr = utab = (struct utmp *)zalloc(utabmax * sizeof(struct utmp));
  2610. X
  2611. X    if (!(in = fopen(UTMP_FILE, "r"))) {
  2612. X    free(utab);
  2613. X    noholdintr();
  2614. X    return;
  2615. X    }
  2616. X    while (fread(uptr, sizeof *uptr, 1, in))
  2617. X#ifdef USER_PROCESS
  2618. X    if (uptr->ut_type == USER_PROCESS)
  2619. X#else
  2620. X    if (uptr->ut_name[0])
  2621. X#endif
  2622. X    {
  2623. X        uptr++;
  2624. X        if (++utabsz == utabmax)
  2625. X        uptr = (utab = (struct utmp *)realloc((vptr) utab, (utabmax *= 2) *
  2626. X                              sizeof(struct utmp))) + utabsz;
  2627. X    }
  2628. X    fclose(in);
  2629. X    noholdintr();
  2630. X    if (errflag) {
  2631. X    free(utab);
  2632. X    return;
  2633. X    }
  2634. X    if (utabsz)
  2635. X    qsort((vptr) utab, utabsz, sizeof(struct utmp),
  2636. X               (int (*)DCLPROTO((const void *, const void *)))ucmp);
  2637. X
  2638. X    wct = wtabsz;
  2639. X    uct = utabsz;
  2640. X    uptr = utab;
  2641. X    wptr = wtab;
  2642. X    if (errflag) {
  2643. X    free(utab);
  2644. X    return;
  2645. X    }
  2646. X    while ((uct || wct) && !errflag)
  2647. X    if (!uct || (wct && ucmp(uptr, wptr) > 0))
  2648. X        wct--, watchlog(0, wptr++, s, fmt);
  2649. X    else if (!wct || (uct && ucmp(uptr, wptr) < 0))
  2650. X        uct--, watchlog(1, uptr++, s, fmt);
  2651. X    else
  2652. X        uptr++, wptr++, wct--, uct--;
  2653. X    free(wtab);
  2654. X    wtab = utab;
  2655. X    wtabsz = utabsz;
  2656. X    fflush(stdout);
  2657. X}
  2658. X
  2659. Xint bin_log(nam, argv, ops, func)    /**/
  2660. Xchar *nam;
  2661. Xchar **argv;
  2662. Xchar *ops;
  2663. Xint func;
  2664. X{
  2665. X    if (!watch)
  2666. X    return 1;
  2667. X    if (wtab)
  2668. X    free(wtab);
  2669. X    wtab = (struct utmp *)zalloc(1);
  2670. X    wtabsz = 0;
  2671. X    lastutmpcheck = 0;
  2672. X    dowatch();
  2673. X    return 0;
  2674. X}
  2675. END_OF_FILE
  2676.   if test 8877 -ne `wc -c <'zsh-2.5.0/src/watch.c'`; then
  2677.     echo shar: \"'zsh-2.5.0/src/watch.c'\" unpacked with wrong size!
  2678.   fi
  2679.   # end of 'zsh-2.5.0/src/watch.c'
  2680. fi
  2681. if test -f 'zsh-2.5.0/src/zle.h' -a "${1}" != "-c" ; then 
  2682.   echo shar: Will not clobber existing file \"'zsh-2.5.0/src/zle.h'\"
  2683. else
  2684.   echo shar: Extracting \"'zsh-2.5.0/src/zle.h'\" \(8927 characters\)
  2685.   sed "s/^X//" >'zsh-2.5.0/src/zle.h' <<'END_OF_FILE'
  2686. X/*
  2687. X *
  2688. X * zle.h - header file for line editor
  2689. X *
  2690. X * This file is part of zsh, the Z shell.
  2691. X *
  2692. X * This software is Copyright 1992 by Paul Falstad
  2693. X *
  2694. X * Permission is hereby granted to copy, reproduce, redistribute or otherwise
  2695. X * use this software as long as: there is no monetary profit gained
  2696. X * specifically from the use or reproduction of this software, it is not
  2697. X * sold, rented, traded or otherwise marketed, and this copyright notice is
  2698. X * included prominently in any copy made.
  2699. X *
  2700. X * The author make no claims as to the fitness or correctness of this software
  2701. X * for any use whatsoever, and it is provided as is. Any use of this software
  2702. X * is at the user's own risk.
  2703. X *
  2704. X */
  2705. X
  2706. X#ifdef ZLEGLOBALS
  2707. X#define ZLEXTERN
  2708. X#else
  2709. X#define ZLEXTERN extern
  2710. X#endif
  2711. X
  2712. X#ifdef ZLE
  2713. X
  2714. X/* cursor position */
  2715. XZLEXTERN int cs;
  2716. X
  2717. X/* line length */
  2718. XZLEXTERN int ll;
  2719. X
  2720. X/* size of line buffer */
  2721. XZLEXTERN int linesz;
  2722. X
  2723. X/* location of mark */
  2724. XZLEXTERN int mark;
  2725. X
  2726. X/* last character pressed */
  2727. XZLEXTERN int c;
  2728. X
  2729. X/* the z_ binding id for this key */
  2730. XZLEXTERN int bindk;
  2731. X
  2732. X/* command argument */
  2733. XZLEXTERN int mult;
  2734. X
  2735. X/* insert mode/overwrite mode flag */
  2736. XZLEXTERN int insmode;
  2737. X
  2738. X/* cost of last update */
  2739. X#ifdef HAS_SELECT
  2740. XZLEXTERN int cost;
  2741. X
  2742. X#endif
  2743. X
  2744. X/* number of lines displayed */
  2745. XZLEXTERN int nlnct;
  2746. X
  2747. X/* flags associated with last command */
  2748. XZLEXTERN int lastcmd;
  2749. X
  2750. X/* column position before last LINEMOVE movement */
  2751. XZLEXTERN int lastcol;
  2752. X
  2753. X/* != 0 if we're getting a vi range */
  2754. XZLEXTERN int virangeflag;
  2755. X
  2756. X/* kludge to get cw and dw to work right */
  2757. XZLEXTERN int wordflag;
  2758. X
  2759. X#endif
  2760. X
  2761. X/* last named command done */
  2762. XZLEXTERN int lastnamed;
  2763. X
  2764. X/* != 0 if we're done editing */
  2765. XZLEXTERN int done;
  2766. X
  2767. X/* length of prompt, rprompt on screen */
  2768. XZLEXTERN int pptlen, ppt2len;
  2769. X
  2770. X/* current history line number */
  2771. XZLEXTERN int histline;
  2772. X
  2773. X/* != 0 if we need to call resetvideo() */
  2774. XZLEXTERN int resetneeded;
  2775. X
  2776. X/* != 0 if the line editor is active */
  2777. XZLEXTERN int zleactive;
  2778. X
  2779. X/* the line buffer */
  2780. XZLEXTERN unsigned char *line;
  2781. X
  2782. X/* the cut buffer */
  2783. XZLEXTERN char *cutbuf;
  2784. X
  2785. X/* prompt and rprompt */
  2786. XZLEXTERN char *pmpt, *pmpt2;
  2787. X
  2788. X/* the last line in the history (the current one) */
  2789. XZLEXTERN char *curhistline;
  2790. X
  2791. X/* the status line */
  2792. XZLEXTERN char *statusline;
  2793. X
  2794. X/* !=0 if a complete added a suffix at the end of a completion */
  2795. XZLEXTERN int addedsuffix;
  2796. X
  2797. X/* 1 if we expect special keys after completing a parameter name */
  2798. XZLEXTERN int complexpect;
  2799. X
  2800. X/*
  2801. X    the current history line and cursor position for the top line
  2802. X    on the buffer stack
  2803. X*/
  2804. X
  2805. XZLEXTERN int stackhist, stackcs;
  2806. X
  2807. X/* != 0 if we are in the middle of a menu completion */
  2808. XZLEXTERN int menucmp;
  2809. X
  2810. X/* != 0 if we are making undo records */
  2811. XZLEXTERN int undoing;
  2812. X
  2813. X/* != 0 if executing a shell function called from zle */
  2814. XZLEXTERN int inzlefunc;
  2815. X
  2816. X/* last vi change buffer */
  2817. XZLEXTERN int vichgbufsz, vichgbufptr, vichgflag;
  2818. XZLEXTERN char *vichgbuf;
  2819. X
  2820. XZLEXTERN int viinsbegin;
  2821. X
  2822. Xtypedef void bindfunc DCLPROTO((void));
  2823. Xtypedef bindfunc *F;
  2824. X
  2825. Xstruct key {
  2826. X    struct hashnode *next;
  2827. X    char *nam;            /* hash data */
  2828. X    int func;            /* function code for this key */
  2829. X    char *str;            /* string corresponding to this key,
  2830. X               if func = z_sendstring */
  2831. X    int len;            /* length of string */
  2832. X    int prefixct;        /* number of strings for which this is a prefix */
  2833. X};
  2834. X
  2835. Xstruct zlecmd {
  2836. X    char *name;            /* name of function */
  2837. X    F func;            /* handler function */
  2838. X    int flags;
  2839. X};
  2840. X
  2841. X/* undo event */
  2842. X
  2843. Xstruct undoent {
  2844. X    int pref;            /* number of initial chars unchanged */
  2845. X    int suff;            /* number of trailing chars unchanged */
  2846. X    int len;            /* length of changed chars */
  2847. X    int cs;            /* cursor pos before change */
  2848. X    char *change;        /* NOT null terminated */
  2849. X};
  2850. X
  2851. X#define UNDOCT 64
  2852. X
  2853. XZLEXTERN struct undoent undos[UNDOCT];
  2854. X
  2855. X/* the line before last mod (for undo purposes) */
  2856. XZLEXTERN unsigned char *lastline;
  2857. X
  2858. X/* buffer specified with "x */
  2859. XZLEXTERN int vibufspec;
  2860. X
  2861. XZLEXTERN int undoct, lastcs;
  2862. X
  2863. XZLEXTERN char *visrchstr;
  2864. XZLEXTERN int visrchsense;
  2865. X
  2866. X#define ZLE_MOVEMENT       1
  2867. X#define ZLE_MENUCMP       2
  2868. X#define ZLE_UNDO           4
  2869. X#define ZLE_YANK          8
  2870. X#define ZLE_LINEMOVE      16
  2871. X#define ZLE_ARG           32
  2872. X#define ZLE_NAMEDBUFFER 128
  2873. X#define ZLE_KILL        (64|ZLE_NAMEDBUFFER)
  2874. X#define ZLE_HISTSEARCH  256
  2875. X#define ZLE_NEGARG      512
  2876. X#define ZLE_INSERT     1024
  2877. X#define ZLE_DELETE     2048
  2878. X
  2879. Xtypedef struct key *Key;
  2880. X
  2881. XZLEXTERN int *bindtab, *mainbindtab;
  2882. Xextern int emacsbind[], viinsbind[], vicmdbind[];
  2883. XZLEXTERN int altbindtab[256];
  2884. X
  2885. X#define KRINGCT 8
  2886. XZLEXTERN char *kring[KRINGCT];
  2887. XZLEXTERN int kringnum;
  2888. XZLEXTERN char *vibuf[36];
  2889. X
  2890. X#define z_acceptandhold 0
  2891. X#define z_acceptandinfernexthistory 1
  2892. X#define z_acceptandmenucomplete 2
  2893. X#define z_acceptline 3
  2894. X#define z_acceptlineanddownhistory 4
  2895. X#define z_backwardchar 5
  2896. X#define z_backwarddeletechar 6
  2897. X#define z_backwarddeleteword 7
  2898. X#define z_backwardkillline 8
  2899. X#define z_backwardkillword 9
  2900. X#define z_backwardword 10
  2901. X#define z_beginningofbufferorhistory 11
  2902. X#define z_beginningofhistory 12
  2903. X#define z_beginningofline 13
  2904. X#define z_beginningoflinehist 14
  2905. X#define z_capitalizeword 15
  2906. X#define z_clearscreen 16
  2907. X#define z_completeword 17
  2908. X#define z_copyprevword 18
  2909. X#define z_copyregionaskill 19
  2910. X#define z_deletechar 20
  2911. X#define z_deletecharorlist 21
  2912. X#define z_deleteword 22
  2913. X#define z_digitargument 23
  2914. X#define z_downcaseword 24
  2915. X#define z_downhistory 25
  2916. X#define z_downlineorhistory 26
  2917. X#define z_endofbufferorhistory 27
  2918. X#define z_endofhistory 28
  2919. X#define z_endofline 29
  2920. X#define z_endoflinehist 30
  2921. X#define z_exchangepointandmark 31
  2922. X#define z_executelastnamedcmd 32
  2923. X#define z_executenamedcmd 33
  2924. X#define z_expandhistory 34
  2925. X#define z_expandorcomplete 35
  2926. X#define z_expandword 36
  2927. X#define z_forwardchar 37
  2928. X#define z_forwardword 38
  2929. X#define z_getline 39
  2930. X#define z_gosmacstransposechars 40
  2931. X#define z_historyincrementalsearchbackward 41
  2932. X#define z_historyincrementalsearchforward 42
  2933. X#define z_historysearchbackward 43
  2934. X#define z_historysearchforward 44
  2935. X#define z_infernexthistory 45
  2936. X#define z_insertlastword 46
  2937. X#define z_killbuffer 47
  2938. X#define z_killline 48
  2939. X#define z_killregion 49
  2940. X#define z_killwholeline 50
  2941. X#define z_listchoices 51
  2942. X#define z_listexpand 52
  2943. X#define z_magicspace 53
  2944. X#define z_menucompleteword 54
  2945. X#define z_menuexpandorcomplete 55
  2946. X#define z_overwritemode 56
  2947. X#define z_pushline 57
  2948. X#define z_quotedinsert 58
  2949. X#define z_quoteline 59
  2950. X#define z_quoteregion 60
  2951. X#define z_redisplay 61
  2952. X#define z_reversemenucomplete 62
  2953. X#define z_runhelp 63
  2954. X#define z_selfinsert 64
  2955. X#define z_selfinsertunmeta 65
  2956. X#define z_sendbreak 66
  2957. X#define z_sendstring 67
  2958. X#define z_sequenceleadin 68
  2959. X#define z_setmarkcommand 69
  2960. X#define z_spellword 70
  2961. X#define z_toggleliteralhistory 71
  2962. X#define z_transposechars 72
  2963. X#define z_transposewords 73
  2964. X#define z_undefinedkey 74
  2965. X#define z_undo 75
  2966. X#define z_universalargument 76
  2967. X#define z_upcaseword 77
  2968. X#define z_uphistory 78
  2969. X#define z_uplineorhistory 79
  2970. X#define z_viaddeol 80
  2971. X#define z_viaddnext 81
  2972. X#define z_vibackwardblankword 82
  2973. X#define z_vibackwardchar 83
  2974. X#define z_vibackwarddeletechar 84
  2975. X#define z_vibeginningofline 85
  2976. X#define z_vicapslockpanic 86
  2977. X#define z_vichange 87
  2978. X#define z_vichangeeol 88
  2979. X#define z_vichangewholeline 89
  2980. X#define z_vicmdmode 90
  2981. X#define z_videlete 91
  2982. X#define z_videletechar 92
  2983. X#define z_vidigitorbeginningofline 93
  2984. X#define z_viendofline 94
  2985. X#define z_vifetchhistory 95
  2986. X#define z_vifindnextchar 96
  2987. X#define z_vifindnextcharskip 97
  2988. X#define z_vifindprevchar 98
  2989. X#define z_vifindprevcharskip 99
  2990. X#define z_vifirstnonblank 100
  2991. X#define z_viforwardblankword 101
  2992. X#define z_viforwardblankwordend 102
  2993. X#define z_viforwardchar 103
  2994. X#define z_viforwardwordend 104
  2995. X#define z_vigotocolumn 105
  2996. X#define z_vigotomark 106
  2997. X#define z_vigotomarkline 107
  2998. X#define z_vihistorysearchbackward 108
  2999. X#define z_vihistorysearchforward 109
  3000. X#define z_viindent 110
  3001. X#define z_viinsert 111
  3002. X#define z_viinsertbol 112
  3003. X#define z_vijoin 113
  3004. X#define z_vimatchbracket 114
  3005. X#define z_viopenlineabove 115
  3006. X#define z_viopenlinebelow 116
  3007. X#define z_vioperswapcases 117
  3008. X#define z_viputafter 118
  3009. X#define z_virepeatchange 119
  3010. X#define z_virepeatfind 120
  3011. X#define z_virepeatsearch 121
  3012. X#define z_vireplace 122
  3013. X#define z_vireplacechars 123
  3014. X#define z_virevrepeatfind 124
  3015. X#define z_virevrepeatsearch 125
  3016. X#define z_visetbuffer 126
  3017. X#define z_visetmark 127
  3018. X#define z_visubstitute 128
  3019. X#define z_viswapcase 129
  3020. X#define z_viundochange 130
  3021. X#define z_viunindent 131
  3022. X#define z_viyank 132
  3023. X#define z_viyankeol 133
  3024. X#define z_whichcommand 134
  3025. X#define z_yank 135
  3026. X#define z_yankpop 136
  3027. X#define z_emacsbackwardword 137
  3028. X#define z_emacsforwardword 138
  3029. X#define z_killword 139
  3030. X#define z_vikillline 140
  3031. X#define z_vibackwardkillword 141
  3032. X#define z_expandcmdpath 142
  3033. X#define z_negargument 143
  3034. X#define z_poundinsert 144
  3035. X#define z_viforwardword 145
  3036. X#define z_vibackwardword 146
  3037. X#define z_uplineorsearch 147
  3038. X#define z_downlineorsearch 148
  3039. X#define z_pushinput 149
  3040. X#define z_pushpopinput 150
  3041. X#define z_historybeginningsearchbackward 151
  3042. X#define z_historybeginningsearchforward 152
  3043. X#define z_expandorcompleteprefix 153
  3044. X#define ZLECMDCOUNT 154
  3045. X
  3046. Xextern struct zlecmd zlecmds[];
  3047. END_OF_FILE
  3048.   if test 8927 -ne `wc -c <'zsh-2.5.0/src/zle.h'`; then
  3049.     echo shar: \"'zsh-2.5.0/src/zle.h'\" unpacked with wrong size!
  3050.   fi
  3051.   # end of 'zsh-2.5.0/src/zle.h'
  3052. fi
  3053. if test -f 'zsh-2.5.0/src/zle_word.c' -a "${1}" != "-c" ; then 
  3054.   echo shar: Will not clobber existing file \"'zsh-2.5.0/src/zle_word.c'\"
  3055. else
  3056.   echo shar: Extracting \"'zsh-2.5.0/src/zle_word.c'\" \(7099 characters\)
  3057.   sed "s/^X//" >'zsh-2.5.0/src/zle_word.c' <<'END_OF_FILE'
  3058. X
  3059. X/*
  3060. X *
  3061. X * zle_word.c - word-related editor functions
  3062. X *
  3063. X * This file is part of zsh, the Z shell.
  3064. X *
  3065. X * This software is Copyright 1992 by Paul Falstad
  3066. X *
  3067. X * Permission is hereby granted to copy, reproduce, redistribute or otherwise
  3068. X * use this software as long as: there is no monetary profit gained
  3069. X * specifically from the use or reproduction of this software, it is not
  3070. X * sold, rented, traded or otherwise marketed, and this copyright notice is
  3071. X * included prominently in any copy made.
  3072. X *
  3073. X * The author make no claims as to the fitness or correctness of this software
  3074. X * for any use whatsoever, and it is provided as is. Any use of this software
  3075. X * is at the user's own risk.
  3076. X *
  3077. X */
  3078. X
  3079. X#define ZLE
  3080. X#include "zsh.h"
  3081. X
  3082. Xvoid forwardword()
  3083. X{                /**/
  3084. X    if (mult < 0) {
  3085. X    mult = -mult;
  3086. X    backwardword();
  3087. X    return;
  3088. X    }
  3089. X    while (mult--) {
  3090. X    while (cs != ll && iword(line[cs]))
  3091. X        cs++;
  3092. X    if (wordflag && !mult)
  3093. X        return;
  3094. X    while (cs != ll && !iword(line[cs]))
  3095. X        cs++;
  3096. X    }
  3097. X}
  3098. X
  3099. Xvoid viforwardword()
  3100. X{                /**/
  3101. X    if (mult < 0) {
  3102. X    mult = -mult;
  3103. X    backwardword();
  3104. X    return;
  3105. X    }
  3106. X    while (mult--) {
  3107. X    if (iident(line[cs]))
  3108. X        while (cs != ll && iident(line[cs]))
  3109. X        cs++;
  3110. X    else
  3111. X        while (cs != ll && !iident(line[cs]) && !iblank(line[cs]))
  3112. X        cs++;
  3113. X    if (wordflag && !mult)
  3114. X        return;
  3115. X    while (cs != ll && iblank(line[cs]))
  3116. X        cs++;
  3117. X    }
  3118. X}
  3119. X
  3120. Xvoid viforwardblankword()
  3121. X{                /**/
  3122. X    if (mult < 0) {
  3123. X    mult = -mult;
  3124. X    vibackwardblankword();
  3125. X    return;
  3126. X    }
  3127. X    while (mult--) {
  3128. X    while (cs != ll && !iblank(line[cs]))
  3129. X        cs++;
  3130. X    if (wordflag && !mult)
  3131. X        return;
  3132. X    while (cs != ll && iblank(line[cs]))
  3133. X        cs++;
  3134. X    }
  3135. X}
  3136. X
  3137. Xvoid emacsforwardword()
  3138. X{                /**/
  3139. X    if (mult < 0) {
  3140. X    mult = -mult;
  3141. X    emacsbackwardword();
  3142. X    return;
  3143. X    }
  3144. X    while (mult--) {
  3145. X    while (cs != ll && !iword(line[cs]))
  3146. X        cs++;
  3147. X    if (wordflag && !mult)
  3148. X        return;
  3149. X    while (cs != ll && iword(line[cs]))
  3150. X        cs++;
  3151. X    }
  3152. X}
  3153. X
  3154. Xvoid viforwardblankwordend()
  3155. X{                /**/
  3156. X    if (mult < 0)
  3157. X    return;
  3158. X    while (mult--) {
  3159. X    while (cs != ll && iblank(line[cs + 1]))
  3160. X        cs++;
  3161. X    while (cs != ll && !iblank(line[cs + 1]))
  3162. X        cs++;
  3163. X    }
  3164. X    if (cs != ll && virangeflag)
  3165. X    cs++;
  3166. X}
  3167. X
  3168. Xvoid viforwardwordend()
  3169. X{                /**/
  3170. X    if (mult < 0) {
  3171. X    mult = -mult;
  3172. X    backwardword();
  3173. X    return;
  3174. X    }
  3175. X    while (mult--) {
  3176. X    if (iblank(line[cs + 1]))
  3177. X        while (cs != ll && iblank(line[cs + 1]))
  3178. X        cs++;
  3179. X    if (iident(line[cs + 1]))
  3180. X        while (cs != ll && iident(line[cs + 1]))
  3181. X        cs++;
  3182. X    else
  3183. X        while (cs != ll && !iident(line[cs + 1]) && !iblank(line[cs + 1]))
  3184. X        cs++;
  3185. X    }
  3186. X    if (cs != ll && virangeflag)
  3187. X    cs++;
  3188. X}
  3189. X
  3190. Xvoid backwardword()
  3191. X{                /**/
  3192. X    if (mult < 0) {
  3193. X    mult = -mult;
  3194. X    forwardword();
  3195. X    return;
  3196. X    }
  3197. X    while (mult--) {
  3198. X    while (cs && !iword(line[cs - 1]))
  3199. X        cs--;
  3200. X    while (cs && iword(line[cs - 1]))
  3201. X        cs--;
  3202. X    }
  3203. X}
  3204. X
  3205. Xvoid vibackwardword()
  3206. X{                /**/
  3207. X    if (mult < 0) {
  3208. X    mult = -mult;
  3209. X    backwardword();
  3210. X    return;
  3211. X    }
  3212. X    while (mult--) {
  3213. X    while (cs && iblank(line[cs - 1]))
  3214. X        cs--;
  3215. X    if (iident(line[cs - 1]))
  3216. X        while (cs && iident(line[cs - 1]))
  3217. X        cs--;
  3218. X    else
  3219. X        while (cs && !iident(line[cs - 1]) && !iblank(line[cs - 1]))
  3220. X        cs--;
  3221. X    }
  3222. X}
  3223. X
  3224. Xvoid vibackwardblankword()
  3225. X{                /**/
  3226. X    if (mult < 0) {
  3227. X    mult = -mult;
  3228. X    viforwardblankword();
  3229. X    return;
  3230. X    }
  3231. X    while (mult--) {
  3232. X    while (cs && iblank(line[cs - 1]))
  3233. X        cs--;
  3234. X    while (cs && !iblank(line[cs - 1]))
  3235. X        cs--;
  3236. X    }
  3237. X}
  3238. X
  3239. Xvoid emacsbackwardword()
  3240. X{                /**/
  3241. X    if (mult < 0) {
  3242. X    mult = -mult;
  3243. X    emacsforwardword();
  3244. X    return;
  3245. X    }
  3246. X    while (mult--) {
  3247. X    while (cs && !iword(line[cs - 1]))
  3248. X        cs--;
  3249. X    while (cs && iword(line[cs - 1]))
  3250. X        cs--;
  3251. X    }
  3252. X}
  3253. X
  3254. Xvoid backwarddeleteword()
  3255. X{                /**/
  3256. X    int x = cs;
  3257. X
  3258. X    if (mult < 0) {
  3259. X    mult = -mult;
  3260. X    deleteword();
  3261. X    return;
  3262. X    }
  3263. X    while (mult--) {
  3264. X    while (x && !iword(line[x - 1]))
  3265. X        x--;
  3266. X    while (x && iword(line[x - 1]))
  3267. X        x--;
  3268. X    }
  3269. X    backdel(cs - x);
  3270. X}
  3271. X
  3272. Xvoid vibackwardkillword()
  3273. X{                /**/
  3274. X    int x = cs;
  3275. X
  3276. X    if (mult < 0) {
  3277. X    feep();
  3278. X    return;
  3279. X    }
  3280. X/* this taken from "vibackwardword" */
  3281. X    while (mult--) {
  3282. X    while ((x > viinsbegin) && iblank(line[x - 1]))
  3283. X        x--;
  3284. X    if (iident(line[x - 1]))
  3285. X        while ((x > viinsbegin) && iident(line[x - 1]))
  3286. X        x--;
  3287. X    else
  3288. X        while ((x > viinsbegin) && !iident(line[x - 1]) && !iblank(line[x - 1]))
  3289. X        x--;
  3290. X    }
  3291. X/*
  3292. X        while (mult--) {
  3293. X                while ( (x > viinsbegin) && (iwordsep(line[x-1]))) x--;
  3294. X                while ( (x > viinsbegin) && (!iwordsep(line[x-1]))) x--;
  3295. X        }
  3296. X        */
  3297. X    backkill(cs - x, 1);
  3298. X}
  3299. X
  3300. Xvoid backwardkillword()
  3301. X{                /**/
  3302. X    int x = cs;
  3303. X
  3304. X    if (mult < 0) {
  3305. X    mult = -mult;
  3306. X    killword();
  3307. X    return;
  3308. X    }
  3309. X    while (mult--) {
  3310. X    while (x && !iword(line[x - 1]))
  3311. X        x--;
  3312. X    while (x && iword(line[x - 1]))
  3313. X        x--;
  3314. X    }
  3315. X    backkill(cs - x, 1);
  3316. X}
  3317. X
  3318. Xvoid upcaseword()
  3319. X{                /**/
  3320. X    int neg = mult < 0, ocs = cs;
  3321. X
  3322. X    if (neg)
  3323. X    mult = -mult;
  3324. X    while (mult--) {
  3325. X    while (cs != ll && !iword(line[cs]))
  3326. X        cs++;
  3327. X    while (cs != ll && iword(line[cs])) {
  3328. X        line[cs] = tuupper(line[cs]);
  3329. X        cs++;
  3330. X    }
  3331. X    }
  3332. X    if (neg)
  3333. X    cs = ocs;
  3334. X}
  3335. X
  3336. Xvoid downcaseword()
  3337. X{                /**/
  3338. X    int neg = mult < 0, ocs = cs;
  3339. X
  3340. X    if (neg)
  3341. X    mult = -mult;
  3342. X    while (mult--) {
  3343. X    while (cs != ll && !iword(line[cs]))
  3344. X        cs++;
  3345. X    while (cs != ll && iword(line[cs])) {
  3346. X        line[cs] = tulower(line[cs]);
  3347. X        cs++;
  3348. X    }
  3349. X    }
  3350. X    if (neg)
  3351. X    cs = ocs;
  3352. X}
  3353. X
  3354. Xvoid capitalizeword()
  3355. X{                /**/
  3356. X    int first;
  3357. X    int neg = mult < 0, ocs = cs;
  3358. X
  3359. X    if (neg)
  3360. X    mult = -mult;
  3361. X    while (mult--) {
  3362. X    first = 1;
  3363. X    while (cs != ll && !iword(line[cs]))
  3364. X        cs++;
  3365. X    while (cs != ll && iword(line[cs])) {
  3366. X        line[cs] = (first) ? tuupper(line[cs]) : tulower(line[cs]);
  3367. X        first = 0;
  3368. X        cs++;
  3369. X    }
  3370. X    }
  3371. X    if (neg)
  3372. X    cs = ocs;
  3373. X}
  3374. X
  3375. Xvoid deleteword()
  3376. X{                /**/
  3377. X    int x = cs;
  3378. X
  3379. X    if (mult < 0) {
  3380. X    mult = -mult;
  3381. X    backwarddeleteword();
  3382. X    return;
  3383. X    }
  3384. X    while (mult--) {
  3385. X    while (x != ll && !iword(line[x]))
  3386. X        x++;
  3387. X    while (x != ll && iword(line[x]))
  3388. X        x++;
  3389. X    }
  3390. X    foredel(x - cs);
  3391. X}
  3392. X
  3393. Xvoid killword()
  3394. X{                /**/
  3395. X    int x = cs;
  3396. X
  3397. X    if (mult < 0) {
  3398. X    mult = -mult;
  3399. X    backwardkillword();
  3400. X    return;
  3401. X    }
  3402. X    while (mult--) {
  3403. X    while (x != ll && !iword(line[x]))
  3404. X        x++;
  3405. X    while (x != ll && iword(line[x]))
  3406. X        x++;
  3407. X    }
  3408. X    forekill(x - cs, 0);
  3409. X}
  3410. X
  3411. Xvoid transposewords()
  3412. X{                /**/
  3413. X    int p1, p2, p3, p4, x = cs;
  3414. X    char *temp, *pp;
  3415. X    int neg = mult < 0, ocs = cs;
  3416. X
  3417. X    if (neg)
  3418. X    mult = -mult;
  3419. X    while (mult--) {
  3420. X    while (x != ll && line[x] != '\n' && !iword(line[x]))
  3421. X        x++;
  3422. X    if (x == ll || line[x] == '\n') {
  3423. X        x = cs;
  3424. X        while (x && line[x - 1] != '\n' && !iword(line[x]))
  3425. X        x--;
  3426. X        if (!x || line[x - 1] == '\n') {
  3427. X        feep();
  3428. X        return;
  3429. X        }
  3430. X    }
  3431. X    for (p4 = x; p4 != ll && iword(line[p4]); p4++);
  3432. X    for (p3 = p4; p3 && iword(line[p3 - 1]); p3--);
  3433. X    if (!p3) {
  3434. X        feep();
  3435. X        return;
  3436. X    }
  3437. X    for (p2 = p3; p2 && !iword(line[p2 - 1]); p2--);
  3438. X    if (!p2) {
  3439. X        feep();
  3440. X        return;
  3441. X    }
  3442. X    for (p1 = p2; p1 && iword(line[p1 - 1]); p1--);
  3443. X    pp = temp = (char *)halloc(p4 - p1 + 1);
  3444. X    struncpy(&pp, UTOSCP(line + p3), p4 - p3);
  3445. X    struncpy(&pp, UTOSCP(line + p2), p3 - p2);
  3446. X    struncpy(&pp, UTOSCP(line + p1), p2 - p1);
  3447. X    strncpy((char *)line + p1, temp, p4 - p1);
  3448. X    cs = p4;
  3449. X    }
  3450. X    if (neg)
  3451. X    cs = ocs;
  3452. X}
  3453. END_OF_FILE
  3454.   if test 7099 -ne `wc -c <'zsh-2.5.0/src/zle_word.c'`; then
  3455.     echo shar: \"'zsh-2.5.0/src/zle_word.c'\" unpacked with wrong size!
  3456.   fi
  3457.   # end of 'zsh-2.5.0/src/zle_word.c'
  3458. fi
  3459. echo shar: End of archive 16 \(of 18\).
  3460. cp /dev/null ark16isdone
  3461. MISSING=""
  3462. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ; do
  3463.     if test ! -f ark${I}isdone ; then
  3464.     MISSING="${MISSING} ${I}"
  3465.     fi
  3466. done
  3467. if test "${MISSING}" = "" ; then
  3468.     echo You have unpacked all 18 archives.
  3469.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  3470. else
  3471.     echo You still must unpack the following archives:
  3472.     echo "        " ${MISSING}
  3473. fi
  3474. exit 0
  3475. exit 0 # Just in case...
  3476.