home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / pc / source / ms_sh16.lzh / ms_sh.4 < prev    next >
Text File  |  1990-05-06  |  39KB  |  1,671 lines

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