home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 1: Amiga
/
FrozenFish-Apr94.iso
/
bbs
/
alib
/
d1xx
/
d145
/
csh.lha
/
Csh
/
DIFFS
< prev
next >
Wrap
Text File
|
1988-05-26
|
12KB
|
507 lines
*** :z/comm1.c Sun Apr 10 20:41:22 1988
--- comm1.c Sat Apr 30 16:47:04 1988
***************
*** 11,18 ****
typedef struct FileInfoBlock FIB;
#define DIR_SHORT 0x01
! #define DIR_FILES 0x02
! #define DIR_DIRS 0x04
extern int has_wild;
char cwd[256];
--- 11,19 ----
typedef struct FileInfoBlock FIB;
#define DIR_SHORT 0x01
! #define DIR_VERY_SHORT 0x02
! #define DIR_FILES 0x04
! #define DIR_DIRS 0x08
extern int has_wild;
char cwd[256];
***************
*** 151,157 ****
bytes = blocks = 0L;
*lspec = '\0';
! options = get_opt("sfd",&i);
if (ac == i) {
++ac;
--- 157,163 ----
bytes = blocks = 0L;
*lspec = '\0';
! options = get_opt("sSfd",&i);
if (ac == i) {
++ac;
***************
*** 158,163 ****
--- 164,170 ----
av[i] = "";
}
if (!(options & (DIR_FILES | DIR_DIRS))) options |= (DIR_FILES | DIR_DIRS);
+ if (options & DIR_VERY_SHORT) options |= DIR_SHORT;
for (; i < ac; ++i) {
char **eav;
***************
*** 170,178 ****
if (CHECKBREAK()) break;
}
if (col) printf("\n");
! if (filecount > 1) {
blocks += filecount; /* account for dir blocks */
! printf (" %ld Blocks, %ld Bytes used in %d files\n", blocks, bytes, filecount);
}
return (0);
}
--- 177,186 ----
if (CHECKBREAK()) break;
}
if (col) printf("\n");
! if (filecount > 1 && !(options & DIR_VERY_SHORT)) {
blocks += filecount; /* account for dir blocks */
! printf (" %ld Blocks, %ld Bytes used in %d files\n",
! blocks, bytes, filecount);
}
return (0);
}
***************
*** 182,194 ****
int options;
char *filestr;
{
- long atol();
int isadir,slen;
char sc;
char *c,*s,*fi;
struct FileLock *lock;
char *get_pwd();
! char *strcpy();
/* if current dir different from lspec then
look for ':' or '/' if found lock it and get_pwd.
--- 190,206 ----
int options;
char *filestr;
{
int isadir,slen;
char sc;
char *c,*s,*fi;
+ #ifdef MANX
struct FileLock *lock;
+ long atol();
char *get_pwd();
! #else
! BPTR lock;
! char *get_pwd(BPTR);
! #endif
/* if current dir different from lspec then
look for ':' or '/' if found lock it and get_pwd.
***************
*** 200,209 ****
*s = '\0';
c = filestr;
if (!*c) c = cwd;
! if (strcmp (c, &lspec)) {
strcpy(lspec, c);
if (col) printf("\n");
! if (lock = (struct FileLock *)Lock(c,SHARED_LOCK)) {
printf ("Directory of %s\n", get_pwd(lock));
UnLock(lock);
}
--- 212,221 ----
*s = '\0';
c = filestr;
if (!*c) c = cwd;
! if (strcmp (c, lspec)) {
strcpy(lspec, c);
if (col) printf("\n");
! if (lock = Lock(c,SHARED_LOCK)) {
printf ("Directory of %s\n", get_pwd(lock));
UnLock(lock);
}
*** :z/execom.c Sun Apr 10 20:41:42 1988
--- execom.c Sat Apr 30 20:08:27 1988
***************
*** 96,110 ****
exec_command(base)
char *base;
{
register char *scr;
register int i;
- char buf[32];
- if (!H_stack) {
- add_history(base);
- sprintf(buf, "%d", H_tail_base + H_len);
- set_var(LEVEL_SET, V_HISTNUM, buf);
- }
scr = malloc((strlen(base) << 2) + 2); /* 4X */
preformat(base, scr);
i = fcomm(scr, 1);
--- 96,169 ----
exec_command(base)
char *base;
{
+ char comBuf[270];
+ register char *cp;
+ char *cpBeg;
+ char *rcp;
+ FILE *argResult;
+ int ch;
+ int l1, l2;
+
+ if (!H_stack) {
+ add_history(base);
+ sprintf(comBuf, "%d", H_tail_base + H_len);
+ set_var(LEVEL_SET, V_HISTNUM, comBuf);
+ }
+ for(cp = base; *cp; cp++) {
+ if(*cp == '\\')
+ cp++;
+ else if(*cp == '`') {
+ cpBeg = cp++;
+ for(; *cp; cp++) {
+ if(*cp == '\\')
+ cp++;
+ else if(*cp == '`')
+ break;
+ }
+ if(*cp != '`')
+ break;
+ if(cp - cpBeg == 1) {
+ strcpy(cpBeg, cp + 1);
+ cp = cpBeg - 1;
+ continue;
+ }
+ movmem(cpBeg + 1, comBuf, cp - cpBeg - 1);
+ comBuf[cp - cpBeg - 1] = 0;
+ strcat(comBuf, " >");
+ strcat(comBuf, argExec);
+ exec1_command(comBuf);
+ rcp = comBuf;
+ if(argResult = fopen(argExec,"r")) {
+ while(rcp - comBuf < sizeof(comBuf) - 1 &&
+ (ch = getc(argResult)) != EOF) {
+ if(ch == '\n')
+ ch = ' ';
+ *rcp++ = ch;
+ }
+ fclose(argResult);
+ DeleteFile(argExec);
+ }
+ l2 = rcp - comBuf;
+ l2 = min(l2, max(0, 255 - (cpBeg - base)));
+ l1 = strlen(cp + 1);
+ l1 = min(l1, max(0, 255 - ((cpBeg + l2) - base)));
+ if(l1 && (cp + 1) != (cpBeg + l2)) {
+ movmem(cp + 1, cpBeg + l2, l1);
+ } else if(!l1)
+ cpBeg[l2] = 0;
+ if(l2)
+ movmem(comBuf, cpBeg, l2);
+ }
+ }
+ return(exec1_command(base));
+ }
+
+ exec1_command(base)
+ char *base;
+ {
register char *scr;
register int i;
scr = malloc((strlen(base) << 2) + 2); /* 4X */
preformat(base, scr);
i = fcomm(scr, 1);
*** :z/globals.c Sun Apr 10 20:41:46 1988
--- globals.c Sat Apr 30 18:20:24 1988
***************
*** 84,89 ****
--- 84,90 ----
long Uniq; /* unique value */
char *Cin_name, *Cout_name; /* redirection input/output name or NULL */
char *Pipe1, *Pipe2; /* the two pipe temp. files */
+ char *argExec; /* `arg exec` temp. file */
struct Process *Myprocess;
int S_histlen = 20; /* Max # history entries */
*** :z/main.c Sun Apr 10 20:41:48 1988
--- main.c Sat Apr 30 18:18:15 1988
***************
*** 90,96 ****
init()
{
! static char pipe1[32], pipe2[32];
stdin->_flags |= 0x80; /* make sure we're set as a tty */
stdout->_flags |= 0x80; /* incase of redirection in .login */
--- 102,108 ----
init()
{
! static char pipe1[32], pipe2[32], arg_exec[32];
stdin->_flags |= 0x80; /* make sure we're set as a tty */
stdout->_flags |= 0x80; /* incase of redirection in .login */
***************
*** 107,114 ****
--- 124,133 ----
Uniq = (long)Myprocess;
Pipe1 = pipe1;
Pipe2 = pipe2;
+ argExec = arg_exec;
sprintf (pipe1, "ram:pipe1_%ld", Uniq);
sprintf (pipe2, "ram:pipe2_%ld", Uniq);
+ sprintf (arg_exec, "ram:argExec_%ld", Uniq);
}
*** :z/shell.h Sun Apr 10 20:42:00 1988
--- shell.h Sat Apr 30 18:19:06 1988
***************
*** 117,122 ****
--- 140,146 ----
extern char *Cin_name, *Cout_name;
extern char Cin_type, Cout_type; /* these variables are in transition */
extern char *Pipe1, *Pipe2;
+ extern char *argExec;
extern long Src_base[MAXSRC];
extern long Src_pos[MAXSRC];
*** :z/rawconsole.c Sun Apr 10 20:41:32 1988
--- rawconsole.c Sat Apr 30 21:43:32 1988
***************
*** 9,32 ****
*
*/
#if RAW_CONSOLE
extern int aux; /* for use with aux: */
- #include "shell.h"
-
void
setraw(onoff)
{
if (onoff) set_raw();
else set_con();
}
char *
rawgets(line,prompt)
char *line, *prompt;
{
! char *get_var();
char *gets();
register int n, pl;
register int max, i;
unsigned char c1,c2,c3;
--- 9,71 ----
*
*/
+ #include "shell.h"
+
#if RAW_CONSOLE
extern int aux; /* for use with aux: */
void
setraw(onoff)
{
+ #ifdef MANX
if (onoff) set_raw();
else set_con();
+ #else
+ if (onoff) raw(stdin);
+ else cooked(stdin);
+ #endif
}
+ /* fignore is a ',' separated list of file name suffixes.
+ * return true if one of the suffixes is a suffix str + baseLength.
+ */
+
+ static int
+ ignoreSuff(baseLength, fignore, str)
+ int baseLength;
+ char *fignore;
+ char *str;
+ {
+ char suff[32];
+ char *endStr;
+ char *cp;
+ int len1, len2;
+
+ if(!fignore || strlen(str) <= baseLength)
+ return(0);
+ endStr = str + baseLength;
+ len1 = strlen(endStr);
+ for(;*fignore; fignore++) {
+ for(cp = suff; *fignore && *fignore != ',';) {
+ *cp++ = *fignore++;
+ }
+ *cp = 0;
+ len2 = strlen(suff);
+ if(!len2 || len1 < len2)
+ continue;
+ if(!strcmp(suff, endStr + (len1 - len2)))
+ return(1);
+ }
+ return(0);
+ }
+
char *
rawgets(line,prompt)
char *line, *prompt;
{
! #ifdef MANX
char *gets();
+ #endif
register int n, pl;
register int max, i;
unsigned char c1,c2,c3;
***************
*** 37,42 ****
--- 76,82 ----
int insert = 1;
char rep[20];
char typeahd[256];
+ char metaExpBuf[256];
static int width;
int recall = -1;
struct HIST *hist;
***************
*** 46,51 ****
--- 86,92 ----
fflush(stdout);
}
if (!IsInteractive(Input()) || aux ) return(gets(line));
+ #ifdef MANX
if (WaitForChar((long)Input(), 100L) || /* don't switch to 1L ...*/
stdin->_bp < stdin->_bend) { /* else causes read err's*/
/* printf("%s",prompt); */
***************
*** 52,57 ****
--- 93,99 ----
gets(line);
return(line);
}
+ #endif
setraw(1);
printf("\015%s\2336n",prompt);
savn = pl = n = 0;
***************
*** 148,153 ****
--- 190,283 ----
break;
}
break;
+ case 4: /* List filename alternatives. The parsing is too simple. */
+ strcpy(metaExpBuf, "dir -S ");
+ {
+ int j;
+
+ for(j = i; j > pl; j--) {
+ if(line[j - 1] == 32)
+ break;
+ }
+ if(i > j) {
+ strncat(metaExpBuf, line + j, i - j);
+ }
+ strcat(metaExpBuf, "*");
+ }
+ printf("\233%dC\n",max - i);
+ setraw(0);
+ exec1_command(metaExpBuf);
+ setraw(1);
+ line[max] = 0;
+ printf( "%s%s\015\233%dC", prompt, ps, i);
+ break;
+ case 9: /* Filename completion. */
+ metaExpBuf[0] = 0;
+ {
+ char **eav;
+ int eac;
+ int j, k;
+ int length;
+ char *c1, *c2;
+ char *fignore;
+ int orgLen;
+
+ fignore = get_var(LEVEL_SET,"fignore");
+ for(j = i; j > pl; j--) {
+ if(line[j - 1] == 32)
+ break;
+ }
+ if(i > j) {
+ strncat(metaExpBuf, line + j, i - j);
+ }
+ orgLen = strlen(metaExpBuf);
+ strcat(metaExpBuf, "*");
+ if(eav = expand(metaExpBuf, &eac)) {
+ for(k = 0; k < eac && fignore; k++) {
+ if(!ignoreSuff(orgLen, fignore, eav[k]))
+ break;
+ }
+ if(k == eac) {
+ free_expand (eav);
+ break;
+ }
+ strcpy(metaExpBuf, eav[k]);
+ for(; k < eac; k++) {
+ if(ignoreSuff(orgLen, fignore, eav[k]))
+ continue;
+ c1 = metaExpBuf;
+ c2 = eav[k];
+ while(*c1 && *c1 == *c2) {
+ c1++;
+ c2++;
+ }
+ *c1 = 0;
+ }
+ free_expand (eav);
+ if(length = strlen(metaExpBuf)) {
+ if(isdir(metaExpBuf)) {
+ if(metaExpBuf[length - 1] != '/' &&
+ metaExpBuf[length - 1] != ':') {
+ strcat(metaExpBuf, "/");
+ length++;
+ }
+ } else if(!access(metaExpBuf, 0)) {
+ strcat(metaExpBuf, " ");
+ length++;
+ }
+ }
+ if(i != j + length && max - i)
+ movmem(line + i, line + j + length,
+ max - i);
+ if(length)
+ movmem(metaExpBuf, line + j, length);
+ max += length - (i - j);
+ line[max] = 0;
+ i = j + length;
+ printf( "\015%s%s\015\233%dC", prompt, ps, i);
+ }
+ }
+ break;
case 8:
if (i > pl) {
i--;
***************
*** 242,247 ****
--- 373,379 ----
line[max] = '\0';
}
}
+ fflush(stdout);
}
setraw(0);
return(NULL);