home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d1xx / d145 / csh.lha / Csh / DIFFS < prev    next >
Text File  |  1988-05-26  |  12KB  |  507 lines

  1. *** :z/comm1.c    Sun Apr 10 20:41:22 1988
  2. --- comm1.c    Sat Apr 30 16:47:04 1988
  3. ***************
  4. *** 11,18 ****
  5.   typedef struct FileInfoBlock FIB;
  6.   
  7.   #define DIR_SHORT 0x01
  8. ! #define DIR_FILES 0x02
  9. ! #define DIR_DIRS  0x04
  10.   
  11.   extern int has_wild;
  12.   char cwd[256];
  13. --- 11,19 ----
  14.   typedef struct FileInfoBlock FIB;
  15.   
  16.   #define DIR_SHORT 0x01
  17. ! #define DIR_VERY_SHORT 0x02
  18. ! #define DIR_FILES 0x04
  19. ! #define DIR_DIRS  0x08
  20.   
  21.   extern int has_wild;
  22.   char cwd[256];
  23. ***************
  24. *** 151,157 ****
  25.      bytes = blocks = 0L;
  26.      *lspec = '\0';
  27.   
  28. !    options  = get_opt("sfd",&i);
  29.   
  30.      if (ac == i) {
  31.         ++ac;
  32. --- 157,163 ----
  33.      bytes = blocks = 0L;
  34.      *lspec = '\0';
  35.   
  36. !    options  = get_opt("sSfd",&i);
  37.   
  38.      if (ac == i) {
  39.         ++ac;
  40. ***************
  41. *** 158,163 ****
  42. --- 164,170 ----
  43.         av[i] = "";
  44.      }
  45.      if (!(options & (DIR_FILES | DIR_DIRS)))  options |= (DIR_FILES | DIR_DIRS);
  46. +    if (options & DIR_VERY_SHORT) options |= DIR_SHORT;
  47.   
  48.      for (; i < ac; ++i) {
  49.         char **eav;
  50. ***************
  51. *** 170,178 ****
  52.         if (CHECKBREAK()) break;
  53.      }
  54.      if (col)  printf("\n");
  55. !    if (filecount > 1) {
  56.         blocks += filecount;     /* account for dir blocks */
  57. !       printf (" %ld Blocks, %ld Bytes used in %d files\n", blocks, bytes, filecount);
  58.      }
  59.      return (0);
  60.   }
  61. --- 177,186 ----
  62.         if (CHECKBREAK()) break;
  63.      }
  64.      if (col)  printf("\n");
  65. !    if (filecount > 1 && !(options & DIR_VERY_SHORT)) {
  66.         blocks += filecount;     /* account for dir blocks */
  67. !       printf (" %ld Blocks, %ld Bytes used in %d files\n",
  68. !           blocks, bytes, filecount);
  69.      }
  70.      return (0);
  71.   }
  72. ***************
  73. *** 182,194 ****
  74.   int options;
  75.   char *filestr;
  76.   {
  77. -    long atol();
  78.      int isadir,slen;
  79.      char sc;
  80.      char *c,*s,*fi;
  81.      struct FileLock *lock;
  82.      char *get_pwd();
  83. !    char *strcpy();
  84.      
  85.   /*     if current dir different from lspec then
  86.          look for ':' or '/' if found lock it and get_pwd.
  87. --- 190,206 ----
  88.   int options;
  89.   char *filestr;
  90.   {
  91.      int isadir,slen;
  92.      char sc;
  93.      char *c,*s,*fi;
  94. + #ifdef MANX
  95.      struct FileLock *lock;
  96. +    long atol();
  97.      char *get_pwd();
  98. ! #else
  99. !    BPTR lock;
  100. !    char *get_pwd(BPTR);
  101. ! #endif
  102.      
  103.   /*     if current dir different from lspec then
  104.          look for ':' or '/' if found lock it and get_pwd.
  105. ***************
  106. *** 200,209 ****
  107.      *s = '\0';
  108.      c = filestr;
  109.      if (!*c) c = cwd;
  110. !    if (strcmp (c, &lspec))  {
  111.         strcpy(lspec, c);
  112.         if (col)      printf("\n");
  113. !       if (lock = (struct FileLock *)Lock(c,SHARED_LOCK)) {
  114.        printf ("Directory of %s\n", get_pwd(lock));
  115.        UnLock(lock);
  116.         }
  117. --- 212,221 ----
  118.      *s = '\0';
  119.      c = filestr;
  120.      if (!*c) c = cwd;
  121. !    if (strcmp (c, lspec))  {
  122.         strcpy(lspec, c);
  123.         if (col)      printf("\n");
  124. !       if (lock = Lock(c,SHARED_LOCK)) {
  125.        printf ("Directory of %s\n", get_pwd(lock));
  126.        UnLock(lock);
  127.         }
  128. *** :z/execom.c    Sun Apr 10 20:41:42 1988
  129. --- execom.c    Sat Apr 30 20:08:27 1988
  130. ***************
  131. *** 96,110 ****
  132.   exec_command(base)
  133.   char *base;
  134.   {
  135.      register char *scr;
  136.      register int i;
  137. -    char buf[32];
  138.    
  139. -    if (!H_stack) {
  140. -       add_history(base);
  141. -       sprintf(buf, "%d", H_tail_base + H_len);
  142. -       set_var(LEVEL_SET, V_HISTNUM, buf);
  143. -    }
  144.      scr = malloc((strlen(base) << 2) + 2);    /* 4X */
  145.      preformat(base, scr);
  146.      i = fcomm(scr, 1);
  147. --- 96,169 ----
  148.   exec_command(base)
  149.   char *base;
  150.   {
  151. +     char comBuf[270];
  152. +     register char *cp;
  153. +     char *cpBeg;
  154. +     char *rcp;
  155. +     FILE *argResult;
  156. +     int ch;
  157. +     int l1, l2;
  158. +  
  159. +     if (!H_stack) {
  160. +     add_history(base);
  161. +     sprintf(comBuf, "%d", H_tail_base + H_len);
  162. +     set_var(LEVEL_SET, V_HISTNUM, comBuf);
  163. +     }
  164. +     for(cp = base; *cp; cp++) {
  165. +     if(*cp == '\\')
  166. +         cp++;
  167. +     else if(*cp == '`') {
  168. +         cpBeg = cp++;
  169. +         for(; *cp; cp++) {
  170. +         if(*cp == '\\')
  171. +             cp++;
  172. +         else if(*cp == '`')
  173. +             break;
  174. +         }
  175. +         if(*cp != '`')
  176. +         break;
  177. +         if(cp - cpBeg == 1) {
  178. +         strcpy(cpBeg, cp + 1);
  179. +         cp = cpBeg - 1;
  180. +         continue;
  181. +         }
  182. +         movmem(cpBeg + 1, comBuf, cp - cpBeg - 1);
  183. +         comBuf[cp - cpBeg - 1] = 0;
  184. +         strcat(comBuf, " >");
  185. +         strcat(comBuf, argExec);
  186. +         exec1_command(comBuf);
  187. +         rcp = comBuf;
  188. +         if(argResult = fopen(argExec,"r")) {
  189. +         while(rcp - comBuf < sizeof(comBuf) - 1 &&
  190. +               (ch = getc(argResult)) != EOF) {
  191. +             if(ch == '\n')
  192. +             ch = ' ';
  193. +             *rcp++ = ch;
  194. +         }
  195. +         fclose(argResult);
  196. +         DeleteFile(argExec);
  197. +         }
  198. +         l2 = rcp - comBuf;
  199. +         l2 = min(l2, max(0, 255 - (cpBeg - base)));
  200. +         l1 = strlen(cp + 1);
  201. +         l1 = min(l1, max(0, 255 - ((cpBeg + l2) - base)));
  202. +         if(l1 && (cp + 1) != (cpBeg + l2)) {
  203. +         movmem(cp + 1, cpBeg + l2, l1);
  204. +         } else if(!l1)
  205. +         cpBeg[l2] = 0;
  206. +         if(l2)
  207. +         movmem(comBuf, cpBeg, l2);
  208. +     }
  209. +     }
  210. +     return(exec1_command(base));
  211. + }
  212. + exec1_command(base)
  213. + char *base;
  214. + {
  215.      register char *scr;
  216.      register int i;
  217.    
  218.      scr = malloc((strlen(base) << 2) + 2);    /* 4X */
  219.      preformat(base, scr);
  220.      i = fcomm(scr, 1);
  221. *** :z/globals.c    Sun Apr 10 20:41:46 1988
  222. --- globals.c    Sat Apr 30 18:20:24 1988
  223. ***************
  224. *** 84,89 ****
  225. --- 84,90 ----
  226.   long  Uniq;              /* unique value                */
  227.   char  *Cin_name, *Cout_name;  /* redirection input/output name or NULL    */
  228.   char  *Pipe1, *Pipe2;          /* the two pipe temp. files        */
  229. + char  *argExec;              /* `arg exec` temp. file            */
  230.   struct Process *Myprocess;
  231.   int   S_histlen = 20;          /* Max # history entries            */
  232.    
  233. *** :z/main.c    Sun Apr 10 20:41:48 1988
  234. --- main.c    Sat Apr 30 18:18:15 1988
  235. ***************
  236. *** 90,96 ****
  237.    
  238.   init()
  239.   {
  240. !    static char pipe1[32], pipe2[32];
  241.    
  242.      stdin->_flags  |= 0x80;         /* make sure we're set as a tty */
  243.      stdout->_flags |= 0x80;       /* incase of redirection in .login */
  244. --- 102,108 ----
  245.    
  246.   init()
  247.   {
  248. !    static char pipe1[32], pipe2[32], arg_exec[32];
  249.    
  250.      stdin->_flags  |= 0x80;         /* make sure we're set as a tty */
  251.      stdout->_flags |= 0x80;       /* incase of redirection in .login */
  252. ***************
  253. *** 107,114 ****
  254. --- 124,133 ----
  255.      Uniq     = (long)Myprocess;
  256.      Pipe1 = pipe1;
  257.      Pipe2 = pipe2;
  258. +    argExec = arg_exec;
  259.      sprintf (pipe1, "ram:pipe1_%ld", Uniq);
  260.      sprintf (pipe2, "ram:pipe2_%ld", Uniq);
  261. +    sprintf (arg_exec, "ram:argExec_%ld", Uniq);
  262.   }
  263.    
  264.    
  265. *** :z/shell.h    Sun Apr 10 20:42:00 1988
  266. --- shell.h    Sat Apr 30 18:19:06 1988
  267. ***************
  268. *** 117,122 ****
  269. --- 140,146 ----
  270.   extern char *Cin_name, *Cout_name;
  271.   extern char  Cin_type,  Cout_type;  /* these variables are in transition */
  272.   extern char *Pipe1, *Pipe2;
  273. + extern char *argExec;
  274.    
  275.   extern long Src_base[MAXSRC];
  276.   extern long Src_pos[MAXSRC];
  277. *** :z/rawconsole.c    Sun Apr 10 20:41:32 1988
  278. --- rawconsole.c    Sat Apr 30 21:43:32 1988
  279. ***************
  280. *** 9,32 ****
  281.    *
  282.    */
  283.   
  284.   #if RAW_CONSOLE
  285.   extern int aux; /* for use with aux: */
  286.   
  287. - #include "shell.h"
  288.   void
  289.   setraw(onoff)
  290.   {
  291.       if (onoff) set_raw();
  292.       else set_con();
  293.   }
  294.   
  295.   char *
  296.   rawgets(line,prompt)
  297.   char *line, *prompt;
  298.   {
  299. !     char *get_var();
  300.       char *gets();
  301.       register int n, pl;
  302.       register int max, i;
  303.       unsigned char c1,c2,c3;
  304. --- 9,71 ----
  305.    *
  306.    */
  307.   
  308. + #include "shell.h"
  309.   #if RAW_CONSOLE
  310.   extern int aux; /* for use with aux: */
  311.   
  312.   void
  313.   setraw(onoff)
  314.   {
  315. + #ifdef MANX
  316.       if (onoff) set_raw();
  317.       else set_con();
  318. + #else
  319. +     if (onoff) raw(stdin);
  320. +     else cooked(stdin);
  321. + #endif
  322.   }
  323.   
  324. + /* fignore is a ',' separated list of file name suffixes.
  325. +  * return true if one of the suffixes is a suffix str + baseLength.
  326. +  */
  327. + static int
  328. + ignoreSuff(baseLength, fignore, str)
  329. + int baseLength;
  330. + char *fignore;
  331. + char *str;
  332. + {
  333. +     char suff[32];
  334. +     char *endStr;
  335. +     char *cp;
  336. +     int len1, len2;
  337. +     if(!fignore || strlen(str) <= baseLength)
  338. +     return(0);
  339. +     endStr = str + baseLength;
  340. +     len1 = strlen(endStr);
  341. +     for(;*fignore; fignore++) {
  342. +     for(cp = suff; *fignore && *fignore != ',';) {
  343. +         *cp++ = *fignore++;
  344. +     }
  345. +     *cp = 0;
  346. +     len2 = strlen(suff);
  347. +     if(!len2 || len1 < len2)
  348. +         continue;
  349. +     if(!strcmp(suff, endStr + (len1 - len2)))
  350. +         return(1);
  351. +     }
  352. +     return(0);
  353. + }
  354.   char *
  355.   rawgets(line,prompt)
  356.   char *line, *prompt;
  357.   {
  358. ! #ifdef MANX
  359.       char *gets();
  360. + #endif
  361.       register int n, pl;
  362.       register int max, i;
  363.       unsigned char c1,c2,c3;
  364. ***************
  365. *** 37,42 ****
  366. --- 76,82 ----
  367.       int insert = 1;
  368.       char rep[20];
  369.       char typeahd[256];
  370. +     char metaExpBuf[256];
  371.       static int width;
  372.       int recall = -1;
  373.       struct HIST *hist;
  374. ***************
  375. *** 46,51 ****
  376. --- 86,92 ----
  377.       fflush(stdout);
  378.       }
  379.       if (!IsInteractive(Input()) || aux ) return(gets(line));
  380. + #ifdef MANX
  381.       if (WaitForChar((long)Input(), 100L) ||   /* don't switch to 1L ...*/
  382.          stdin->_bp < stdin->_bend) {        /* else causes read err's*/
  383.       /*    printf("%s",prompt); */
  384. ***************
  385. *** 52,57 ****
  386. --- 93,99 ----
  387.       gets(line);
  388.       return(line);
  389.       }
  390. + #endif
  391.       setraw(1);
  392.       printf("\015%s\2336n",prompt);
  393.       savn = pl = n = 0;
  394. ***************
  395. *** 148,153 ****
  396. --- 190,283 ----
  397.               break;
  398.               }
  399.           break;
  400. +         case 4: /* List filename alternatives. The parsing is too simple. */
  401. +         strcpy(metaExpBuf, "dir -S ");
  402. +         {
  403. +             int j;
  404. +             for(j = i; j > pl; j--) {
  405. +             if(line[j - 1] == 32)
  406. +                 break;
  407. +             }
  408. +             if(i > j) {
  409. +             strncat(metaExpBuf, line + j, i - j);
  410. +             }
  411. +             strcat(metaExpBuf, "*");
  412. +         }
  413. +         printf("\233%dC\n",max - i);
  414. +         setraw(0);
  415. +         exec1_command(metaExpBuf);
  416. +         setraw(1);
  417. +         line[max] = 0;
  418. +         printf( "%s%s\015\233%dC", prompt, ps, i);
  419. +         break;
  420. +         case 9: /* Filename completion. */
  421. +         metaExpBuf[0] = 0;
  422. +         {
  423. +             char **eav;
  424. +             int eac;
  425. +             int j, k;
  426. +             int length;
  427. +             char *c1, *c2;
  428. +             char *fignore;
  429. +             int orgLen;
  430. +             fignore = get_var(LEVEL_SET,"fignore");
  431. +             for(j = i; j > pl; j--) {
  432. +             if(line[j - 1] == 32)
  433. +                 break;
  434. +             }
  435. +             if(i > j) {
  436. +             strncat(metaExpBuf, line + j, i - j);
  437. +             }
  438. +             orgLen = strlen(metaExpBuf);
  439. +             strcat(metaExpBuf, "*");
  440. +             if(eav = expand(metaExpBuf, &eac)) {
  441. +             for(k = 0; k < eac && fignore; k++) {
  442. +                 if(!ignoreSuff(orgLen, fignore, eav[k]))
  443. +                 break;
  444. +             }
  445. +             if(k == eac) {
  446. +                 free_expand (eav);
  447. +                 break;
  448. +             }
  449. +             strcpy(metaExpBuf, eav[k]);
  450. +             for(; k < eac; k++) {
  451. +                 if(ignoreSuff(orgLen, fignore, eav[k]))
  452. +                 continue;
  453. +                 c1 = metaExpBuf;
  454. +                 c2 = eav[k];
  455. +                 while(*c1 && *c1 == *c2) {
  456. +                 c1++;
  457. +                 c2++;
  458. +                 }
  459. +                 *c1 = 0;
  460. +             }
  461. +             free_expand (eav);
  462. +             if(length = strlen(metaExpBuf)) {
  463. +                 if(isdir(metaExpBuf)) {
  464. +                 if(metaExpBuf[length - 1] != '/' &&
  465. +                    metaExpBuf[length - 1] != ':') {
  466. +                     strcat(metaExpBuf, "/");
  467. +                     length++;
  468. +                 }
  469. +                 } else if(!access(metaExpBuf, 0)) {
  470. +                 strcat(metaExpBuf, " ");
  471. +                 length++;
  472. +                 }
  473. +             }
  474. +             if(i != j + length && max - i)
  475. +                 movmem(line + i, line + j + length,
  476. +                    max - i);
  477. +             if(length)
  478. +                 movmem(metaExpBuf, line + j, length);
  479. +             max += length - (i - j);
  480. +             line[max] = 0;
  481. +             i = j + length;
  482. +             printf( "\015%s%s\015\233%dC", prompt, ps, i);
  483. +             }
  484. +         }
  485. +         break;
  486.           case 8:
  487.           if (i > pl) {
  488.               i--;
  489. ***************
  490. *** 242,247 ****
  491. --- 373,379 ----
  492.               line[max] = '\0';
  493.           }
  494.       }
  495. +     fflush(stdout);
  496.       }
  497.       setraw(0);
  498.       return(NULL);
  499.