home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume19 / zsh2.00 / patch02b < prev    next >
Encoding:
Text File  |  1991-05-16  |  50.6 KB  |  2,449 lines

  1. Newsgroups: comp.sources.misc
  2. From: Paul Falstad <pfalstad@phoenix.princeton.edu>
  3. Subject:  v19i068:  zsh2.00 - The Z shell, Patch02b/6
  4. Message-ID: <1991May15.214836.6981@sparky.IMD.Sterling.COM>
  5. X-Md4-Signature: 3b3d6a436c1fd14b3a08c7736bcec723
  6. Date: Wed, 15 May 1991 21:48:36 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: Paul Falstad <pfalstad@phoenix.princeton.edu>
  10. Posting-number: Volume 19, Issue 68
  11. Archive-name: zsh2.00/patch02b
  12. Patch-To: zsh2.00: Volume 18, Issue 84-98
  13.  
  14. #!/bin/sh
  15. # this is zpatch.02 (part 2 of a multipart archive)
  16. # do not concatenate these parts, unpack them in order with /bin/sh
  17. # file patches continued
  18. #
  19. if test ! -r _shar_seq_.tmp; then
  20.     echo 'Please unpack part 1 first!'
  21.     exit 1
  22. fi
  23. (read Scheck
  24.  if test "$Scheck" != 2; then
  25.     echo Please unpack part "$Scheck" next!
  26.     exit 1
  27.  else
  28.     exit 0
  29.  fi
  30. ) < _shar_seq_.tmp || exit 1
  31. echo 'x - continuing file patches'
  32. sed 's/^X//' << 'SHAR_EOF' >> 'patches' &&
  33. X              else if (on & PMFLAG_u)
  34. X                  {
  35. !                 cc = (Cmdnam) zcalloc(sizeof *cc);
  36. X                  cc->type = SHFUNC;
  37. X                  cc->flags = on;
  38. X                  addhnode(ztrdup(*argv),cc,cmdnamtab,freecmdnam);
  39. ***************
  40. *** 1649,1655 ****
  41. X          }
  42. X      else while (asg = getasg(*argv++))
  43. X          {
  44. !         pm = gethnode(asg->name,paramtab);
  45. X          if (pm)
  46. X              {
  47. X              if (!on && !roff && !asg->value)
  48. --- 1684,1690 ----
  49. X          }
  50. X      else while (asg = getasg(*argv++))
  51. X          {
  52. !         pm = (Param) gethnode(asg->name,paramtab);
  53. X          if (pm)
  54. X              {
  55. X              if (!on && !roff && !asg->value)
  56. ***************
  57. *** 1685,1691 ****
  58. X                  }
  59. X              createparam(ztrdup(asg->name),
  60. X                  ztrdup((asg->value) ? asg->value : ""),on);
  61. !             pm = gethnode(asg->name,paramtab);
  62. X              pm->ct = auxlen;
  63. X              }
  64. X          }
  65. --- 1720,1726 ----
  66. X                  }
  67. X              createparam(ztrdup(asg->name),
  68. X                  ztrdup((asg->value) ? asg->value : ""),on);
  69. !             pm = (Param) gethnode(asg->name,paramtab);
  70. X              pm->ct = auxlen;
  71. X              }
  72. X          }
  73. ***************
  74. *** 1705,1710 ****
  75. --- 1740,1746 ----
  76. X                  {
  77. X                  case 'b': putchar('\b'); break;
  78. X                  case 'c': nnl = 1; break;
  79. +                 case 'e': putchar('\033'); break;
  80. X                  case 'f': putchar('\f'); break;
  81. X                  case 'n': putchar('\n'); break;
  82. X                  case 'r': putchar('\r'); break;
  83. ***************
  84. *** 1799,1805 ****
  85. X  char *name;char **argv;char *ops;int func;
  86. X  {
  87. X  int ret = 0;
  88. ! void *dat;
  89. X  
  90. X      while (*argv)
  91. X          {
  92. --- 1835,1841 ----
  93. X  char *name;char **argv;char *ops;int func;
  94. X  {
  95. X  int ret = 0;
  96. ! vptr dat;
  97. X  
  98. X      while (*argv)
  99. X          {
  100. ***************
  101. *** 1817,1823 ****
  102. X  char *name;char **argv;char *ops;int func;
  103. X  {
  104. X  int retval = 0;
  105. ! void *dat;
  106. X  
  107. X      while (*argv)
  108. X          {
  109. --- 1853,1859 ----
  110. X  char *name;char **argv;char *ops;int func;
  111. X  {
  112. X  int retval = 0;
  113. ! vptr dat;
  114. X  
  115. X      while (*argv)
  116. X          {
  117. ***************
  118. *** 1864,1871 ****
  119. X  char *reply,*pmpt;
  120. X  int bsiz,c,gotnl = 0;
  121. X  char *buf,*bptr;
  122. - char cc;
  123. X  
  124. X      if (*args)
  125. X          reply = *args++;
  126. X      else
  127. --- 1900,1907 ----
  128. X  char *reply,*pmpt;
  129. X  int bsiz,c,gotnl = 0;
  130. X  char *buf,*bptr;
  131. X  
  132. +     attachtty(mypgrp);
  133. X      if (*args)
  134. X          reply = *args++;
  135. X      else
  136. ***************
  137. *** 1974,1980 ****
  138. X  struct bincmd *b;
  139. X  char ops[128],*arg,*pp,*name,**argv,**oargv;
  140. X  int t0,flags,sense,argc = 0,retval,op;
  141. - void *data;
  142. X  Lknode n;
  143. X  
  144. X      auxdata = NULL;
  145. --- 2010,2015 ----
  146. ***************
  147. *** 2006,2015 ****
  148. X      arg = ugetnode(args);
  149. X      if (b->optstr)
  150. X          while (arg &&
  151. !                 ((sense = *arg == '-') ||  fset(BINF_PLUSOPTS) && *arg == '+') &&
  152. !                 !atoi(arg))
  153. X              {
  154. X              pp = arg;
  155. X              if (!arg[1])
  156. X                  {
  157. X                  ops['-'] = 1;
  158. --- 2041,2052 ----
  159. X      arg = ugetnode(args);
  160. X      if (b->optstr)
  161. X          while (arg &&
  162. !                 ((sense = *arg == '-') || fset(BINF_PLUSOPTS) && *arg == '+') &&
  163. !                 (fset(BINF_PLUSOPTS) || !atoi(arg)))
  164. X              {
  165. X              pp = arg;
  166. +             if (arg[1] == '-')
  167. +                 arg++;
  168. X              if (!arg[1])
  169. X                  {
  170. X                  ops['-'] = 1;
  171. ***************
  172. *** 2020,2026 ****
  173. X                  ops['@'] = 1;
  174. X              while (*++arg)
  175. X                  if (strchr(b->optstr,op = *arg))
  176. !                     ops[*arg] = (sense) ? 1 : -1;
  177. X                  else
  178. X                      break;
  179. X              if (*arg)
  180. --- 2057,2063 ----
  181. X                  ops['@'] = 1;
  182. X              while (*++arg)
  183. X                  if (strchr(b->optstr,op = *arg))
  184. !                     ops[*arg] = (sense) ? 1 : 2;
  185. X                  else
  186. X                      break;
  187. X              if (*arg)
  188. ***************
  189. *** 2080,2086 ****
  190. X      if (*argv++ = arg)
  191. X          while (*argv++ = ugetnode(args));
  192. X      argv = oargv;
  193. -     data = argv;
  194. X      if (errflag)
  195. X          return 1;
  196. X      if (argc < b->minargs || (argc > b->maxargs && b->maxargs != -1))
  197. --- 2117,2122 ----
  198. ***************
  199. *** 2090,2096 ****
  200. X          retval = 1;
  201. X          }
  202. X      else
  203. !         retval = (*(b->handlerfunc))(name,data,ops,b->funcid);
  204. X      return retval;
  205. X  }
  206. X  
  207. --- 2126,2132 ----
  208. X          retval = 1;
  209. X          }
  210. X      else
  211. !         retval = (*(b->handlerfunc))(name,argv,ops,b->funcid);
  212. X      return retval;
  213. X  }
  214. X  
  215. ***************
  216. *** 2101,2106 ****
  217. --- 2137,2147 ----
  218. X  
  219. X      if (!s)
  220. X          return NULL;
  221. +     if (*s == '=')
  222. +         {
  223. +         zerr("bad assignment",NULL,0);
  224. +         return NULL;
  225. +         }
  226. X      asg.name = s;
  227. X      for (; *s && *s != '='; s++);
  228. X      if (*s)
  229. ***************
  230. *** 2209,2215 ****
  231. X  {
  232. X  struct tms buf;
  233. X  
  234. !     if (times(&buf))
  235. X          return 1;
  236. X      pttime(buf.tms_utime);
  237. X      putchar(' ');
  238. --- 2250,2256 ----
  239. X  {
  240. X  struct tms buf;
  241. X  
  242. !     if (times(&buf) == -1)
  243. X          return 1;
  244. X      pttime(buf.tms_utime);
  245. X      putchar(' ');
  246. ***************
  247. *** 2242,2248 ****
  248. X          }
  249. X      if (optind >= arrlen(args))
  250. X          return 1;
  251. !     str = args[optind-1];
  252. X      if (*str != '+' && *str != '-' || optcind >= strlen(str) ||
  253. X              !strcmp("--",str))
  254. X          {
  255. --- 2283,2289 ----
  256. X          }
  257. X      if (optind >= arrlen(args))
  258. X          return 1;
  259. !     str = args[optind];
  260. X      if (*str != '+' && *str != '-' || optcind >= strlen(str) ||
  261. X              !strcmp("--",str))
  262. X          {
  263. ***************
  264. *** 2254,2260 ****
  265. X      if (!optcind)
  266. X          optcind = 1;
  267. X      *opch = str[optcind++];
  268. !     if (!args[optcind])
  269. X          {
  270. X          optind++;
  271. X          optcind = 0;
  272. --- 2295,2301 ----
  273. X      if (!optcind)
  274. X          optcind = 1;
  275. X      *opch = str[optcind++];
  276. !     if (!args[optind][optcind])
  277. X          {
  278. X          optind++;
  279. X          optcind = 0;
  280. ***************
  281. *** 2276,2282 ****
  282. X      setsparam(var,ztrdup(opch-(*str == '+')));
  283. X      if (optstr[1] == ':')
  284. X          {
  285. !         if (!args[optind-1])
  286. X              {
  287. X              if (quiet)
  288. X                  {
  289. --- 2317,2323 ----
  290. X      setsparam(var,ztrdup(opch-(*str == '+')));
  291. X      if (optstr[1] == ':')
  292. X          {
  293. !         if (!args[optind])
  294. X              {
  295. X              if (quiet)
  296. X                  {
  297. ***************
  298. *** 2326,2332 ****
  299. X                      printf("TRAP%s () {}\n",sigs[t0]);
  300. X                  else
  301. X                      {
  302. !                     char *s = gettext((void *) sigfuncs[t0],1);
  303. X                      printf("TRAP%s () {\n\t%s\n}\n",sigs[t0],s);
  304. X                      free(s);
  305. X                      }
  306. --- 2367,2373 ----
  307. X                      printf("TRAP%s () {}\n",sigs[t0]);
  308. X                  else
  309. X                      {
  310. !                     char *s = gettext((vptr) sigfuncs[t0],1);
  311. X                      printf("TRAP%s () {\n\t%s\n}\n",sigs[t0],s);
  312. X                      free(s);
  313. X                      }
  314. *** src/zsh0/zsh2.00/src/cond.c    Tue Apr 23 11:34:17 1991
  315. --- zsh2.00/src/cond.c    Fri May 10 06:25:49 1991
  316. ***************
  317. *** 31,37 ****
  318. X  */
  319. X  
  320. X  #include "zsh.h"
  321. - #include "funcs.h"
  322. X  
  323. X  #ifndef F_OK
  324. X  #define F_OK 00
  325. --- 31,36 ----
  326. ***************
  327. *** 53,64 ****
  328. X          }
  329. X      singsub((char **) &c->left);
  330. X      untokenize(c->left);
  331. !     if (c->type != COND_STREQ && c->type != COND_STRNEQ)
  332. !         if (c->right)
  333. !             {
  334. !             singsub((char **) &c->right);
  335. X              untokenize(c->right);
  336. !             }
  337. X      switch (c->type)
  338. X          {
  339. X          case COND_STREQ: return matchpat(c->left,c->right);
  340. --- 52,63 ----
  341. X          }
  342. X      singsub((char **) &c->left);
  343. X      untokenize(c->left);
  344. !     if (c->right)
  345. !         {
  346. !         singsub((char **) &c->right);
  347. !         if (c->type != COND_STREQ && c->type != COND_STRNEQ)
  348. X              untokenize(c->right);
  349. !         }
  350. X      switch (c->type)
  351. X          {
  352. X          case COND_STREQ: return matchpat(c->left,c->right);
  353. ***************
  354. *** 82,88 ****
  355. X          case 'w': return(doaccess(c->left,W_OK));
  356. X          case 'x': return(doaccess(c->left,X_OK));
  357. X          case 'z': return(!strlen(c->left));
  358. !         case 'L': return(S_ISLNK(dostat(c->left)));
  359. X          case 'O': return((st = getstat(c->left)) && st->st_uid == geteuid());
  360. X          case 'G': return((st = getstat(c->left)) && st->st_gid == getegid());
  361. X          case 't': return isatty(matheval(c->left));
  362. --- 81,87 ----
  363. X          case 'w': return(doaccess(c->left,W_OK));
  364. X          case 'x': return(doaccess(c->left,X_OK));
  365. X          case 'z': return(!strlen(c->left));
  366. !         case 'L': return(S_ISLNK(dolstat(c->left)));
  367. X          case 'O': return((st = getstat(c->left)) && st->st_uid == geteuid());
  368. X          case 'G': return((st = getstat(c->left)) && st->st_gid == getegid());
  369. X          case 't': return isatty(matheval(c->left));
  370. ***************
  371. *** 126,142 ****
  372. X      return !access(s,c);
  373. X  }
  374. X  
  375. X  struct stat *getstat(s) /**/
  376. X  char *s;
  377. X  {
  378. - static struct stat st;
  379. X      if (!strncmp(s,"/dev/fd/",8))
  380. X          {
  381. X          if (fstat(atoi(s+8),&st))
  382. X              return NULL;
  383. X          }
  384. !     else if (lstat(s,&st))
  385. X          return NULL;
  386. X      return &st;
  387. X  }
  388. --- 125,141 ----
  389. X      return !access(s,c);
  390. X  }
  391. X  
  392. + static struct stat st;
  393. X  struct stat *getstat(s) /**/
  394. X  char *s;
  395. X  {
  396. X      if (!strncmp(s,"/dev/fd/",8))
  397. X          {
  398. X          if (fstat(atoi(s+8),&st))
  399. X              return NULL;
  400. X          }
  401. !     else if (stat(s,&st))
  402. X          return NULL;
  403. X      return &st;
  404. X  }
  405. ***************
  406. *** 149,154 ****
  407. --- 148,163 ----
  408. X      if (!(st = getstat(s)))
  409. X          return 0;
  410. X      return st->st_mode;
  411. + }
  412. + /* pem@aaii.oz; needed since dostat now uses "stat" */
  413. + unsigned short dolstat(s) /**/
  414. + char *s;
  415. + {
  416. +     if (lstat(s, &st) < 0)
  417. +         return 0;
  418. +     return st.st_mode;
  419. X  }
  420. X  
  421. X  int optison(s) /**/
  422. *** src/zsh0/zsh2.00/src/cond.pro    Tue Apr 23 00:29:58 1991
  423. --- zsh2.00/src/cond.pro    Tue May  7 22:53:25 1991
  424. ***************
  425. *** 2,5 ****
  426. --- 2,6 ----
  427. X  int doaccess DCLPROTO((char *s,int c));
  428. X  struct stat *getstat DCLPROTO((char *s));
  429. X  unsigned short dostat DCLPROTO((char *s));
  430. + unsigned short dolstat DCLPROTO((char *s));
  431. X  int optison DCLPROTO((char *s));
  432. *** src/zsh0/zsh2.00/src/exec.c    Tue Apr 23 11:53:10 1991
  433. --- zsh2.00/src/exec.c    Fri May 10 06:55:08 1991
  434. ***************
  435. *** 31,37 ****
  436. X  */
  437. X  
  438. X  #include "zsh.h"
  439. - #include "funcs.h"
  440. X  #include <sys/errno.h>
  441. X  #include <sys/dir.h>
  442. X  
  443. --- 31,36 ----
  444. ***************
  445. *** 78,84 ****
  446. X  void newrunlist(l) /**/
  447. X  List l;
  448. X  {
  449. !     List a = dupstruct(l); runlist(a);
  450. X  }
  451. X  
  452. X  /* fork and set limits */
  453. --- 77,83 ----
  454. X  void newrunlist(l) /**/
  455. X  List l;
  456. X  {
  457. !     List a = (List) dupstruct(l); runlist(a);
  458. X  }
  459. X  
  460. X  /* fork and set limits */
  461. ***************
  462. *** 167,174 ****
  463. X                          }
  464. X                      else
  465. X                          {
  466. !                         argv[-1] = MYSELF;
  467. !                         execve(MYSELF,argv-1,environ);
  468. X                          }
  469. X                  else
  470. X                      {
  471. --- 166,173 ----
  472. X                          }
  473. X                      else
  474. X                          {
  475. !                         argv[-1] = "sh";
  476. !                         execve("/bin/sh",argv-1,environ);
  477. X                          }
  478. X                  else
  479. X                      {
  480. ***************
  481. *** 208,214 ****
  482. X  Cmdnam cn;
  483. X  int tl,ee = 0;
  484. X  
  485. !     cn = gethnode(peekfirst(args),cmdnamtab);
  486. X      if (s = zgetenv("STTY"))
  487. X          zyztem("stty",s);
  488. X      arg0 = peekfirst(args);
  489. --- 207,213 ----
  490. X  Cmdnam cn;
  491. X  int tl,ee = 0;
  492. X  
  493. !     cn = (Cmdnam) gethnode(peekfirst(args),cmdnamtab);
  494. X      if (s = zgetenv("STTY"))
  495. X          zyztem("stty",s);
  496. X      arg0 = peekfirst(args);
  497. ***************
  498. *** 275,281 ****
  499. X  {
  500. X  char *s,buf[MAXPATHLEN];
  501. X  int tl;
  502. ! struct cmdnam *cn = gethnode(arg0,cmdnamtab);
  503. X  char **pp = path;
  504. X  
  505. X      if (cn && (cn->type == EXCMD_POSTDOT || cn->type == EXCMD_PREDOT))
  506. --- 274,280 ----
  507. X  {
  508. X  char *s,buf[MAXPATHLEN];
  509. X  int tl;
  510. ! struct cmdnam *cn = (Cmdnam) gethnode(arg0,cmdnamtab);
  511. X  char **pp = path;
  512. X  
  513. X      if (cn && (cn->type == EXCMD_POSTDOT || cn->type == EXCMD_PREDOT))
  514. ***************
  515. *** 440,446 ****
  516. X                  char *s,*text;
  517. X  
  518. X                  close(pipes[0]);
  519. !                 text = s = gettext((void *) pline->right,0);
  520. X                  addproc(pid,text)->lastfg = 1;
  521. X                  pline->right = NULL;
  522. X                  }
  523. --- 439,445 ----
  524. X                  char *s,*text;
  525. X  
  526. X                  close(pipes[0]);
  527. !                 text = s = gettext((vptr) pline->right,0);
  528. X                  addproc(pid,text)->lastfg = 1;
  529. X                  pline->right = NULL;
  530. X                  }
  531. ***************
  532. *** 512,520 ****
  533. X      for (node = firstnode(l); node; node = next)
  534. X          {
  535. X          next = nextnode(node);
  536. !         if (*(char *) getdata(node))
  537. !             untokenize(getdata(node));
  538. !         else
  539. X              uremnode(l,node);
  540. X          }
  541. X  }
  542. --- 511,518 ----
  543. X      for (node = firstnode(l); node; node = next)
  544. X          {
  545. X          next = nextnode(node);
  546. !         untokenize(getdata(node));
  547. !         if (!*(char *) getdata(node))
  548. X              uremnode(l,node);
  549. X          }
  550. X  }
  551. ***************
  552. *** 589,595 ****
  553. X  
  554. X      if (!mfds[fd1])    /* starting a new multio */
  555. X          {
  556. !         mfds[fd1] = alloc(sizeof(struct multio));
  557. X          if (!forked && fd1 != fd2 && fd1 < 10)
  558. X              save[fd1] = movefd(fd1);
  559. X          redup(fd2,fd1);
  560. --- 587,593 ----
  561. X  
  562. X      if (!mfds[fd1])    /* starting a new multio */
  563. X          {
  564. !         mfds[fd1] = (struct multio *) alloc(sizeof(struct multio));
  565. X          if (!forked && fd1 != fd2 && fd1 < 10)
  566. X              save[fd1] = movefd(fd1);
  567. X          redup(fd2,fd1);
  568. ***************
  569. *** 628,634 ****
  570. X          {
  571. X          char **arr,**ptr;
  572. X  
  573. !         v = ugetnode(l);
  574. X          singsub(&v->name);
  575. X          if (errflag)
  576. X              return;
  577. --- 626,632 ----
  578. X          {
  579. X          char **arr,**ptr;
  580. X  
  581. !         v = (struct varasg *) ugetnode(l);
  582. X          singsub(&v->name);
  583. X          if (errflag)
  584. X              return;
  585. ***************
  586. *** 646,652 ****
  587. X          postfork(vl,1);
  588. X          if (errflag)
  589. X              return;
  590. !         if (v->type == PMFLAG_s)
  591. X              {
  592. X              Param pm;
  593. X              char *val;
  594. --- 644,650 ----
  595. X          postfork(vl,1);
  596. X          if (errflag)
  597. X              return;
  598. !         if (v->type == PMFLAG_s && (!full(vl) || !nextnode(firstnode(vl))))
  599. X              {
  600. X              Param pm;
  601. X              char *val;
  602. ***************
  603. *** 662,671 ****
  604. X                  addenv(v->name,val);
  605. X              continue;
  606. X              }
  607. !         ptr = arr = (char **) zalloc(sizeof(char **)*(countnodes(v->arr)+1));
  608. !         while (full(v->arr))
  609. X              {
  610. !             *ptr = ztrdup(ugetnode(v->arr));
  611. X              untokenize(*ptr++);
  612. X              }
  613. X          *ptr = NULL;
  614. --- 660,669 ----
  615. X                  addenv(v->name,val);
  616. X              continue;
  617. X              }
  618. !         ptr = arr = (char **) zalloc(sizeof(char **)*(countnodes(vl)+1));
  619. !         while (full(vl))
  620. X              {
  621. !             *ptr = ztrdup(ugetnode(vl));
  622. X              untokenize(*ptr++);
  623. X              }
  624. X          *ptr = NULL;
  625. ***************
  626. *** 707,713 ****
  627. X          insnode(args,(Lknode) args,strdup((bkg) ? "bg" : "fg"));
  628. X          bkg = 0;
  629. X          }
  630. !     if (isset(AUTORESUME) && !full(cmd->redir) && full(args) &&
  631. X              type == SIMPLE && !nextnode(firstnode(args)) &&
  632. X              findjobnam(peekfirst(args)) != -1)
  633. X          pushnode(args,strdup("fg"));
  634. --- 705,711 ----
  635. X          insnode(args,(Lknode) args,strdup((bkg) ? "bg" : "fg"));
  636. X          bkg = 0;
  637. X          }
  638. !     if (isset(AUTORESUME) && !bkg && !full(cmd->redir) && full(args) &&
  639. X              type == SIMPLE && !nextnode(firstnode(args)) &&
  640. X              findjobnam(peekfirst(args)) != -1)
  641. X          pushnode(args,strdup("fg"));
  642. ***************
  643. *** 723,729 ****
  644. X      if (jobbing)    /* get the text associated with this command */
  645. X          {
  646. X          char *s;
  647. !         s = text = gettext((void *) cmd,0);
  648. X          }
  649. X      else
  650. X          text = NULL;
  651. --- 721,727 ----
  652. X      if (jobbing)    /* get the text associated with this command */
  653. X          {
  654. X          char *s;
  655. !         s = text = gettext((vptr) cmd,0);
  656. X          }
  657. X      else
  658. X          text = NULL;
  659. ***************
  660. *** 734,746 ****
  661. X          return;
  662. X          }
  663. X      if (full(args) && !(cmd->flags & CFLAG_COMMAND))
  664. !         chn = gethnode(peekfirst(args),cmdnamtab);
  665. X      if (!pathsuppress && !chn && isset(AUTOCD) && full(args) &&
  666. X              !full(cmd->redir) &&
  667. X              !nextnode(firstnode(args)) && cancd(peekfirst(args)))
  668. X          {
  669. X          pushnode(args,strdup("cd"));
  670. !         chn = gethnode("cd",cmdnamtab);
  671. X          }
  672. X  
  673. X      /* this is nonzero if cmd is a current shell procedure */
  674. --- 732,744 ----
  675. X          return;
  676. X          }
  677. X      if (full(args) && !(cmd->flags & CFLAG_COMMAND))
  678. !         chn = (Cmdnam) gethnode(peekfirst(args),cmdnamtab);
  679. X      if (!pathsuppress && !chn && isset(AUTOCD) && full(args) &&
  680. X              !full(cmd->redir) &&
  681. X              !nextnode(firstnode(args)) && cancd(peekfirst(args)))
  682. X          {
  683. X          pushnode(args,strdup("cd"));
  684. !         chn = (Cmdnam) gethnode("cd",cmdnamtab);
  685. X          }
  686. X  
  687. X      /* this is nonzero if cmd is a current shell procedure */
  688. ***************
  689. *** 757,767 ****
  690. --- 755,774 ----
  691. X      if (bkg || !(iscursh || (cmd->flags & CFLAG_EXEC)) ||
  692. X              (chn && (chn->type == BUILTIN || chn->type == SHFUNC) && output))
  693. X          {
  694. +         int synch[2];
  695. +         pipe(synch);
  696. X          pid = (last1 && execok()) ? 0 : phork();
  697. X          if (pid == -1)
  698. +             {
  699. +             close(synch[0]);
  700. +             close(synch[1]);
  701. X              return;
  702. +             }
  703. X          if (pid)
  704. X              {
  705. +             close(synch[1]);
  706. +             read(synch[0],"foo",1);
  707. X              if (pid == -1)
  708. X                  zerr("%e",NULL,errno);
  709. X              else
  710. ***************
  711. *** 768,774 ****
  712. --- 775,783 ----
  713. X                  ( void ) addproc(pid,text);
  714. X              return;
  715. X              }
  716. +         close(synch[0]);
  717. X          entersubsh(bkg);
  718. +         close(synch[1]);
  719. X          forked = 1;
  720. X          }
  721. X      if (bkg && isset(BGNICE))    /* stupid */
  722. ***************
  723. *** 779,785 ****
  724. X          addfd(forked,save,mfds,1,output,1);
  725. X      spawnpipes(cmd->redir);        /* do process substitutions */
  726. X      while (full(cmd->redir))
  727. !         if ((fn = ugetnode(cmd->redir))->type == INPIPE)
  728. X              {
  729. X              if (fn->fd2 == -1)
  730. X                  execerr();
  731. --- 788,794 ----
  732. X          addfd(forked,save,mfds,1,output,1);
  733. X      spawnpipes(cmd->redir);        /* do process substitutions */
  734. X      while (full(cmd->redir))
  735. !         if ((fn = (struct redir*) ugetnode(cmd->redir))->type == INPIPE)
  736. X              {
  737. X              if (fn->fd2 == -1)
  738. X                  execerr();
  739. ***************
  740. *** 821,831 ****
  741. X                  }
  742. X              else if (fn->type == CLOSE)
  743. X                  {
  744. !                 if (!forked && fn->fd1 < 3)
  745. !                     {
  746. !                     zerr("can't close fd %d without forking",NULL,fn->fd1);
  747. !                     execerr();
  748. !                     }
  749. X                  closemn(mfds,fn->fd1);
  750. X                  close(fn->fd1);
  751. X                  }
  752. --- 830,837 ----
  753. X                  }
  754. X              else if (fn->type == CLOSE)
  755. X                  {
  756. !                 if (!forked && fn->fd1 < 10)
  757. !                     save[fn->fd1] = movefd(fn->fd1);
  758. X                  closemn(mfds,fn->fd1);
  759. X                  close(fn->fd1);
  760. X                  }
  761. ***************
  762. *** 989,996 ****
  763. X  
  764. X  /* convert here document into a here string */
  765. X  
  766. ! char *gethere(str) /**/
  767. ! char *str;
  768. X  {
  769. X  char pbuf[256];
  770. X  int qt = 0,siz = 0,l,strip = 0;
  771. --- 995,1002 ----
  772. X  
  773. X  /* convert here document into a here string */
  774. X  
  775. ! char *gethere(str,typ) /**/
  776. ! char *str;int typ;
  777. X  {
  778. X  char pbuf[256];
  779. X  int qt = 0,siz = 0,l,strip = 0;
  780. ***************
  781. *** 1000,1008 ****
  782. X          if (*s == Nularg)
  783. X              qt = 1;
  784. X      untokenize(str);
  785. !     if (*str == '-')
  786. X          {
  787. -         str++;
  788. X          strip = 1;
  789. X          while (*str == '\t')
  790. X              str++;
  791. --- 1006,1013 ----
  792. X          if (*s == Nularg)
  793. X              qt = 1;
  794. X      untokenize(str);
  795. !     if (typ == HEREDOCDASH)
  796. X          {
  797. X          strip = 1;
  798. X          while (*str == '\t')
  799. X              str++;
  800. ***************
  801. *** 1247,1252 ****
  802. --- 1252,1259 ----
  803. X              }
  804. X      if (qt && ptr != buf && ptr[-1] == '\n')
  805. X          ptr[-1] = '\0';
  806. +     else
  807. +         *ptr = '\0';
  808. X      if (cnt)
  809. X          addnode(ret,ztrdup(buf));
  810. X      free(buf);
  811. ***************
  812. *** 1557,1567 ****
  813. X  Lklist l;
  814. X  {
  815. X  Lknode n = firstnode(l);
  816. ! struct redir *f;
  817. X  
  818. X      for (; n; incnode(n))
  819. X          {
  820. !         f = getdata(n);
  821. X          if (f->type == OUTPIPE)
  822. X              {
  823. X              char *str = f->name;
  824. --- 1564,1574 ----
  825. X  Lklist l;
  826. X  {
  827. X  Lknode n = firstnode(l);
  828. ! Redir f;
  829. X  
  830. X      for (; n; incnode(n))
  831. X          {
  832. !         f = (Redir) getdata(n);
  833. X          if (f->type == OUTPIPE)
  834. X              {
  835. X              char *str = f->name;
  836. ***************
  837. *** 1598,1607 ****
  838. X      permalloc();
  839. X      while (s = ugetnode(cmd->args))
  840. X          {
  841. !         cc = zalloc(sizeof *cc);
  842. X          cc->type = SHFUNC;
  843. X          cc->flags = 0;
  844. !         cc->u.list = dupstruct(cmd->u.list);
  845. X          addhnode(ztrdup(s),cc,cmdnamtab,freecmdnam);
  846. X          if (!strncmp(s,"TRAP",4))
  847. X              {
  848. --- 1605,1614 ----
  849. X      permalloc();
  850. X      while (s = ugetnode(cmd->args))
  851. X          {
  852. !         cc = (Cmdnam) zalloc(sizeof *cc);
  853. X          cc->type = SHFUNC;
  854. X          cc->flags = 0;
  855. !         cc->u.list = (List) dupstruct(cmd->u.list);
  856. X          addhnode(ztrdup(s),cc,cmdnamtab,freecmdnam);
  857. X          if (!strncmp(s,"TRAP",4))
  858. X              {
  859. ***************
  860. *** 1648,1654 ****
  861. X              }
  862. X          cn->flags &= ~PMFLAG_u;
  863. X          permalloc();
  864. !         cn->u.list = dupstruct(l);
  865. X          heapalloc();
  866. X          }
  867. X      flags = cn->flags;
  868. --- 1655,1661 ----
  869. X              }
  870. X          cn->flags &= ~PMFLAG_u;
  871. X          permalloc();
  872. !         cn->u.list = (List) dupstruct(l);
  873. X          heapalloc();
  874. X          }
  875. X      flags = cn->flags;
  876. ***************
  877. *** 1656,1664 ****
  878. X      xexitfn = sigfuncs[SIGEXIT];
  879. X      tab = pparams;
  880. X      oargv0 = argzero;
  881. X      if (flags & PMFLAG_t)
  882. X          opts[XTRACE] = OPT_SET;
  883. !     pparams = x = zcalloc(((sizeof *x)*(1+countnodes(cmd->args))));
  884. X      argzero = ztrdup(ugetnode(cmd->args));
  885. X      while (*x = ugetnode(cmd->args))
  886. X          *x = ztrdup(*x), x++;
  887. --- 1663,1672 ----
  888. X      xexitfn = sigfuncs[SIGEXIT];
  889. X      tab = pparams;
  890. X      oargv0 = argzero;
  891. +     optind = 0;
  892. X      if (flags & PMFLAG_t)
  893. X          opts[XTRACE] = OPT_SET;
  894. !     pparams = x = (char **) zcalloc(((sizeof *x)*(1+countnodes(cmd->args))));
  895. X      argzero = ztrdup(ugetnode(cmd->args));
  896. X      while (*x = ugetnode(cmd->args))
  897. X          *x = ztrdup(*x), x++;
  898. ***************
  899. *** 1679,1685 ****
  900. X      pparams = tab;
  901. X      if (sigtrapped[SIGEXIT])
  902. X          dotrap(SIGEXIT);
  903. !     if (sigfuncs[SIGEXIT])
  904. X          freestruct(sigfuncs[SIGEXIT]);
  905. X      sigtrapped[SIGEXIT] = xexittr;
  906. X      sigfuncs[SIGEXIT] = xexitfn;
  907. --- 1687,1693 ----
  908. X      pparams = tab;
  909. X      if (sigtrapped[SIGEXIT])
  910. X          dotrap(SIGEXIT);
  911. !     if (sigfuncs[SIGEXIT] && sigfuncs[SIGEXIT] != xexitfn)
  912. X          freestruct(sigfuncs[SIGEXIT]);
  913. X      sigtrapped[SIGEXIT] = xexittr;
  914. X      sigfuncs[SIGEXIT] = xexitfn;
  915. ***************
  916. *** 1730,1746 ****
  917. X  int cancd(s)
  918. X  char *s;
  919. X  {
  920. ! char *t;
  921. !     for (t = s; *t; t++)
  922. !         if (*t == '/')
  923. !             break;
  924. !     if (!*t)
  925. X          {
  926. X          char sbuf[MAXPATHLEN],**cp;
  927. X  
  928. X          if (cancd2(s))
  929. X              return 1;
  930. X          for (cp = cdpath; *cp; cp++)
  931. X              {
  932. X              sprintf(sbuf,"%s/%s",*cp,s);
  933. --- 1738,1751 ----
  934. X  int cancd(s)
  935. X  char *s;
  936. X  {
  937. !     if (*s != '/')
  938. X          {
  939. X          char sbuf[MAXPATHLEN],**cp;
  940. X  
  941. X          if (cancd2(s))
  942. X              return 1;
  943. +         if (access(s,X_OK) == 0)
  944. +             return 0;
  945. X          for (cp = cdpath; *cp; cp++)
  946. X              {
  947. X              sprintf(sbuf,"%s/%s",*cp,s);
  948. ***************
  949. *** 1757,1762 ****
  950. X  {
  951. X  struct stat buf;
  952. X  
  953. !     return !(access(s,X_OK) || lstat(s,&buf) || !S_ISDIR(buf.st_mode));
  954. X  }
  955. X  
  956. --- 1762,1767 ----
  957. X  {
  958. X  struct stat buf;
  959. X  
  960. !     return !(access(s,X_OK) || stat(s,&buf) || !S_ISDIR(buf.st_mode));
  961. X  }
  962. X  
  963. *** src/zsh0/zsh2.00/src/exec.pro    Tue Apr 23 00:29:58 1991
  964. --- zsh2.00/src/exec.pro    Tue May  7 22:53:25 1991
  965. ***************
  966. *** 22,28 ****
  967. X  void fixfds DCLPROTO((int *save));
  968. X  void entersubsh DCLPROTO((int bkg));
  969. X  void closem DCLPROTO((void));
  970. ! char *gethere DCLPROTO((char *str));
  971. X  int getherestr DCLPROTO((struct redir *fn));
  972. X  void catproc DCLPROTO((struct multio *mn));
  973. X  void teeproc DCLPROTO((struct multio *mn));
  974. --- 22,28 ----
  975. X  void fixfds DCLPROTO((int *save));
  976. X  void entersubsh DCLPROTO((int bkg));
  977. X  void closem DCLPROTO((void));
  978. ! char *gethere DCLPROTO((char *str,int typ));
  979. X  int getherestr DCLPROTO((struct redir *fn));
  980. X  void catproc DCLPROTO((struct multio *mn));
  981. X  void teeproc DCLPROTO((struct multio *mn));
  982. *** src/zsh0/zsh2.00/src/glob.c    Sat Apr 27 00:15:09 1991
  983. --- zsh2.00/src/glob.c    Fri May 10 07:16:44 1991
  984. ***************
  985. *** 31,37 ****
  986. X  */
  987. X  
  988. X  #include "zsh.h"
  989. - #include "funcs.h"
  990. X  #include <sys/dir.h>
  991. X  #include <sys/errno.h>
  992. X  
  993. --- 31,36 ----
  994. ***************
  995. *** 103,116 ****
  996. X                      func = qualflags;
  997. X                      data = 0;
  998. X                      while (idigit(*s))
  999. !                         data = data*010+(*s-'0');
  1000. X                      }
  1001. X                  else switch (*s++)
  1002. X                      {
  1003. !                     case Hat: sense = 1-sense; break;
  1004. X                      case '@': func = qualmode; data = S_IFLNK; break;
  1005. X                      case '=': func = qualmode; data = S_IFSOCK; break;
  1006. X                      case 'p': func = qualmode; data = S_IFIFO; break;
  1007. X                      case '/': func = qualmode; data = S_IFDIR; break;
  1008. X                      case '.': func = qualmode; data = S_IFREG; break;
  1009. X                      case '%': func = qualisdev; break;
  1010. --- 102,117 ----
  1011. X                      func = qualflags;
  1012. X                      data = 0;
  1013. X                      while (idigit(*s))
  1014. !                         data = data*010+(*s++-'0');
  1015. X                      }
  1016. X                  else switch (*s++)
  1017. X                      {
  1018. !                     case Hat: case '^': sense = 1-sense; break;
  1019. X                      case '@': func = qualmode; data = S_IFLNK; break;
  1020. X                      case '=': func = qualmode; data = S_IFSOCK; break;
  1021. + #ifdef S_IFIFO
  1022. X                      case 'p': func = qualmode; data = S_IFIFO; break;
  1023. + #endif
  1024. X                      case '/': func = qualmode; data = S_IFDIR; break;
  1025. X                      case '.': func = qualmode; data = S_IFREG; break;
  1026. X                      case '%': func = qualisdev; break;
  1027. ***************
  1028. *** 246,256 ****
  1029. X          char *t;
  1030. X          int ll = strlen(s);
  1031. X  
  1032. !         t = zalloc(ll+2);
  1033. X          strcpy(t,s);
  1034. X          t[ll] = '/';
  1035. X          t[ll+1] = '\0';
  1036. -         free(s);
  1037. X          s = t;
  1038. X          }
  1039. X      *matchptr++ = s;
  1040. --- 247,256 ----
  1041. X          char *t;
  1042. X          int ll = strlen(s);
  1043. X  
  1044. !         t = ncalloc(ll+2);
  1045. X          strcpy(t,s);
  1046. X          t[ll] = '/';
  1047. X          t[ll+1] = '\0';
  1048. X          s = t;
  1049. X          }
  1050. X      *matchptr++ = s;
  1051. ***************
  1052. *** 491,499 ****
  1053. X  char *a;char *b;
  1054. X  {
  1055. X  Comp c;
  1056. ! int val;
  1057. X  
  1058. !     c = parsereg(b);
  1059. X      if (!c)
  1060. X          {
  1061. X          zerr("bad pattern: %s",b,0);
  1062. --- 491,506 ----
  1063. X  char *a;char *b;
  1064. X  {
  1065. X  Comp c;
  1066. ! int val,len;
  1067. ! char *b2;
  1068. X  
  1069. !     len = strlen(b);
  1070. !     b2 = alloc(len+3);
  1071. !     strcpy(b2+1,b);
  1072. !     b2[0] = Inpar;
  1073. !     b2[len+1] = Outpar;
  1074. !     b2[len+2] = '\0';
  1075. !     c = parsereg(b2);
  1076. X      if (!c)
  1077. X          {
  1078. X          zerr("bad pattern: %s",b,0);
  1079. ***************
  1080. *** 625,631 ****
  1081. X              char *fn;
  1082. X              int dirs = !!q->next;
  1083. X              struct direct *de;
  1084. !             DIR *lock = opendir(pathbuf);
  1085. X               
  1086. X              if (lock == NULL)
  1087. X                  return;
  1088. --- 632,638 ----
  1089. X              char *fn;
  1090. X              int dirs = !!q->next;
  1091. X              struct direct *de;
  1092. !             DIR *lock = opendir((*pathbuf) ? pathbuf : ".");
  1093. X               
  1094. X              if (lock == NULL)
  1095. X                  return;
  1096. ***************
  1097. *** 720,725 ****
  1098. --- 727,733 ----
  1099. X  }
  1100. X  
  1101. X  static char *pptr;
  1102. + static Comp tail = 0;
  1103. X  static int first;
  1104. X  
  1105. X  int domatch(str,c,fist) /**/
  1106. ***************
  1107. *** 737,743 ****
  1108. X  {
  1109. X  char *pat = c->str;
  1110. X  
  1111. !     if (c->closure)
  1112. X          {
  1113. X          char *saves = pptr;
  1114. X          int savei = first;
  1115. --- 745,751 ----
  1116. X  {
  1117. X  char *pat = c->str;
  1118. X  
  1119. !     if (c->closure == 1)
  1120. X          {
  1121. X          char *saves = pptr;
  1122. X          int savei = first;
  1123. ***************
  1124. *** 969,974 ****
  1125. --- 977,984 ----
  1126. X  Comp c = (Comp) alloc(sizeof *c),c1,c2;
  1127. X  char *s = c->str = alloc(MAXPATHLEN*2),*ls = NULL;
  1128. X  
  1129. +     c->next = tail;
  1130. X      while (*pptr && (mode || *pptr != '/') && *pptr != Bar &&
  1131. X              *pptr != Outpar)
  1132. X          {
  1133. ***************
  1134. *** 995,1014 ****
  1135. X              }
  1136. X          if (*pptr == Inpar)
  1137. X              {
  1138. !             *s++ = '\0';
  1139. !             pptr++;
  1140. !             c->next = (Comp) alloc(sizeof *c);
  1141. !             c->next->left = c1 = parsecompsw();
  1142. !             if (*pptr != Outpar)
  1143. X                  {
  1144. X                  errflag = 1;
  1145. X                  return NULL;
  1146. X                  }
  1147. -             pptr++;
  1148. X              if (*pptr == Pound)
  1149. X                  {
  1150. !                 int dpnd = 1;
  1151. X                  pptr++;
  1152. X                  if (*pptr == Pound)
  1153. X                      {
  1154. --- 1005,1028 ----
  1155. X              }
  1156. X          if (*pptr == Inpar)
  1157. X              {
  1158. !             int pars = 1;
  1159. !             char *startp = pptr, *endp;
  1160. !             Comp stail = tail;
  1161. !             int dpnd = 0;
  1162. !             for (pptr = pptr+1; *pptr && pars; pptr++)
  1163. !                 if (*pptr == Inpar)
  1164. !                     pars++;
  1165. !                 else if (*pptr == Outpar)
  1166. !                     pars--;
  1167. !             if (pptr[-1] != Outpar)
  1168. X                  {
  1169. X                  errflag = 1;
  1170. X                  return NULL;
  1171. X                  }
  1172. X              if (*pptr == Pound)
  1173. X                  {
  1174. !                 dpnd = 1;
  1175. X                  pptr++;
  1176. X                  if (*pptr == Pound)
  1177. X                      {
  1178. ***************
  1179. *** 1015,1026 ****
  1180. X                      pptr++;
  1181. X                      dpnd = 2;
  1182. X                      }
  1183. -                 c->next->closure = dpnd;
  1184. X                  }
  1185. !             c2 = parsecomp();
  1186. !             if (!c2)
  1187. X                  return NULL;
  1188. !             c->next->next = c2;
  1189. X              return c;
  1190. X              }
  1191. X          if (*pptr == Pound)
  1192. --- 1029,1049 ----
  1193. X                      pptr++;
  1194. X                      dpnd = 2;
  1195. X                      }
  1196. X                  }
  1197. !             c1 = parsecomp();
  1198. !             if (!c1)
  1199. X                  return NULL;
  1200. !             tail = c1;
  1201. !             endp = pptr;
  1202. !             pptr = startp;
  1203. !             pptr++;
  1204. !             *s++ = '\0';
  1205. !             c->next = (Comp) alloc(sizeof *c);
  1206. !             c->next->left = parsecompsw();
  1207. !             c->next->closure = dpnd;
  1208. !             c->next->next = (Comp) alloc(sizeof *c);
  1209. !             pptr = endp;
  1210. !             tail = stail;
  1211. X              return c;
  1212. X              }
  1213. X          if (*pptr == Pound)
  1214. ***************
  1215. *** 1029,1039 ****
  1216. X              pptr++;
  1217. X              if (!ls)
  1218. X                  return NULL;
  1219. !             c->next = c1 = (Comp) alloc(sizeof *c);
  1220. !             c1->str = strdup(ls);
  1221. !             c1->closure = 1;
  1222. !             c1->next = parsecomp();
  1223. !             if (!c1->next)
  1224. X                  return NULL;
  1225. X              *ls++ = '\0';
  1226. X              return c;
  1227. --- 1052,1070 ----
  1228. X              pptr++;
  1229. X              if (!ls)
  1230. X                  return NULL;
  1231. !             if (*pptr == Pound) 
  1232. !                 {
  1233. !                 pptr++;
  1234. !                 c->next = c1 = (Comp) alloc(sizeof *c);
  1235. !                 c1->str = strdup(ls);
  1236. !                 }
  1237. !             else
  1238. !                 c1 = c;
  1239. !             c1->next = c2 = (Comp) alloc(sizeof *c);
  1240. !             c2->str = strdup(ls);
  1241. !             c2->closure = 1;
  1242. !             c2->next = parsecomp();
  1243. !             if (!c2->next)
  1244. X                  return NULL;
  1245. X              *ls++ = '\0';
  1246. X              return c;
  1247. *** src/zsh0/zsh2.00/src/hist.c    Tue Apr 23 00:30:05 1991
  1248. --- zsh2.00/src/hist.c    Fri May 10 06:37:00 1991
  1249. ***************
  1250. *** 31,37 ****
  1251. X  */
  1252. X  
  1253. X  #include "zsh.h"
  1254. - #include "funcs.h"
  1255. X  
  1256. X  static int lastc;
  1257. X  
  1258. --- 31,36 ----
  1259. ***************
  1260. *** 40,49 ****
  1261. X  void hwaddc(c) /**/
  1262. X  int c;
  1263. X  {
  1264. !     if (hlastw && hline && (!errflag || c == HISTSPACE))
  1265. X          {
  1266. -         if (c == EOF || c == HERR)
  1267. -             c = ' ';
  1268. X          *hptr++ = c;
  1269. X          if (hptr-hline >= hlinesz)
  1270. X              {
  1271. --- 39,46 ----
  1272. X  void hwaddc(c) /**/
  1273. X  int c;
  1274. X  {
  1275. !     if (hlastw && hline && (!(errflag || lexstop) || c == HISTSPACE))
  1276. X          {
  1277. X          *hptr++ = c;
  1278. X          if (hptr-hline >= hlinesz)
  1279. X              {
  1280. ***************
  1281. *** 61,67 ****
  1282. X          }
  1283. X  }
  1284. X  
  1285. ! #define habort() { errflag = 1; return HERR; }
  1286. X  
  1287. X  /* get a character after performing history substitution */
  1288. X  
  1289. --- 58,64 ----
  1290. X          }
  1291. X  }
  1292. X  
  1293. ! #define habort() { errflag = lexstop = 1; return ' '; }
  1294. X  
  1295. X  /* get a character after performing history substitution */
  1296. X  
  1297. ***************
  1298. *** 73,79 ****
  1299. X  
  1300. X  tailrec:
  1301. X      c = hgetch();
  1302. !     if (stophist)
  1303. X          {
  1304. X          hwaddc(c);
  1305. X          return c;
  1306. --- 70,76 ----
  1307. X  
  1308. X  tailrec:
  1309. X      c = hgetch();
  1310. !     if (stophist || alstackind)
  1311. X          {
  1312. X          hwaddc(c);
  1313. X          return c;
  1314. ***************
  1315. *** 81,87 ****
  1316. X      if (isfirstch && c == hatchar)
  1317. X          {
  1318. X          isfirstch = 0;
  1319. !         hungets(":s^");
  1320. X          c = bangchar;
  1321. X          goto hatskip;
  1322. X          }
  1323. --- 78,85 ----
  1324. X      if (isfirstch && c == hatchar)
  1325. X          {
  1326. X          isfirstch = 0;
  1327. !         hungetch(hatchar);
  1328. !         hungets(":s");
  1329. X          c = bangchar;
  1330. X          goto hatskip;
  1331. X          }
  1332. ***************
  1333. *** 108,361 ****
  1334. X      *hptr = '\0';
  1335. X      if ((c = hgetch()) == '{')
  1336. X          {
  1337. !             bflag = cflag = 1;
  1338. X              c = hgetch();
  1339. X              }
  1340. !         if (c == '\"')
  1341. X              {
  1342. !             stophist = 1;
  1343. !             goto tailrec;
  1344. X              }
  1345. !         if (!cflag && inblank(c) || c == '=' || c == '(' || c == EOF)
  1346. X              {
  1347. !             hungetch(c);
  1348. !             hwaddc(bangchar);
  1349. !             return bangchar;
  1350. !             }
  1351. !         cflag = 0;
  1352. !         ptr = buf;
  1353. !         /* get event number */
  1354. !         if (c == '?')
  1355. !             {
  1356. !             for(;;)
  1357. X                  {
  1358. X                  c = hgetch();
  1359. !                 if (c == '?' || c == '\n' || c == -1)
  1360. !                     break;
  1361. !                 else
  1362. !                     *ptr++ = c;
  1363. X                  }
  1364. !             if (c != '\n' && c != -1)
  1365. !                 c = hgetch();
  1366. !             *ptr = '\0';
  1367. !             ev = hconsearch(hsubl = ztrdup(buf),&marg);
  1368. !             if (ev == -1)
  1369. !                 {
  1370. !                 herrflush();
  1371. !                 zerr("no such event: %s",buf,0);
  1372. !                 habort();
  1373. !                 }
  1374. X              }
  1375. !         else
  1376. X              {
  1377. !             int t0;
  1378. !      
  1379. !             for (;;)
  1380. !                 {
  1381. !                 if (inblank(c) || c == ':' || c == '^' || c == '$' || c == '*'
  1382. !                         || c == '%' || c == '}' || c == -1)
  1383. !                     break;
  1384. !                 if (ptr != buf && c == '-')
  1385. !                     break;
  1386. !                 *ptr++ = c;
  1387. !                 if (c == '#' || c == '!')
  1388. !                     {
  1389. !                     c = hgetch();
  1390. !                     break;
  1391. !                     }
  1392. X                  c = hgetch();
  1393. !                 }
  1394. !             *ptr = 0;
  1395. !             if (!*buf)
  1396. !                 ev = defev;
  1397. !             else if (t0 = atoi(buf))
  1398. !                 ev = (t0 < 0) ? curhist+t0 : t0;
  1399. !             else if (*buf == '!')
  1400. !                 ev = curhist-1;
  1401. !             else if (*buf == '#')
  1402. !                 ev = curhist;
  1403. !             else if ((ev = hcomsearch(buf)) == -1)
  1404. !                 {
  1405. !                 zerr("event not found: %s",buf,0);
  1406. !                 while (c != '\n' && c != -1)
  1407. !                     c = hgetch();
  1408. !                 habort();
  1409. !                 }
  1410. X              }
  1411. X  
  1412. !         /* get the event */
  1413. X  
  1414. !         if (!(eline = getevent(defev = ev)))
  1415. !             habort();
  1416. X  
  1417. !         /* extract the relevant arguments */
  1418. X  
  1419. !         argc = getargc(eline);
  1420. !         if (c == ':')
  1421. !             {
  1422. !             cflag = 1;
  1423. !             c = hgetch();
  1424. !             }
  1425. X          if (c == '*')
  1426. X              {
  1427. -             farg = 1;
  1428. -             larg = argc;
  1429. X              cflag = 0;
  1430. X              }
  1431. !         else
  1432. X              {
  1433. !             hungetch(c);
  1434. !             larg = farg = getargspec(argc,marg);
  1435. X              if (larg == -2)
  1436. X                  habort();
  1437. !             if (farg != -1)
  1438. !                 cflag = 0;
  1439. !             c = hgetch();
  1440. !             if (c == '*')
  1441. !                 {
  1442. !                 cflag = 0;
  1443. !                 larg = argc;
  1444. !                 }
  1445. !             else if (c == '-')
  1446. !                 {
  1447. !                 cflag = 0;
  1448. !                 larg = getargspec(argc,marg);
  1449. !                 if (larg == -2)
  1450. !                     habort();
  1451. !                 if (larg == -1)
  1452. !                     larg = argc-1;
  1453. !                 }
  1454. !             else
  1455. !                 hungetch(c);
  1456. X              }
  1457. !         if (farg == -1)
  1458. !             farg = 0;
  1459. !         if (larg == -1)
  1460. !             larg = argc;
  1461. !         if (!(sline = getargs(eline,farg,larg)))
  1462. !             habort();
  1463. X  
  1464. !         /* do the modifiers */
  1465. X  
  1466. !         for(;;)
  1467. X              {
  1468. !             c = (cflag) ? ':' : hgetch();
  1469. !             cflag = 0;
  1470. !             if (c == ':')
  1471. X                  {
  1472. !                 int gbal = 0;
  1473. !             
  1474. !                 if ((c = hgetch()) == 'g')
  1475. X                      {
  1476. !                     gbal = 1;
  1477. !                     c = hgetch();
  1478. X                      }
  1479. !                 switch(c)
  1480. !                     {
  1481. !                     case 'p':
  1482. !                         histdone = 2;
  1483. !                         break;
  1484. !                     case 'h':
  1485. !                         if (!remtpath(&sline))
  1486. !                             {
  1487. !                             herrflush();
  1488. !                             zerr("modifier failed: h",NULL,0);
  1489. !                             habort();
  1490. !                             }
  1491. !                         break;
  1492. !                     case 'e':
  1493. !                         if (!rembutext(&sline))
  1494. !                             {
  1495. !                             herrflush();
  1496. !                             zerr("modifier failed: e",NULL,0);
  1497. !                             habort();
  1498. !                             }
  1499. !                         break;
  1500. !                     case 'r':
  1501. !                         if (!remtext(&sline))
  1502. !                             {
  1503. !                             herrflush();
  1504. !                             zerr("modifier failed: r",NULL,0);
  1505. !                             habort();
  1506. !                             }
  1507. !                         break;
  1508. !                     case 't':
  1509. !                         if (!remlpaths(&sline))
  1510. !                             {
  1511. !                             herrflush();
  1512. !                             zerr("modifier failed: t",NULL,0);
  1513. !                             habort();
  1514. !                             }
  1515. !                         break;
  1516. !                     case 's':
  1517. X                          {
  1518. !                         int del;
  1519. !                         char *ptr1,*ptr2;
  1520. !                     
  1521. !                         del = hgetch();
  1522. !                         ptr1 = hdynread(del);
  1523. !                         if (!ptr1)
  1524. X                              habort();
  1525. -                         ptr2 = hdynread2(del);
  1526. -                         if (strlen(ptr1))
  1527. -                             {
  1528. -                             if (hsubl)
  1529. -                                 free(hsubl);
  1530. -                             hsubl = ptr1;
  1531. -                             }
  1532. -                         if (hsubr)
  1533. -                             free(hsubr);
  1534. -                         hsubr = ptr2;
  1535. X                          }
  1536. !                     case '&':
  1537. !                         if (hsubl && hsubr)
  1538. !                             {
  1539. !                             if (subst(&sline,hsubl,hsubr,gbal))
  1540. !                                 habort();
  1541. !                             }
  1542. !                         else
  1543. !                             {
  1544. !                             herrflush();
  1545. !                             zerr("no previous substitution with &",NULL,0);
  1546. !                             habort();
  1547. !                             }
  1548. !                         break;
  1549. !                     case 'q':
  1550. !                         quote(&sline);
  1551. !                         break;
  1552. !                     case 'x':
  1553. !                         quotebreak(&sline);
  1554. !                         break;
  1555. !                     case 'l':
  1556. !                         downcase(&sline);
  1557. !                         break;
  1558. !                     case 'u':
  1559. !                         upcase(&sline);
  1560. !                         break;
  1561. !                     default:
  1562. X                          herrflush();
  1563. !                         zerr("illegal modifier: %c",NULL,c);
  1564. !                     habort();
  1565. X                      break;
  1566. !                 }
  1567. X              }
  1568. !         else
  1569. X              {
  1570. !             if (c != '}' || !bflag)
  1571. !                 hungetch(c);
  1572. !             if (c != '}' && bflag)
  1573. !                 {
  1574. !                 zerr("'}' expected",NULL,0);
  1575. !                 habort();
  1576. !                 }
  1577. !             break;
  1578. X              }
  1579. X          }
  1580. !     
  1581. X      /* stuff the resulting string in the input queue and start over */
  1582. X  
  1583. X      if (alstackind != MAXAL)
  1584. X          {
  1585. X          hungets(HISTMARK);
  1586. --- 106,363 ----
  1587. X      *hptr = '\0';
  1588. X      if ((c = hgetch()) == '{')
  1589. X          {
  1590. !         bflag = cflag = 1;
  1591. !         c = hgetch();
  1592. !         }
  1593. !     if (c == '\"')
  1594. !         {
  1595. !         stophist = 1;
  1596. !         goto tailrec;
  1597. !         }
  1598. !     if (!cflag && inblank(c) || c == '=' || c == '(' || lexstop)
  1599. !         {
  1600. !         if (lexstop)
  1601. !             lexstop = 0;
  1602. !         else
  1603. !             hungetch(c);
  1604. !         hwaddc(bangchar);
  1605. !         return bangchar;
  1606. !         }
  1607. !     cflag = 0;
  1608. !     ptr = buf;
  1609. !     /* get event number */
  1610. !     if (c == '?')
  1611. !         {
  1612. !         for(;;)
  1613. !             {
  1614. X              c = hgetch();
  1615. +             if (c == '?' || c == '\n' || lexstop)
  1616. +                 break;
  1617. +             else
  1618. +                 *ptr++ = c;
  1619. X              }
  1620. !         if (c != '\n' && !lexstop)
  1621. !             c = hgetch();
  1622. !         *ptr = '\0';
  1623. !         ev = hconsearch(hsubl = ztrdup(buf),&marg);
  1624. !         if (ev == -1)
  1625. X              {
  1626. !             herrflush();
  1627. !             zerr("no such event: %s",buf,0);
  1628. !             habort();
  1629. X              }
  1630. !         }
  1631. !     else
  1632. !         {
  1633. !         int t0;
  1634. !  
  1635. !         for (;;)
  1636. X              {
  1637. !             if (inblank(c) || c == ':' || c == '^' || c == '$' || c == '*'
  1638. !                     || c == '%' || c == '}' || lexstop)
  1639. !                 break;
  1640. !             if (ptr != buf && c == '-')
  1641. !                 break;
  1642. !             *ptr++ = c;
  1643. !             if (c == '#' || c == bangchar)
  1644. X                  {
  1645. X                  c = hgetch();
  1646. !                 break;
  1647. X                  }
  1648. !             c = hgetch();
  1649. X              }
  1650. !         *ptr = 0;
  1651. !         if (!*buf)
  1652. !             ev = defev;
  1653. !         else if (t0 = atoi(buf))
  1654. !             ev = (t0 < 0) ? curhist+t0 : t0;
  1655. !         else if (*buf == bangchar)
  1656. !             ev = curhist-1;
  1657. !         else if (*buf == '#')
  1658. !             ev = curhist;
  1659. !         else if ((ev = hcomsearch(buf)) == -1)
  1660. X              {
  1661. !             zerr("event not found: %s",buf,0);
  1662. !             while (c != '\n' && !lexstop)
  1663. X                  c = hgetch();
  1664. !             habort();
  1665. X              }
  1666. +         }
  1667. X  
  1668. !     /* get the event */
  1669. X  
  1670. !     if (!(eline = getevent(defev = ev)))
  1671. !         habort();
  1672. X  
  1673. !     /* extract the relevant arguments */
  1674. X  
  1675. !     argc = getargc(eline);
  1676. !     if (c == ':')
  1677. !         {
  1678. !         cflag = 1;
  1679. !         c = hgetch();
  1680. !         }
  1681. !     if (c == '*')
  1682. !         {
  1683. !         farg = 1;
  1684. !         larg = argc;
  1685. !         cflag = 0;
  1686. !         }
  1687. !     else
  1688. !         {
  1689. !         hungetch(c);
  1690. !         larg = farg = getargspec(argc,marg);
  1691. !         if (larg == -2)
  1692. !             habort();
  1693. !         if (farg != -1)
  1694. !             cflag = 0;
  1695. !         c = hgetch();
  1696. X          if (c == '*')
  1697. X              {
  1698. X              cflag = 0;
  1699. +             larg = argc;
  1700. X              }
  1701. !         else if (c == '-')
  1702. X              {
  1703. !             cflag = 0;
  1704. !             larg = getargspec(argc,marg);
  1705. X              if (larg == -2)
  1706. X                  habort();
  1707. !             if (larg == -1)
  1708. !                 larg = argc-1;
  1709. X              }
  1710. !         else
  1711. !             hungetch(c);
  1712. !         }
  1713. !     if (farg == -1)
  1714. !         farg = 0;
  1715. !     if (larg == -1)
  1716. !         larg = argc;
  1717. !     if (!(sline = getargs(eline,farg,larg)))
  1718. !         habort();
  1719. X  
  1720. !     /* do the modifiers */
  1721. X  
  1722. !     for(;;)
  1723. !         {
  1724. !         c = (cflag) ? ':' : hgetch();
  1725. !         cflag = 0;
  1726. !         if (c == ':')
  1727. X              {
  1728. !             int gbal = 0;
  1729. !         
  1730. !             if ((c = hgetch()) == 'g')
  1731. X                  {
  1732. !                 gbal = 1;
  1733. !                 c = hgetch();
  1734. !                 }
  1735. !             switch(c)
  1736. !                 {
  1737. !                 case 'p':
  1738. !                     histdone = 2;
  1739. !                     break;
  1740. !                 case 'h':
  1741. !                     if (!remtpath(&sline))
  1742. !                         {
  1743. !                         herrflush();
  1744. !                         zerr("modifier failed: h",NULL,0);
  1745. !                         habort();
  1746. !                         }
  1747. !                     break;
  1748. !                 case 'e':
  1749. !                     if (!rembutext(&sline))
  1750. !                         {
  1751. !                         herrflush();
  1752. !                         zerr("modifier failed: e",NULL,0);
  1753. !                         habort();
  1754. !                         }
  1755. !                     break;
  1756. !                 case 'r':
  1757. !                     if (!remtext(&sline))
  1758. !                         {
  1759. !                         herrflush();
  1760. !                         zerr("modifier failed: r",NULL,0);
  1761. !                         habort();
  1762. !                         }
  1763. !                     break;
  1764. !                 case 't':
  1765. !                     if (!remlpaths(&sline))
  1766. !                         {
  1767. !                         herrflush();
  1768. !                         zerr("modifier failed: t",NULL,0);
  1769. !                         habort();
  1770. !                         }
  1771. !                     break;
  1772. !                 case 's':
  1773. X                      {
  1774. !                     int del;
  1775. !                     char *ptr1,*ptr2;
  1776. !                 
  1777. !                     del = hgetch();
  1778. !                     ptr1 = hdynread(del);
  1779. !                     if (!ptr1)
  1780. !                         habort();
  1781. !                     ptr2 = hdynread2(del);
  1782. !                     if (strlen(ptr1))
  1783. !                         {
  1784. !                         if (hsubl)
  1785. !                             free(hsubl);
  1786. !                         hsubl = ptr1;
  1787. !                         }
  1788. !                     if (hsubr)
  1789. !                         free(hsubr);
  1790. !                     hsubr = ptr2;
  1791. X                      }
  1792. !                 case '&':
  1793. !                     if (hsubl && hsubr)
  1794. X                          {
  1795. !                         if (subst(&sline,hsubl,hsubr,gbal))
  1796. X                              habort();
  1797. X                          }
  1798. !                     else
  1799. !                         {
  1800. X                          herrflush();
  1801. !                         zerr("no previous substitution with &",NULL,0);
  1802. !                         habort();
  1803. !                         }
  1804. X                      break;
  1805. !                 case 'q':
  1806. !                     quote(&sline);
  1807. !                     break;
  1808. !                 case 'x':
  1809. !                     quotebreak(&sline);
  1810. !                     break;
  1811. !                 case 'l':
  1812. !                     downcase(&sline);
  1813. !                     break;
  1814. !                 case 'u':
  1815. !                     upcase(&sline);
  1816. !                     break;
  1817. !                 default:
  1818. !                     herrflush();
  1819. !                     zerr("illegal modifier: %c",NULL,c);
  1820. !                 habort();
  1821. !                 break;
  1822. X              }
  1823. !         }
  1824. !     else
  1825. !         {
  1826. !         if (c != '}' || !bflag)
  1827. !             hungetch(c);
  1828. !         if (c != '}' && bflag)
  1829. X              {
  1830. !             zerr("'}' expected",NULL,0);
  1831. !             habort();
  1832. X              }
  1833. +         break;
  1834. X          }
  1835. !     }
  1836. X      /* stuff the resulting string in the input queue and start over */
  1837. X  
  1838. +     lexstop = 0;
  1839. X      if (alstackind != MAXAL)
  1840. X          {
  1841. X          hungets(HISTMARK);
  1842. ***************
  1843. *** 385,391 ****
  1844. X              if (!alstackind)
  1845. X                  {
  1846. X                  zerr("alias stack underflow",NULL,0);
  1847. !                 return lastc = HERR;
  1848. X                  }
  1849. X              ix = alstack[--alstackind];
  1850. X              if (ix)
  1851. --- 387,394 ----
  1852. X              if (!alstackind)
  1853. X                  {
  1854. X                  zerr("alias stack underflow",NULL,0);
  1855. !                 errflag = lexstop = 1;
  1856. !                 return lastc = ' ';
  1857. X                  }
  1858. X              ix = alstack[--alstackind];
  1859. X              if (ix)
  1860. ***************
  1861. *** 399,410 ****
  1862. X                  }
  1863. X              goto start;
  1864. X              }
  1865. X          return lastc;
  1866. X          }
  1867. !     if (strin)
  1868. !         return lastc = EOF;
  1869. !     if (errflag)
  1870. !         return lastc = HERR;
  1871. X      if (interact && isset(SHINSTDIN))
  1872. X          if (!isfirstln)
  1873. X              pmpt = putprompt(prompt2,&plen);
  1874. --- 402,416 ----
  1875. X                  }
  1876. X              goto start;
  1877. X              }
  1878. +         if (itok(lastc))
  1879. +             goto start;
  1880. X          return lastc;
  1881. X          }
  1882. !     if (strin || errflag)
  1883. !         {
  1884. !         lexstop = 1;
  1885. !         return lastc = ' ';
  1886. !         }
  1887. X      if (interact && isset(SHINSTDIN))
  1888. X          if (!isfirstln)
  1889. X              pmpt = putprompt(prompt2,&plen);
  1890. ***************
  1891. *** 424,430 ****
  1892. X      else
  1893. X          line = zleread(pmpt,pmpt2,plen);
  1894. X      if (!line)
  1895. !         return lastc = EOF;
  1896. X      if (interact && isset(SHINSTDIN))
  1897. X          {
  1898. X          char *s = getdata(lastnode(lithistlist));
  1899. --- 430,444 ----
  1900. X      else
  1901. X          line = zleread(pmpt,pmpt2,plen);
  1902. X      if (!line)
  1903. !         {
  1904. !         lexstop = 1;
  1905. !         return lastc = ' ';
  1906. !         }
  1907. !     if (errflag)
  1908. !         {
  1909. !         lexstop = errflag = 1;
  1910. !         return lastc = ' ';
  1911. !         }
  1912. X      if (interact && isset(SHINSTDIN))
  1913. X          {
  1914. X          char *s = getdata(lastnode(lithistlist));
  1915. ***************
  1916. *** 513,519 ****
  1917. X  void hungetc(c) /**/
  1918. X  int c;
  1919. X  {
  1920. !     if (c == -1)
  1921. X          return;
  1922. X      if (hlastw)
  1923. X          {
  1924. --- 527,533 ----
  1925. X  void hungetc(c) /**/
  1926. X  int c;
  1927. X  {
  1928. !     if (lexstop)
  1929. X          return;
  1930. X      if (hlastw)
  1931. X          {
  1932. ***************
  1933. *** 528,534 ****
  1934. X  void hungetch(c) /**/
  1935. X  int c;
  1936. X  {
  1937. !     if (c == -1)
  1938. X          return;
  1939. X      if (inbufct == inbufsz)
  1940. X          {
  1941. --- 542,548 ----
  1942. X  void hungetch(c) /**/
  1943. X  int c;
  1944. X  {
  1945. !     if (lexstop)
  1946. X          return;
  1947. X      if (inbufct == inbufsz)
  1948. X          {
  1949. ***************
  1950. *** 808,814 ****
  1951. X  {
  1952. X  int t0;
  1953. X  Lknode node;
  1954. - char *s,*t;
  1955. X  
  1956. X      if (curhist-firsthist < 1)
  1957. X          return -1;
  1958. --- 822,827 ----
  1959. ***************
  1960. *** 880,886 ****
  1961. X  char *str = *junkptr;
  1962. X  
  1963. X      for (; *str; str++)
  1964. !         *str = toupper(*str);
  1965. X      return 1;
  1966. X  }
  1967. X  
  1968. --- 893,899 ----
  1969. X  char *str = *junkptr;
  1970. X  
  1971. X      for (; *str; str++)
  1972. !         *str = tuupper(*str);
  1973. X      return 1;
  1974. X  }
  1975. X  
  1976. ***************
  1977. *** 890,896 ****
  1978. X  char *str = *junkptr;
  1979. X  
  1980. X      for (; *str; str++)
  1981. !         *str = tolower(*str);
  1982. X      return 1;
  1983. X  }
  1984. X  
  1985. --- 903,909 ----
  1986. X  char *str = *junkptr;
  1987. X  
  1988. X      for (; *str; str++)
  1989. !         *str = tulower(*str);
  1990. X      return 1;
  1991. X  }
  1992. X  
  1993. ***************
  1994. *** 1046,1052 ****
  1995. X  char *pp = *(char **) x;
  1996. X  
  1997. X      for (; *pp; pp++)
  1998. !         *pp = toupper(*pp);
  1999. X  }
  2000. X  
  2001. X  void downcase(x) /**/
  2002. --- 1059,1065 ----
  2003. X  char *pp = *(char **) x;
  2004. X  
  2005. X      for (; *pp; pp++)
  2006. !         *pp = tuupper(*pp);
  2007. X  }
  2008. X  
  2009. X  void downcase(x) /**/
  2010. ***************
  2011. *** 1055,1061 ****
  2012. X  char *pp = *(char **) x;
  2013. X  
  2014. X      for (; *pp; pp++)
  2015. !         *pp = tolower(*pp);
  2016. X  }
  2017. X  
  2018. X  int quote(tr) /**/
  2019. --- 1068,1074 ----
  2020. X  char *pp = *(char **) x;
  2021. X  
  2022. X      for (; *pp; pp++)
  2023. !         *pp = tulower(*pp);
  2024. X  }
  2025. X  
  2026. X  int quote(tr) /**/
  2027. ***************
  2028. *** 1140,1146 ****
  2029. X  {
  2030. X  char *ss,*ttyname DCLPROTO((int)),*bl0;
  2031. X  static char buf1[256],buf2[256],*buf;
  2032. ! int t0;
  2033. X  struct tm *tm = NULL;
  2034. X  time_t timet;
  2035. X  
  2036. --- 1153,1159 ----
  2037. X  {
  2038. X  char *ss,*ttyname DCLPROTO((int)),*bl0;
  2039. X  static char buf1[256],buf2[256],*buf;
  2040. ! int t0,bracepos = 0;
  2041. X  struct tm *tm = NULL;
  2042. X  time_t timet;
  2043. X  
  2044. ***************
  2045. *** 1200,1205 ****
  2046. --- 1213,1220 ----
  2047. X                  case 'b': tstradd("me");
  2048. X                  case 'U': tstradd("us");
  2049. X                  case 'u': tstradd("ue");
  2050. +                 case '{': bracepos = bp-buf; break;
  2051. +                 case '}': lensb += (bp-buf)-bracepos; break;
  2052. X                  case 't': case '@':
  2053. X                      timet = time(NULL);
  2054. X                      tm = localtime(&timet);
  2055. ***************
  2056. *** 1281,1287 ****
  2057. X  {
  2058. X      if (strin)
  2059. X          hflush();
  2060. !     else while (lastc != '\n' && lastc != HERR)
  2061. X          hgetch();
  2062. X  }
  2063. X  
  2064. --- 1296,1302 ----
  2065. X  {
  2066. X      if (strin)
  2067. X          hflush();
  2068. !     else while (lastc != '\n' && !lexstop)
  2069. X          hgetch();
  2070. X  }
  2071. X  
  2072. ***************
  2073. *** 1294,1300 ****
  2074. X  char *buf = zalloc(bsiz),*ptr;
  2075. X   
  2076. X      ptr = buf;
  2077. !     while ((c = hgetch()) != stop && c != '\n' && c != EOF && c != HERR)
  2078. X          {
  2079. X          if (c == '\\')
  2080. X              c = hgetch();
  2081. --- 1309,1315 ----
  2082. X  char *buf = zalloc(bsiz),*ptr;
  2083. X   
  2084. X      ptr = buf;
  2085. !     while ((c = hgetch()) != stop && c != '\n' && !lexstop)
  2086. X          {
  2087. X          if (c == '\\')
  2088. X              c = hgetch();
  2089. ***************
  2090. *** 1323,1329 ****
  2091. X  char *buf = zalloc(bsiz),*ptr;
  2092. X   
  2093. X      ptr = buf;
  2094. !     while ((c = hgetch()) != stop && c != '\n' && c != EOF && c != HERR)
  2095. X          {
  2096. X          if (c == '\n')
  2097. X              {
  2098. --- 1338,1344 ----
  2099. X  char *buf = zalloc(bsiz),*ptr;
  2100. X   
  2101. X      ptr = buf;
  2102. !     while ((c = hgetch()) != stop && c != '\n' && !lexstop)
  2103. X          {
  2104. X          if (c == '\n')
  2105. X              {
  2106. ***************
  2107. *** 1394,1400 ****
  2108. X  int arg = pgrp;
  2109. X  
  2110. X      if (jobbing)
  2111. ! #ifdef TCSETPGRP
  2112. X          if (SHTTY != -1 && tcsetpgrp(SHTTY,pgrp) == -1 && !ep)
  2113. X  #else
  2114. X          if (SHTTY != -1 && ioctl(SHTTY,TIOCSPGRP,&arg) == -1 && !ep)
  2115. --- 1409,1415 ----
  2116. X  int arg = pgrp;
  2117. X  
  2118. X      if (jobbing)
  2119. ! #ifndef TIOCSPGRP
  2120. X          if (SHTTY != -1 && tcsetpgrp(SHTTY,pgrp) == -1 && !ep)
  2121. X  #else
  2122. X          if (SHTTY != -1 && ioctl(SHTTY,TIOCSPGRP,&arg) == -1 && !ep)
  2123. *** src/zsh0/zsh2.00/src/init.c    Tue Apr 23 01:29:26 1991
  2124. --- zsh2.00/src/init.c    Fri May 10 06:46:07 1991
  2125. ***************
  2126. *** 32,38 ****
  2127. X  
  2128. X  #define GLOBALS
  2129. X  #include "zsh.h"
  2130. - #include "funcs.h"
  2131. X  #include <pwd.h>
  2132. X  
  2133. X  extern int yydebug;
  2134. --- 32,37 ----
  2135. ***************
  2136. *** 132,138 ****
  2137. X  {
  2138. X  int c;
  2139. X  
  2140. !     for (c = 0; c != 128; c++)
  2141. X          opts[c] = OPT_INVALID;
  2142. X      for (c = 'a'; c <= 'z'; c++)
  2143. X          opts[c] = opts[c-'a'+'A'] = OPT_UNSET;
  2144. --- 131,139 ----
  2145. X  {
  2146. X  int c;
  2147. X  
  2148. !     for (c = 0; c != 32; c++)
  2149. !         opts[c] = OPT_UNSET;
  2150. !     for (c = 32; c != 128; c++)
  2151. X          opts[c] = OPT_INVALID;
  2152. X      for (c = 'a'; c <= 'z'; c++)
  2153. X          opts[c] = opts[c-'a'+'A'] = OPT_UNSET;
  2154. ***************
  2155. *** 185,194 ****
  2156. X                  {
  2157. X                  int c;
  2158. X  
  2159. !                 argv++;
  2160. X                  c = optlookup(*argv);
  2161. X                  if (c == -1)
  2162. !                     zerr("no such option: %s",argv[-1],0);
  2163. X                  else
  2164. X                      opts[c] = action;
  2165. X                  break;
  2166. --- 186,201 ----
  2167. X                  {
  2168. X                  int c;
  2169. X  
  2170. !                 if (!*++*argv)
  2171. !                     argv++;
  2172. !                 if (!*argv)
  2173. !                     {
  2174. !                     zerr("string expected after -o",NULL,0);
  2175. !                     exit(1);
  2176. !                     }
  2177. X                  c = optlookup(*argv);
  2178. X                  if (c == -1)
  2179. !                     zerr("no such option: %s",*argv,0);
  2180. X                  else
  2181. X                      opts[c] = action;
  2182. X                  break;
  2183. ***************
  2184. *** 227,232 ****
  2185. --- 234,240 ----
  2186. X      setbuffer(stdout,malloc(BUFSIZ),BUFSIZ);
  2187. X      setbuffer(stderr,malloc(BUFSIZ),BUFSIZ);
  2188. X      subsh = 0;
  2189. + #ifdef JOB_CONTROL
  2190. X      opts[MONITOR] = (interact) ? OPT_SET : OPT_UNSET;
  2191. X      if (jobbing)
  2192. X          {
  2193. ***************
  2194. *** 234,245 ****
  2195. --- 242,265 ----
  2196. X          if (SHTTY == -1)
  2197. X              opts[MONITOR] = OPT_UNSET;
  2198. X          else
  2199. +             {
  2200. X              gettyinfo(&shttyinfo);    /* get tty state */
  2201. +             savedttyinfo = shttyinfo;
  2202. +             }
  2203. X          if ((mypgrp = getpgrp(0)) <= 0)
  2204. X              opts[MONITOR] = OPT_UNSET;
  2205. X          }
  2206. X      else
  2207. X          SHTTY = -1;
  2208. + #else
  2209. +     opts[MONITOR] = OPT_UNSET;
  2210. +     SHTTY = movefd((isatty(0)) ? dup(0) : open("/dev/tty",O_RDWR));
  2211. +     if (SHTTY != -1)
  2212. +         {
  2213. +         gettyinfo(&shttyinfo);
  2214. +         savedttyinfo = shttyinfo;
  2215. +         }
  2216. + #endif
  2217. X  }
  2218. X  
  2219. X  void setupvals() /**/
  2220. ***************
  2221. *** 269,284 ****
  2222. X      paramtab = newhtable(151);
  2223. X      cmdnamtab = newhtable(13);
  2224. X      initxbindtab();
  2225. !     if (interact)
  2226. !         {
  2227. !         prompt = ztrdup("%m%# ");
  2228. !         prompt2 = ztrdup("> ");
  2229. !         prompt3 = ztrdup("?# ");
  2230. !         prompt4 = ztrdup("+ ");
  2231. !         }
  2232. X      ppid = getppid();
  2233. X  #ifdef TERMIOS
  2234. !     baud = bauds[cfgetospeed(&shttyinfo.termios)];
  2235. X  #else
  2236. X  #ifdef TERMIO
  2237. X      baud = bauds[shttyinfo.termio.c_cflag & CBAUD];
  2238. --- 289,301 ----
  2239. X      paramtab = newhtable(151);
  2240. X      cmdnamtab = newhtable(13);
  2241. X      initxbindtab();
  2242. !     prompt = ztrdup("%m%# ");
  2243. !     prompt2 = ztrdup("> ");
  2244. !     prompt3 = ztrdup("?# ");
  2245. !     prompt4 = ztrdup("+ ");
  2246. X      ppid = getppid();
  2247. X  #ifdef TERMIOS
  2248. !     baud = bauds[shttyinfo.termios.c_cflag & CBAUD];
  2249. X  #else
  2250. X  #ifdef TERMIO
  2251. X      baud = bauds[shttyinfo.termio.c_cflag & CBAUD];
  2252. ***************
  2253. *** 295,301 ****
  2254. X      columns = 80;
  2255. X      lines = 24;
  2256. X  #endif
  2257. -     home = ztrdup("/");
  2258. X      ifs = ztrdup(" \t\n");
  2259. X      if (pwd = getpwuid(getuid()))
  2260. X          {
  2261. --- 312,317 ----
  2262. ***************
  2263. *** 311,316 ****
  2264. --- 327,333 ----
  2265. X      watchfmt = ztrdup(DEFWATCHFMT);
  2266. X      ttystrname = ztrdup(ttyname(SHTTY));
  2267. X      wordchars = ztrdup(DEFWORDCHARS);
  2268. +     fceditparam = ztrdup(DEFFCEDIT);
  2269. X      if (ispwd(home))
  2270. X          cwd = ztrdup(home);
  2271. X      else if ((ptr = zgetenv("PWD")) && ispwd(ptr))
  2272. ***************
  2273. *** 334,340 ****
  2274. X      userdirsz = 2;
  2275. X      userdirct = 0;
  2276. X      optarg = ztrdup("");
  2277. !     optind = 1;
  2278. X      path = (char **) zalloc(4*sizeof *path);
  2279. X      path[0] = ztrdup("/bin"); path[1] = ztrdup("/usr/bin");
  2280. X      path[2] = ztrdup("/usr/ucb"); path[3] = NULL;
  2281. --- 351,358 ----
  2282. X      userdirsz = 2;
  2283. X      userdirct = 0;
  2284. X      optarg = ztrdup("");
  2285. !     optind = 0;
  2286. !     schedcmds = NULL;
  2287. X      path = (char **) zalloc(4*sizeof *path);
  2288. X      path[0] = ztrdup("/bin"); path[1] = ztrdup("/usr/bin");
  2289. X      path[2] = ztrdup("/usr/ucb"); path[3] = NULL;
  2290. ***************
  2291. *** 341,346 ****
  2292. --- 359,365 ----
  2293. X      for (ptr = hostm; *ptr && *ptr != '.'; ptr++);
  2294. X      *ptr = '\0';
  2295. X      inittyptab();
  2296. +     initlextabs();
  2297. X      setupparams();
  2298. X      setparams();
  2299. X      inittyptab();
  2300. ***************
  2301. *** 363,369 ****
  2302. X      inbuf = zalloc(inbufsz = 256);
  2303. X      inbufptr = inbuf+inbufsz;
  2304. X      inbufct = 0;
  2305. !     /*signal(SIGQUIT,SIG_IGN);*/
  2306. X      for (t0 = 0; t0 != RLIM_NLIMITS; t0++)
  2307. X          getrlimit(t0,limits+t0);
  2308. X      hsubl = hsubr = NULL;
  2309. --- 382,388 ----
  2310. X      inbuf = zalloc(inbufsz = 256);
  2311. X      inbufptr = inbuf+inbufsz;
  2312. X      inbufct = 0;
  2313. !     signal(SIGQUIT,SIG_IGN);
  2314. X      for (t0 = 0; t0 != RLIM_NLIMITS; t0++)
  2315. X          getrlimit(t0,limits+t0);
  2316. X      hsubl = hsubr = NULL;
  2317. ***************
  2318. *** 392,398 ****
  2319. X  static char *reswds[] = {
  2320. X      "do", "done", "esac", "then", "elif", "else", "fi", "for", "case",
  2321. X      "if", "while", "function", "repeat", "time", "until", "exec", "command",
  2322. !     "select", "coproc", "noglob", "-", NULL
  2323. X      };
  2324. X  int t0;
  2325. X  
  2326. --- 411,417 ----
  2327. X  static char *reswds[] = {
  2328. X      "do", "done", "esac", "then", "elif", "else", "fi", "for", "case",
  2329. X      "if", "while", "function", "repeat", "time", "until", "exec", "command",
  2330. !     "select", "coproc", "noglob", "-", "nocorrect", NULL
  2331. X      };
  2332. X  int t0;
  2333. X  
  2334. ***************
  2335. *** 402,408 ****
  2336. X  
  2337. X  void runscripts() /**/
  2338. X  {
  2339. !     if (interact && opts[NORCS] == OPT_UNSET)
  2340. X          {
  2341. X  #ifdef GLOBALZSHRC
  2342. X          source(GLOBALZSHRC);
  2343. --- 421,430 ----
  2344. X  
  2345. X  void runscripts() /**/
  2346. X  {
  2347. !     if (opts[NORCS] == OPT_SET)
  2348. !         return;
  2349. !     sourcehome(".zshenv");
  2350. !     if (interact)
  2351. X          {
  2352. X  #ifdef GLOBALZSHRC
  2353. X          source(GLOBALZSHRC);
  2354. ***************
  2355. *** 417,423 ****
  2356. X              }
  2357. X          }
  2358. X      if (interact)
  2359. !         readhistfile();
  2360. X      if (opts['c'] == OPT_SET)
  2361. X          {
  2362. X          if (SHIN >= 10)
  2363. --- 439,445 ----
  2364. X              }
  2365. X          }
  2366. X      if (interact)
  2367. !         readhistfile(getsparam("HISTFILE"),0);
  2368. X      if (opts['c'] == OPT_SET)
  2369. X          {
  2370. X          if (SHIN >= 10)
  2371. ***************
  2372. *** 441,452 ****
  2373. X      isfirstln = 1;
  2374. X  }
  2375. X  
  2376. ! void readhistfile() /**/
  2377. X  {
  2378. ! char *s,buf[1024];
  2379. X  FILE *in;
  2380. X  
  2381. !     if (!(s = getsparam("HISTFILE")))
  2382. X          return;
  2383. X      if (in = fopen(s,"r"))
  2384. X          {
  2385. --- 463,475 ----
  2386. X      isfirstln = 1;
  2387. X  }
  2388. X  
  2389. ! void readhistfile(s,err) /**/
  2390. ! char *s;int err;
  2391. X  {
  2392. ! char buf[1024];
  2393. X  FILE *in;
  2394. X  
  2395. !     if (!s)
  2396. X          return;
  2397. X      if (in = fopen(s,"r"))
  2398. X          {
  2399. ***************
  2400. *** 454,462 ****
  2401. --- 477,489 ----
  2402. X          while (fgets(buf,1024,in))
  2403. X              {
  2404. X              int l = strlen(buf);
  2405. +             char *pt = buf;
  2406. X  
  2407. X              if (l && buf[l-1] == '\n')
  2408. X                  buf[l-1] = '\0';
  2409. +             for (;*pt;pt++)
  2410. +                 if (*pt == ' ')
  2411. +                 *pt = HISTSPACE;
  2412. X              addnode(histlist,ztrdup(buf));
  2413. X              addnode(lithistlist,ztrdup(buf));
  2414. X              curhist++;
  2415. ***************
  2416. *** 464,479 ****
  2417. X          fclose(in);
  2418. X          lastalloc();
  2419. SHAR_EOF
  2420. true || echo 'restore of patches failed'
  2421. echo 'End of  part 2'
  2422. echo 'File patches is continued in part 3'
  2423. echo 3 > _shar_seq_.tmp
  2424. exit 0
  2425.               Paul Falstad  pfalstad@phoenix.princeton.edu
  2426.          And on the roads, too, vicious gangs of KEEP LEFT signs!
  2427.      If Princeton knew my opinions, they'd have expelled me long ago.
  2428.  
  2429. exit 0 # Just in case...
  2430. -- 
  2431. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  2432. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  2433. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  2434. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  2435.