home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
GEMini Atari
/
GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso
/
zip
/
cli
/
tcsh.zoo
/
source
/
diffs
< prev
next >
Wrap
Text File
|
1991-12-15
|
52KB
|
2,170 lines
*** ./orig/config_f.h Fri Oct 25 22:35:28 1991
--- ./config_f.h Mon Nov 11 17:19:28 1991
***************
*** 56,62 ****
* if you don't have <locale.h>, you don't want
* to define this.
*/
! #define NLS
/*
* LOGINFIRST Source ~/.login before ~/.cshrc
--- 56,62 ----
* if you don't have <locale.h>, you don't want
* to define this.
*/
! #undef NLS
/*
* LOGINFIRST Source ~/.login before ~/.cshrc
***************
*** 95,101 ****
* on the name of the tty, and environment.
* Does not make sense in the modern window systems!
*/
! #define AUTOLOGOUT
/*
* SUSPENDED Newer shells say 'Suspended' instead of 'Stopped'.
--- 95,101 ----
* on the name of the tty, and environment.
* Does not make sense in the modern window systems!
*/
! #undef AUTOLOGOUT
/*
* SUSPENDED Newer shells say 'Suspended' instead of 'Stopped'.
***************
*** 116,121 ****
--- 116,129 ----
* provided.
*/
#undef SYSMALLOC
+
+
+ /*
+ * ALTESC Allow the user to define the escape character to be something
+ * other than \ (useful if \ is a common file name character.
+ * e.g. for MiNT)
+ */
+ #define ALTESC
/*
*** ./orig/ed.chared.c Fri Oct 25 22:33:24 1991
--- ./ed.chared.c Mon Nov 11 17:55:18 1991
***************
*** 470,476 ****
--- 470,480 ----
for (;;) {
while (*p != HIST && p < Cursor)
++p;
+ #ifdef ALTESC
+ for (i = 1; (p - i) >= InputBuf && p[-i] == escchar; i++);
+ #else
for (i = 1; (p - i) >= InputBuf && p[-i] == '\\'; i++);
+ #endif
if (i % 2 == 0)
++p;
if (p >= Cursor)
*** ./orig/ed.init.c Fri Oct 25 22:33:42 1991
--- ./ed.init.c Mon Nov 11 16:20:30 1991
***************
*** 43,48 ****
--- 43,52 ----
#include "tc.h"
#include "ed.defns.h"
+ #ifdef __MINT__
+ extern int __mint; /* version of MiNT we're running under */
+ #endif
+
#if defined(TERMIO) || defined(POSIX)
/*
* Aix compatible names
***************
*** 1035,1044 ****
--- 1039,1061 ----
#else /* GSTTY */
if (T_Tabs) { /* order of &= and |= is important to XTABS */
xb.sg_flags &= ~(RAW | ECHO | LCASE | XTABS | VTDELAY | ALLDELAY);
+ # ifdef __MINT__
+ /* TOS, and older versions of MiNT, have trouble with CBREAK mode, so we use
+ * raw mode instead
+ */
+ if (__mint < 91)
+ xb.sg_flags |= (RAW | CRMOD | ANYP);
+ else
+ # endif /* __MINT__ */
xb.sg_flags |= (CBREAK | CRMOD | ANYP);
}
else {
xb.sg_flags &= ~(RAW | ECHO | LCASE | VTDELAY | ALLDELAY);
+ # ifdef __MINT__
+ if (__mint < 91)
+ xb.sg_flags |= (RAW | CRMOD | ANYP | XTABS);
+ else
+ # endif /* __MINT__ */
xb.sg_flags |= (CBREAK | CRMOD | ANYP | XTABS);
}
*** ./orig/ed.inputl.c Fri Oct 25 22:33:46 1991
--- ./ed.inputl.c Mon Nov 25 12:55:42 1991
***************
*** 53,59 ****
--- 53,63 ----
extern bool Tty_raw_mode;
/* mismatched first character */
+ #ifdef ALTESC
+ static Char mismatch[] = {'!', '^', '-', '%', '\0'};
+ #else
static Char mismatch[] = {'!', '\\', '^', '-', '%', '\0'};
+ #endif
static int GetNextCommand __P((KEYCMD *, Char *));
static int SpellLine __P((int));
***************
*** 86,92 ****
--- 90,101 ----
if (!Tty_raw_mode && MacroLvl < 0) {
long chrs = 0;
+ #ifndef __MINT__
+ /* MiNT _always_ wants to go into raw mode, so don't bother with the
+ * FIONREAD test
+ */
(void) ioctl(SHIN, FIONREAD, (ioctl_t) & chrs);
+ #endif
if (chrs == 0) {
if (Rawmode() < 0)
return 0;
***************
*** 553,559 ****
--- 562,572 ----
Cursor--;
endflag = 0;
}
+ #ifdef ALTESC
+ if (!Strchr(mismatch, *argptr) && *argptr != escchar &&
+ #else
if (!Strchr(mismatch, *argptr) &&
+ #endif
(!cmdonly || starting_a_command(argptr, InputBuf))) {
switch (tenematch(InputBuf, INBUFSIZ, Cursor - InputBuf, SPELL)) {
case 1: /* corrected */
*** ./orig/glob.c Tue Aug 6 03:19:38 1991
--- ./glob.c Mon Nov 11 23:59:02 1991
***************
*** 114,123 ****
#define NOT '!'
#define ALTNOT '^'
#define QUESTION '?'
! #define QUOTE '\\'
#define RANGE '-'
#define RBRACKET ']'
#define SEP '/'
#define STAR '*'
#define TILDE '~'
#define UNDERSCORE '_'
--- 114,130 ----
#define NOT '!'
#define ALTNOT '^'
#define QUESTION '?'
! #ifdef ALTESC
! #define QUOTE escchar
! #else
! #define QUOTE '\\'
! #endif
#define RANGE '-'
#define RBRACKET ']'
#define SEP '/'
+ #if defined(__MINT__) && defined(ALTESC)
+ #define SEP2 '\\'
+ #endif
#define STAR '*'
#define TILDE '~'
#define UNDERSCORE '_'
***************
*** 449,454 ****
--- 456,464 ----
return (0);
if (((pglob->gl_flags & GLOB_MARK) &&
+ #if defined(__MINT__) && defined(ALTESC)
+ (pathend[-1] != SEP2 || escchar == SEP2) &&
+ #endif
pathend[-1] != SEP) &&
(S_ISDIR(sbuf.st_mode)
#ifdef S_IFLNK
***************
*** 467,473 ****
--- 477,487 ----
/* find end of next segment, copy tentatively to pathend */
q = pathend;
p = pattern;
+ #if defined(__MINT__) && defined(ALTESC)
+ while (*p != EOS && *p != SEP && (*p != SEP2 || escchar == SEP2)) {
+ #else
while (*p != EOS && *p != SEP) {
+ #endif
if (ismeta(*p))
anymeta = 1;
*q++ = *p++;
***************
*** 476,482 ****
--- 490,500 ----
if (!anymeta) { /* no expansion, do next segment */
pathend = q;
pattern = p;
+ #if defined(__MINT__) && defined(ALTESC)
+ while (*pattern == SEP || (escchar != SEP2 && *pattern == SEP2))
+ #else
while (*pattern == SEP)
+ #endif
*pathend++ = *pattern++;
}
else /* need expansion, recurse */
*** ./orig/pathnames.h Fri Oct 25 22:35:32 1991
--- ./pathnames.h Sun Nov 10 00:56:32 1991
***************
*** 54,59 ****
--- 54,65 ----
# define _PATH_DOTCSHRC "/etc/cshrc"
#endif /* convex || __convex__ */
+ #ifdef __MINT__
+ # define _PATH_DOTLOGIN "/etc/login.csh"
+ # define _PATH_DOTLOGOUT "/etc/logout.csh"
+ # define _PATH_DOTCSHRC "/etc/csh.rc"
+ #endif /* __MINT__ */
+
#if defined(sgi) || defined(OREO)
# define _PATH_DOTLOGIN "/etc/cshrc"
#endif /* sgi || OREO */
***************
*** 70,76 ****
--- 76,86 ----
#ifdef notdef
# define _PATH_CSHELL "/bin/csh"
#endif
+ #ifdef __MINT__
+ #define _PATH_TCSHELL "/bin/tcsh"
+ #else
#define _PATH_TCSHELL "/usr/local/bin/tcsh"
+ #endif
#define _PATH_LOGIN "/bin/login"
#ifdef NEWGRP
*** ./orig/sh.char.c Fri Oct 25 22:32:00 1991
--- ./sh.char.c Mon Nov 11 00:31:38 1991
***************
*** 49,56 ****
--- 49,61 ----
/* bs ht nl vt */
_CTR, _CTR|_SP|_META, _CTR|_NL|_META, _CTR,
+ #ifndef __MINT__
/* np cr so si */
_CTR, _CTR, _CTR, _CTR,
+ #else
+ /* np cr so si */
+ _CTR, _CTR|_SP|_META, _CTR, _CTR,
+ #endif
/* dle dc1 dc2 dc3 */
_CTR, _CTR, _CTR, _CTR,
*** ./orig/sh.dir.c Fri Oct 25 22:31:48 1991
--- ./sh.dir.c Sat Nov 16 19:42:16 1991
***************
*** 39,44 ****
--- 39,48 ----
#include "sh.h"
+ #ifdef __MINT__
+ extern Char *Lastslash();
+ #endif
+
/*
* C Shell - directory management
*/
***************
*** 408,414 ****
--- 412,422 ----
{
Char *dp;
+ #ifdef __MINT__
+ if (!is_abspath(cp)) {
+ #else
if (*cp != '/') {
+ #endif
register Char *p, *q;
int cwdlen;
***************
*** 477,484 ****
--- 485,497 ----
serrno = errno;
}
+ #ifdef __MINT__
+ if (!is_abspath(cp) && !prefix(STRdotsl, cp) &&
+ !prefix(STRdotdotsl, cp) && (c = adrof(STRcdpath))) {
+ #else
if (cp[0] != '/' && !prefix(STRdotsl, cp) && !prefix(STRdotdotsl, cp)
&& (c = adrof(STRcdpath))) {
+ #endif
Char **cdp;
register Char *p;
Char buf[MAXPATHLEN];
***************
*** 496,502 ****
--- 509,519 ----
}
}
dp = value(cp);
+ #ifdef __MINT__
+ if ((is_abspath(dp) || dp[0] == '.') && chdir(short2str(dp)) >= 0) {
+ #else
if ((dp[0] == '/' || dp[0] == '.') && chdir(short2str(dp)) >= 0) {
+ #endif
xfree((ptr_t) cp);
cp = Strsave(dp);
printd = 1;
***************
*** 717,727 ****
--- 734,752 ----
* christos: if the path given does not start with a slash prepend cwd. If
* cwd does not start with a slash or the result would be too long abort().
*/
+ #ifdef __MINT__
+ if (!is_abspath(cp)) {
+ #else
if (*cp != '/') {
+ #endif
Char tmpdir[MAXPATHLEN];
p1 = value(STRcwd);
+ #ifdef __MINT__
+ if (p1 == NULL || !is_abspath(p1))
+ #else
if (p1 == NULL || *p1 != '/')
+ #endif
abort();
if (Strlen(p1) + Strlen(cp) + 1 >= MAXPATHLEN)
abort();
***************
*** 743,756 ****
--- 768,790 ----
while (*p) { /* for each component */
sp = p; /* save slash address */
+ #ifdef __MINT__
+ do { ++p;
+ } while (is_dirsep(*p)); /* flush extra slashes */
+ #else
while (*++p == '/') /* flush extra slashes */
;
+ #endif
if (p != ++sp)
for (p1 = sp, p2 = p; *p1++ = *p2++;);
p = sp; /* save start of component */
slash = 0;
while (*++p) /* find next slash or end of path */
+ #ifdef __MINT__
+ if (is_dirsep(*p)) {
+ #else
if (*p == '/') {
+ #endif
slash = 1;
*p = 0;
break;
***************
*** 798,809 ****
--- 832,851 ----
* find length of p
*/
for (p1 = p; *p1++;);
+ #ifdef __MINT__
+ if (!is_abspath(link)) {
+ #else
if (*link != '/') {
+ #endif
/*
* Relative path, expand it between the "yyy/" and the
* "/..". First, back sp up to the character past "yyy/".
*/
+ #ifdef __MINT__
+ do { --sp; } while (!is_dirsep(*sp)) ;
+ #else
while (*--sp != '/');
+ #endif
sp++;
*sp = 0;
/*
***************
*** 846,852 ****
--- 888,898 ----
#endif /* S_IFLNK */
*sp = '/';
if (sp != cp)
+ #ifdef __MINT__
+ do { --sp; } while (!is_dirsep(*sp));
+ #else
while (*--sp != '/');
+ #endif
if (slash) {
for (p1 = sp + 1, p2 = p + 1; *p1++ = *p2++;);
p = sp;
***************
*** 881,893 ****
--- 927,947 ----
* find length of p
*/
for (p1 = p; *p1++;);
+ #ifdef __MINT__
+ if (!is_abspath(link)) {
+ #else
if (*link != '/') {
+ #endif
/*
* Relative path, expand it between the "yyy/" and the
* remainder. First, back sp up to the character past
* "yyy/".
*/
+ #ifdef __MINT__
+ do { --sp; } while (!is_dirsep(*sp));
+ #else
while (*--sp != '/');
+ #endif
sp++;
*sp = 0;
/*
***************
*** 942,949 ****
--- 996,1008 ----
/*
* See if we're not in a subdir of STRhome
*/
+ #ifdef __MINT__
+ if (p1 && is_abspath(p1) &&
+ (Strncmp(p1, cp, cc) != 0 || (!is_dirsep(cp[cc]) && cp[cc] != '\0'))) {
+ #else
if (p1 && *p1 == '/' &&
(Strncmp(p1, cp, cc) != 0 || (cp[cc] != '/' && cp[cc] != '\0'))) {
+ #endif
static ino_t home_ino = -1;
static dev_t home_dev = -1;
static Char *home_ptr = NULL;
***************
*** 968,975 ****
--- 1027,1040 ----
sp = (Char *) - 1;
break;
}
+ #ifdef __MINT__
+ sp = Lastslash(p2);
+ if (sp == 0 && p2[1] == ':') sp = p2;
+ if (sp) *sp = '\0';
+ #else
if (sp = Strrchr(p2, '/'))
*sp = '\0';
+ #endif
}
/*
* See if we found it
*** ./orig/sh.dol.c Fri Oct 25 22:31:52 1991
--- ./sh.dol.c Sat Nov 16 16:40:26 1991
***************
*** 173,179 ****
for (;;) {
c = DgetC(DODOL);
! if (c == '\\') {
c = DgetC(0);
if (c == DEOF) {
unDredc(c);
--- 173,179 ----
for (;;) {
c = DgetC(DODOL);
! if (c == escchar) {
c = DgetC(0);
if (c == DEOF) {
unDredc(c);
***************
*** 297,303 ****
--- 297,308 ----
}
break;
+ #ifdef ALTESC
+ default:
+ if (c != escchar) break;
+ #else
case '\\':
+ #endif
c = DgetC(0); /* No $ subst! */
if (c == '\n' || c == DEOF) {
done = 0;
***************
*** 748,755 ****
register Char *lbp, *obp, *mbp;
Char **vp;
bool quoted;
char *tmp;
-
if (creat(tmp = short2str(shtemp), 0600) < 0)
stderror(ERR_SYSTEM, tmp, strerror(errno));
(void) close(0);
--- 753,769 ----
register Char *lbp, *obp, *mbp;
Char **vp;
bool quoted;
+ #ifdef __MINT__
+ int tf;
+ extern int csh_tmpfile(); /* in sh.c */
+
+ tf = csh_tmpfile();
+ if (tf < 0)
+ stderror(ERR_SYSTEM, "tmpfile", strerror(errno));
+ (void)dup2(tf, 0);
+ (void)close(tf);
+ #else
char *tmp;
if (creat(tmp = short2str(shtemp), 0600) < 0)
stderror(ERR_SYSTEM, tmp, strerror(errno));
(void) close(0);
***************
*** 760,766 ****
--- 774,783 ----
errno = oerrno;
stderror(ERR_SYSTEM, tmp, strerror(errno));
}
+
(void) unlink(tmp); /* 0 0 inode! */
+ #endif /* __MINT__ */
+
Dv[0] = term;
Dv[1] = NOSTR;
gflag = 0;
***************
*** 830,839 ****
if ((c &= TRIM) == 0)
continue;
/* \ quotes \ $ ` here */
! if (c == '\\') {
c = DgetC(0);
if (!any("$\\`", c))
! unDgetC(c | QUOTE), c = '\\';
else
c |= QUOTE;
}
--- 847,860 ----
if ((c &= TRIM) == 0)
continue;
/* \ quotes \ $ ` here */
! if (c == escchar) {
c = DgetC(0);
+ #ifdef ALTESC
+ if (c != '$' && c != escchar && c != '`')
+ #else
if (!any("$\\`", c))
! #endif
! unDgetC(c | QUOTE), c = escchar;
else
c |= QUOTE;
}
***************
*** 887,889 ****
--- 908,911 ----
blkfree(pargv), pargv = 0;
}
}
+
*** ./orig/sh.exec.c Fri Oct 25 22:31:58 1991
--- ./sh.exec.c Sun Nov 10 13:07:34 1991
***************
*** 41,50 ****
--- 41,64 ----
#include "tc.h"
#include "tw.h"
+ #ifdef __MINT__
+ /* MiNT/TOS programs are typically given one of the following extensions;
+ * during an exec we should try all of them
+ */
+ #define TOS_EXT 6
+ char *tos_extension[] = { "", ".ttp", ".prg", ".tos", ".gtp", ".csh" };
+ #endif
+
/*
* C shell
*/
+ #ifdef __MINT__
+ extern char **environ;
+ int csh_execve(char *, char **, char **);
+ #define execv(f, t) csh_execve(f, t, environ)
+ #endif
+
/*
* System level search and execute of a command.
* We look in each directory for the specified command name.
***************
*** 480,485 ****
--- 494,511 ----
(dp->d_name[1] == '\0' ||
dp->d_name[1] == '.' && dp->d_name[2] == '\0'))
continue;
+ #ifdef __MINT__
+ { char *s = rindex(dp->d_name, '.');
+ int i;
+
+ if (s)
+ for (i = 0; i < TOS_EXT; i++) {
+ if (!strcmp(s, tos_extension[i])) {
+ *s = 0; break;
+ }
+ }
+ }
+ #endif /* __MINT__ */
hashval = hash(hashname(str2short(dp->d_name)), i);
bis(xhash, hashval);
/* tw_add_comm_name (dp->d_name); */
***************
*** 586,591 ****
--- 612,653 ----
* if dir_ok is set and the pathname refers to a directory.
* This is a bit kludgy, but in the name of optimization...
*/
+ #ifdef __MINT__
+ int
+ executable(dir, name, dir_ok)
+ Char *dir, *name;
+ bool dir_ok;
+ {
+ char *ext;
+ int i;
+ struct stat stbuf;
+ Char path[MAXPATHLEN + 1];
+ char *strname;
+
+ if (dir && *dir) {
+ copyn(path, dir, MAXPATHLEN);
+ catn(path, name, MAXPATHLEN);
+ strname = short2str(path);
+ }
+ else
+ strname = short2str(name);
+
+ ext = name = alloca(strlen(strname) + 5);
+ while (*strname)
+ *ext++ = *strname++;
+
+ for (i = 0; i < TOS_EXT; i++) {
+ strcpy(ext, tos_extension[i]);
+ if (stat(name, &stbuf) != -1 &&
+ ((dir_ok && S_ISDIR(stbuf.st_mode)) ||
+ (S_ISREG(stbuf.st_mode) &&
+ ((stbuf.st_mode & (S_IXOTH|S_IXGRP|S_IXUSR)) || i == TOS_EXT-1))))
+ return 1;
+ }
+ return 0;
+ }
+
+ #else /* __MINT__ */
int
executable(dir, name, dir_ok)
Char *dir, *name;
***************
*** 609,614 ****
--- 671,677 ----
access(strname, X_OK) == 0) ||
(dir_ok && S_ISDIR(stbuf.st_mode))));
}
+ #endif /* __MINT__ */
void
tellmewhat(lex)
***************
*** 699,701 ****
--- 762,792 ----
}
sp->word = s0; /* we save and then restore this */
}
+
+ #ifdef __MINT__
+
+ #include <process.h>
+
+ int
+ csh_execve(path, argv, envp)
+ char *path;
+ char **argv, **envp;
+ {
+ int i;
+ char *newpath, *s;
+
+ newpath = s = alloca(strlen(path) + 5);
+ while (*path) {
+ *s++ = *path++;
+ }
+ *s = 0;
+
+ for (i = 0; i < TOS_EXT; i++) {
+ strcpy(s, tos_extension[i]);
+ if (access(newpath, 0) == 0) {
+ return _spawnve(P_OVERLAY, newpath, argv, envp);
+ }
+ }
+ return -1;
+ }
+ #endif /* __MINT__ */
*** ./orig/sh.func.c Fri Oct 25 22:32:12 1991
--- ./sh.func.c Mon Nov 11 18:06:16 1991
***************
*** 272,278 ****
--- 272,289 ----
islogin();
rechist();
(void) signal(SIGTERM, parterm);
+ #ifdef __MINT__
+ {
+ extern int csh_execve(); /* in sh.exec.c */
+ extern char **environ;
+ char *args[3];
+
+ args[0] = "login"; args[1] = short2str(v[1]); args[2] = NULL;
+ (void)csh_execve(_PATH_LOGIN, args, environ);
+ }
+ #else
(void) execl(_PATH_LOGIN, "login", short2str(v[1]), NULL);
+ #endif
untty();
xexit(1);
}
***************
*** 818,824 ****
--- 829,839 ----
found = 1;
do {
c = readc(1);
+ #ifdef ALTESC
+ if (c == escchar && (c = readc(1)) == '\n')
+ #else
if (c == '\\' && (c = readc(1)) == '\n')
+ #endif
c = ' ';
if (c == '\'' || c == '"')
if (d == 0)
*** ./orig/sh.glob.c Fri Oct 25 22:32:16 1991
--- ./sh.glob.c Mon Nov 11 23:52:12 1991
***************
*** 95,101 ****
--- 95,106 ----
gstart = gbuf;
*gstart++ = *s++;
u = s;
+ #ifdef __MINT__
+ for (b = gstart, e = &gbuf[MAXPATHLEN-1]; *s && *s != '/' && *s != '\\' &&
+ b < e;
+ #else
for (b = gstart, e = &gbuf[MAXPATHLEN - 1]; *s && *s != '/' && b < e;
+ #endif
*b++ = *s++);
*b = EOS;
if (gethdir(gstart)) {
***************
*** 132,138 ****
--- 137,148 ----
* kfk - 17 Jan 1984 - stack hack allows user to get at arbitrary dir names
* in stack. PWP: let =foobar pass through (for X windows)
*/
+ #ifdef __MINT__
+ if ((Isdigit(s[1]) || s[1] == '-') && (s[2] == '\0' || s[2] == '/' ||
+ s[2] == '\\')) {
+ #else
if ((Isdigit(s[1]) || s[1] == '-') && (s[2] == '\0' || s[2] == '/')) {
+ #endif
dig = (s[1] == '-') ? -1 : s[1] - '0';
if (!getstakd(gp, dig)) {
blkfree(nv);
***************
*** 613,619 ****
--- 623,633 ----
}
lp++;
for (rp = lp; *rp && *rp != '`'; rp++)
+ #ifdef ALTESC
+ if (*rp == escchar) {
+ #else
if (*rp == '\\') {
+ #endif
rp++;
if (!*rp)
goto oops;
***************
*** 742,748 ****
--- 756,766 ----
hadnl = 1;
continue;
}
+ #ifndef __MINT__
if (!quoted && (c == ' ' || c == '\t'))
+ #else
+ if (!quoted && (c == ' ' || c == '\t' || c == '\r'))
+ #endif
break;
cnt++;
psave(c | quoted);
*** ./orig/sh.h Fri Oct 25 22:32:58 1991
--- ./sh.h Sat Nov 16 18:55:06 1991
***************
*** 106,112 ****
#ifdef _SEQUENT_
# include <sys/procstats.h>
#endif /* _SEQUENT_ */
! #if defined(POSIX) || SVID > 0
# include <sys/times.h>
#endif /* POSIX || SVID > 0 */
--- 106,112 ----
#ifdef _SEQUENT_
# include <sys/procstats.h>
#endif /* _SEQUENT_ */
! #if defined(POSIX) || SVID > 0 || defined(__MINT__)
# include <sys/times.h>
#endif /* POSIX || SVID > 0 */
***************
*** 142,148 ****
# include <termios.h>
#endif /* POSIX */
! #ifdef POSIX
/*
* We should be using setpgid and setpgid
* by now, but in some systems we use the
--- 142,148 ----
# include <termios.h>
#endif /* POSIX */
! #if defined(POSIX) || defined(__MINT__)
/*
* We should be using setpgid and setpgid
* by now, but in some systems we use the
***************
*** 245,250 ****
--- 245,255 ----
#endif
+ #ifdef __MINT__
+ #define is_dirsep(c) ((c) == '/' || (c) == '\\')
+ #define is_abspath(p) (is_dirsep(*p) || (p[1] == ':'))
+ #endif
+
typedef int bool;
#include "sh.types.h"
***************
*** 433,438 ****
--- 438,449 ----
sigret_t (*parintr) (); /* Parents interrupt catch */
sigret_t (*parterm) (); /* Parents terminate catch */
+
+ #ifdef ALTESC
+ Char escchar; /* character that should be used instead of \ for quoting */
+ #else
+ #define escchar '\\'
+ #endif
/*
* Lexical definitions.
*** ./orig/sh.lex.c Fri Oct 25 22:32:28 1991
--- ./sh.lex.c Sun Nov 17 14:27:08 1991
***************
*** 114,120 ****
--- 114,128 ----
*/
static bool hadhist = 0;
+ #ifdef ALTESC
/*
+ * this is the actual escape character (normally hardwired to '\\'),
+ * which we allow changing via "set histchar=^", for example.
+ */
+ Char escchar = '\\';
+ #endif
+
+ /*
* Avoid alias expansion recursion via \!#
*/
int hleft;
***************
*** 148,154 ****
--- 156,166 ----
alvecp = 0, hadhist = 0;
do
c = readc(0);
+ #ifdef __MINT__
+ while (c == ' ' || c == '\t' || c == '\r');
+ #else
while (c == ' ' || c == '\t');
+ #endif
if (c == HISTSUB && intty)
/* ^lef^rit from tty is short !:s^lef^rit */
getexcl(c);
***************
*** 249,255 ****
--- 261,271 ----
wp = wbuf;
i = BUFSIZ - 4;
loop:
+ #ifdef __MINT__
+ while ((c = getC(DOALL)) == ' ' || c == '\t' || c == '\r');
+ #else
while ((c = getC(DOALL)) == ' ' || c == '\t');
+ #endif
if (cmap(c, _META | _ESC))
switch (c) {
case '&':
***************
*** 272,278 ****
c1 = c;
c = getC(0);
} while (c != '\n');
! if (c1 == '\\')
goto loop;
/* fall into ... */
--- 288,294 ----
c1 = c;
c = getC(0);
} while (c != '\n');
! if (c1 == escchar)
goto loop;
/* fall into ... */
***************
*** 283,289 ****
--- 299,310 ----
*wp++ = c;
goto ret;
+ #ifdef ALTESC
+ default:
+ if (c != escchar) break;
+ #else
case '\\':
+ #endif
c = getC(0);
if (c == '\n') {
if (onelflg == 1)
***************
*** 291,297 ****
goto loop;
}
if (c != HIST)
! *wp++ = '\\', --i;
c |= QUOTE;
}
c1 = 0;
--- 312,318 ----
goto loop;
}
if (c != HIST)
! *wp++ = escchar, --i;
c |= QUOTE;
}
c1 = 0;
***************
*** 302,308 ****
c1 = 0;
dolflg = DOALL;
}
! else if (c == '\\') {
c = getC(0);
/*
* PWP: this is dumb, but how all of the other shells work. If \ quotes
--- 323,329 ----
c1 = 0;
dolflg = DOALL;
}
! else if (c == escchar) {
c = getC(0);
/*
* PWP: this is dumb, but how all of the other shells work. If \ quotes
***************
*** 316,322 ****
else {
if (bslash_quote &&
((c == '\'') || (c == '"') ||
! (c == '\\'))) {
c |= QUOTE;
}
else {
--- 337,343 ----
else {
if (bslash_quote &&
((c == '\'') || (c == '"') ||
! (c == escchar))) {
c |= QUOTE;
}
else {
***************
*** 326,332 ****
*/
c |= QUOTE;
ungetC(c);
! c = '\\';
}
}
}
--- 347,353 ----
*/
c |= QUOTE;
ungetC(c);
! c = escchar;
}
}
}
***************
*** 337,343 ****
}
}
else if (cmap(c, _META | _Q | _Q1 | _ESC)) {
! if (c == '\\') {
c = getC(0);
if (c == '\n') {
if (onelflg == 1)
--- 358,364 ----
}
}
else if (cmap(c, _META | _Q | _Q1 | _ESC)) {
! if (c == escchar) {
c = getC(0);
if (c == '\n') {
if (onelflg == 1)
***************
*** 345,351 ****
break;
}
if (c != HIST)
! *wp++ = '\\', --i;
c |= QUOTE;
}
else if (cmap(c, _Q | _Q1)) { /* '"` */
--- 366,372 ----
break;
}
if (c != HIST)
! *wp++ = escchar, --i;
c |= QUOTE;
}
else if (cmap(c, _Q | _Q1)) { /* '"` */
***************
*** 440,446 ****
--- 461,471 ----
np = name, *np++ = '$';
c = sc = getC(DOEXCL);
+ #ifdef __MINT__
+ if (any("\t \n\r", c)) {
+ #else
if (any("\t \n", c)) {
+ #endif
ungetD(c);
ungetC('$' | QUOTE);
return;
***************
*** 762,768 ****
--- 787,797 ----
case 's':
delim = getC(0);
+ #ifdef __MINT__
+ if (letter(delim) || Isdigit(delim) || any(" \t\r\n", delim)) {
+ #else
if (letter(delim) || Isdigit(delim) || any(" \t\n", delim)) {
+ #endif
unreadc(delim);
lhsb[0] = 0;
seterror(ERR_BADSUBST);
***************
*** 782,791 ****
seterror(ERR_BADSUBST);
return (en);
}
! if (c == '\\') {
c = getC(0);
! if (c != delim && c != '\\')
! *cp++ = '\\';
}
*cp++ = c;
}
--- 811,820 ----
seterror(ERR_BADSUBST);
return (en);
}
! if (c == escchar) {
c = getC(0);
! if (c != delim && c != escchar)
! *cp++ = escchar;
}
*cp++ = c;
}
***************
*** 819,828 ****
seterror(ERR_RHSLONG);
return (en);
}
! if (c == '\\') {
c = getC(0);
if (c != delim /* && c != '~' */ )
! *cp++ = '\\';
}
*cp++ = c;
}
--- 848,857 ----
seterror(ERR_RHSLONG);
return (en);
}
! if (c == escchar) {
c = getC(0);
if (c != delim /* && c != '~' */ )
! *cp++ = escchar;
}
*cp++ = c;
}
***************
*** 965,971 ****
--- 994,1004 ----
case 'q':
wp = Strsave(cp);
for (xp = wp; c = *xp; xp++)
+ #ifdef __MINT__
+ if ((c != ' ' && c != '\t' && c != '\r') || type == 'q')
+ #else
if ((c != ' ' && c != '\t') || type == 'q')
+ #endif
*xp |= QUOTE;
return (wp);
***************
*** 1145,1151 ****
--- 1178,1188 ----
}
np = lhsb;
event = 0;
+ #ifdef __MINT__
+ while (!any(": \t\\\n\r}", c)) {
+ #else
while (!any(": \t\\\n}", c)) {
+ #endif
if (event != -1 && Isdigit(c))
event = event * 10 + c - '0';
else
***************
*** 1603,1608 ****
--- 1640,1649 ----
wfree();
bfree();
}
+
+ #ifdef __MINT__
+ #define ESPIPE EINVAL
+ #endif
void
settell()
*** ./orig/sh.misc.c Fri Oct 25 22:32:28 1991
--- ./sh.misc.c Sat Nov 16 19:02:46 1991
***************
*** 39,44 ****
--- 39,48 ----
#include "sh.h"
+ #ifdef __MINT__
+ extern int __mint; /* kernel version */
+ #endif
+
static int renum __P((int, int));
/*
***************
*** 263,268 ****
--- 267,277 ----
{
register int f;
+ #ifdef __MINT__
+ /* in TOS, all handles are shared by all processes! (ack!) */
+ if (__mint == 0)
+ return;
+ #endif
if (didcch)
return;
didcch = 1;
***************
*** 301,306 ****
--- 310,318 ----
if (i == j || i < 0)
return (i);
#ifdef HAVEDUP2
+ # ifdef __MINT__
+ if (__mint != 0) /* TOS screws up dup2 */
+ # endif
if (j >= 0) {
(void) dup2(i, j);
if (j != i)
***************
*** 321,326 ****
--- 333,343 ----
if (i == j || i < 0 || j < 0 && i > 2)
return (i);
+ #ifdef __MINT__
+ if (__mint == 0 && j > 5) {
+ return (i <= 5) ? dup(i) : j;
+ }
+ #endif
#ifdef HAVEDUP2
if (j >= 0) {
(void) dup2(i, j);
***************
*** 455,457 ****
--- 472,489 ----
return (0);
}
}
+
+ #ifdef __MINT__
+ Char *
+ Lastslash(pth)
+ Char *pth;
+ {
+ Char *slash = 0, c;
+
+ while ( (c = *pth++) != 0) {
+ if (is_dirsep(c))
+ slash = pth - 1;
+ }
+ return slash;
+ }
+ #endif /* __MINT__ */
*** ./orig/sh.proc.c Fri Oct 25 22:32:42 1991
--- ./sh.proc.c Wed Nov 13 01:32:54 1991
***************
*** 117,128 ****
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L};
# else /* !sun && !hp9000 */
! # ifdef masscomp
/*
* Initialization of this structure under RTU 4.1A & RTU 5.0 is problematic
* because the first two elements are unions of a time_t and a struct timeval.
* So we'll just have to trust the loader to do the "right thing", DAS DEC-90.
*/
static struct rusage zru;
# else /* masscomp */
static struct rusage zru = {{0L, 0L}, {0L, 0L}, 0, 0, 0, 0, 0, 0, 0,
--- 117,132 ----
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L};
# else /* !sun && !hp9000 */
! # if defined(masscomp) || defined(__MINT__)
/*
* Initialization of this structure under RTU 4.1A & RTU 5.0 is problematic
* because the first two elements are unions of a time_t and a struct timeval.
* So we'll just have to trust the loader to do the "right thing", DAS DEC-90.
*/
+
+ /* MiNT is missing a lot of fields, so we also trust the loader (we can
+ * trust it) to avoid getting errors from the compiler
+ */
static struct rusage zru;
# else /* masscomp */
static struct rusage zru = {{0L, 0L}, {0L, 0L}, 0, 0, 0, 0, 0, 0, 0,
***************
*** 153,158 ****
--- 157,180 ----
static struct process *pgetcurr __P((struct process *));
static void okpcntl __P((void));
+ #ifdef __MINT__
+ /*
+ * MiNT's fork() is a lot like vfork() in some respects; in particular,
+ * if we set job control signals to SIG_DFL after fork() and then
+ * get a signal, our parent will never be able to reclaim the address
+ * space and everything will hang :-(. Solution: rather than SIG_DFL,
+ * set the signals to a null signal handler; if we exec(), they will
+ * be set to SIG_DFL automatically, and before then the signals will
+ * effectively be ignored.
+ */
+
+ void
+ sig_tmp_ign(int sig)
+ {
+ /* do nothing, and rely on the magic of restartable system calls :-) */
+ }
+ #endif
+
/*
* pchild - called at interrupt level by the SIGCHLD signal
* indicating that at least one child has terminated or stopped
***************
*** 1740,1748 ****
--- 1762,1777 ----
#ifdef BSDJOBS
if (wanttty >= 0) {
/* make stoppable */
+ # ifdef __MINT__
+ /* see comments for sig_tmp_ign above */
+ (void) signal(SIGTSTP, sig_tmp_ign);
+ (void) signal(SIGTTIN, sig_tmp_ign);
+ (void) signal(SIGTTOU, sig_tmp_ign);
+ # else
(void) signal(SIGTSTP, SIG_DFL);
(void) signal(SIGTTIN, SIG_DFL);
(void) signal(SIGTTOU, SIG_DFL);
+ # endif
}
#endif /* BSDJOBS */
(void) signal(SIGTERM, parterm);
*** ./orig/sh.sem.c Fri Oct 25 22:32:44 1991
--- ./sh.sem.c Sun Nov 17 14:32:32 1991
***************
*** 417,425 ****
--- 417,434 ----
}
if (wanttty >= 0) {
+ #ifdef __MINT__
+ /* see sh.proc.c */
+ extern void sig_tmp_ign();
+
+ (void) signal(SIGTSTP, sig_tmp_ign);
+ (void) signal(SIGTTIN, sig_tmp_ign);
+ (void) signal(SIGTTOU, sig_tmp_ign);
+ #else
(void) signal(SIGTSTP, SIG_DFL);
(void) signal(SIGTTIN, SIG_DFL);
(void) signal(SIGTTOU, SIG_DFL);
+ #endif
}
(void) signal(SIGTERM, parterm);
***************
*** 524,531 ****
--- 533,542 ----
execute(t->t_dcar, wanttty, pipein, pv);
t->t_dcdr->t_dflg |= F_PIPEIN | (t->t_dflg &
(F_PIPEOUT | F_AMPERSAND | F_NOFORK | F_NOINTERRUPT));
+ #ifndef __MINT__
if (wanttty > 0)
wanttty = 0; /* got tty already */
+ #endif
execute(t->t_dcdr, wanttty, pv, pipeout);
break;
***************
*** 633,650 ****
--- 644,675 ----
(void) dmove(fd, 0);
}
else if (flags & F_PIPEIN) {
+ #ifdef __MINT__
+ (void) dup2(pipein[0], 0);
+ #else
(void) close(0);
(void) dup(pipein[0]);
+ #endif
(void) close(pipein[0]);
(void) close(pipein[1]);
}
else if ((flags & F_NOINTERRUPT) && tpgrp == -1) {
+ #ifdef __MINT__
+ int fd = open(_PATH_DEVNULL, O_RDONLY);
+ (void)dup2(fd, 0);
+ (void)close(fd);
+ #else
(void) close(0);
(void) open(_PATH_DEVNULL, O_RDONLY);
+ #endif
}
else {
+ #ifdef __MINT__
+ (void) dup2(OLDSTD, 0);
+ #else
(void) close(0);
(void) dup(OLDSTD);
+ #endif
#ifdef FIOCLEX
# ifdef CLEX_DUPS
/*
***************
*** 691,703 ****
--- 716,736 ----
is1atty = isatty(1);
}
else if (flags & F_PIPEOUT) {
+ #ifdef __MINT__
+ (void) dup2(pipeout[1], 1);
+ #else
(void) close(1);
(void) dup(pipeout[1]);
+ #endif
is1atty = 0;
}
else {
+ #ifdef __MINT__
+ (void) dup2(SHOUT, 1);
+ #else
(void) close(1);
(void) dup(SHOUT);
+ #endif
is1atty = isoutatty;
#ifdef FIOCLEX
# ifdef CLEX_DUPS
***************
*** 708,718 ****
--- 741,759 ----
(void) close(2);
if (flags & F_STDERR) {
+ #ifdef __MINT__
+ (void) dup2(1, 2);
+ #else
(void) dup(1);
+ #endif
is2atty = is1atty;
}
else {
+ #ifdef __MINT__
+ (void) dup2(SHDIAG, 2);
+ #else
(void) dup(SHDIAG);
+ #endif
is2atty = isdiagatty;
#ifdef FIOCLEX
# ifdef CLEX_DUPS
*** ./orig/sh.set.c Fri Oct 25 22:32:48 1991
--- ./sh.set.c Sun Nov 17 16:00:50 1991
***************
*** 196,201 ****
--- 196,216 ----
else if (eq(vp, STRwatch)) {
resetwatch();
}
+ #ifdef ALTESC
+ else if (eq(vp, STRescchar)) {
+ register Char *cp;
+
+ cp = value(vp);
+ _cmap[escchar] &= ~_ESC;
+ escchar = (cp && *cp) ? *cp : '\001';
+ _cmap[escchar] |= _ESC;
+ }
+ #endif
+ #ifdef __MINT__
+ else if (eq(vp, STRdosslashes)) {
+ STRslash[0] = '\\';
+ }
+ #endif
} while (p = *v++);
}
***************
*** 577,582 ****
--- 592,608 ----
editing = 0;
if (adrof(STRbackslash_quote) == 0)
bslash_quote = 0;
+ #ifdef ALTESC
+ if (adrof(STRescchar) == 0) {
+ _cmap[escchar] &= ~_ESC;
+ escchar = '\\';
+ _cmap[escchar] |= _ESC;
+ }
+ #endif
+ #ifdef __MINT__
+ if (adrof(STRdosslashes) == 0)
+ STRslash[0] = '/';
+ #endif
if (did_only && adrof(STRrecognize_only_executables) == 0)
tw_clear_comm_list();
}
*** ./orig/sh.time.c Fri Oct 25 22:32:50 1991
--- ./sh.time.c Mon Nov 11 02:42:08 1991
***************
*** 168,173 ****
--- 168,174 ----
{
tvadd(&ru->ru_utime, &ru2->ru_utime);
tvadd(&ru->ru_stime, &ru2->ru_stime);
+ #ifndef __MINT__
if (ru2->ru_maxrss > ru->ru_maxrss)
ru->ru_maxrss = ru2->ru_maxrss;
***************
*** 184,189 ****
--- 185,191 ----
ru->ru_nsignals += ru2->ru_nsignals;
ru->ru_nvcsw += ru2->ru_nvcsw;
ru->ru_nivcsw += ru2->ru_nivcsw;
+ #endif /* __MINT__ */
}
#else /* BSDTIMES */
***************
*** 313,319 ****
--- 315,325 ----
int ms =
(e->tv_sec - b->tv_sec) * 100 + (e->tv_usec - b->tv_usec) / 10000;
+ # ifdef __MINT__
+ cp = "%Uu %Ss %E %P";
+ # else
cp = "%Uu %Ss %E %P %X+%Dk %I+%Oio %Fpf+%Ww";
+ # endif
#else
# ifdef _SEQUENT_
int ms =
***************
*** 404,410 ****
xprintf("%ld.%01ld%%", i / 10, i % 10); /* nn.n% */
break;
! #ifdef BSDTIMES
case 'W': /* number of swaps */
i = r1->ru_nswap - r0->ru_nswap;
xprintf("%ld", i);
--- 410,416 ----
xprintf("%ld.%01ld%%", i / 10, i % 10); /* nn.n% */
break;
! #if defined(BSDTIMES) && !defined(__MINT__)
case 'W': /* number of swaps */
i = r1->ru_nswap - r0->ru_nswap;
xprintf("%ld", i);
*** ./orig/sh.types.h Fri Oct 25 22:34:36 1991
--- ./sh.types.h Sat Nov 9 11:08:40 1991
***************
*** 386,392 ****
#endif /* ! POSIX */
!
/***
*** This is our own junk types.
--- 386,395 ----
#endif /* ! POSIX */
! #ifdef __MINT__
! # define _SIGMASK_T
! typedef long sigmask_t;
! #endif
/***
*** This is our own junk types.
*** ./orig/tc.alloc.c Fri Oct 25 22:34:02 1991
--- ./tc.alloc.c Wed Nov 20 23:00:24 1991
***************
*** 48,53 ****
--- 48,57 ----
#include "sh.h"
+ #ifdef __MINT__
+ long _stksize = -128*1024L;
+ #endif /* __MINT__ */
+
char *memtop = NULL; /* PWP: top of current memory */
char *membot = NULL; /* PWP: bottom of allocatable memory */
***************
*** 239,248 ****
--- 243,255 ----
memtop = (char *) op;
if (membot == NULL)
membot = memtop;
+
+ #ifndef __MINT__
if ((int) op & 0x3ff) {
memtop = (char *) sbrk(1024 - ((int) op & 0x3ff));
memtop += 1024 - ((int) op & 0x3ff);
}
+ #endif
/* take 2k unless the block is bigger than that */
rnu = (bucket <= 8) ? 11 : bucket + 3;
***************
*** 288,294 ****
return;
CHECK(!memtop || !membot, "free(%lx) called before any allocations.", cp);
CHECK(cp > (ptr_t) memtop, "free(%lx) above top of memory.", cp);
! CHECK(cp < (ptr_t) membot, "free(%lx) above top of memory.", cp);
op = (union overhead *) (((caddr_t) cp) - MEMALIGN(sizeof(union overhead)));
CHECK(op->ov_magic != MAGIC, "free(%lx) bad block.", cp);
--- 295,301 ----
return;
CHECK(!memtop || !membot, "free(%lx) called before any allocations.", cp);
CHECK(cp > (ptr_t) memtop, "free(%lx) above top of memory.", cp);
! CHECK(cp < (ptr_t) membot, "free(%lx) below bottom of memory.", cp);
op = (union overhead *) (((caddr_t) cp) - MEMALIGN(sizeof(union overhead)));
CHECK(op->ov_magic != MAGIC, "free(%lx) bad block.", cp);
*** ./orig/tc.const.c Fri Oct 25 22:34:08 1991
--- ./tc.const.c Sun Nov 17 15:56:40 1991
***************
*** 76,96 ****
--- 76,122 ----
Char STRhistfile[] = { 'h', 'i', 's', 't', 'f', 'i', 'l', 'e', '\0' };
Char STRsource[] = { 's', 'o', 'u', 'r', 'c', 'e', '\0' };
Char STRmh[] = { '-', 'h', '\0' };
+
+ #ifndef __MINT__
Char STRtildothist[] = { '~', '/', '.', 'h', 'i', 's', 't', 'o', 'r',
'y', '\0' };
+ #else
+ Char STRtildothist[] = { '~', '/', 'h', 'i', 's', 't', 'o', 'r', 'y',
+ '.', 'c', 's', 'h', '\0' };
+ #endif
#ifdef CSHDIRS
+ # ifndef __MINT__
Char STRdirfile[] = { '~', '/', '.', 'c', 's', 'h', 'd', 'i', 'r',
's', '\0' };
Char STRsldtdirs[] = { '/', '.', 'c', 's', 'h', 'd', 'i', 'r', 's', '\0' };
+ # else
+ Char STRdirfile[] = { '~', '/', 'c', 's', 'h', 'd', 'i', 'r', 's',
+ '.', 'c', 's', 'h', '\0' };
+ Char STRsldtdirs[] = { '/', 'c', 's', 'h', 'd', 'i', 'r', 's', '.',
+ 'c', 's', 'h', '\0' };
+ # endif
Char STRsavedirs[] = { 's', 'a', 'v', 'e', 'd', 'i', 'r', 's', '\0' };
#endif
Char STRargv[] = { 'a', 'r', 'g', 'v', '\0' };
Char STRsavehist[] = { 's', 'a', 'v', 'e', 'h', 'i', 's', 't', '\0' };
+
+ #ifndef __MINT__
Char STRsldthist[] = { '/', '.', 'h', 'i', 's', 't', 'o', 'r', 'y', '\0' };
+ #else
+ Char STRsldthist[] = { '/', 'h', 'i', 's', 't', 'o', 'r', 'y', '.',
+ 'c', 's', 'h', '\0' };
+ #endif
+
Char STRnormal[] = { 'n', 'o', 'r', 'm', 'a', 'l', '\0' };
+
+ #ifndef __MINT__
Char STRsldtlogout[] = { '/', '.', 'l', 'o', 'g', 'o', 'u', 't', '\0' };
+ #else
+ Char STRsldtlogout[] = { '/', 'l', 'o', 'g', 'o', 'u', 't', '.', 'c', 's',
+ 'h', '\0' };
+ #endif
Char STRjobs[] = { 'j', 'o', 'b', 's', '\0' };
Char STRsymhash[] = { '#', ' ', '\0' };
Char STRsymarrow[] = { '>', ' ', '\0' };
***************
*** 183,191 ****
--- 209,224 ----
Char STRmail[] = { 'm', 'a', 'i', 'l', '\0' };
Char STRwatch[] = { 'w', 'a', 't', 'c', 'h', '\0' };
+ #ifndef __MINT__
Char STRsldottcshrc[] = { '/', '.', 't', 'c', 's', 'h', 'r', 'c', '\0' };
Char STRsldotcshrc[] = { '/', '.', 'c', 's', 'h', 'r', 'c', '\0' };
Char STRsldotlogin[] = { '/', '.', 'l', 'o', 'g', 'i', 'n', '\0' };
+ #else
+ Char STRsldottcshrc[] = { '/', 't', 'c', 's', 'h', '.', 'r', 'c', '\0' };
+ Char STRsldotcshrc[] = { '/', 'c', 's', 'h', '.', 'r', 'c', '\0' };
+ Char STRsldotlogin[] = { '/', 'l', 'o', 'g', 'i', 'n', '.', 'c', 's',
+ 'h','\0' };
+ #endif
Char STRignoreeof[] = { 'i', 'g', 'n', 'o', 'r', 'e', 'e', 'o', 'f', '\0' };
Char STRnoclobber[] = { 'n', 'o', 'c', 'l', 'o', 'b', 'b', 'e', 'r', '\0' };
Char STRhelpcommand[] = { 'h', 'e', 'l', 'p', 'c', 'o', 'm', 'm', 'a', 'n',
***************
*** 254,256 ****
--- 287,298 ----
Char STRsys53[] = { 's', 'y', 's', '5', '.', '3', '\0' };
Char STRver[] = { 'v', 'e', 'r', '\0' };
#endif /* apollo */
+
+ #ifdef ALTESC
+ Char STRescchar[] = { 'e', 's', 'c', 'c', 'h', 'a', 'r', '\0' };
+ #endif
+
+ #ifdef __MINT__
+ Char STRdosslashes[] = { 'd', 'o', 's', 's', 'l', 'a', 's', 'h', 'e', 's',
+ '\0' };
+ #endif
*** ./orig/tc.os.c Fri Oct 25 22:34:20 1991
--- ./tc.os.c Sat Nov 9 21:59:52 1991
***************
*** 687,693 ****
--- 687,695 ----
{
extern ptr_t membot;
+ #ifndef __MINT__
membot = (char *) sbrk(0);
+ #endif
#ifdef OREO
set42sig();
*** ./orig/tc.os.h Fri Oct 25 22:34:24 1991
--- ./tc.os.h Sun Nov 10 17:38:20 1991
***************
*** 318,323 ****
--- 318,324 ----
extern int atoi();
extern char *ttyname();
+ #ifndef __MINT__
# ifndef hpux
extern int abort();
extern int qsort();
***************
*** 325,330 ****
--- 326,332 ----
extern void abort();
extern void qsort();
# endif
+ #endif /* __MINT__ */
extern void perror();
#ifndef NEEDgethostname
*** ./orig/tc.sig.c Fri Oct 25 22:34:32 1991
--- ./tc.sig.c Sat Nov 9 10:53:10 1991
***************
*** 403,405 ****
--- 403,425 ----
Synch_Cnt++;
}
#endif /* SIGSYNCH */
+
+ #ifdef __MINT__
+ /* MiNT has most BSD signal things, but not sigvec; punt */
+ void
+ mysigvec(sig, new, old)
+ int sig;
+ sigvec_t *new, *old;
+ {
+ void (*oldhandler)();
+
+ if (new) {
+ oldhandler = signal(sig, new->sv_handler);
+ } else {
+ oldhandler = signal(sig, SIG_IGN);
+ signal(sig, oldhandler);
+ }
+ if (old)
+ old->sv_handler = oldhandler;
+ }
+ #endif /* __MINT__ */
*** ./orig/tc.sig.h Fri Oct 25 22:34:32 1991
--- ./tc.sig.h Sat Nov 9 11:20:02 1991
***************
*** 62,67 ****
--- 62,75 ----
# define sv_handler sa_handler
# endif /* _SEQUENT */
+ # ifdef __MINT__
+ # define HAVE_SIGVEC
+ typedef struct sigvec {
+ sigret_t (*sv_handler)();
+ } sigvec_t;
+ extern void mysigvec(int, sigvec_t *, sigvec_t *);
+ #endif /* __MINT__ */
+
# ifdef hpux
# define HAVE_SIGVEC
# define mysigvec(a, b, c) sigvector(a, b, c)
***************
*** 101,110 ****
--- 109,120 ----
/*
* For 4.2bsd signals.
*/
+ #ifndef __MINT__
# ifdef sigmask
# undef sigmask
# endif /* sigmask */
# define sigmask(s) (1 << ((s)-1))
+ #endif /* __MINT__ */
# ifdef _SEQUENT_
# define sigpause(a) bsd_sigpause(a)
# define signal(a, b) sigset(a, b)
*** ./orig/tc.vers.c Fri Oct 25 22:34:38 1991
--- ./tc.vers.c Sun Nov 10 02:19:00 1991
***************
*** 348,353 ****
--- 348,357 ----
hosttype = str2short("amdahl");
#endif /* uts */
+ # ifdef atarist
+ # define _havehosttype_
+ hosttype = str2short("atarist");
+ # endif
# ifndef _havehosttype_
# define _havehosttype_
*** ./orig/tw.parse.c Fri Oct 25 22:33:16 1991
--- ./tw.parse.c Thu Nov 21 09:32:44 1991
***************
*** 45,50 ****
--- 45,54 ----
#include "ed.h"
#include "tc.h"
+ #ifdef __MINT__
+ extern Char *Lastslash();
+ #endif
+
/* #define TENEDEBUG */
/* true if the path has relative elements */
***************
*** 127,136 ****
*/
for (cmd_st = str_end; cmd_st > inputline; --cmd_st)
if (iscmdmeta(cmd_st[-1])
! && ((cmd_st - 1 == inputline) || (cmd_st[-2] != '\\')))
break;
/* step forward over leading spaces */
while (*cmd_st != '\0' && (*cmd_st == ' ' || *cmd_st == '\t'))
cmd_st++;
/*
--- 131,144 ----
*/
for (cmd_st = str_end; cmd_st > inputline; --cmd_st)
if (iscmdmeta(cmd_st[-1])
! && ((cmd_st - 1 == inputline) || (cmd_st[-2] != escchar)))
break;
/* step forward over leading spaces */
+ #ifdef __MINT__
+ while (*cmd_st && (*cmd_st == ' ' || *cmd_st == '\t' || *cmd_st == '\r'))
+ #else
while (*cmd_st != '\0' && (*cmd_st == ' ' || *cmd_st == '\t'))
+ #endif
cmd_st++;
/*
***************
*** 140,146 ****
for (word_start = str_end; word_start > inputline; --word_start) {
if ((ismeta(word_start[-1]) || isaset(cmd_st, word_start)) &&
(word_start[-1] != '#') && (word_start[-1] != '$') &&
! ((word_start - 1 == inputline) || (word_start[-2] != '\\')))
break;
}
--- 148,154 ----
for (word_start = str_end; word_start > inputline; --word_start) {
if ((ismeta(word_start[-1]) || isaset(cmd_st, word_start)) &&
(word_start[-1] != '#') && (word_start[-1] != '$') &&
! ((word_start - 1 == inputline) || (word_start[-2] != escchar)))
break;
}
***************
*** 209,214 ****
--- 217,223 ----
*/
*wp++ = *cmd_start;
break;
+ #ifndef ALTESC
case '\\':
if (in_single || in_double)
*wp++ = *cmd_start | QUOTE;
***************
*** 215,221 ****
--- 224,244 ----
else
*wp++ = *++cmd_start | QUOTE;
break;
+ #endif
default:
+ #ifdef ALTESC
+ if (*cmd_start == escchar) {
+ if (in_single || in_double)
+ *wp++ = *cmd_start | QUOTE;
+ else
+ *wp++ = *++cmd_start | QUOTE;
+ } else
+ # ifdef __MINT__
+ if (*cmd_start == '\\')
+ *wp++ = *cmd_start;
+ else
+ # endif
+ #endif
*wp++ = *cmd_start | in_single;
break;
}
***************
*** 240,246 ****
--- 263,273 ----
case RECOGNIZE:
if (adrof(STRautocorrect)) {
+ #ifdef __MINT__
+ if ((slshp = Lastslash(word)) != NULL && slshp[1] != '\0') {
+ #else
if ((slshp = Strrchr(word, '/')) != NULL && slshp[1] != '\0') {
+ #endif
SearchNoDirErr = 1;
for (bptr = word; bptr < slshp; bptr++) {
/*
***************
*** 406,412 ****
if ((cmap(*wptr, _META | _DOL | _Q | _ESC | _GLOB) || *wptr == HIST ||
*wptr == HISTSUB) &&
(*wptr != ' ' || !trail_space || *(wptr + 1) != '\0'))
! *bptr++ = '\\';
*bptr++ = *wptr++;
}
*bptr = '\0';
--- 433,439 ----
if ((cmap(*wptr, _META | _DOL | _Q | _ESC | _GLOB) || *wptr == HIST ||
*wptr == HISTSUB) &&
(*wptr != ' ' || !trail_space || *(wptr + 1) != '\0'))
! *bptr++ = escchar;
*bptr++ = *wptr++;
}
*bptr = '\0';
***************
*** 635,645 ****
--- 662,680 ----
non_unique_match = FALSE; /* See the recexact code below */
extract_dir_and_name(word, dir, name);
+ #ifdef __MINT__
+ looking_for_lognames = (*word == '~') && (Lastslash(word) == NULL);
+ looking_for_shellvar = (target = Strrchr(name, '$')) &&
+ (Lastslash(name) == NULL);
+ looking_for_file = (!looking_for_command && !looking_for_lognames &&
+ !looking_for_shellvar) || Lastslash(word);
+ #else
looking_for_lognames = (*word == '~') && (Strchr(word, '/') == NULL);
looking_for_shellvar = (target = Strrchr(name, '$')) &&
(Strchr(name, '/') == NULL);
looking_for_file = (!looking_for_command && !looking_for_lognames &&
!looking_for_shellvar) || Strchr(word, '/');
+ #endif
/* PWP: don't even bother when doing ALL of the commands */
if (looking_for_command && (*word == '\0'))
***************
*** 675,681 ****
if (nd) {
if (*tilded_dir != '\0') {
Char *s, *d, *p;
!
/*
* Copy and append a / if there was one
*/
--- 710,735 ----
if (nd) {
if (*tilded_dir != '\0') {
Char *s, *d, *p;
! #ifdef __MINT__
! Char slashc = '/';
! /*
! * Copy and append a / if there was one
! */
! for (p = tilded_dir; *p; p++);
! --p;
! if (is_dirsep(*p)) {
! slashc = *p;
! for (p = nd; *p; p++);
! --p;
! if (!is_dirsep(*p))
! p = NULL;
! }
! for (d = tilded_dir, s = nd; *d++ = *s++;);
! if (!p) {
! *d-- = '\0';
! *d = slashc;
! }
! #else
/*
* Copy and append a / if there was one
*/
***************
*** 690,695 ****
--- 744,750 ----
*d-- = '\0';
*d = '/';
}
+ #endif
}
xfree((ptr_t) nd);
}
***************
*** 771,778 ****
--- 826,838 ----
if (dir_fd != NULL)
FREE_DIR(dir_fd);
entry = NULL;
+ #ifdef __MINT__
+ while (*pathv && (pathv[0][0] == '/' || pathv[0][0] == '\\'))
+ pathv++;
+ #else
while (*pathv && pathv[0][0] == '/')
pathv++;
+ #endif
if (*pathv) {
/*
* We complete directories only on '.' should that
***************
*** 1108,1114 ****
--- 1168,1178 ----
{
register Char *p;
+ #ifdef __MINT__
+ p = Lastslash(path);
+ #else
p = Strrchr(path, '/');
+ #endif
if (p == NULL) {
copyn(name, path, MAXNAMLEN);
dir[0] = '\0';
***************
*** 1235,1241 ****
--- 1299,1309 ----
}
new[0] = '\0';
+ #ifdef __MINT__
+ for (p = new, o = &old[1]; *o && !is_dirsep(*o); *p++ = *o++);
+ #else
for (p = new, o = &old[1]; *o && *o != '/'; *p++ = *o++);
+ #endif
*p = '\0';
if (old[0] == '~') {
***************
*** 1306,1311 ****
--- 1374,1384 ----
if (S_ISBLK(statb.st_mode)) /* block device */
return ('#');
if (S_ISDIR(statb.st_mode)) /* normal Directory */
+ #ifdef __MINT__
+ if (is_set(STRdosslashes))
+ return ('\\');
+ else
+ #endif
return ('/');
if (statb.st_mode & 0111)
return ('*');
***************
*** 1483,1489 ****
--- 1556,1566 ----
if (adrof(STRrecognize_only_executables)) {
for (pv = v->vec; *pv; pv++) {
+ #ifdef __MINT__
+ if (pv[0][0] != '/' && pv[0][0] != '\\') {
+ #else
if (pv[0][0] != '/') {
+ #endif
relatives_in_path = 1;
continue;
}
***************
*** 1504,1510 ****
--- 1581,1591 ----
}
else {
for (pv = v->vec; *pv; pv++) {
+ #ifdef __MINT__
+ if (pv[0][0] != '/' && pv[0][0] != '\\') {
+ #else
if (pv[0][0] != '/') {
+ #endif
relatives_in_path = 1;
continue;
}
*** ./orig/tw.spell.c Fri Oct 25 22:33:18 1991
--- ./tw.spell.c Sun Nov 17 15:12:40 1991
***************
*** 40,45 ****
--- 40,49 ----
#include "sh.h"
#include "tw.h"
+ #ifdef __MINT__
+ extern Char *Lastslash();
+ #endif
+
extern Char **command_list;
extern int numcommands;
***************
*** 56,63 ****
--- 60,78 ----
bool foundslash = 0;
int retval;
+ #ifdef __MINT__
+ /* skip drive specification, if any */
+ if (*old && old[1] == ':' && is_dirsep(old[2])) {
+ *new++ = *old++; *new++ = *old++;
+ }
+ #endif
+
for (;;) {
+ #ifdef __MINT__
+ while (is_dirsep(*old)) {
+ #else
while (*old == '/') { /* skip '/' */
+ #endif
*new++ = *old++;
foundslash = 1;
}
***************
*** 76,82 ****
--- 91,101 ----
if (p < guess + FILSIZ)
*p++ = *cp;
ws = p;
+ #ifdef __MINT__
+ for (; !is_dirsep(*old) && *old != '\0'; old++)
+ #else
for (; *old != '/' && *old != '\0'; old++)/* add current file name */
+ #endif
if (p < guess + FILSIZ)
*p++ = *old;
*p = '\0'; /* terminate it */
***************
*** 86,93 ****
--- 105,117 ----
* far but there are later - or it will look for *all* commands
*/
/* (*should* say "looking for directory" whenever '/' is next...) */
+ #ifdef __MINT__
+ retval = t_search(guess, p, SPELL, FILSIZ,
+ looking_for_cmd && (foundslash || !is_dirsep(*old)), 1);
+ #else
retval = t_search(guess, p, SPELL, FILSIZ,
looking_for_cmd && (foundslash || *old != '/'), 1);
+ #endif
if (retval >= 4 || retval < 0)
return -1; /* hopeless */
for (p = ws; *new = *p++;)