home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume12 / ms_sh-1.6 / part04 < prev    next >
Encoding:
Text File  |  1990-05-05  |  38.2 KB  |  1,678 lines

  1. Newsgroups: comp.sources.misc
  2. from: istewart@datlog.co.uk
  3. subject: v12i022: MS_SH 1.6 Upgrade Kit - Part 04 of 08
  4. Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  5.  
  6. Posting-number: Volume 12, Issue 22
  7. Submitted-by: istewart@datlog.co.uk
  8. Archive-name: ms_sh-1.6/part04
  9.  
  10. #!/bin/sh
  11. # this is part 4 of a multipart archive
  12. # do not concatenate these parts, unpack them in order with /bin/sh
  13. # file Patch1.6 continued
  14. #
  15. CurArch=4
  16. if test ! -r s2_seq_.tmp
  17. then echo "Please unpack part 1 first!"
  18.      exit 1; fi
  19. ( read Scheck
  20.   if test "$Scheck" != $CurArch
  21.   then echo "Please unpack part $Scheck next!"
  22.        exit 1;
  23.   else exit 0; fi
  24. ) < s2_seq_.tmp || exit 1
  25. echo "x - Continuing file Patch1.6"
  26. sed 's/^X//' << 'SHAR_EOF' >> Patch1.6
  27. X!                     /* Always leave room for NL    */
  28. X!     char    *ep = &e.linep[LINE_MAX - 3];
  29. X  
  30. X!     while ((ip = t->words[n++]) != (char *)NULL)
  31. X      {
  32. X      if ((n == 2) && (strcmp (ip, "-n") == 0))
  33. X      {
  34. X          no_eol++;
  35. X--- 311,339 ----
  36. X  static int    doecho (t)
  37. X  register C_Op    *t;
  38. X  {
  39. X!     int        n = 1;            /* Argument number        */
  40. X      int        no_eol = 0;        /* No EOL            */
  41. X      char    *ip;            /* Input pointer        */
  42. X      int        c_val;            /* Current character        */
  43. X      char    c;
  44. X      bool    end_s;
  45. X!     Out_Buf    *bp;
  46. X  
  47. X! /* Get some memory for the buffer */
  48. X! 
  49. X!     if ((bp = Open_buffer (1, FALSE)) == (Out_Buf *)NULL)
  50. X      {
  51. X+     print_error ("echo: %s\n", strerror (ENOMEM));
  52. X+     return 1;
  53. X+     }
  54. X+ 
  55. X+ /* Process the arguments */
  56. X+ 
  57. X+     while ((ip = t->words[n++]) != (char *)NULL)
  58. X+     {
  59. X+ 
  60. X+ /* Check for -n switch */
  61. X+ 
  62. X      if ((n == 2) && (strcmp (ip, "-n") == 0))
  63. X      {
  64. X          no_eol++;
  65. X***************
  66. X*** 305,332 ****
  67. X  
  68. X  /* Output the character */
  69. X  
  70. X!         if (cp < ep)
  71. X!         *(cp++) = c;
  72. X  
  73. X-         else
  74. X-         {
  75. X-         v1_putsn (e.linep, (int)(cp - e.linep));
  76. X-         cp = e.linep;
  77. X-         }
  78. X- 
  79. X      } while (!end_s);
  80. X      }
  81. X  
  82. X  /* Is EOL required ? */
  83. X  
  84. X      if (!no_eol)
  85. X!     *(cp++) = NL;
  86. X  
  87. X  /* Flush buffer */
  88. X  
  89. X!     if ((n = (int)(cp - e.linep)))
  90. X!     v1_putsn (e.linep, n);
  91. X! 
  92. X      return 0;
  93. X  }
  94. X  
  95. X--- 375,393 ----
  96. X  
  97. X  /* Output the character */
  98. X  
  99. X!         Add_buffer (c, bp);
  100. X  
  101. X      } while (!end_s);
  102. X      }
  103. X  
  104. X  /* Is EOL required ? */
  105. X  
  106. X      if (!no_eol)
  107. X!     Add_buffer (NL, bp);
  108. X  
  109. X  /* Flush buffer */
  110. X  
  111. X!     Close_buffer (bp);
  112. X      return 0;
  113. X  }
  114. X  
  115. X***************
  116. X*** 375,382 ****
  117. X  
  118. X  /* Check for an octal string */
  119. X  
  120. X!     if ((c_val >= 0) && (c_val < 8))
  121. X      {
  122. X      while ((IS_OCTAL (**cp)))
  123. X          c_val = (c_val * 8) + *((*cp)++) - '0';
  124. X  
  125. X--- 436,445 ----
  126. X  
  127. X  /* Check for an octal string */
  128. X  
  129. X!     if (IS_OCTAL (c_val))
  130. X      {
  131. X+     c_val -= '0';
  132. X+ 
  133. X      while ((IS_OCTAL (**cp)))
  134. X          c_val = (c_val * 8) + *((*cp)++) - '0';
  135. X  
  136. X***************
  137. X*** 393,400 ****
  138. X  static int    dover (t)
  139. X  C_Op        *t;
  140. X  {
  141. X!     v1printf (Copy_Right1, _osmajor, _osminor);
  142. X!     v1a_puts (Copy_Right2);
  143. X      return 0;
  144. X  }
  145. X  
  146. X--- 456,462 ----
  147. X  static int    dover (t)
  148. X  C_Op        *t;
  149. X  {
  150. X!     Print_Version (1);
  151. X      return 0;
  152. X  }
  153. X  
  154. X***************
  155. X*** 896,904 ****
  156. X  static int    dochdir (t)
  157. X  register C_Op    *t;
  158. X  {
  159. X!     char        *p;
  160. X!     char        *nd;
  161. X!     register char    *cp;
  162. X      int            first = 0;
  163. X      unsigned int    dummy;
  164. X      unsigned int    cdrive;
  165. X--- 958,967 ----
  166. X  static int    dochdir (t)
  167. X  register C_Op    *t;
  168. X  {
  169. X!     char        *p;        /* Original new directory    */
  170. X!     char        *nd;        /* New directory        */
  171. X!     register char    *cp;        /* In CDPATH Pointer        */
  172. X!     char        *directory;
  173. X      int            first = 0;
  174. X      unsigned int    dummy;
  175. X      unsigned int    cdrive;
  176. X***************
  177. X*** 917,942 ****
  178. X      return 1;
  179. X      }
  180. X  
  181. X! /* Save the current drive */
  182. X  
  183. X      _dos_getdrive (&cdrive);
  184. X  
  185. X  /* Scan for the directory.  If there is not a / or : at start, use the
  186. X   * CDPATH variable
  187. X   */
  188. X  
  189. X!     cp = (*p == '/') ? null : lookup ("CDPATH", FALSE)->value;
  190. X!     cp = (*(p + 1) == ':') ? null : cp;
  191. X  
  192. X      do
  193. X      {
  194. X!     cp = path_append (cp, p, e.linep);
  195. X  
  196. X  /* Check for new disk drive */
  197. X  
  198. X!     nd = e.linep;
  199. X  
  200. X!     if (*(nd+ 1) == ':')
  201. X      {
  202. X          _dos_setdrive (tolower (*nd) - 'a' + 1, &dummy);
  203. X          nd += 2;
  204. X--- 980,1011 ----
  205. X      return 1;
  206. X      }
  207. X  
  208. X!     if ((directory = getcell (FFNAME_MAX)) == (char *)NULL)
  209. X!     {
  210. X!     print_error ("cd: %s\n", strerror (ENOMEM));
  211. X!     return 1;
  212. X!     }
  213. X  
  214. X+ /* Save the current drive */
  215. X+ 
  216. X      _dos_getdrive (&cdrive);
  217. X  
  218. X  /* Scan for the directory.  If there is not a / or : at start, use the
  219. X   * CDPATH variable
  220. X   */
  221. X  
  222. X!     cp = ((*p == '/') || (*(p + 1) == ':')) ? null
  223. X!                         : lookup ("CDPATH", FALSE)->value;
  224. X  
  225. X      do
  226. X      {
  227. X!     cp = path_append (cp, p, directory);
  228. X  
  229. X  /* Check for new disk drive */
  230. X  
  231. X!     nd = directory;
  232. X  
  233. X!     if (*(nd + 1) == ':')
  234. X      {
  235. X          _dos_setdrive (tolower (*nd) - 'a' + 1, &dummy);
  236. X          nd += 2;
  237. X***************
  238. X*** 976,1004 ****
  239. X   * Extract the next path from a string and build a new path from the
  240. X   * extracted path and a file name
  241. X   */
  242. X! char        *path_append (s1, s2, si)
  243. X! register char    *s1;            /* Path string            */
  244. X! register char    *s2;            /* File name string        */
  245. X! char        *si;            /* Output path            */
  246. X  {
  247. X!     register char    *s;
  248. X  
  249. X!     s = si;
  250. X  
  251. X!     while (*s1 && *s1 != ';')
  252. X!     *s++ = *s1++;
  253. X! 
  254. X!     if ((si != s) && (*(s - 1) != '/'))
  255. X      *s++ = '/';
  256. X  
  257. X      *s = '\0';
  258. X  
  259. X!     if (s2 != (char *)NULL)
  260. X!     strcpy (s, s2);
  261. X  
  262. X!     return (*s1 ? ++s1 : (char *)NULL);
  263. X! }
  264. X  
  265. X  /*
  266. X   * Execute a shift command: shift <n>
  267. X   */
  268. X--- 1045,1074 ----
  269. X   * Extract the next path from a string and build a new path from the
  270. X   * extracted path and a file name
  271. X   */
  272. X! char        *path_append (path_s, file_s, output_s)
  273. X! register char    *path_s;        /* Path string            */
  274. X! register char    *file_s;        /* File name string        */
  275. X! char        *output_s;        /* Output path            */
  276. X  {
  277. X!     register char    *s = output_s;
  278. X!     int            fsize = 0;
  279. X  
  280. X!     while (*path_s && (*path_s != ';') && (fsize++ < FFNAME_MAX))
  281. X!     *s++ = *path_s++;
  282. X  
  283. X!     if ((output_s != s) && (*(s - 1) != '/') && (fsize++ < FFNAME_MAX))
  284. X      *s++ = '/';
  285. X  
  286. X      *s = '\0';
  287. X  
  288. X!     if (file_s != (char *)NULL)
  289. X!     strncpy (s, file_s, FFNAME_MAX - fsize);
  290. X  
  291. X!     output_s[FFNAME_MAX - 1] = 0;
  292. X  
  293. X+     return (*path_s ? ++path_s : (char *)NULL);
  294. X+ }
  295. X+ 
  296. X  /*
  297. X   * Execute a shift command: shift <n>
  298. X   */
  299. X***************
  300. X*** 1062,1086 ****
  301. X      register int    i;
  302. X      jmp_buf        ex;
  303. X      int            *ofail;
  304. X  
  305. X-     t->ioact = (IO_Actions **)NULL;
  306. X- 
  307. X      for (i = 0; (t->words[i] = t->words[i + 1]) != (char *)NULL; i++)
  308. X      ;
  309. X  
  310. X!     if (i == 0)
  311. X!     return 0;
  312. X  
  313. X      execflg = 1;
  314. X      ofail = failpt;
  315. X  
  316. X  /* Set execute function recursive level to zero */
  317. X  
  318. X      Execute_stack_depth = 0;
  319. X  
  320. X      if (setjmp (failpt = ex) == 0)
  321. X      execute (t, NOPIPE, NOPIPE, FEXEC);
  322. X  
  323. X      failpt = ofail;
  324. X      execflg = 0;
  325. X      return 1;
  326. X--- 1132,1162 ----
  327. X      register int    i;
  328. X      jmp_buf        ex;
  329. X      int            *ofail;
  330. X+     IO_Actions        **ios = t->ioact;
  331. X  
  332. X      for (i = 0; (t->words[i] = t->words[i + 1]) != (char *)NULL; i++)
  333. X      ;
  334. X  
  335. X! /* Left the I/O as it is */
  336. X  
  337. X+     if (i == 0)
  338. X+     return restore_std (0, FALSE);
  339. X+ 
  340. X      execflg = 1;
  341. X      ofail = failpt;
  342. X  
  343. X  /* Set execute function recursive level to zero */
  344. X  
  345. X      Execute_stack_depth = 0;
  346. X+     t->ioact = (IO_Actions **)NULL;
  347. X  
  348. X      if (setjmp (failpt = ex) == 0)
  349. X      execute (t, NOPIPE, NOPIPE, FEXEC);
  350. X  
  351. X+ /* Clear the extended file if an interrupt happened */
  352. X+ 
  353. X+     Clear_Extended_File ();
  354. X+     t->ioact = ios;
  355. X      failpt = ofail;
  356. X      execflg = 0;
  357. X      return 1;
  358. X***************
  359. X*** 1096,1119 ****
  360. X      register int    i;
  361. X      register char    *sp;
  362. X      char        *cp;
  363. X  
  364. X      if ((cp = t->words[1]) == (char *)NULL)
  365. X      return 0;
  366. X  
  367. X!     sp = any ('/', cp) ? null : path->value;
  368. X  
  369. X!     do
  370. X      {
  371. X!     sp = path_append (sp, cp, e.linep);
  372. X  
  373. X!     if ((i = O_for_execute (e.linep)) >= 0)
  374. X!     {
  375. X!         exstat = 0;
  376. X!         next (remap (i));
  377. X!         return exstat;
  378. X!     }
  379. X!     } while (sp != (char *)NULL);
  380. X  
  381. X      print_error ("%s: not found\n", cp);
  382. X      return 1;
  383. X  }
  384. X--- 1172,1203 ----
  385. X      register int    i;
  386. X      register char    *sp;
  387. X      char        *cp;
  388. X+     char        *l_path;
  389. X  
  390. X      if ((cp = t->words[1]) == (char *)NULL)
  391. X      return 0;
  392. X  
  393. X! /* Get some space */
  394. X  
  395. X!     if ((l_path = getcell (FFNAME_MAX)) == (char *)NULL)
  396. X      {
  397. X!     print_error (".: %s\n", strerror (ENOMEM));
  398. X!     return 1;
  399. X!     }
  400. X  
  401. X! /* Save the current drive */
  402. X  
  403. X+     sp = (any ('/', cp) || (*(cp + 1) == ':')) ? null : path->value;
  404. X+ 
  405. X+     do
  406. X+     {
  407. X+     sp = path_append (sp, cp, l_path);
  408. X+ 
  409. X+     if ((i = O_for_execute (l_path, (char **)NULL, (int *)NULL)) >= 0)
  410. X+         return RUN (afile, remap (i), filechar, FALSE);
  411. X+ 
  412. X+     } while (sp != (char *)NULL);
  413. X+ 
  414. X      print_error ("%s: not found\n", cp);
  415. X      return 1;
  416. X  }
  417. X***************
  418. X*** 1125,1147 ****
  419. X  static int    doread (t)
  420. X  C_Op        *t;
  421. X  {
  422. X!     register char    *cp, **wp;
  423. X      register int    nb;
  424. X  
  425. X      if (t->words[1] == (char *)NULL)
  426. X      {
  427. X      print_error ("Usage: read name ...\n");
  428. X      return 1;
  429. X      }
  430. X  
  431. X!     for (wp = t->words + 1; *wp != (char *)NULL; wp++)
  432. X      {
  433. X!     for (cp = e.linep; cp < e.eline - 1; cp++)
  434. X      {
  435. X          if (((nb = read (STDIN_FILENO, cp, 1)) != 1) || (*cp == NL) ||
  436. X          ((wp[1] != (char *)NULL) && any (*cp, ifs->value)))
  437. X  
  438. X!         break;
  439. X      }
  440. X  
  441. X      *cp = 0;
  442. X--- 1209,1256 ----
  443. X  static int    doread (t)
  444. X  C_Op        *t;
  445. X  {
  446. X!     register char    *cp;
  447. X!     register char    **wp;
  448. X      register int    nb;
  449. X+     bool        nl_detected = FALSE;
  450. X+     char        *buffer;
  451. X+     char        *ep;
  452. X  
  453. X+ /* Check usage */
  454. X+ 
  455. X      if (t->words[1] == (char *)NULL)
  456. X      {
  457. X      print_error ("Usage: read name ...\n");
  458. X      return 1;
  459. X      }
  460. X  
  461. X! /* Get some memory */
  462. X! 
  463. X!     if ((buffer = getcell (LINE_MAX)) == (char *)NULL)
  464. X      {
  465. X!     print_error ("read: %s\n", strerror (ENOMEM));
  466. X!     return 1;
  467. X!     }
  468. X! 
  469. X!     ep = &buffer[LINE_MAX - 2];
  470. X! 
  471. X! /* Save the current drive */
  472. X! 
  473. X!     for (wp = t->words + 1; *wp != (char *)NULL; wp++)
  474. X!     {
  475. X! 
  476. X! /* Read in until end of line, file or a field separator is detected */
  477. X! 
  478. X!     for (cp = buffer; !nl_detected && (cp < ep); cp++)
  479. X      {
  480. X          if (((nb = read (STDIN_FILENO, cp, 1)) != 1) || (*cp == NL) ||
  481. X          ((wp[1] != (char *)NULL) && any (*cp, ifs->value)))
  482. X+         {
  483. X+         if ((nb != 1) || (*cp == NL))
  484. X+             nl_detected = TRUE;
  485. X  
  486. X!         break;
  487. X!         }
  488. X      }
  489. X  
  490. X      *cp = 0;
  491. X***************
  492. X*** 1149,1155 ****
  493. X      if (nb <= 0)
  494. X          break;
  495. X  
  496. X!     setval (lookup (*wp, TRUE), e.linep);
  497. X      }
  498. X  
  499. X      return (nb <= 0);
  500. X--- 1258,1264 ----
  501. X      if (nb <= 0)
  502. X          break;
  503. X  
  504. X!     setval (lookup (*wp, TRUE), buffer);
  505. X      }
  506. X  
  507. X      return (nb <= 0);
  508. X***************
  509. X*** 1162,1168 ****
  510. X  static int    doeval (t)
  511. X  register C_Op    *t;
  512. X  {
  513. X!     return RUN (awordlist, t->words + 1, wdchar);
  514. X  }
  515. X  
  516. X  /*
  517. X--- 1271,1277 ----
  518. X  static int    doeval (t)
  519. X  register C_Op    *t;
  520. X  {
  521. X!     return RUN (awordlist, t->words + 1, wdchar, TRUE);
  522. X  }
  523. X  
  524. X  /*
  525. X***************
  526. X*** 1177,1183 ****
  527. X      char        tval[10];
  528. X      char        *cp;
  529. X  
  530. X- 
  531. X      if (t->words[1] == (char *)NULL)
  532. X      {
  533. X  
  534. X--- 1286,1291 ----
  535. X***************
  536. X*** 1472,1478 ****
  537. X          if ((vp->status & key) && isalpha (*vp->name))
  538. X          {
  539. X          v1_puts (tstring);
  540. X!         v1_putsn (vp->name, (int)(findeq (vp->name) - vp->name));
  541. X          v1_putc (NL);
  542. X          }
  543. X      }
  544. X--- 1580,1587 ----
  545. X          if ((vp->status & key) && isalpha (*vp->name))
  546. X          {
  547. X          v1_puts (tstring);
  548. X!         write (STDOUT_FILENO, vp->name,
  549. X!                (int)(findeq (vp->name) - vp->name));
  550. X          v1_putc (NL);
  551. X          }
  552. X      }
  553. X***************
  554. X*** 1617,1622 ****
  555. X--- 1726,1732 ----
  556. X   * History functions - display, initialise, enable, disable
  557. X   */
  558. X  
  559. X+ #ifndef NO_HISTORY
  560. X  static int    dohistory (t)
  561. X  C_Op        *t;
  562. X  {
  563. X***************
  564. X*** 1639,1651 ****
  565. X  
  566. X      return 0;
  567. X  }
  568. X  
  569. X  /*
  570. X   * Type fucntion: For each name, indicate how it would be interpreted
  571. X   */
  572. X  
  573. X  static char    *type_ext[] = {
  574. X!     "", ".exe", ".com", ".sh"
  575. X  };
  576. X  
  577. X  static int    dotype (t)
  578. X--- 1749,1762 ----
  579. X  
  580. X      return 0;
  581. X  }
  582. X+ #endif
  583. X  
  584. X  /*
  585. X   * Type fucntion: For each name, indicate how it would be interpreted
  586. X   */
  587. X  
  588. X  static char    *type_ext[] = {
  589. X!     "", ".exe", ".com", ".sh", ".bat"
  590. X  };
  591. X  
  592. X  static int    dotype (t)
  593. X***************
  594. X*** 1659,1690 ****
  595. X      int            n = 1;            /* Argument count    */
  596. X      int            i, fp;    
  597. X      bool        found;            /* Found flag        */
  598. X  
  599. X!     while ((cp = t->words[n++]) != (char *)NULL)
  600. X!     {
  601. X!     sp = any ('/', cp) ? null : path->value;
  602. X!     found = FALSE;
  603. X  
  604. X      do
  605. X      {
  606. X!         sp = path_append (sp, cp, e.linep);
  607. X!         ep = &e.linep[strlen (e.linep)];
  608. X  
  609. X  /* Get start of file name */
  610. X  
  611. X!         if ((xp1 = strrchr (e.linep, '/')) == (char *)NULL)
  612. X!         xp1 = e.linep;
  613. X          
  614. X          else
  615. X          ++xp1;
  616. X  
  617. X! /* Look up all 4 types */
  618. X  
  619. X!         for (i = 0; (i < 4) && !found; i++)
  620. X          {
  621. X          strcpy (ep, type_ext[i]);
  622. X  
  623. X!         if (access (e.linep, F_OK) == 0)
  624. X          {
  625. X  
  626. X  /* If no extension or .sh extension, check for shell script */
  627. X--- 1770,1826 ----
  628. X      int            n = 1;            /* Argument count    */
  629. X      int            i, fp;    
  630. X      bool        found;            /* Found flag        */
  631. X+     char        *l_path;
  632. X+     Fun_Ops        *fops;
  633. X  
  634. X! /* Get some memory for the buffer */
  635. X  
  636. X+     if ((l_path = getcell (FFNAME_MAX + 4)) == (char *)NULL)
  637. X+     {
  638. X+     print_error ("type: %s\n", strerror (ENOMEM));
  639. X+     return 1;
  640. X+     }
  641. X+ 
  642. X+ /* Process each parameter */
  643. X+ 
  644. X+     while ((cp = t->words[n++]) != (char *)NULL)
  645. X+     {
  646. X+ 
  647. X+ /* Check for a function */
  648. X+ 
  649. X+     if ((fops = Fun_Search (cp)) != (Fun_Ops *)NULL)
  650. X+     {
  651. X+         v1_puts (cp);
  652. X+         v1a_puts (" is a function");
  653. X+         Print_ExTree (fops->tree);
  654. X+         continue;
  655. X+     }
  656. X+ 
  657. X+ /* Scan the path for an executable */
  658. X+ 
  659. X+     sp = (any ('/', cp) || (*(cp + 1) == ':')) ? null : path->value;
  660. X+     found = FALSE;
  661. X+ 
  662. X      do
  663. X      {
  664. X!         sp = path_append (sp, cp, l_path);
  665. X!         ep = &l_path[strlen (l_path)];
  666. X  
  667. X  /* Get start of file name */
  668. X  
  669. X!         if ((xp1 = strrchr (l_path, '/')) == (char *)NULL)
  670. X!         xp1 = l_path;
  671. X          
  672. X          else
  673. X          ++xp1;
  674. X  
  675. X! /* Look up all 5 types */
  676. X  
  677. X!         for (i = 0; (i < 5) && !found; i++)
  678. X          {
  679. X          strcpy (ep, type_ext[i]);
  680. X  
  681. X!         if (access (l_path, F_OK) == 0)
  682. X          {
  683. X  
  684. X  /* If no extension or .sh extension, check for shell script */
  685. X***************
  686. X*** 1692,1708 ****
  687. X              if (((xp = strchr (xp1, '.')) == (char *)NULL) ||
  688. X              (stricmp (xp, ".sh") == 0))
  689. X              {
  690. X!             if ((fp = Check_Script (e.linep)) < 0)
  691. X                  continue;
  692. X  
  693. X              S_close (fp, TRUE);
  694. X              }
  695. X  
  696. X              else if ((stricmp (xp, ".exe") != 0) &&
  697. X!                  (stricmp (xp, ".com") != 0))
  698. X              continue;
  699. X  
  700. X!             print_error ("%s is %s\n", cp, e.linep);
  701. X              found = TRUE;
  702. X          }
  703. X          }
  704. X--- 1828,1846 ----
  705. X              if (((xp = strchr (xp1, '.')) == (char *)NULL) ||
  706. X              (stricmp (xp, ".sh") == 0))
  707. X              {
  708. X!             if ((fp = Check_Script (l_path, (char **)NULL,
  709. X!                         (int *)NULL)) < 0)
  710. X                  continue;
  711. X  
  712. X              S_close (fp, TRUE);
  713. X              }
  714. X  
  715. X              else if ((stricmp (xp, ".exe") != 0) &&
  716. X!                  (stricmp (xp, ".com") != 0) &&
  717. X!                  (stricmp (xp, ".bat") != 0))
  718. X              continue;
  719. X  
  720. X!             print_error ("%s is %s\n", cp, l_path);
  721. X              found = TRUE;
  722. X          }
  723. X          }
  724. X***************
  725. X*** 1730,1736 ****
  726. X--- 1868,1876 ----
  727. X      "exit",        doexit,
  728. X      "export",    doexport,
  729. X      "getopt",    dogetopt,
  730. X+ #ifndef NO_HISTORY
  731. X      "history",    dohistory,
  732. X+ #endif
  733. X      "msdos",    domsdos,
  734. X      "pwd",        dopwd,
  735. X      "read",        doread,
  736. X***************
  737. X*** 1766,1772 ****
  738. X          return bp->fn;
  739. X      }
  740. X  
  741. X!     return NULL;
  742. X  }
  743. X  
  744. X  /* Write to stdout functions - printf, fputs, fputc, and a special */
  745. X--- 1906,1912 ----
  746. X          return bp->fn;
  747. X      }
  748. X  
  749. X!     return (int (*)())NULL;
  750. X  }
  751. X  
  752. X  /* Write to stdout functions - printf, fputs, fputc, and a special */
  753. X***************
  754. X*** 1811,1832 ****
  755. X  }
  756. X  
  757. X  /*
  758. X-  * Write n characters to STDOUT
  759. X-  */
  760. X- 
  761. X- static void    v1_putsn (s, n)
  762. X- char        *s;
  763. X- int        n;
  764. X- {
  765. X-     write (STDOUT_FILENO, s, n);
  766. X- }
  767. X- 
  768. X- /*
  769. X   * Write 1 character to STDOUT
  770. X   */
  771. X  
  772. X  void        v1_putc (c)
  773. X  char        c;
  774. X  {
  775. X!     write (STDOUT_FILENO, &c, 1);
  776. X  }
  777. X--- 1951,1962 ----
  778. X  }
  779. X  
  780. X  /*
  781. X   * Write 1 character to STDOUT
  782. X   */
  783. X  
  784. X  void        v1_putc (c)
  785. X  char        c;
  786. X  {
  787. X!     if ((c != 0x07) || Ring_Bell ())
  788. X!     write (STDOUT_FILENO, &c, 1);
  789. X  }
  790. XIndex: shell/sh9.c
  791. XPrereq: 1.2
  792. X*** ../sh15/shell/sh9.c    Mon Feb 19 15:49:13 1990
  793. X--- shell/sh9.c    Tue May  1 19:49:58 1990
  794. X***************
  795. X*** 12,20 ****
  796. X   * 2.  The sources (or parts thereof) or objects generated from the sources
  797. X   *     (or parts of sources) cannot be sold under any circumstances.
  798. X   *
  799. X!  *    $Header: sh9.c 1.2 90/02/19 15:42:39 MS_user Exp $
  800. X   *
  801. X   *    $Log:    sh9.c $
  802. X   * Revision 1.2  90/02/19  15:42:39  MS_user
  803. X   * Remove dependency on ANSI.SYS
  804. X   * 
  805. X--- 12,55 ----
  806. X   * 2.  The sources (or parts thereof) or objects generated from the sources
  807. X   *     (or parts of sources) cannot be sold under any circumstances.
  808. X   *
  809. X!  *    $Header: sh9.c 1.11 90/03/27 20:22:07 MS_user Exp $
  810. X   *
  811. X   *    $Log:    sh9.c $
  812. X+  * Revision 1.11  90/03/27  20:22:07  MS_user
  813. X+  * Fix problem with paging down history file - the last item was incorrect
  814. X+  * 
  815. X+  * Revision 1.10  90/03/26  04:10:53  MS_user
  816. X+  * Scan_History uses the Match length and not the string length for matching
  817. X+  * 
  818. X+  * Revision 1.9  90/03/21  14:05:26  MS_user
  819. X+  * History search sometimes includes the optionals in the search string.
  820. X+  * 
  821. X+  * Revision 1.8  90/03/14  13:23:48  MS_user
  822. X+  * Change names of configuration fields to reflect function
  823. X+  * 
  824. X+  * Revision 1.7  90/03/13  18:36:07  MS_user
  825. X+  * Add initialisation file processing
  826. X+  * 
  827. X+  * Revision 1.6  90/03/09  16:07:40  MS_user
  828. X+  * Add SH_ALT_KEYS processing
  829. X+  * Fix bottom line processing so that cursor doesn't disappear
  830. X+  * Fix EGA detection so we get the correct screen size
  831. X+  * 
  832. X+  * Revision 1.5  90/03/06  16:50:57  MS_user
  833. X+  * Add disable history option
  834. X+  * 
  835. X+  * Revision 1.4  90/03/06  15:14:40  MS_user
  836. X+  * Complete changes for file name completion
  837. X+  * Add find Max Lines function
  838. X+  * 
  839. X+  * Revision 1.3  90/03/05  13:54:28  MS_user
  840. X+  * Fix get previous command request
  841. X+  * Add filename completion
  842. X+  * Add Max Columns from BIOS
  843. X+  * Add cursor position check function
  844. X+  * Add !! option
  845. X+  * Change erase to end of line processing to remove ANSI.SYS dependency
  846. X+  * 
  847. X   * Revision 1.2  90/02/19  15:42:39  MS_user
  848. X   * Remove dependency on ANSI.SYS
  849. X   * 
  850. X***************
  851. X*** 38,45 ****
  852. X--- 73,108 ----
  853. X  #include <limits.h>
  854. X  #include <dos.h>
  855. X  #include <unistd.h>
  856. X+ #include <dirent.h>
  857. X  #include "sh.h"
  858. X  
  859. X+ /* Keyboard functions */
  860. X+ 
  861. X+ #define KF_LENGTH        (sizeof (KF_List) / sizeof (KF_List[0]))
  862. X+ #define KF_SCANBACKWARD    0x00        /* Scan backwards in history    */
  863. X+ #define KF_SCANFOREWARD    0x01        /* Scan forewards in history    */
  864. X+ #define KF_PREVIOUS    0x02        /* Previous command        */
  865. X+ #define KF_NEXT        0x03        /* Next command            */
  866. X+ #define KF_LEFT        0x04        /* Left one character        */
  867. X+ #define KF_RIGHT    0x05        /* Right one character        */
  868. X+ #define KF_WORDRIGHT    0x06        /* Right one word        */
  869. X+ #define KF_WORDLEFT    0x07        /* Left one word        */
  870. X+ #define KF_START    0x08        /* Move to start of line    */
  871. X+ #define KF_CLEAR    0x09        /* Clear input line        */
  872. X+ #define KF_FLUSH    0x0a        /* Flush to end of line        */
  873. X+ #define KF_END        0x0b        /* End of line            */
  874. X+ #define KF_INSERT    0x0c        /* Insert mode switch        */
  875. X+ #define KF_DELETERIGHT    0x0d        /* Delete right character    */    
  876. X+ #define KF_DELETELEFT    0x0e        /* Delete left character    */
  877. X+ #define KF_COMPLETE    0x0f        /* Complete file name        */
  878. X+ #define KF_DIRECTORY    0x10        /* Complete directory function    */
  879. X+ #define KF_END_FKEYS    0x11        /* End of function keys        */
  880. X+ #define KF_RINGBELL    0x11        /* Ring bell            */
  881. X+ #define KF_HALFHEIGTH    0x12        /* Half height cursor        */
  882. X+ 
  883. X+ /* Function Declarations */
  884. X+ 
  885. X+ #ifndef NO_HISTORY
  886. X  static bool    alpha_numeric (int);
  887. X  static bool    function (int);
  888. X  static bool    Process_History (int);
  889. X***************
  890. X*** 50,68 ****
  891. X  static bool    UpDate_CLine (char *);
  892. X  static bool    Re_start (char *);
  893. X  static void    memrcpy (char *, char *, int);
  894. X- static void    read_cursor_position (void);
  895. X  static void    set_cursor_position (int);
  896. X  static void    gen_cursor_position (void);
  897. X  static void    erase_to_end_of_line (void);
  898. X  
  899. X  static bool    insert_mode = FALSE;
  900. X  static char    *c_buffer_pos;        /* Position in command line    */
  901. X  static char    *end_buffer;        /* End of command line        */
  902. X- static int    s_cursor;        /* Start cursor position    */
  903. X  static int    m_line = 0;        /* Max write line number    */
  904. X  static int    c_history = -1;        /* Current entry        */
  905. X  static int    l_history = 0;        /* End of history array        */
  906. X  static int    M_length = -1;        /* Match length            */
  907. X  static char    l_buffer[LINE_MAX + 1];
  908. X  static char    *No_prehistory   = "history: No previous commands";
  909. X  static char    *No_MatchHistory = "history: No history match found";
  910. X--- 113,140 ----
  911. X  static bool    UpDate_CLine (char *);
  912. X  static bool    Re_start (char *);
  913. X  static void    memrcpy (char *, char *, int);
  914. X  static void    set_cursor_position (int);
  915. X  static void    gen_cursor_position (void);
  916. X  static void    erase_to_end_of_line (void);
  917. X+ static void    set_cursor_shape (bool);
  918. X+ static bool    Complete_file (char *, bool);
  919. X+ static void    Init_Input (bool);
  920. X+ #endif
  921. X+ static void    read_cursor_position (void);
  922. X+ static void    Get_Screen_Params (void);
  923. X  
  924. X+ static int    s_cursor;        /* Start cursor position    */
  925. X+ static int    Max_Cols  = 80;        /* Max columns            */
  926. X+ static int    Max_Lines = 25;        /* Max Lines            */
  927. X+ #ifndef NO_HISTORY
  928. X  static bool    insert_mode = FALSE;
  929. X  static char    *c_buffer_pos;        /* Position in command line    */
  930. X  static char    *end_buffer;        /* End of command line        */
  931. X  static int    m_line = 0;        /* Max write line number    */
  932. X  static int    c_history = -1;        /* Current entry        */
  933. X  static int    l_history = 0;        /* End of history array        */
  934. X  static int    M_length = -1;        /* Match length            */
  935. X+ static int    Max_Length = 0;        /* Max line length        */
  936. X  static char    l_buffer[LINE_MAX + 1];
  937. X  static char    *No_prehistory   = "history: No previous commands";
  938. X  static char    *No_MatchHistory = "history: No history match found";
  939. X***************
  940. X*** 70,77 ****
  941. X  static char    *History_2long   = "history: History line too long";
  942. X  static char    *H_TooLongI = "History file line too long - ignored (%d)\n";
  943. X  
  944. X! /* Arrary of history Items */
  945. X  
  946. X  static struct    cmd_history {
  947. X      int        number;
  948. X      char    *command;
  949. X--- 142,181 ----
  950. X  static char    *History_2long   = "history: History line too long";
  951. X  static char    *H_TooLongI = "History file line too long - ignored (%d)\n";
  952. X  
  953. X! /* Function Key table */
  954. X  
  955. X+ static struct Key_Fun_List {
  956. X+     char    *kf_name;
  957. X+     char    akey;
  958. X+     char    fkey;
  959. X+     char    fcode;
  960. X+ } KF_List[] = {
  961. X+     { "ScanBackward",    0,    'I',    KF_SCANBACKWARD },
  962. X+     { "ScanForeward",    0,    'Q',    KF_SCANFOREWARD },
  963. X+     { "Previous",    0,    'H',    KF_PREVIOUS },
  964. X+     { "Next",        0,    'P',    KF_NEXT },
  965. X+     { "Left",        0,    'K',    KF_LEFT },
  966. X+     { "Right",        0,    'M',    KF_RIGHT },
  967. X+     { "WordRight",    0,    't',    KF_WORDRIGHT },
  968. X+     { "WordLeft",    0,    's',    KF_WORDLEFT },
  969. X+     { "Start",        0,    'G',    KF_START },
  970. X+     { "Clear",        0,    'v',    KF_CLEAR },
  971. X+     { "Flush",        0,    'u',    KF_FLUSH },
  972. X+     { "End",        0,    'O',    KF_END },
  973. X+     { "Insert",        0,    'R',    KF_INSERT },
  974. X+     { "DeleteRight",    0,    'S',    KF_DELETERIGHT },
  975. X+     { "DeleteLeft",    0x08,    0,    KF_DELETELEFT },
  976. X+     { "Complete",    0,    'w',    KF_COMPLETE },
  977. X+     { "Directory",    0,    0x0f,    KF_DIRECTORY },
  978. X+ 
  979. X+ /* End of function keys - flags */
  980. X+ 
  981. X+     { "Bell",        1,    0,    KF_RINGBELL },
  982. X+     { "HalfHeight",    0,    0,    KF_HALFHEIGTH }
  983. X+ };
  984. X+ 
  985. X+ /* Arrary of history Items */
  986. X+ 
  987. X  static struct    cmd_history {
  988. X      int        number;
  989. X      char    *command;
  990. X***************
  991. X*** 119,149 ****
  992. X  
  993. X  static void    Process_Stdin ()
  994. X  {
  995. X      int        i;
  996. X-     char    *control = "^x";
  997. X  
  998. X  /* Set to last history item */
  999. X  
  1000. X!     c_history = l_history - 1;
  1001. X  
  1002. X  /* Process the input */
  1003. X  
  1004. X      while (TRUE)
  1005. X      {
  1006. X!     c_buffer_pos = l_buffer;    /* Initialise            */
  1007. X!     end_buffer = l_buffer;
  1008. X!     insert_mode = FALSE;
  1009. X!     M_length = -1;
  1010. X!     read_cursor_position ();
  1011. X  
  1012. X!     while (((i = getch ()) != 0x1a) && (i != NL) && (i != '\r'))
  1013. X      {
  1014. X  
  1015. X! /* Re-position the line? */
  1016. X  
  1017. X!         if (((i) ? alpha_numeric (i) : function (getch ())))
  1018. X!         Redisplay_Line ();
  1019. X  
  1020. X  /* Reposition the cursor */
  1021. X  
  1022. X          gen_cursor_position ();
  1023. X--- 223,270 ----
  1024. X  
  1025. X  static void    Process_Stdin ()
  1026. X  {
  1027. X+     char    a_key, f_key;
  1028. X      int        i;
  1029. X  
  1030. X  /* Set to last history item */
  1031. X  
  1032. X!     c_history = l_history;
  1033. X  
  1034. X  /* Process the input */
  1035. X  
  1036. X      while (TRUE)
  1037. X      {
  1038. X!     Init_Input (FALSE);            /* Initialise        */
  1039. X  
  1040. X!     while (((a_key = (char)getch ()) != 0x1a) && (a_key != NL) &&
  1041. X!         (a_key != '\r'))
  1042. X      {
  1043. X  
  1044. X! /* If function key, get the fkey value */
  1045. X!     
  1046. X!         if (!a_key)
  1047. X!         f_key = (char)getch ();
  1048. X  
  1049. X! /* Look up the keystroke to see if it is one of our functions */
  1050. X  
  1051. X+         for (i = 0; (i < KF_END_FKEYS); ++i)
  1052. X+         {
  1053. X+         if (KF_List[i].akey != a_key)
  1054. X+             continue;
  1055. X+         
  1056. X+         if ((a_key != 0) || (KF_List[i].fkey == f_key))
  1057. X+             break;
  1058. X+         }
  1059. X+ 
  1060. X+ /* If this is a function key and is not ours, ignore it */
  1061. X+ 
  1062. X+         if ((i == KF_END_FKEYS) && (!a_key))
  1063. X+         continue;
  1064. X+ 
  1065. X+         if (((i == KF_END_FKEYS) ? alpha_numeric (a_key)
  1066. X+                   : function (KF_List[i].fcode)))
  1067. X+         Redisplay_Line ();
  1068. X+ 
  1069. X  /* Reposition the cursor */
  1070. X  
  1071. X          gen_cursor_position ();
  1072. X***************
  1073. X*** 153,158 ****
  1074. X--- 274,280 ----
  1075. X  
  1076. X      *end_buffer = 0;
  1077. X      v1_putc (NL);
  1078. X+     s_cursor = -1;
  1079. X  
  1080. X  /* Line input - check for history */
  1081. X  
  1082. X***************
  1083. X*** 164,176 ****
  1084. X  
  1085. X      else if (*l_buffer != '!')
  1086. X          break;
  1087. X- 
  1088. X- /* Output prompt and try again */
  1089. X- 
  1090. X-     Re_start ((char *)NULL);
  1091. X      }
  1092. X  
  1093. X!     *end_buffer = (char)((i == '\r') ? NL : i);
  1094. X  }
  1095. X  
  1096. X  /* Handler Alpha_numeric characters */
  1097. X--- 286,295 ----
  1098. X  
  1099. X      else if (*l_buffer != '!')
  1100. X          break;
  1101. X      }
  1102. X  
  1103. X!     set_cursor_shape (FALSE);
  1104. X!     *end_buffer = (char)((a_key == '\r') ? NL : a_key);
  1105. X  }
  1106. X  
  1107. X  /* Handler Alpha_numeric characters */
  1108. X***************
  1109. X*** 180,206 ****
  1110. X  {
  1111. X      bool    redisplay = FALSE;
  1112. X  
  1113. X- /* Backspace processing */
  1114. X- 
  1115. X-     if (c == 0x08)
  1116. X-     {
  1117. X-     if (c_buffer_pos == l_buffer)
  1118. X-     {
  1119. X-         v1_putc (0x07);        /* Ring bell            */
  1120. X-         return FALSE;
  1121. X-     }
  1122. X- 
  1123. X- /* Decrement current position */
  1124. X- 
  1125. X-     if ((c_buffer_pos--) == end_buffer)
  1126. X-         --end_buffer;
  1127. X- 
  1128. X-     else
  1129. X-         *c_buffer_pos = ' ';
  1130. X- 
  1131. X-         return TRUE;
  1132. X-     }
  1133. X- 
  1134. X  /* Normal character processing */
  1135. X  
  1136. X      if ((c_buffer_pos - l_buffer) == LINE_MAX)
  1137. X--- 299,304 ----
  1138. X***************
  1139. X*** 254,278 ****
  1140. X  static bool    function (fn)
  1141. X  int        fn;
  1142. X  {
  1143. X      switch (fn)
  1144. X      {
  1145. X!     case 'I':            /* Scan back command line    */
  1146. X!     case 'Q':            /* Scan up command line        */
  1147. X!         if (M_length == -1)
  1148. X!         break;
  1149. X  
  1150. X!         Page_History ((fn == 'I') ? -1 : 1);
  1151. X          return TRUE;
  1152. X  
  1153. X!     case 'H':            /* Previous command line    */
  1154. X          Process_History (-1);
  1155. X          return TRUE;
  1156. X  
  1157. X!     case 'P':            /* Next command line        */
  1158. X          Process_History (1);
  1159. X          return TRUE;
  1160. X  
  1161. X!     case 'K':            /* Cursor left            */
  1162. X          if (c_buffer_pos != l_buffer)
  1163. X          --c_buffer_pos;
  1164. X  
  1165. X--- 352,381 ----
  1166. X  static bool    function (fn)
  1167. X  int        fn;
  1168. X  {
  1169. X+     bool    fn_search = FALSE;
  1170. X+ 
  1171. X      switch (fn)
  1172. X      {
  1173. X!     case KF_SCANBACKWARD:        /* Scan backwards in history    */
  1174. X!     case KF_SCANFOREWARD:        /* Scan forewards in history    */
  1175. X!         *end_buffer = 0;
  1176. X  
  1177. X!         if (M_length == -1)
  1178. X!         M_length = strlen (l_buffer);
  1179. X! 
  1180. X!         Page_History ((fn == KF_SCANBACKWARD) ? -1 : 1);
  1181. X          return TRUE;
  1182. X  
  1183. X!     case KF_PREVIOUS:        /* Previous command        */
  1184. X!         *end_buffer = 0;
  1185. X          Process_History (-1);
  1186. X          return TRUE;
  1187. X  
  1188. X!     case KF_NEXT:            /* Next command line        */
  1189. X          Process_History (1);
  1190. X          return TRUE;
  1191. X  
  1192. X!     case KF_LEFT:            /* Cursor left            */
  1193. X          if (c_buffer_pos != l_buffer)
  1194. X          --c_buffer_pos;
  1195. X  
  1196. X***************
  1197. X*** 281,287 ****
  1198. X  
  1199. X          return FALSE;
  1200. X  
  1201. X!     case 'M':            /* Cursor right            */
  1202. X          if (c_buffer_pos != end_buffer)
  1203. X          ++c_buffer_pos;
  1204. X  
  1205. X--- 384,390 ----
  1206. X  
  1207. X          return FALSE;
  1208. X  
  1209. X!     case KF_RIGHT:            /* Cursor right            */
  1210. X          if (c_buffer_pos != end_buffer)
  1211. X          ++c_buffer_pos;
  1212. X  
  1213. X***************
  1214. X*** 290,296 ****
  1215. X  
  1216. X          return FALSE;
  1217. X  
  1218. X!     case 's':            /* Cursor left a word        */
  1219. X          if (c_buffer_pos != l_buffer)
  1220. X          {
  1221. X          --c_buffer_pos;        /* Reposition on previous char    */
  1222. X--- 393,399 ----
  1223. X  
  1224. X          return FALSE;
  1225. X  
  1226. X!     case KF_WORDLEFT:        /* Cursor left a word        */
  1227. X          if (c_buffer_pos != l_buffer)
  1228. X          {
  1229. X          --c_buffer_pos;        /* Reposition on previous char    */
  1230. X***************
  1231. X*** 310,316 ****
  1232. X  
  1233. X          return FALSE;
  1234. X  
  1235. X!     case 't':            /* Cursor right a word        */
  1236. X          if (c_buffer_pos != end_buffer)
  1237. X          {
  1238. X  
  1239. X--- 413,419 ----
  1240. X  
  1241. X          return FALSE;
  1242. X  
  1243. X!     case KF_WORDRIGHT:        /* Cursor right a word        */
  1244. X          if (c_buffer_pos != end_buffer)
  1245. X          {
  1246. X  
  1247. X***************
  1248. X*** 330,345 ****
  1249. X  
  1250. X          return FALSE;
  1251. X  
  1252. X!     case 'G':            /* Cursor home            */
  1253. X          c_buffer_pos = l_buffer;
  1254. X          return FALSE;
  1255. X  
  1256. X!     case 'u':            /* Flush to end            */
  1257. X          memset (c_buffer_pos, ' ', end_buffer - c_buffer_pos);
  1258. X          end_buffer = c_buffer_pos;
  1259. X          return TRUE;
  1260. X  
  1261. X!     case 'O':            /* Cursor end of command    */
  1262. X          if (*l_buffer == '!')
  1263. X          {
  1264. X          *end_buffer = 0;
  1265. X--- 433,451 ----
  1266. X  
  1267. X          return FALSE;
  1268. X  
  1269. X!     case KF_START:            /* Cursor home            */
  1270. X          c_buffer_pos = l_buffer;
  1271. X          return FALSE;
  1272. X  
  1273. X!     case KF_CLEAR:            /* Erase buffer            */
  1274. X!         c_buffer_pos = l_buffer;
  1275. X! 
  1276. X!     case KF_FLUSH:            /* Flush to end            */
  1277. X          memset (c_buffer_pos, ' ', end_buffer - c_buffer_pos);
  1278. X          end_buffer = c_buffer_pos;
  1279. X          return TRUE;
  1280. X  
  1281. X!     case KF_END:            /* Cursor end of command    */
  1282. X          if (*l_buffer == '!')
  1283. X          {
  1284. X          *end_buffer = 0;
  1285. X***************
  1286. X*** 350,364 ****
  1287. X          c_buffer_pos = end_buffer;
  1288. X          return FALSE;
  1289. X  
  1290. X!     case 'R':            /* Switch insert mode        */
  1291. X          insert_mode = (insert_mode) ? FALSE : TRUE;
  1292. X          return FALSE;
  1293. X  
  1294. X!     case 'S':            /* Delete character        */
  1295. X!         if (c_buffer_pos != end_buffer)
  1296. X!         memcpy (c_buffer_pos, c_buffer_pos + 1,
  1297. X!             end_buffer - c_buffer_pos);
  1298. X  
  1299. X          if (end_buffer == l_buffer)
  1300. X          {
  1301. X          v1_putc (0x07);
  1302. X--- 456,472 ----
  1303. X          c_buffer_pos = end_buffer;
  1304. X          return FALSE;
  1305. X  
  1306. X!     case KF_INSERT:            /* Switch insert mode        */
  1307. X          insert_mode = (insert_mode) ? FALSE : TRUE;
  1308. X+         set_cursor_shape (insert_mode);
  1309. X          return FALSE;
  1310. X  
  1311. X!     case KF_DELETERIGHT:        /* Delete right character    */
  1312. X!         if (c_buffer_pos == end_buffer)
  1313. X!         return FALSE;
  1314. X  
  1315. X+         memcpy (c_buffer_pos, c_buffer_pos + 1, end_buffer - c_buffer_pos);
  1316. X+ 
  1317. X          if (end_buffer == l_buffer)
  1318. X          {
  1319. X          v1_putc (0x07);
  1320. X***************
  1321. X*** 369,380 ****
  1322. X          --c_buffer_pos;
  1323. X  
  1324. X             return TRUE;
  1325. X-     }
  1326. X  
  1327. X!     v1_putc (0x07);
  1328. X!     return FALSE;
  1329. X! }
  1330. X  
  1331. X  /* Read Cursor position */
  1332. X  
  1333. X  static void    read_cursor_position ()
  1334. X--- 477,539 ----
  1335. X          --c_buffer_pos;
  1336. X  
  1337. X             return TRUE;
  1338. X  
  1339. X!     case KF_DIRECTORY:        /* File name directory        */
  1340. X!         fn_search = TRUE;
  1341. X  
  1342. X+     case KF_COMPLETE:        /* File name completion        */
  1343. X+     {
  1344. X+         char    *fn_start = c_buffer_pos;
  1345. X+ 
  1346. X+         *end_buffer = 0;
  1347. X+ 
  1348. X+         if (isspace (*fn_start))
  1349. X+         --fn_start;
  1350. X+         
  1351. X+         if (isspace (*fn_start) || (fn_start < l_buffer))
  1352. X+         break;
  1353. X+ 
  1354. X+         return Complete_file (fn_start, fn_search);
  1355. X+     }
  1356. X+ 
  1357. X+     case KF_DELETELEFT:        /* Delete left character    */
  1358. X+         if (c_buffer_pos == l_buffer)
  1359. X+         {
  1360. X+         v1_putc (0x07);        /* Ring bell            */
  1361. X+         return FALSE;
  1362. X+         }
  1363. X+ 
  1364. X+ /* Decrement current position */
  1365. X+ 
  1366. X+         --c_buffer_pos;
  1367. X+         memcpy (c_buffer_pos, c_buffer_pos + 1, end_buffer - c_buffer_pos);
  1368. X+         --end_buffer;
  1369. X+         return TRUE;
  1370. X+     }
  1371. X+ }
  1372. X+ 
  1373. X+ /* Set cursor shape */
  1374. X+ 
  1375. X+ static void    set_cursor_shape (mode)
  1376. X+ bool        mode;
  1377. X+ {
  1378. X+     union REGS        r;
  1379. X+ 
  1380. X+ /* Get the current cursor position to get the cursor lines */
  1381. X+ 
  1382. X+     r.h.ah = 0x03;        
  1383. X+     int86 (0x10, &r, &r);
  1384. X+ 
  1385. X+ /* Reset the type */
  1386. X+ 
  1387. X+     r.h.ah = 0x01;
  1388. X+     r.h.ch = (unsigned char)(!mode ? r.h.cl - 1
  1389. X+                    : (KF_List[KF_HALFHEIGTH].akey
  1390. X+                     ? (r.h.cl / 2) + 1 : 1));
  1391. X+     int86 (0x10, &r, &r);
  1392. X+ }
  1393. X+ #endif
  1394. X+ 
  1395. X  /* Read Cursor position */
  1396. X  
  1397. X  static void    read_cursor_position ()
  1398. X***************
  1399. X*** 384,416 ****
  1400. X      r.h.ah = 0x03;                /* Read cursor position    */
  1401. X      r.h.bh = 0;                    /* Page zero        */
  1402. X      int86 (0x10, &r, &r);
  1403. X!     s_cursor = (r.h.dh * 80) + r.h.dl;
  1404. X!     m_line = r.h.dh;
  1405. X  }
  1406. X  
  1407. X  /* Re-position the cursor */
  1408. X  
  1409. X  static void    set_cursor_position (new)
  1410. X  int        new;
  1411. X  {
  1412. X      union REGS    r;
  1413. X  
  1414. X      r.h.ah = 0x02;                /* Set new position    */
  1415. X      r.h.bh = 0;                    /* Page zero        */
  1416. X!     r.h.dh = (unsigned char)(new / 80);
  1417. X!     r.h.dl = (unsigned char)(new % 80);
  1418. X  
  1419. X  /* Are we at the bottom of the page? */
  1420. X  
  1421. X!     if (r.h.dh == 25)
  1422. X      {
  1423. X!     r.h.dh = 24;
  1424. X!     s_cursor -= 80;
  1425. X      }
  1426. X  
  1427. X-     if (m_line < r.h.dh)
  1428. X-     m_line = r.h.dh;
  1429. X- 
  1430. X      int86 (0x10, &r, &r);
  1431. X  }
  1432. X  
  1433. X--- 543,574 ----
  1434. X      r.h.ah = 0x03;                /* Read cursor position    */
  1435. X      r.h.bh = 0;                    /* Page zero        */
  1436. X      int86 (0x10, &r, &r);
  1437. X!     s_cursor = (r.h.dh * Max_Cols) + r.h.dl;
  1438. X  }
  1439. X  
  1440. X  /* Re-position the cursor */
  1441. X  
  1442. X+ #ifndef NO_HISTORY
  1443. X  static void    set_cursor_position (new)
  1444. X  int        new;
  1445. X  {
  1446. X+     int        diff;
  1447. X      union REGS    r;
  1448. X  
  1449. X      r.h.ah = 0x02;                /* Set new position    */
  1450. X      r.h.bh = 0;                    /* Page zero        */
  1451. X!     r.h.dh = (unsigned char)(new / Max_Cols);
  1452. X!     r.h.dl = (unsigned char)(new % Max_Cols);
  1453. X  
  1454. X  /* Are we at the bottom of the page? */
  1455. X  
  1456. X!     if (r.h.dh >= (unsigned char)Max_Lines)
  1457. X      {
  1458. X!     diff = r.h.dh + 1 - Max_Lines;
  1459. X!     r.h.dh = (unsigned char)(Max_Lines - 1);
  1460. X!     s_cursor -= Max_Cols * diff;
  1461. X      }
  1462. X  
  1463. X      int86 (0x10, &r, &r);
  1464. X  }
  1465. X  
  1466. X***************
  1467. X*** 418,433 ****
  1468. X  
  1469. X  static void    erase_to_end_of_line ()
  1470. X  {
  1471. X!     union REGS    r;
  1472. X  
  1473. X!     r.h.ah = 0x03;
  1474. X      r.h.bh = 0;
  1475. X      int86 (0x10, &r, &r);
  1476. X  
  1477. X!     if ((r.x.cx = 80 - r.h.dl + (m_line - r.h.dh) * 80) > 0)
  1478. X      {
  1479. X!     r.x.ax = 0x0920;
  1480. X!     r.x.bx = 0x0007;
  1481. X      int86 (0x10, &r, &r);
  1482. X      }
  1483. X  }
  1484. X--- 576,604 ----
  1485. X  
  1486. X  static void    erase_to_end_of_line ()
  1487. X  {
  1488. X!     union REGS        r;
  1489. X!     unsigned char    backg;
  1490. X  
  1491. X! /* Get the background attribute of the cursor */
  1492. X! 
  1493. X!     r.h.ah = 0x08;
  1494. X      r.h.bh = 0;
  1495. X      int86 (0x10, &r, &r);
  1496. X+     backg = r.h.ah & 0x07;
  1497. X  
  1498. X!     r.h.ah = 0x03;
  1499. X!     r.h.bh = 0;
  1500. X!     int86 (0x10, &r, &r);
  1501. X! 
  1502. X! /* Check that we use the correct m_line */
  1503. X! 
  1504. X!     if (m_line < r.h.dh) 
  1505. X!     m_line = r.h.dh;
  1506. X! 
  1507. X!     if ((r.x.cx = Max_Cols - r.h.dl + (m_line - r.h.dh) * Max_Cols) > 0)
  1508. X      {
  1509. X!     r.x.ax = 0x0a20;
  1510. X!     r.x.bx = backg;
  1511. X      int86 (0x10, &r, &r);
  1512. X      }
  1513. X  }
  1514. X***************
  1515. X*** 498,504 ****
  1516. X--- 669,679 ----
  1517. X      ++cp;
  1518. X      }
  1519. X  
  1520. X+     if ((m_line = ((s_cursor + Max_Length) / Max_Cols) + 1) >= Max_Lines)
  1521. X+     m_line = Max_Lines - 1;
  1522. X+ 
  1523. X      erase_to_end_of_line ();        /* clear to end of line    */
  1524. X+     Max_Length = end_buffer - l_buffer;
  1525. X  }
  1526. X  
  1527. X  /* Process history command
  1528. X***************
  1529. X*** 523,529 ****
  1530. X      case -1:            /* Move up one line        */
  1531. X          if (c_history < 0)
  1532. X          {
  1533. X!         ++c_history;
  1534. X          return Re_start (No_prehistory);
  1535. X          }
  1536. X  
  1537. X--- 698,704 ----
  1538. X      case -1:            /* Move up one line        */
  1539. X          if (c_history < 0)
  1540. X          {
  1541. X!         c_history = -1;
  1542. X          return Re_start (No_prehistory);
  1543. X          }
  1544. X  
  1545. X***************
  1546. X*** 532,538 ****
  1547. X      case 1:                /* Move to next history line    */
  1548. X          if (c_history >= l_history)
  1549. X          {
  1550. X!         --c_history;
  1551. X          return Re_start (No_posthistory);
  1552. X          }
  1553. X  
  1554. X--- 707,713 ----
  1555. X      case 1:                /* Move to next history line    */
  1556. X          if (c_history >= l_history)
  1557. X          {
  1558. X!         c_history = l_history;
  1559. X          return Re_start (No_posthistory);
  1560. X          }
  1561. X  
  1562. X***************
  1563. X*** 545,569 ****
  1564. X  /* Find the end of the first part */
  1565. X  
  1566. X          while (!isspace (*optionals) && *optionals)
  1567. X!         ++optionals;
  1568. X  
  1569. X! /* Terminate the history command */
  1570. X  
  1571. X!         if (*optionals)
  1572. X!         *(optionals++) = 0;
  1573. X  
  1574. X! /* Find the end of the space separator part which gives the start of the
  1575. X!  * optionals
  1576. X!  */
  1577. X  
  1578. X!         while (isspace (*optionals))
  1579. X!         ++optionals;
  1580. X  
  1581. X  
  1582. X! /* Copy selected item into line buffer */
  1583. X  
  1584. X      case 2:
  1585. X!         M_length = strlen (l_buffer) - 1;
  1586. X          if (!Scan_History ())
  1587. X          return FALSE;
  1588. X  
  1589. X--- 720,759 ----
  1590. X  /* Find the end of the first part */
  1591. X  
  1592. X          while (!isspace (*optionals) && *optionals)
  1593. X!         {
  1594. X!         if (*optionals == '!')
  1595. X!         {
  1596. X  
  1597. X! /* Terminate at !! */
  1598. X  
  1599. X!             if (*(optionals + 1) == '!')
  1600. X!             {                    
  1601. X!             optionals += 2;
  1602. X!             break;
  1603. X!             }
  1604. X  
  1605. X! /* Terminate at a numeric value */
  1606. X  
  1607. X!             else if (isdigit (*(optionals + 1)) ||
  1608. X!                  (*(optionals + 1) == '-'))
  1609. X!             {
  1610. X!             optionals += 2;
  1611. X!             while (isdigit (*optionals))
  1612. X!                 ++optionals;
  1613. X  
  1614. X+             break;
  1615. X+             }
  1616. X+         }
  1617. X  
  1618. X!         ++optionals;
  1619. X!         }
  1620. X  
  1621. X+ /* Copy selected item into line buffer */
  1622. X+ 
  1623. X      case 2:
  1624. X!         M_length = (optionals == null) ? strlen (l_buffer) - 1
  1625. X!                        : optionals - l_buffer - 1;
  1626. X! 
  1627. X          if (!Scan_History ())
  1628. X          return FALSE;
  1629. X  
  1630. X***************
  1631. X*** 588,604 ****
  1632. X      return Re_start (History_2long);
  1633. X  
  1634. X      if (end_buffer > optionals)
  1635. X!     memrcpy (end_buffer + 1 + opt_len, optionals + opt_len, opt_len + 1);
  1636. X  
  1637. X      else
  1638. X!     strcpy (end_buffer + 1, optionals);
  1639. X  
  1640. X!     strcpy (l_buffer, cmd_history[c_history].command);
  1641. X! 
  1642. X!     if (opt_len)
  1643. X!     *end_buffer = ' ';
  1644. X! 
  1645. X      end_buffer = &l_buffer[strlen (l_buffer)];
  1646. X      return TRUE;
  1647. X  }
  1648. X  
  1649. X--- 778,791 ----
  1650. X      return Re_start (History_2long);
  1651. X  
  1652. X      if (end_buffer > optionals)
  1653. X!     memrcpy (end_buffer + opt_len, optionals + opt_len, opt_len + 1);
  1654. X  
  1655. X      else
  1656. X!     strcpy (end_buffer, optionals);
  1657. X  
  1658. X!     strncpy (l_buffer, cmd_history[c_history].command, (end_buffer - l_buffer));
  1659. X      end_buffer = &l_buffer[strlen (l_buffer)];
  1660. X+     c_buffer_pos = end_buffer;
  1661. X      return TRUE;
  1662. X  }
  1663. X  
  1664. X***************
  1665. X*** 606,625 ****
  1666. X  
  1667. X  static bool    Scan_History ()
  1668. X  {
  1669. X!     char    *cp = &l_buffer[1];
  1670. X!     int        c_len = strlen (cp);
  1671. X      char    *ep;
  1672. SHAR_EOF
  1673. echo "End of part 4"
  1674. echo "File Patch1.6 is continued in part 5"
  1675. echo "5" > s2_seq_.tmp
  1676. exit 0
  1677.  
  1678.