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

  1.  
  2. #!/bin/sh
  3. # this is part 3 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=3
  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+     DELETE (local_path);
  20. X+     return FALSE;
  21. X+     }
  22. X+     
  23. X+     res = (access (local_path, X_OK) == 0) ? TRUE : FALSE;
  24. X+     DELETE (local_path);
  25. X+     return res;
  26. X+ }
  27. X+ 
  28. X  /*
  29. X   * Run the command produced by generator `f' applied to stream `arg'.
  30. X   */
  31. X  
  32. X! int        run (argp, f, f_loop)
  33. X  IO_Args        *argp;
  34. X  int        (*f)(IO_State *);
  35. X+ bool        f_loop;
  36. X  {
  37. X      Word_B        *swdlist = wdlist;
  38. X      Word_B        *siolist = iolist;
  39. X***************
  40. X*** 853,868 ****
  41. X      int            rv = -1;
  42. X      Break_C        *S_RList = Return_List;    /* Save loval links    */
  43. X      Break_C        *S_BList = Break_List;
  44. X-     Break_C        *S_SList = SShell_List;
  45. X-     Break_C        bc;
  46. X      int            LS_depth = Execute_stack_depth;
  47. X      C_Op        *outtree;
  48. X  
  49. X- /* Create a new environment in which to run */
  50. X- 
  51. X-     if (Create_NG_VL () == -1)
  52. X-     return -1;
  53. X- 
  54. X  /* Create a new save area */
  55. X  
  56. X      areanum++;
  57. X--- 1039,1049 ----
  58. X      int            rv = -1;
  59. X      Break_C        *S_RList = Return_List;    /* Save loval links    */
  60. X      Break_C        *S_BList = Break_List;
  61. X      int            LS_depth = Execute_stack_depth;
  62. X+     int            sjr;
  63. X      C_Op        *outtree;
  64. X+     int            s_execflg = execflg;
  65. X  
  66. X  /* Create a new save area */
  67. X  
  68. X      areanum++;
  69. X***************
  70. X*** 877,900 ****
  71. X      iolist      = (Word_B *)NULL;
  72. X  
  73. X      pushio (argp, f);
  74. X!     e.iobase = e.iop;
  75. X!     yynerrs = 0;
  76. X  
  77. X! 
  78. X!     if ((setjmp (failpt = rt) == 0) &&
  79. X!         ((outtree = yyparse ()) != (C_Op *)NULL))
  80. X      {
  81. X!         if (setjmp (bc.brkpt) == 0)
  82. X!         {
  83. X!         bc.nextlev = SShell_List;
  84. X!         SShell_List = &bc;
  85. X!         rv = execute (outtree, NOPIPE, NOPIPE, 0);
  86. X!         }
  87. X  
  88. X!         else
  89. X!         rv = getn (lookup ("?", FALSE)->value);
  90. X!     }
  91. X  
  92. X      quitenv ();
  93. X      }
  94. X  
  95. X--- 1058,1091 ----
  96. X      iolist      = (Word_B *)NULL;
  97. X  
  98. X      pushio (argp, f);
  99. X!     e.iobase  = e.iop;
  100. X!     e.eof_p   = (bool)!f_loop;    /* Set EOF processing        */
  101. X!     SW_intr   = 0;
  102. X!     multiline = 0;
  103. X!     inparse   = 0;
  104. X!     execflg   = (!f_loop) ? 1 : execflg;
  105. X  
  106. X! /* Read Input (if f_loop is not set, we are processing a . file command)
  107. X!  * either for one line or until end of file.
  108. X!  */
  109. X!     do
  110. X      {
  111. X!         yynerrs = 0;
  112. X  
  113. X!         if (((sjr = setjmp (failpt = rt)) == 0) &&
  114. X!         ((outtree = yyparse ()) != (C_Op *)NULL))
  115. X!         rv = execute (outtree, NOPIPE, NOPIPE, 0);
  116. X! 
  117. X! /* Fail or no loop - zap any files if necessary */
  118. X  
  119. X+         else if (sjr || f_loop)
  120. X+         {
  121. X+         Clear_Extended_File ();
  122. X+         break;
  123. X+         }
  124. X+ 
  125. X+     } while (!f_loop);
  126. X+ 
  127. X      quitenv ();
  128. X      }
  129. X  
  130. X***************
  131. X*** 902,908 ****
  132. X  
  133. X      Return_List = S_RList;
  134. X      Break_List = S_BList;
  135. X!     SShell_List = S_SList;
  136. X      wdlist = swdlist;
  137. X      iolist = siolist;
  138. X      failpt = ofail;
  139. X--- 1093,1099 ----
  140. X  
  141. X      Return_List = S_RList;
  142. X      Break_List = S_BList;
  143. X!     execflg = s_execflg;
  144. X      wdlist = swdlist;
  145. X      iolist = siolist;
  146. X      failpt = ofail;
  147. X***************
  148. X*** 938,944 ****
  149. X      int            res, serrno;
  150. X      struct MCB_list    *mp = (struct MCB_list *)((unsigned long)c_cur << 16L);
  151. X  
  152. X- 
  153. X  /* Check to see if the file exists */
  154. X  
  155. X      strcpy (path_line, path);
  156. X--- 1129,1134 ----
  157. X***************
  158. X*** 965,971 ****
  159. X  
  160. X      else if ((stricmp (ep1, ".exe") != 0) && (stricmp (ep1, ".com") != 0))
  161. X      {
  162. X!     errno = ENOEXEC;
  163. X      return -1;
  164. X      }
  165. X  
  166. X--- 1155,1163 ----
  167. X  
  168. X      else if ((stricmp (ep1, ".exe") != 0) && (stricmp (ep1, ".com") != 0))
  169. X      {
  170. X!     if (access (path_line, F_OK) == 0)
  171. X!         errno = ENOEXEC;
  172. X! 
  173. X      return -1;
  174. X      }
  175. X  
  176. X***************
  177. X*** 1010,1026 ****
  178. X   * function to swap us out
  179. X   */
  180. X  
  181. X!     get_sys_info ();
  182. X  
  183. X! /* Ok - 3 methods of swapping */
  184. X  
  185. X  /* If expanded memory - try that */
  186. X  
  187. X!     if (Swap_Mode & SWAP_EXPAND)
  188. X      {
  189. X      int    cr;
  190. X-     SW_Mode = 3;            /* Set Expanded memory swap    */
  191. X  
  192. X      res = SA_spawn (envp);
  193. X      cr = EMS_Close ();        /* Close EMS            */
  194. X  
  195. X--- 1202,1222 ----
  196. X   * function to swap us out
  197. X   */
  198. X  
  199. X! /* Save the interrupt 0 and 23 addresses */
  200. X  
  201. X!     SW_I0_V  = _dos_getvect (0x00);
  202. X!     SW_I23_V = _dos_getvect (0x23);
  203. X  
  204. X+ /* Ok - 3 methods of swapping */
  205. X+ 
  206. X  /* If expanded memory - try that */
  207. X  
  208. X!     if ((Swap_Mode & SWAP_EXPAND) && Get_EMS_Driver ())
  209. X      {
  210. X      int    cr;
  211. X  
  212. X+     SW_Mode = 3;            /* Set Expanded memory swap    */
  213. X+ 
  214. X      res = SA_spawn (envp);
  215. X      cr = EMS_Close ();        /* Close EMS            */
  216. X  
  217. X***************
  218. X*** 1044,1063 ****
  219. X      Swap_Mode &= (~SWAP_EXPAND);
  220. X      }
  221. X  
  222. X!     if (Swap_Mode & SWAP_EXTEND)
  223. X      {
  224. X!     SW_Mode = 2;            /* Set Extended memory swap    */
  225. X  
  226. X!         if ((SW_EMsize <= SW_Blocks) ||
  227. X!         ((SW_EMstart - 0x100000L +
  228. X!           ((long)(SW_Blocks - SW_EMsize) * 16L * 1024L)) < 0L))
  229. X!         print_warn ("Not enough Extended memory for swap\n");
  230. X  
  231. X!     else if ((res = SA_spawn (envp)) == -2)
  232. X!         print_warn ("Extended memory swap failed (%x)\n", errno);
  233. X  
  234. X!     else
  235. X      {
  236. X          Clear_Extended_File ();
  237. X          return res;
  238. X      }
  239. X--- 1240,1267 ----
  240. X      Swap_Mode &= (~SWAP_EXPAND);
  241. X      }
  242. X  
  243. X!     if ((Swap_Mode & SWAP_EXTEND) && Get_XMS_Driver ())
  244. X      {
  245. X!     int    cr;
  246. X  
  247. X! /* Set Extended memory or XMS driver */
  248. X  
  249. X!     SW_Mode = (SW_fp == -1) ? 2 : 4;
  250. X  
  251. X!     res = SA_spawn (envp);
  252. X!     cr = XMS_Close ();        /* Close XMS            */
  253. X! 
  254. X!     if ((res != -2) && cr)        /* Report Close error ?        */
  255. X      {
  256. X+         res = -2;
  257. X+         errno = cr;
  258. X+     }
  259. X+ 
  260. X+     if (res == -2)
  261. X+         XMS_error ("Extended memory swap failed (%x)\n", errno);
  262. X+ 
  263. X+     else
  264. X+     {
  265. X          Clear_Extended_File ();
  266. X          return res;
  267. X      }
  268. X***************
  269. X*** 1073,1078 ****
  270. X--- 1277,1283 ----
  271. X      {
  272. X      if ((SW_fp = S_open (TRUE, g_tempname (), O_SMASK, 0600)) < 0)
  273. X      {
  274. X+         Swap_Mode &= (~SWAP_DISK);
  275. X          print_error ("No Swap files\n");
  276. X          errno = ENOSPC;
  277. X          return -1;
  278. X***************
  279. X*** 1088,1093 ****
  280. X--- 1293,1299 ----
  281. X  
  282. X      if (res == -2)
  283. X      {
  284. X+         Swap_Mode &= (~SWAP_DISK);
  285. X          print_warn ("Swap file write failed\n");
  286. X          errno = ENOSPC;
  287. X          res = -1;
  288. X***************
  289. X*** 1109,1145 ****
  290. X      return -1;
  291. X  }
  292. X  
  293. X! /* Get some system info */
  294. X  
  295. X! static void    get_sys_info ()
  296. X  {
  297. X      union REGS        or;
  298. X      struct SREGS    sr;
  299. X!     char        *sp;
  300. X  
  301. X- /* Save the interrupt 0 address */
  302. X- 
  303. X-     SW_I0_V = _dos_getvect (0x00);
  304. X- 
  305. X- /* Save the interrupt 23 address */
  306. X- 
  307. X-     SW_I23_V = _dos_getvect (0x23);
  308. X- 
  309. X  /* Get max Extended memory pages, and convert to 16K blocks.  If Extended
  310. X   * memory swapping disabled, set to zero
  311. X   */
  312. X  
  313. X!     or.x.ax = 0x8800;
  314. X!     int86 (0x15, &or, &or);
  315. X!     SW_EMsize = (Swap_Mode & SWAP_EXTEND) ? or.x.ax / 16 : 0;
  316. X  
  317. X! /* Check for the Expand Memory System */
  318. X  
  319. X!     if (!(Swap_Mode & SWAP_EXPAND))
  320. X!     return;
  321. X  
  322. X!     SW_fp = -1;                /* Set EMS handler not defined    */
  323. X  
  324. X      or.x.ax = 0x3567;
  325. X      intdosx (&or, &or, &sr);
  326. X  
  327. X--- 1315,1382 ----
  328. X      return -1;
  329. X  }
  330. X  
  331. X! /* Get the XMS Driver information */
  332. X  
  333. X! static bool    Get_XMS_Driver ()
  334. X  {
  335. X      union REGS        or;
  336. X      struct SREGS    sr;
  337. X!     unsigned int    SW_EMsize;    /* Number of extend memory blks    */
  338. X  
  339. X  /* Get max Extended memory pages, and convert to 16K blocks.  If Extended
  340. X   * memory swapping disabled, set to zero
  341. X   */
  342. X  
  343. X!     SW_fp = -1;                /* Set EMS/XMS handler not    */
  344. X!                     /* defined            */
  345. X  
  346. X! /* Is a XMS memory driver installed */
  347. X  
  348. X!     or.x.ax = 0x4300;
  349. X!     int86 (0x2f, &or, &or);
  350. X  
  351. X!     if (or.h.al != 0x80)
  352. X!     {
  353. X!     or.x.ax = 0x8800;
  354. X!     int86 (0x15, &or, &or);
  355. X!     SW_EMsize = or.x.ax / 16;
  356. X  
  357. X+     if ((SW_EMsize <= SW_Blocks) ||
  358. X+          ((SW_EMstart - 0x100000L +
  359. X+           ((long)(SW_Blocks - SW_EMsize) * 16L * 1024L)) < 0L))
  360. X+         return XMS_error ("Not enough Extended memory for swap\n", 0);
  361. X+ 
  362. X+     else
  363. X+         return TRUE;
  364. X+     }
  365. X+ 
  366. X+ /* Get the driver interface */
  367. X+ 
  368. X+     or.x.ax = 0x4310;
  369. X+     int86x (0x2f, &or, &or, &sr);
  370. X+     SW_XMS_Driver = (void (*)())((unsigned long)(sr.es) << 16L | or.x.bx);
  371. X+ 
  372. X+     if ((SW_XMS_Gversion () & 0xff00) != 0x0200)
  373. X+     return XMS_error ("Warning: XMS Version != 2\n", 0);
  374. X+ 
  375. X+     else if ((SW_fp = SW_XMS_Allocate (SW_Blocks * 16)) == -1)
  376. X+     return XMS_error (XMS_emsg, errno);
  377. X+ 
  378. X+     return TRUE;
  379. X+ }
  380. X+ 
  381. X+ /* Get the EMS Driver information */
  382. X+ 
  383. X+ static bool    Get_EMS_Driver ()
  384. X+ {
  385. X+     union REGS        or;
  386. X+     struct SREGS    sr;
  387. X+     char        *sp;
  388. X+ 
  389. X+ /* Set EMS/XMS handler not defined */
  390. X+ 
  391. X+     SW_fp = -1;
  392. X+ 
  393. X      or.x.ax = 0x3567;
  394. X      intdosx (&or, &or, &sr);
  395. X  
  396. X***************
  397. X*** 1148,1166 ****
  398. X  /* If not there - disable */
  399. X  
  400. X      if (memcmp ("EMMXXXX0", sp, 8) != 0)
  401. X!     {
  402. X!     EMS_error ("Warning: EMS not available\n", 0);
  403. X!     return;
  404. X!     }
  405. X  
  406. X      or.h.ah = 0x40;            /* Check status            */
  407. X      int86 (0x67, &or, &or);
  408. X  
  409. X      if (or.h.ah != 0)
  410. X!     {
  411. X!     EMS_error (EMS_emsg, or.h.ah);
  412. X!     return;
  413. X!     }
  414. X  
  415. X  /* Check version greater than 3.2 */
  416. X  
  417. X--- 1385,1397 ----
  418. X  /* If not there - disable */
  419. X  
  420. X      if (memcmp ("EMMXXXX0", sp, 8) != 0)
  421. X!     return EMS_error ("Warning: EMS not available\n", 0);
  422. X  
  423. X      or.h.ah = 0x40;            /* Check status            */
  424. X      int86 (0x67, &or, &or);
  425. X  
  426. X      if (or.h.ah != 0)
  427. X!     return EMS_error (EMS_emsg, or.h.ah);
  428. X  
  429. X  /* Check version greater than 3.2 */
  430. X  
  431. X***************
  432. X*** 1168,1177 ****
  433. X      int86 (0x67, &or, &or);
  434. X  
  435. X      if ((or.h.ah != 0) || (or.h.al < 0x32))
  436. X!     {
  437. X!     EMS_error ("Warning: EMS Version < 3.2\n", 0);
  438. X!     return;
  439. X!     }
  440. X  
  441. X  /*  get page frame address */
  442. X  
  443. X--- 1399,1405 ----
  444. X      int86 (0x67, &or, &or);
  445. X  
  446. X      if ((or.h.ah != 0) || (or.h.al < 0x32))
  447. X!     return EMS_error ("Warning: EMS Version < 3.2\n", 0);
  448. X  
  449. X  /*  get page frame address */
  450. X  
  451. X***************
  452. X*** 1179,1188 ****
  453. X      int86 (0x67, &or, &or);
  454. X  
  455. X      if (or.h.ah != 0)
  456. X!     {
  457. X!     EMS_error (EMS_emsg, or.h.ah);
  458. X!     return;
  459. X!     }
  460. X  
  461. X      SW_EMSFrame = or.x.bx;        /* Save the page frame        */
  462. X  
  463. X--- 1407,1413 ----
  464. X      int86 (0x67, &or, &or);
  465. X  
  466. X      if (or.h.ah != 0)
  467. X!     return EMS_error (EMS_emsg, or.h.ah);
  468. X  
  469. X      SW_EMSFrame = or.x.bx;        /* Save the page frame        */
  470. X  
  471. X***************
  472. X*** 1193,1202 ****
  473. X      int86 (0x67, &or, &or);
  474. X  
  475. X      if (or.h.ah != 0)
  476. X!     {
  477. X!     EMS_error (EMS_emsg, or.h.ah);
  478. X!     return;
  479. X!     }
  480. X  
  481. X  /* Save the EMS Handler */
  482. X  
  483. X--- 1418,1424 ----
  484. X      int86 (0x67, &or, &or);
  485. X  
  486. X      if (or.h.ah != 0)
  487. X!     return EMS_error (EMS_emsg, or.h.ah);
  488. X  
  489. X  /* Save the EMS Handler */
  490. X  
  491. X***************
  492. X*** 1208,1236 ****
  493. X      or.x.dx = SW_fp;
  494. X      int86 (0x67, &or, &or);
  495. X  
  496. X!     if (or.h.ah != 0)
  497. X!     {
  498. X!     EMS_error (EMS_emsg, or.h.ah);
  499. X!     return;
  500. X!     }
  501. X  }
  502. X  
  503. X  /* Print EMS error message */
  504. X  
  505. X! static void    EMS_error (s, v)
  506. X  char        *s;
  507. X  int        v;
  508. X  {
  509. X      print_warn (s, v);
  510. X      Swap_Mode &= ~(SWAP_EXPAND);
  511. X      EMS_Close ();
  512. X  }
  513. X  
  514. X  
  515. X! /* If the handler is defined - close it */
  516. X! 
  517. X! static int    EMS_Close ()
  518. X  {
  519. X      union REGS        or;
  520. X      int            res = 0;
  521. X  
  522. X--- 1430,1481 ----
  523. X      or.x.dx = SW_fp;
  524. X      int86 (0x67, &or, &or);
  525. X  
  526. X!     return (or.h.ah != 0) ? EMS_error (EMS_emsg, or.h.ah) : TRUE;
  527. X  }
  528. X  
  529. X  /* Print EMS error message */
  530. X  
  531. X! static bool    EMS_error (s, v)
  532. X  char        *s;
  533. X  int        v;
  534. X  {
  535. X      print_warn (s, v);
  536. X      Swap_Mode &= ~(SWAP_EXPAND);
  537. X      EMS_Close ();
  538. X+     return FALSE;
  539. X  }
  540. X  
  541. X+ /* Print XMS error message */
  542. X  
  543. X! static bool    XMS_error (s, v)
  544. X! char        *s;
  545. X! int        v;
  546. X  {
  547. X+     print_warn (s, v);
  548. X+     Swap_Mode &= ~(SWAP_EXTEND);
  549. X+     XMS_Close ();
  550. X+     return FALSE;
  551. X+ }
  552. X+ 
  553. X+ /* If the XMS handler is defined - close it */
  554. X+ 
  555. X+ static int    XMS_Close ()
  556. X+ {
  557. X+     int        res = 0;
  558. X+ 
  559. X+ /* Release XMS page */
  560. X+ 
  561. X+     if (SW_fp != -1)
  562. X+     res = SW_XMS_Free (SW_fp);
  563. X+ 
  564. X+     SW_fp = -1;
  565. X+     return res;
  566. X+ }
  567. X+ 
  568. X+ /* If the EMS handler is defined - close it */
  569. X+ 
  570. X+ static int    EMS_Close ()
  571. X+ {
  572. X      union REGS        or;
  573. X      int            res = 0;
  574. X  
  575. X***************
  576. X*** 1285,1292 ****
  577. X  
  578. X  /* Translate process name to MSDOS format */
  579. X  
  580. X!     Convert_Slashes (path);
  581. X!     strupr (path);
  582. X  
  583. X  /* Extended command line processing */
  584. X  
  585. X--- 1530,1537 ----
  586. X  
  587. X  /* Translate process name to MSDOS format */
  588. X  
  589. X!     if ((argv[0] = Gen_Full_Path_Name (path)) == (char *)NULL)
  590. X!     return -1;
  591. X  
  592. X  /* Extended command line processing */
  593. X  
  594. X***************
  595. X*** 1337,1342 ****
  596. X--- 1582,1591 ----
  597. X          ((fd = S_open (FALSE, Extend_file = g_tempname (), O_CMASK,
  598. X                 0600)) >= 0))
  599. X      {
  600. X+         if ((ep = space (strlen (Extend_file) + 1)) != (char *)NULL)
  601. X+         strcpy (ep, Extend_file);
  602. X+         
  603. X+         Extend_file = ep;
  604. X  
  605. X  /* Copy to end of list */
  606. X  
  607. X***************
  608. X*** 1362,1375 ****
  609. X  /* Set up cmd_line[1] to contain the filename */
  610. X  
  611. X          memset (cmd_line, 0, CMD_LINE_MAX);
  612. X!         cmd_line[1] = '@';
  613. X!         strcpy (&cmd_line[2], Extend_file);
  614. X!         cmd_line[0] = (char)(strlen (Extend_file) + 1);
  615. X  
  616. X  /* Correctly terminate cmd_line in no swap mode */
  617. X  
  618. X          if (Swap_Mode != SWAP_OFF)
  619. X!         cmd_line[cmd_line[0] + 1] = '\r';
  620. X  
  621. X  /* If the name in the file is in upper case - use \ for separators */
  622. X  
  623. X--- 1611,1625 ----
  624. X  /* Set up cmd_line[1] to contain the filename */
  625. X  
  626. X          memset (cmd_line, 0, CMD_LINE_MAX);
  627. X!         cmd_line[1] = ' ';
  628. X!         cmd_line[2] = '@';
  629. X!         strcpy (&cmd_line[3], Extend_file);
  630. X!         cmd_line[0] = (char)(strlen (Extend_file) + 2);
  631. X  
  632. X  /* Correctly terminate cmd_line in no swap mode */
  633. X  
  634. X          if (Swap_Mode != SWAP_OFF)
  635. X!         cmd_line[cmd_line[0] + 2] = '\r';
  636. X  
  637. X  /* If the name in the file is in upper case - use \ for separators */
  638. X  
  639. X***************
  640. X*** 1396,1422 ****
  641. X      res = 0;
  642. X      cmd_line[0] = 0;
  643. X      cmd_line[1] = '\r';
  644. X-     ep = cmd_line;
  645. X  
  646. X  /* Skip the first parameter and get the length of the rest */
  647. X  
  648. X      if (*argv != (char *)NULL)
  649. X      {
  650. X      while (*pl != (char *)NULL)
  651. X      {
  652. X!         if ((res += (strlen (*pl) + 1)) >= CMD_LINE_MAX)
  653. X!         {
  654. X!         errno = E2BIG;
  655. X!         return -1;
  656. X!         }
  657. X  
  658. X!         strcat (strcat (ep, " "), *(pl++));
  659. X!     }
  660. X  
  661. X!     if (res)
  662. X!         cmd_line[res--] = '\r';
  663. X!     }
  664. X  
  665. X  /* Terminate the line and insert the line length */
  666. X  
  667. X      cmd_line[0] = (char)res;
  668. X--- 1646,1678 ----
  669. X      res = 0;
  670. X      cmd_line[0] = 0;
  671. X      cmd_line[1] = '\r';
  672. X  
  673. X  /* Skip the first parameter and get the length of the rest */
  674. X  
  675. X      if (*argv != (char *)NULL)
  676. X      {
  677. X+     *(ep = cmd_line + 1) = 0;
  678. X+ 
  679. X      while (*pl != (char *)NULL)
  680. X      {
  681. X!         res += white_space_len (*pl, &found);
  682. X  
  683. X!         if (res >= CMD_LINE_MAX)
  684. X!           {
  685. X!           errno = E2BIG;
  686. X!           return -1;
  687. X!           }
  688. X!   
  689. X!         if (found)
  690. X!             strcat (strcat (strcat (ep, " \""), *(pl++)), "\"");
  691. X  
  692. X!         else
  693. X!         strcat (strcat (ep, " "), *(pl++));
  694. X!       }
  695. X  
  696. X+     cmd_line[res + 1] = '\r';
  697. X+     }
  698. X+ 
  699. X  /* Terminate the line and insert the line length */
  700. X  
  701. X      cmd_line[0] = (char)res;
  702. X***************
  703. X*** 1426,1437 ****
  704. X      return (Swap_Mode == SWAP_OFF) ? spawnve (P_WAIT, path, argv, envp) : 0;
  705. X  }
  706. X  
  707. X! /* Clear Extended command line file */
  708. X  
  709. X! static void    Clear_Extended_File ()
  710. X  {
  711. X      if (Extend_file != (char *)NULL)
  712. X      unlink (Extend_file);
  713. X  
  714. X      Extend_file = (char *)NULL;
  715. X  }
  716. X--- 1682,1769 ----
  717. X      return (Swap_Mode == SWAP_OFF) ? spawnve (P_WAIT, path, argv, envp) : 0;
  718. X  }
  719. X  
  720. X! /* Check string for white space */
  721. X  
  722. X! static size_t    white_space_len (s, wsf)
  723. X! char        *s;
  724. X! bool        *wsf;
  725. X  {
  726. X+     char    *os = s;
  727. X+ 
  728. X+     *wsf = FALSE;
  729. X+ 
  730. X+     while (*s)
  731. X+     {
  732. X+         if (isspace (*s))
  733. X+         *wsf = TRUE;
  734. X+ 
  735. X+     ++s;
  736. X+     }
  737. X+ 
  738. X+     return (size_t)(s - os) + (*wsf ? 3 : 1);
  739. X+ }
  740. X+ 
  741. X+ /* Clear Extended command line file */
  742. X+ 
  743. X+ void    Clear_Extended_File ()
  744. X+ {
  745. X      if (Extend_file != (char *)NULL)
  746. X+     {
  747. X      unlink (Extend_file);
  748. X+     DELETE (Extend_file);
  749. X+     }
  750. X  
  751. X      Extend_file = (char *)NULL;
  752. X+ }
  753. X+ 
  754. X+ /* Convert the executable path to the full path name */
  755. X+ 
  756. X+ static char    *Gen_Full_Path_Name (path)
  757. X+ char        *path;
  758. X+ {
  759. X+     char        cpath[PATH_MAX + 4];
  760. X+     char        npath[PATH_MAX + NAME_MAX + 4];
  761. X+     char        *p;
  762. X+     unsigned int    dummy;
  763. X+ 
  764. X+     Convert_Slashes (path);
  765. X+     strupr (path);
  766. X+ 
  767. X+ /* Get the current path */
  768. X+ 
  769. X+     getcwd (cpath, PATH_MAX + 3);
  770. X+     strcpy (npath, cpath);
  771. X+ 
  772. X+ /* In current directory ? */
  773. X+ 
  774. X+     if ((p = strrchr (path, '\\')) == (char *)NULL)
  775. X+      p = path;
  776. X+ 
  777. X+     else
  778. X+     {
  779. X+     *(p++) = 0;
  780. X+ 
  781. X+ /* Change to the directory containing the executable */
  782. X+ 
  783. X+     if (*(path + 1) == ':')
  784. X+         _dos_setdrive (tolower (*path) - 'a' + 1, &dummy);
  785. X+ 
  786. X+     if (chdir (path) < 0)
  787. X+         return (char *)NULL;
  788. X+ 
  789. X+     getcwd (npath, PATH_MAX + 3);
  790. X+ 
  791. X+ /* Restore our original directory */
  792. X+ 
  793. X+     _dos_setdrive (tolower (*cpath) - 'a' + 1, &dummy);
  794. X+ 
  795. X+     if (chdir (cpath) < 0)
  796. X+         return (char *)NULL;
  797. X+     }
  798. X+ 
  799. X+     if (npath[strlen (npath) - 1] != '\\')
  800. X+     strcat (npath, "\\");
  801. X+ 
  802. X+     strcat (npath, p);
  803. X+     return strcpy (path, npath);
  804. X  }
  805. XIndex: shell/sh10.c
  806. XPrereq: 1.1
  807. X*** ../sh15/shell/sh10.c    Fri Feb 16 19:19:05 1990
  808. X--- shell/sh10.c    Tue May  1 19:48:22 1990
  809. X***************
  810. X*** 12,20 ****
  811. X   * 2.  The sources (or parts thereof) or objects generated from the sources
  812. X   *     (or parts of sources) cannot be sold under any circumstances.
  813. X   *
  814. X!  *    $Header: sh10.c 1.1 90/01/25 13:40:54 MS_user Exp $
  815. X   *
  816. X   *    $Log:    sh10.c $
  817. X   * Revision 1.1  90/01/25  13:40:54  MS_user
  818. X   * Initial revision
  819. X   * 
  820. X--- 12,23 ----
  821. X   * 2.  The sources (or parts thereof) or objects generated from the sources
  822. X   *     (or parts of sources) cannot be sold under any circumstances.
  823. X   *
  824. X!  *    $Header: sh10.c 1.2 90/04/25 22:34:04 MS_user Exp $
  825. X   *
  826. X   *    $Log:    sh10.c $
  827. X+  * Revision 1.2  90/04/25  22:34:04  MS_user
  828. X+  * Fix case in TELIF where then and else parts are not defined
  829. X+  * 
  830. X   * Revision 1.1  90/01/25  13:40:54  MS_user
  831. X   * Initial revision
  832. X   * 
  833. X***************
  834. X*** 145,164 ****
  835. X          
  836. X          Print_ExTree (t->left);
  837. X  
  838. X!         Print_indent -= 1;
  839. X!         Print_IString ("then\n", 1);
  840. X!         Print_ExTree (t->right->left);
  841. X! 
  842. X!         if (t->right->right != (C_Op *)NULL)
  843. X          {
  844. X          Print_indent -= 1;
  845. X  
  846. X!         if (t->right->right->type != TELIF)
  847. X!             Print_IString ("else\n", 1);
  848. X  
  849. X!         Print_ExTree (t->right->right);
  850. X!         }
  851. X  
  852. X          if (t->type == TIF)
  853. X          Print_IString ("fi\n", -1);
  854. X  
  855. X--- 148,170 ----
  856. X          
  857. X          Print_ExTree (t->left);
  858. X  
  859. X!         if (t->right != (C_Op *)NULL)
  860. X          {
  861. X          Print_indent -= 1;
  862. X+         Print_IString ("then\n", 1);
  863. X+         Print_ExTree (t->right->left);
  864. X  
  865. X!         if (t->right->right != (C_Op *)NULL)
  866. X!         {
  867. X!             Print_indent -= 1;
  868. X  
  869. X!             if (t->right->right->type != TELIF)
  870. X!             Print_IString ("else\n", 1);
  871. X  
  872. X+             Print_ExTree (t->right->right);
  873. X+         }
  874. X+         }
  875. X+ 
  876. X          if (t->type == TIF)
  877. X          Print_IString ("fi\n", -1);
  878. X  
  879. X***************
  880. X*** 508,516 ****
  881. X  
  882. X      case TIF:            /* IF and ELSE IF functions    */
  883. X      case TELIF:
  884. X!         Set_Free_ExTree (t->right->left, func);
  885. X!         Set_Free_ExTree (t->right->right, func);
  886. X!         (*func)((char *)t->right);
  887. X  
  888. X      case TBRACE:            /* {} statement            */
  889. X          Set_Free_ExTree (t->left, func);
  890. X--- 514,525 ----
  891. X  
  892. X      case TIF:            /* IF and ELSE IF functions    */
  893. X      case TELIF:
  894. X!         if (t->right != (C_Op *)NULL)
  895. X!         {
  896. X!         Set_Free_ExTree (t->right->left, func);
  897. X!         Set_Free_ExTree (t->right->right, func);
  898. X!         (*func)((char *)t->right);
  899. X!         }
  900. X  
  901. X      case TBRACE:            /* {} statement            */
  902. X          Set_Free_ExTree (t->left, func);
  903. XIndex: shell/sh5.c
  904. XPrereq: 1.1
  905. X*** ../sh15/shell/sh5.c    Fri Feb 16 19:20:07 1990
  906. X--- shell/sh5.c    Tue May  1 19:49:12 1990
  907. X***************
  908. X*** 13,21 ****
  909. X   * 2.  The sources (or parts thereof) or objects generated from the sources
  910. X   *     (or parts of sources) cannot be sold under any circumstances.
  911. X   *
  912. X!  *    $Header: sh5.c 1.1 90/01/25 13:41:50 MS_user Exp $
  913. X   *
  914. X   *    $Log:    sh5.c $
  915. X   * Revision 1.1  90/01/25  13:41:50  MS_user
  916. X   * Initial revision
  917. X   * 
  918. X--- 13,45 ----
  919. X   * 2.  The sources (or parts thereof) or objects generated from the sources
  920. X   *     (or parts of sources) cannot be sold under any circumstances.
  921. X   *
  922. X!  *    $Header: sh5.c 1.8 90/04/25 10:58:41 MS_user Exp $
  923. X   *
  924. X   *    $Log:    sh5.c $
  925. X+  * Revision 1.8  90/04/25  10:58:41  MS_user
  926. X+  * Fix re-reading re-assigned buffers correctly.
  927. X+  * 
  928. X+  * Revision 1.7  90/04/25  09:20:08  MS_user
  929. X+  * Fix lseek problem and TAG problem on here documents
  930. X+  * 
  931. X+  * Revision 1.6  90/04/09  17:04:50  MS_user
  932. X+  * g_tempname must check for slash or backslash
  933. X+  * 
  934. X+  * Revision 1.5  90/03/21  14:03:47  MS_user
  935. X+  * Add new gravechar procedure for handling here documents
  936. X+  * 
  937. X+  * Revision 1.4  90/03/14  19:31:28  MS_user
  938. X+  * Add buffered output for here document processing.
  939. X+  * Fix here document processing so it works correctly.
  940. X+  * Add missing IOTHERE (<<-) processing for here documents.
  941. X+  * 
  942. X+  * Revision 1.3  90/03/06  16:49:58  MS_user
  943. X+  * Add disable history option
  944. X+  * 
  945. X+  * Revision 1.2  90/03/05  13:51:45  MS_user
  946. X+  * Add functionality to readc to support dot command via run function
  947. X+  * Add $HOME as a temporary file directory
  948. X+  * 
  949. X   * Revision 1.1  90/01/25  13:41:50  MS_user
  950. X   * Initial revision
  951. X   * 
  952. X***************
  953. X*** 47,53 ****
  954. X  static Here_D    *acthere = (Here_D *)NULL;
  955. X  
  956. X  static int    dol1_char (IO_State *);
  957. X! static void    readhere (char **, char *, int);
  958. X  static int    herechar (IO_State *);
  959. X  
  960. X  int        Getc (ec)
  961. X--- 71,77 ----
  962. X  static Here_D    *acthere = (Here_D *)NULL;
  963. X  
  964. X  static int    dol1_char (IO_State *);
  965. X! static void    readhere (char **, char *, int, int);
  966. X  static int    herechar (IO_State *);
  967. X  
  968. X  int        Getc (ec)
  969. X***************
  970. X*** 170,184 ****
  971. X          if (multiline)
  972. X              return e.iop->prev = 0;
  973. X  
  974. X!         if (talking && e.iop == iostack + 1)
  975. X              put_prompt (ps1->value);
  976. X          }
  977. X      }
  978. X      }
  979. X  
  980. X!     if (e.iop >= iostack)
  981. X!     return 0;
  982. X  
  983. X      leave();
  984. X      /* NOTREACHED */
  985. X  }
  986. X--- 194,212 ----
  987. X          if (multiline)
  988. X              return e.iop->prev = 0;
  989. X  
  990. X!         if (talking && (e.iop == iostack + 1) && !e.eof_p)
  991. X              put_prompt (ps1->value);
  992. X          }
  993. X      }
  994. X      }
  995. X  
  996. X! /* End of file detected.  If more data on stack and the special EOF
  997. X!  * processing is not enabled - return 0
  998. X!  */
  999. X  
  1000. X+     if ((e.iop >= iostack) && !e.eof_p)
  1001. X+     return 0;
  1002. X+ 
  1003. X      leave();
  1004. X      /* NOTREACHED */
  1005. X  }
  1006. X***************
  1007. X*** 210,216 ****
  1008. X  
  1009. X      if ((isatty (e.iop->argp->afile) == 0) &&
  1010. X          ((e.iop == &iostack[0]) ||
  1011. X!          (lseek (e.iop->argp->afile, 0L, 1) != -1L)))
  1012. X      {
  1013. X          if (++bufid == AFID_NOBUF)
  1014. X          bufid = AFID_ID;
  1015. X--- 238,244 ----
  1016. X  
  1017. X      if ((isatty (e.iop->argp->afile) == 0) &&
  1018. X          ((e.iop == &iostack[0]) ||
  1019. X!          (lseek (e.iop->argp->afile, 0L, SEEK_CUR) != -1L)))
  1020. X      {
  1021. X          if (++bufid == AFID_NOBUF)
  1022. X          bufid = AFID_ID;
  1023. X***************
  1024. X*** 227,233 ****
  1025. X      if ((fn == filechar) || (fn == linechar))
  1026. X      e.iop->task = XIO;
  1027. X  
  1028. X!     else if ((fn == gravechar) || (fn == qgravechar))
  1029. X      e.iop->task = XGRAVE;
  1030. X  
  1031. X      else
  1032. X--- 255,261 ----
  1033. X      if ((fn == filechar) || (fn == linechar))
  1034. X      e.iop->task = XIO;
  1035. X  
  1036. X!     else if ((fn == gravechar) || (fn == qgravechar) || (fn == sgravechar))
  1037. X      e.iop->task = XGRAVE;
  1038. X  
  1039. X      else
  1040. X***************
  1041. X*** 402,410 ****
  1042. X--- 430,452 ----
  1043. X      {
  1044. X      if ((i = (ap->afid != bp->id)) || (bp->bufp == bp->ebufp))
  1045. X      {
  1046. X+ 
  1047. X+ /* Are we re-reading a corrupted buffer? */
  1048. X+ 
  1049. X          if (i)
  1050. X          lseek (ap->afile, ap->afpos, SEEK_SET);
  1051. X  
  1052. X+ /* No, filling so set offset to zero */
  1053. X+ 
  1054. X+         else
  1055. X+         ap->afoff = 0;
  1056. X+ 
  1057. X+ /* Save the start of the next buffer */
  1058. X+ 
  1059. X+         ap->afpos = lseek (ap->afile, 0L, SEEK_CUR);
  1060. X+ 
  1061. X+ /* Read in the next buffer */
  1062. X+ 
  1063. X          if ((i = read (ap->afile, bp->buf, sizeof (bp->buf))) <= 0)
  1064. X          {
  1065. X          if (ap->afile > STDERR_FILENO)
  1066. X***************
  1067. X*** 413,431 ****
  1068. X          return 0;
  1069. X          }
  1070. X  
  1071. X!         bp->id = ap->afid;
  1072. X!         bp->ebufp = (bp->bufp  = bp->buf) + i;
  1073. X!     }
  1074. X  
  1075. X!     ap->afpos++;
  1076. X  
  1077. X      return *bp->bufp++ & 0177;
  1078. X      }
  1079. X  
  1080. X  /* If this is the terminal, there is special input processing */
  1081. X  
  1082. X      else if ((ap->afile == 0) && isatty (ap->afile))
  1083. X          return Get_stdin (ap);
  1084. X  
  1085. X      if ((i = read (ap->afile, &c, sizeof(c))) == sizeof (c))
  1086. X      return (int)c & 0177;
  1087. X--- 455,479 ----
  1088. X          return 0;
  1089. X          }
  1090. X  
  1091. X! /* Set up buffer id, start and end */
  1092. X  
  1093. X!         bp->id    = ap->afid;
  1094. X!         bp->bufp  = bp->buf + ap->afoff;
  1095. X!         bp->ebufp = bp->buf + i;
  1096. X!     }
  1097. X! 
  1098. X! /* Return the next character from the buffer */
  1099. X  
  1100. X+     ++(ap->afoff);
  1101. X      return *bp->bufp++ & 0177;
  1102. X      }
  1103. X  
  1104. X  /* If this is the terminal, there is special input processing */
  1105. X  
  1106. X+ #ifndef NO_HISTORY
  1107. X      else if ((ap->afile == 0) && isatty (ap->afile))
  1108. X          return Get_stdin (ap);
  1109. X+ #endif
  1110. X  
  1111. X      if ((i = read (ap->afile, &c, sizeof(c))) == sizeof (c))
  1112. X      return (int)c & 0177;
  1113. X***************
  1114. X*** 456,467 ****
  1115. X  
  1116. X  /*
  1117. X   * Return the characters produced by a process (`...`).
  1118. X!  * Quote them if required, and remove any trailing newline characters.
  1119. X   */
  1120. X  
  1121. X! int        gravechar (iop)
  1122. X  IO_State    *iop;
  1123. X  {
  1124. X      register int c;
  1125. X  
  1126. X      if ((c = qgravechar (iop) & ~QUOTE) == NL)
  1127. X--- 504,526 ----
  1128. X  
  1129. X  /*
  1130. X   * Return the characters produced by a process (`...`).
  1131. X!  * De-quote them if required.  Use in here documents.
  1132. X   */
  1133. X  
  1134. X! int        sgravechar (iop)
  1135. X  IO_State    *iop;
  1136. X  {
  1137. X+     return  qgravechar (iop) & ~QUOTE;
  1138. X+ }
  1139. X+ 
  1140. X+ /*
  1141. X+  * Return the characters produced by a process (`...`).
  1142. X+  * De-quote them if required, and converting NL to space.
  1143. X+  */
  1144. X+ 
  1145. X+ int        gravechar (iop)
  1146. X+ IO_State    *iop;
  1147. X+ {
  1148. X      register int c;
  1149. X  
  1150. X      if ((c = qgravechar (iop) & ~QUOTE) == NL)
  1151. X***************
  1152. X*** 501,513 ****
  1153. X      iop->xchar = (char)c;
  1154. X  
  1155. X      if (c == 0)
  1156. X!         return(c);
  1157. X  
  1158. X      iop->nlcount--;
  1159. X      c = NL;
  1160. X      }
  1161. X  
  1162. X!     return (c != 0) ? (c | QUOTE): 0;
  1163. X  }
  1164. X  
  1165. X  /*
  1166. X--- 560,572 ----
  1167. X      iop->xchar = (char)c;
  1168. X  
  1169. X      if (c == 0)
  1170. X!         return c;
  1171. X  
  1172. X      iop->nlcount--;
  1173. X      c = NL;
  1174. X      }
  1175. X  
  1176. X!     return (c != 0) ? (c | QUOTE) : 0;
  1177. X  }
  1178. X  
  1179. X  /*
  1180. X***************
  1181. X*** 631,637 ****
  1182. X  /* Scan here files first leaving inhere list in place */
  1183. X  
  1184. X      for (hp = h = inhere; h != (Here_D *)NULL; hp = h, h = h->h_next)
  1185. X!     readhere (&h->h_iop->io_name, h->h_tag, h->h_dosub ? 0 : '\'');
  1186. X  
  1187. X  /* Make inhere list active - keep list intact for scraphere */
  1188. X  
  1189. X--- 690,697 ----
  1190. X  /* Scan here files first leaving inhere list in place */
  1191. X  
  1192. X      for (hp = h = inhere; h != (Here_D *)NULL; hp = h, h = h->h_next)
  1193. X!     readhere (&h->h_iop->io_name, h->h_tag, h->h_dosub ? 0 : '\'',
  1194. X!           h->h_iop->io_flag);
  1195. X  
  1196. X  /* Make inhere list active - keep list intact for scraphere */
  1197. X  
  1198. X***************
  1199. X*** 643,660 ****
  1200. X      }
  1201. X  }
  1202. X  
  1203. X! static void    readhere (name, s, ec)
  1204. X  char        **name;
  1205. X  register char    *s;
  1206. X  {
  1207. X      int            tf;
  1208. X      register int    c;
  1209. X      jmp_buf        ev;
  1210. X      char        *line;
  1211. X      char        *next;
  1212. X  
  1213. X!     *name = strsave (g_tempname (), areanum);
  1214. X  
  1215. X      if ((tf = S_open (FALSE, *name, O_CMASK | O_NOINHERIT, 0600)) < 0)
  1216. X      return;
  1217. X  
  1218. X--- 703,727 ----
  1219. X      }
  1220. X  }
  1221. X  
  1222. X! static void    readhere (name, s, ec, ioflag)
  1223. X  char        **name;
  1224. X  register char    *s;
  1225. X+ int        ec;
  1226. X+ int        ioflag;
  1227. X  {
  1228. X      int            tf;
  1229. X      register int    c;
  1230. X      jmp_buf        ev;
  1231. X      char        *line;
  1232. X      char        *next;
  1233. X+     int            stop_len;
  1234. X+     int            c_len;
  1235. X+     Out_Buf        *bp;
  1236. X  
  1237. X! /* Create a temporary file and open it */
  1238. X  
  1239. X+     *name = strsave (g_tempname (), areanum);
  1240. X+ 
  1241. X      if ((tf = S_open (FALSE, *name, O_CMASK | O_NOINHERIT, 0600)) < 0)
  1242. X      return;
  1243. X  
  1244. X***************
  1245. X*** 663,700 ****
  1246. X  
  1247. X      else
  1248. X      {
  1249. X-     line = space (LINE_MAX + 1);
  1250. X      pushio (e.iop->argp, e.iop->iofn);
  1251. X      e.iobase = e.iop;
  1252. X  
  1253. X!     while (1)
  1254. X!     {
  1255. X!         if (talking && e.iop <= iostack)
  1256. X!         put_prompt (ps2->value);
  1257. X  
  1258. X!         next = line;
  1259. X          while ((c = Getc (ec)) != NL && c)
  1260. X          {
  1261. X          if (ec == '\'')
  1262. X              c &= ~ QUOTE;
  1263. X  
  1264. X!         if (next >= &line[LINE_MAX])
  1265. X!         {
  1266. X!             c = 0;
  1267. X!             break;
  1268. X!         }
  1269. X  
  1270. X!         *next++ = (char)c;
  1271. X!         }
  1272. X  
  1273. X          *next = 0;
  1274. X          if (strcmp (s, line) == 0 || c == 0)
  1275. X          break;
  1276. X  
  1277. X!         *next++ = NL;
  1278. X!         write (tf, line, (int)(next-line));
  1279. X!     }
  1280. X  
  1281. X      if (c == 0)
  1282. X          print_error ("here document `%s' unclosed\n", s);
  1283. X  
  1284. X--- 730,814 ----
  1285. X  
  1286. X      else
  1287. X      {
  1288. X      pushio (e.iop->argp, e.iop->iofn);
  1289. X      e.iobase = e.iop;
  1290. X  
  1291. X! /* Strip leading tabs? */
  1292. X  
  1293. X!     if (ioflag & IOTHERE)
  1294. X!     {
  1295. X!         while (*s && (*s == '\t'))
  1296. X!         ++s;
  1297. X!     }
  1298. X! 
  1299. X! /* Open the Output buffer */
  1300. X! 
  1301. X!     line = space ((stop_len = strlen (s) + 2) + 1);
  1302. X!     bp = Open_buffer (tf, TRUE);
  1303. X! 
  1304. X! /* Read in */
  1305. X! 
  1306. X!     while (1)
  1307. X!     {
  1308. X!         next = line;
  1309. X!         c_len = 0;
  1310. X! 
  1311. X!         if (talking && e.iop <= iostack + 1)
  1312. X!         {
  1313. X! #ifndef NO_HISTORY
  1314. X!         Add_History (FALSE);
  1315. X! #endif
  1316. X!         put_prompt (ps2->value);
  1317. X!         }
  1318. X! 
  1319. X! /* Read the here document */
  1320. X! 
  1321. X          while ((c = Getc (ec)) != NL && c)
  1322. X          {
  1323. X+ 
  1324. X+ /* Strip leading tabs? */
  1325. X+ 
  1326. X+         if ((ioflag & IOTHERE) && (c == '\t') && (next == line))
  1327. X+             continue;
  1328. X+ 
  1329. X          if (ec == '\'')
  1330. X              c &= ~ QUOTE;
  1331. X  
  1332. X! /* If not end of search string, add to search string */
  1333. X  
  1334. X!         if ((++c_len) < stop_len)
  1335. X!             *(next++) = (char)c;
  1336. X  
  1337. X+ /* If one greater that search string, buffer search string */
  1338. X+ 
  1339. X+         else
  1340. X+         {
  1341. X+             if (c_len == stop_len)
  1342. X+             {
  1343. X+             *next = 0;
  1344. X+             Adds_buffer (line, bp);
  1345. X+             }
  1346. X+ 
  1347. X+ /* Buffer the current character */
  1348. X+ 
  1349. X+             Add_buffer ((char)c, bp);
  1350. X+         }
  1351. X+         }
  1352. X+ 
  1353. X+ /* Check for end of document */
  1354. X+ 
  1355. X          *next = 0;
  1356. X          if (strcmp (s, line) == 0 || c == 0)
  1357. X          break;
  1358. X  
  1359. X!         if (c_len < stop_len)
  1360. X!             Adds_buffer (line, bp);
  1361. X  
  1362. X+         Add_buffer (NL, bp);
  1363. X+     }
  1364. X+ 
  1365. X+     Close_buffer (bp);
  1366. X+ 
  1367. X      if (c == 0)
  1368. X          print_error ("here document `%s' unclosed\n", s);
  1369. X  
  1370. X***************
  1371. X*** 715,730 ****
  1372. X  {
  1373. X      register int    hf, tf;
  1374. X  
  1375. X      if (hname == (char *)NULL)
  1376. X      return -1;
  1377. X  
  1378. X      if ((hf = S_open (FALSE, hname, O_RDONLY)) < 0)
  1379. X      return -1;
  1380. X  
  1381. X      if (xdoll)
  1382. X      {
  1383. X      char        c;
  1384. X!     char        *tname = g_tempname();
  1385. X      jmp_buf        ev;
  1386. X  
  1387. X      if ((tf = S_open (FALSE, tname, O_CMASK | O_NOINHERIT, 0600)) < 0)
  1388. X--- 829,849 ----
  1389. X  {
  1390. X      register int    hf, tf;
  1391. X  
  1392. X+ /* If the here document is invalid or does not exist, return */
  1393. X+ 
  1394. X      if (hname == (char *)NULL)
  1395. X      return -1;
  1396. X  
  1397. X      if ((hf = S_open (FALSE, hname, O_RDONLY)) < 0)
  1398. X      return -1;
  1399. X  
  1400. X+ /* If processing for $, ` and ' is required, do it */
  1401. X+ 
  1402. X      if (xdoll)
  1403. X      {
  1404. X      char        c;
  1405. X!     char        *tname = strsave (g_tempname (), areanum);
  1406. X!     Out_Buf        *bp;
  1407. X      jmp_buf        ev;
  1408. X  
  1409. X      if ((tf = S_open (FALSE, tname, O_CMASK | O_NOINHERIT, 0600)) < 0)
  1410. X***************
  1411. X*** 732,752 ****
  1412. X  
  1413. X      if (newenv (setjmp (errpt = ev)) == FALSE)
  1414. X      {
  1415. X          PUSHIO (afile, hf, herechar);
  1416. X          e.iobase = e.iop;
  1417. X  
  1418. X!         while ((c = (char)subgetc(0, 0)) != 0)
  1419. X          {
  1420. X-         c &= ~ QUOTE;
  1421. X-         write (tf, &c, sizeof c);
  1422. X-         }
  1423. X  
  1424. X          quitenv ();
  1425. X      }
  1426. X  
  1427. X      else
  1428. X          S_Delete (tf);
  1429. X  
  1430. X      S_close (tf, TRUE);
  1431. X      return S_open (TRUE, tname, O_RDONLY);
  1432. X      }
  1433. X--- 851,880 ----
  1434. X  
  1435. X      if (newenv (setjmp (errpt = ev)) == FALSE)
  1436. X      {
  1437. X+         bp = Open_buffer (tf, TRUE);
  1438. X          PUSHIO (afile, hf, herechar);
  1439. X          e.iobase = e.iop;
  1440. X  
  1441. X!         while ((c = (char)subgetc (0, 0)) != 0)
  1442. X          {
  1443. X  
  1444. X+ /* Determine how many characters to write.  If MSB set, write \x.
  1445. X+  * Otherwise, write x
  1446. X+  */
  1447. X+ 
  1448. X+         if ((c & QUOTE) && !any ((c & ~QUOTE), "$`\\"))
  1449. X+             Add_buffer ('\\', bp);
  1450. X+ 
  1451. X+         Add_buffer ((char)(c & (~QUOTE)), bp);
  1452. X+         }
  1453. X+ 
  1454. X          quitenv ();
  1455. X      }
  1456. X  
  1457. X      else
  1458. X          S_Delete (tf);
  1459. X  
  1460. X+     Close_buffer (bp);
  1461. X      S_close (tf, TRUE);
  1462. X      return S_open (TRUE, tname, O_RDONLY);
  1463. X      }
  1464. X***************
  1465. X*** 798,818 ****
  1466. X      static char    tmpfile[FFNAME_MAX];
  1467. X      char    *tmpdir;    /* Points to directory prefix of pipe    */
  1468. X      static int    temp_count = 0;
  1469. X  
  1470. X  /* Find out where we should put temporary files */
  1471. X  
  1472. X!     if ((tmpdir = lookup ("TMPDIR", FALSE)->value) == null)
  1473. X!     tmpdir = lookup ("TMP", FALSE)->value;
  1474. X  
  1475. X  /* Get a unique temporary file name */
  1476. X  
  1477. X      while (1)
  1478. X      {
  1479. X!     sprintf (tmpfile, "%s/sht%.5u.tmp", tmpdir, temp_count++);
  1480. X  
  1481. X      if (access (tmpfile, F_OK) != 0)
  1482. X          break;
  1483. X      }
  1484. X  
  1485. X      return tmpfile;
  1486. X  }
  1487. X--- 926,959 ----
  1488. X      static char    tmpfile[FFNAME_MAX];
  1489. X      char    *tmpdir;    /* Points to directory prefix of pipe    */
  1490. X      static int    temp_count = 0;
  1491. X+     char    *sep = "/";
  1492. X  
  1493. X  /* Find out where we should put temporary files */
  1494. X  
  1495. X!     if (((tmpdir = lookup ("TMP", FALSE)->value) == null) &&
  1496. X!     ((tmpdir = lookup (home, FALSE)->value) == null))
  1497. X!     tmpdir = lookup ("TMPDIR", FALSE)->value;
  1498. X!     
  1499. X!     if (any (tmpdir[strlen (tmpdir) - 1], "/\\"))
  1500. X!     sep = null;
  1501. X  
  1502. X  /* Get a unique temporary file name */
  1503. X  
  1504. X      while (1)
  1505. X      {
  1506. X!     sprintf (tmpfile, "%s%ssht%.5u.tmp", tmpdir, sep, temp_count++);
  1507. X  
  1508. X      if (access (tmpfile, F_OK) != 0)
  1509. X          break;
  1510. X      }
  1511. X  
  1512. X      return tmpfile;
  1513. X+ }
  1514. X+ 
  1515. X+ /* Test to see if the current Input device is the console */
  1516. X+ 
  1517. X+ bool    Interactive ()
  1518. X+ {
  1519. X+     return (talking && (e.iop->task == XIO) && isatty (e.iop->argp->afile))
  1520. X+        ? TRUE : FALSE;
  1521. X  }
  1522. XIndex: shell/sh7.c
  1523. XPrereq: 1.2
  1524. X*** ../sh15/shell/sh7.c    Fri Feb 16 19:16:21 1990
  1525. X--- shell/sh7.c    Tue May  1 19:49:34 1990
  1526. X***************
  1527. X*** 15,23 ****
  1528. X   * 2.  The sources (or parts thereof) or objects generated from the sources
  1529. X   *     (or parts of sources) cannot be sold under any circumstances.
  1530. X   *
  1531. X!  *    $Header: sh7.c 1.2 90/01/30 14:43:34 MS_user Exp $
  1532. X   *
  1533. X   *    $Log:    sh7.c $
  1534. X   * Revision 1.2  90/01/30  14:43:34  MS_user
  1535. X   * Add missing author note
  1536. X   * 
  1537. X--- 15,67 ----
  1538. X   * 2.  The sources (or parts thereof) or objects generated from the sources
  1539. X   *     (or parts of sources) cannot be sold under any circumstances.
  1540. X   *
  1541. X!  *    $Header: sh7.c 1.16 90/04/30 19:50:44 MS_user Exp $
  1542. X   *
  1543. X   *    $Log:    sh7.c $
  1544. X+  * Revision 1.16  90/04/30  19:50:44  MS_user
  1545. X+  * Stop search path if second character of name is colon
  1546. X+  * 
  1547. X+  * Revision 1.15  90/04/25  22:35:53  MS_user
  1548. X+  * Fix bug in doread to stop multi-line reads
  1549. X+  * 
  1550. X+  * Revision 1.14  90/04/25  09:21:11  MS_user
  1551. X+  * Change version message processing
  1552. X+  * 
  1553. X+  * Revision 1.13  90/04/03  17:59:43  MS_user
  1554. X+  * type didnot check for functions before searching PATH
  1555. X+  * 
  1556. X+  * Revision 1.12  90/03/27  20:33:58  MS_user
  1557. X+  * Clear extended file name on interrupt
  1558. X+  * 
  1559. X+  * Revision 1.11  90/03/26  20:57:38  MS_user
  1560. X+  * Change I/O restore so that "exec >filename" works
  1561. X+  * 
  1562. X+  * Revision 1.10  90/03/14  19:32:05  MS_user
  1563. X+  * Change buffered output to be re-entrant and add it to getopt
  1564. X+  * 
  1565. X+  * Revision 1.9  90/03/14  16:45:52  MS_user
  1566. X+  * New Open_buffer parameter
  1567. X+  * 
  1568. X+  * Revision 1.8  90/03/13  21:19:50  MS_user
  1569. X+  * Use the new Buffered Output routines in doecho
  1570. X+  * 
  1571. X+  * Revision 1.7  90/03/12  20:43:52  MS_user
  1572. X+  * Change bell test to check initialisation file
  1573. X+  * 
  1574. X+  * Revision 1.6  90/03/12  17:09:38  MS_user
  1575. X+  * Add a missing cast
  1576. X+  * 
  1577. X+  * Revision 1.5  90/03/09  16:06:41  MS_user
  1578. X+  * Add SH_BELL processing
  1579. X+  * 
  1580. X+  * Revision 1.4  90/03/06  16:50:10  MS_user
  1581. X+  * Add disable history option
  1582. X+  * 
  1583. X+  * Revision 1.3  90/03/05  13:52:49  MS_user
  1584. X+  * Changes to eval and dot functionality
  1585. X+  * Fix bug in escape processing in doecho
  1586. X+  * Add some array size checks
  1587. X+  * 
  1588. X   * Revision 1.2  90/01/30  14:43:34  MS_user
  1589. X   * Add missing author note
  1590. X   * 
  1591. X***************
  1592. X*** 172,178 ****
  1593. X  static int        dohistory (C_Op *);
  1594. X  static void        setsig (int, int (*)());
  1595. X  static int        rdexp (char **, int, char *);
  1596. X- static void        v1_putsn (char *, int);
  1597. X  
  1598. X  static char        **test_alist;
  1599. X  static struct test_op    *test_op;
  1600. X--- 216,221 ----
  1601. X***************
  1602. X*** 198,203 ****
  1603. X--- 241,248 ----
  1604. X      int            argc;
  1605. X      char        **argv = t->words;
  1606. X      int            c;
  1607. X+     Out_Buf        *bp;
  1608. X+     char        *c_s = "-c ";
  1609. X  
  1610. X  /* Count arguments */
  1611. X  
  1612. X***************
  1613. X*** 212,217 ****
  1614. X--- 257,270 ----
  1615. X      return 2;
  1616. X      }
  1617. X  
  1618. X+ /* Get some memory for the buffer */
  1619. X+ 
  1620. X+     if ((bp = Open_buffer (1, FALSE)) == (Out_Buf *)NULL)
  1621. X+     {
  1622. X+     print_error ("getopt: %s\n", strerror (ENOMEM));
  1623. X+     return 1;
  1624. X+     }
  1625. X+ 
  1626. X      argc -= 2;
  1627. X      argv += 2;
  1628. X  
  1629. X***************
  1630. X*** 222,247 ****
  1631. X      if (c == '?')
  1632. X          return 2;
  1633. X  
  1634. X!     v1printf ("-%c ", c);
  1635. X  
  1636. X  /* Check for addition parameter */
  1637. X  
  1638. X      if (*(strchr (t->words[1], c) + 1) == ':')
  1639. X      {
  1640. X!         v1_puts (optarg);
  1641. X!         v1_putc (SP);
  1642. X      }
  1643. X      }
  1644. X  
  1645. X!     v1_puts ("-- ");
  1646. X!     argv += optind;
  1647. X  
  1648. X      while (optind++ < argc)
  1649. X      {
  1650. X!     v1_puts (*argv++);
  1651. X!     v1_putc ((char)((optind == argc) ? NL : SP));
  1652. X      }
  1653. X  
  1654. X      return 0;
  1655. X  }
  1656. X  
  1657. X--- 275,306 ----
  1658. X      if (c == '?')
  1659. X          return 2;
  1660. X  
  1661. X!     *(c_s + 1) = (char)c;
  1662. X!     Adds_buffer (c_s, bp);
  1663. X  
  1664. X  /* Check for addition parameter */
  1665. X  
  1666. X      if (*(strchr (t->words[1], c) + 1) == ':')
  1667. X      {
  1668. X!         Adds_buffer (optarg, bp);
  1669. X!         Add_buffer (SP, bp);
  1670. X      }
  1671. X      }
  1672. X  
  1673. X! /* Output the separator */
  1674. X  
  1675. X+     Adds_buffer ("-- ", bp);
  1676. X+     argv += optind;
  1677. X+ 
  1678. X+ /* Output the arguments */
  1679. X+ 
  1680. X      while (optind++ < argc)
  1681. X      {
  1682. X!     Adds_buffer (*argv++, bp);
  1683. X!     Add_buffer ((char)((optind == argc) ? NL : SP), bp);
  1684. X      }
  1685. X  
  1686. X+     Close_buffer (bp);
  1687. X      return 0;
  1688. X  }
  1689. X  
  1690. X***************
  1691. X*** 252,269 ****
  1692. X  static int    doecho (t)
  1693. X  register C_Op    *t;
  1694. X  {
  1695. X!     int        n = 1;
  1696. X      int        no_eol = 0;        /* No EOL            */
  1697. X      char    *ip;            /* Input pointer        */
  1698. X      int        c_val;            /* Current character        */
  1699. X      char    c;
  1700. X      bool    end_s;
  1701. X!     char    *cp = e.linep;
  1702. SHAR_EOF
  1703. echo "End of part 3"
  1704. echo "File Patch1.6 is continued in part 4"
  1705. echo "4" > s2_seq_.tmp
  1706. exit 0
  1707.  
  1708.  
  1709.