home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / editors / elvis17.zoo / diffs next >
Encoding:
Text File  |  1993-09-21  |  56.5 KB  |  2,457 lines

  1. diff -ur ./alias.c /local/src/elvis/17/src/alias.c
  2. --- ./alias.c    Thu Feb  4 12:48:38 1993
  3. +++ /local/src/elvis/17/src/alias.c    Wed Mar 24 15:45:26 1993
  4. @@ -27,6 +27,15 @@
  5.  #define ELVIS    "elvis"
  6.  #endif
  7.  
  8. +#if __STDC__
  9. +#include <string.h>
  10. +#include <stdlib.h>
  11. +#endif
  12. +
  13. +#if MINT
  14. +extern char *getenv();
  15. +#endif
  16. +
  17.  extern char **environ;
  18.  extern int errno;
  19.  
  20. @@ -40,6 +49,9 @@
  21.  #if OSK
  22.      extern int chainc();
  23.  #endif
  24. +#if TOS || MINT
  25. +    extern char myname[];
  26. +#endif
  27.  
  28.      /* allocate enough space for a copy of the argument list, plus a
  29.       * terminating NULL, plus maybe an added flag.
  30. @@ -55,9 +67,15 @@
  31.          exit(2);
  32.      }
  33.  
  34. +#if TOS || MINT
  35. +    /* some stupid TOS shells haven't heared about argv[0]  -nox */
  36. +    if (!**argv)
  37. +        *argv = myname;    /* (see myname.c) */
  38. +#endif
  39. +
  40.      /* find the last letter in the invocation name of this program */
  41.      i = strlen(argv[0]);
  42. -#if MSDOS || TOS
  43. +#if MSDOS || TOS || MINT
  44.      /* we almost certainly must bypass ".EXE" or ".TTP" from argv[0] */
  45.      if (i > 4 && argv[0][i - 4] == '.')
  46.          i -= 4;
  47. @@ -65,6 +83,14 @@
  48.      letter = argv[0][i - 1];
  49.  
  50.      /* copy argv to argblk, possibly inserting a flag such as "-R" */
  51. +#if MINT
  52. +    /* see if elvis is the $EDITOR and has a path, so that execvp()
  53. +       doesn't have to search $PATH (yes, GEMDOS is slow...)  -nox */
  54. +    if (strpbrk(ELVIS, "/\\") || !(argblk[0]=getenv("EDITOR")) ||
  55. +        !strpbrk(argblk[0], "/\\") ||
  56. +        (strcmp(argblk[0]+strlen(argblk[0])-sizeof(ELVIS)+1, ELVIS) &&
  57. +         strcmp(argblk[0]+strlen(argblk[0])-sizeof(ELVIS)-3, ELVIS ".ttp")))
  58. +#endif
  59.      argblk[0] = ELVIS;
  60.      i = j = 1;
  61.      switch (letter)
  62. @@ -98,4 +124,5 @@
  63.      (void)execvp(argblk[0], argblk);
  64.      perror(ELVIS);
  65.  #endif
  66. +    exit(2);
  67.  }
  68. diff -ur ./atari.c /local/src/elvis/17/src/atari.c
  69. --- ./atari.c    Thu Feb  4 12:48:42 1993
  70. +++ /local/src/elvis/17/src/atari.c    Sun Apr 25 15:16:52 1993
  71. @@ -16,9 +16,20 @@
  72.  #include "config.h"
  73.  #include "vi.h"
  74.  
  75. -#if TOS
  76. +#if TOS || MINT
  77.  #include <osbind.h>
  78.  
  79. +#if MINT
  80. +#include <ioctl.h>
  81. +
  82. +#ifndef    TCURSBLINK
  83. +#define TCURSBLINK    (('c'<< 8) | 2)
  84. +#define TCURSSTEADY    (('c'<< 8) | 3)
  85. +#endif
  86. +#endif
  87. +
  88. +# if !MINT /* MiNT's library is a little more complete :-) */
  89. +
  90.  /* vi uses mode==0 only ... */
  91.  int access(file, mode)
  92.      char *file;
  93. @@ -36,7 +47,9 @@
  94.      return template;
  95.  }
  96.  
  97. -#ifndef __GNUC__
  98. +# endif
  99. +
  100. +# ifndef __GNUC__
  101.  char *getcwd(buf, size)
  102.      char *buf;
  103.  {
  104. @@ -47,10 +60,11 @@
  105.      Dgetpath(buf + 2, 0);
  106.      return buf;
  107.  }
  108. -#endif
  109. +# endif
  110.  
  111.  /* read -- text mode, compress \r\n to \n
  112.   * warning: might fail when maxlen==1 and at eol
  113. + * ...no longer :-)  -nox
  114.   */
  115.  
  116.  int tread(fd, buf, maxlen)
  117. @@ -61,8 +75,16 @@
  118.      int i, j, nread=read(fd, buf, (unsigned)maxlen);
  119.  
  120.      if (nread && buf[nread-1]=='\r')
  121. -    {    nread--;
  122. -        lseek(fd, -1l, 1);
  123. +    {
  124. +        if (--nread)
  125. +            lseek(fd, -1l, 1);
  126. +        else {
  127. +            if (read(fd, buf, 1) && *buf != '\n') {
  128. +                *buf = '\r';
  129. +                lseek(fd, -1l, 1);
  130. +            }
  131. +            return 1;
  132. +        }
  133.      }
  134.      for (i=j=0; j<nread; i++,j++)
  135.      {    if (buf[j]=='\r' && buf[j+1]=='\n')
  136. @@ -77,6 +99,24 @@
  137.      char *buf;
  138.      int maxlen;
  139.  {
  140. +# if 1
  141. +    int i, j;
  142. +    /* uh, we can have that easier...  -nox */
  143. +    static char writbuf[BLKSIZE*2];
  144. +
  145. +    for (i=j=0; j<maxlen; )
  146. +    {
  147. +        if ((writbuf[i++]=buf[j++])=='\n')
  148. +        {    writbuf[i-1]='\r';
  149. +            writbuf[i++]='\n';
  150. +        }
  151. +    }
  152. +    /* ...and make the result a little bit more reasonable too :-)  */
  153. +    if (!i || !(maxlen = write(fd, writbuf, (unsigned)i)))
  154. +        return 0;
  155. +    return j - i + maxlen;
  156. +}
  157. +# else
  158.      int i, j, nwritten=0, hadnl=0;
  159.      char writbuf[BLKSIZE];
  160.  
  161. @@ -104,6 +144,7 @@
  162.          write(fd, writbuf, (unsigned)i);
  163.      return j;
  164.  }
  165. +# endif
  166.  
  167.  
  168.  /* The "timer" variable is used as a shadow of the system's timer.  Since the
  169. @@ -111,12 +152,14 @@
  170.   * do a Supexec(gettime) to copy the system's timer in to the User-mode "timer"
  171.   * variable.
  172.   */
  173. -static int timer;
  174. -static gettime()
  175. +static long timer;
  176. +static void gettime()
  177.  {
  178.      timer = *(long *)(0x4ba);
  179.  }
  180. +#endif /* TOS || MINT */
  181.  
  182. +#if TOS
  183.  /* This function implements a read-with-timeout from the keyboard. */
  184.  /*ARGSUSED*/
  185.  int ttyread(buf, len, time)
  186. @@ -129,11 +172,11 @@
  187.      long    endtime;
  188.  
  189.      /* compute the ending time, in increments of 1/200th seconds */
  190. -    Supexec(gettime);
  191. +    (void) Supexec(gettime);
  192.      endtime = time * 20 + timer;
  193.  
  194.      /* wait until time runs out, or we get a keystroke */
  195. -    while (!pos && (!time || timer < endtime))
  196. +    while (!pos && (!time || (timer-endtime) < 0))
  197.      {
  198.          if (Bconstat(2))
  199.          {
  200. @@ -145,7 +188,7 @@
  201.                  buf[pos++] = l >> 16;
  202.              }
  203.          }
  204. -        Supexec(gettime);
  205. +        (void) Supexec(gettime);
  206.      }
  207.      return pos;
  208.  }
  209. @@ -158,4 +201,203 @@
  210.      while (len--)
  211.          Bconout(2, *buf++);
  212.  }
  213. +#endif /* TOS */
  214. +
  215. +#if MINT
  216. +extern int __mint;
  217. +
  218. +# include <signal.h>
  219. +# include <setjmp.h>
  220. +
  221. +static jmp_buf env;
  222. +
  223. +/* ctputs(): same as tputs(), but recognizes #blink / #noblink to
  224. +   set the cursormode (have to do it this way because those are not
  225. +   available thru the ST's `VT52' emulator...) */
  226. +
  227. +void ctputs(cp, affcnt, outfn)
  228. +    char    *cp;
  229. +    int    affcnt;
  230. +    int    (*outfn)();
  231. +{
  232. +    if (!strcmp(cp, "#blink")) {
  233. +        if (__mint >= 96)
  234. +            (void) ioctl (2, TCURSBLINK, (void *) NULL);
  235. +        else
  236. +            (void) Cursconf(2, 0);
  237. +        return;
  238. +    }
  239. +    if (!strcmp(cp, "#noblink")) {
  240. +        if (__mint >= 96)
  241. +            (void) ioctl (2, TCURSSTEADY, (void *) NULL);
  242. +        else
  243. +            (void) Cursconf(3, 0);
  244. +        return;
  245. +    }
  246. +    tputs(cp, affcnt, outfn);
  247. +}
  248. +
  249. +/* this turns those shifted cursor- / insert / home keys into
  250. +   something useful (without this, they would return digits...) */
  251. +
  252. +static long fixkey(l)
  253. +    long    l;
  254. +{
  255. +    if (l < 0 || !(char) l)
  256. +        return l;
  257. +    switch ((unsigned char) (l >> 16)) {
  258. +        case 72:        /* shift- ^    -> PgUp */
  259. +            return 73l << 16;
  260. +        case 80:        /* shift- v    -> PgDn */
  261. +            return 81l << 16;
  262. +        case 71:        /* shift-Home    -> End */
  263. +            return 79l << 16;
  264. +        case 75:        /* shift- <-    -> ctrl- <- */
  265. +            return 115l << 16;
  266. +        case 77:        /* shift- ->    -> ctrl- -> */
  267. +            return 116l << 16;
  268. +        case 82:        /* shift-Insert    -> Printscreen */
  269. +            return 55l << 16;
  270. +    }
  271. +    return l;
  272. +}
  273. +
  274. +/*ARGSUSED*/
  275. +static void dummy(signo)
  276. +    int    signo;
  277. +{
  278. +    longjmp(env, 1);
  279. +}
  280. +
  281. +/* This function implements a read-with-timeout from the keyboard. */
  282. +/*ARGSUSED*/
  283. +int ttyread(buf, len, time)
  284. +    char    *buf;    /* where to store the gotten characters */
  285. +    int    len;    /* maximum number of characters to get -- ignored on terminals */
  286. +    int    time;    /* maximum time to allow for reading */
  287. +{
  288. +    int    pos=0;
  289. +    long    l;
  290. +    long    endtime;
  291. +    static    tty;    /* 'y' if reading from tty, or 'n' if not a tty */
  292. +    extern    int got_winch;    /* flag from our getsize() SIGWINCH handler */
  293. +
  294. +    /* do we know whether this is a tty or not? */
  295. +    if (!tty)
  296. +        tty = (isatty(0) ? 'y' : 'n');
  297. +
  298. +    if (tty != 'y')
  299. +        return read(0, buf, (unsigned) len);
  300. +
  301. +    if (!__mint) {
  302. +        /* no MiNT -> eat cycles :-)  */
  303. +
  304. +        /* compute the ending time, in increments of 1/200th seconds */
  305. +        (void) Supexec(gettime);
  306. +        endtime = time * 20 + timer;
  307. +
  308. +        /* wait until time runs out, or we get a keystroke */
  309. +        while (!pos && (!time || (timer-endtime) < 0))
  310. +        {
  311. +            if (*o_stbios ? Bconstat(2) : Cconis())
  312. +            {
  313. +                l = fixkey(*o_stbios ? Bconin(2) : Crawcin());
  314. +                if (l < 0)
  315. +                    return l;
  316. +                buf[pos] = l;
  317. +                if (buf[pos++] == '\0')
  318. +                {
  319. +                    buf[pos-1] = '#';
  320. +                    buf[pos++] = l >> 16;
  321. +                }
  322. +            }
  323. +            (void) Supexec(gettime);
  324. +        }
  325. +        return pos;
  326. +    }
  327. +    /* MiNT is there -> do it with alarm()
  328. +       [yes MiNT also has select(), but as of MiNT version 0.94
  329. +        that won't yet work over e.g. a serial line...] */
  330. +
  331. +    /* arrange for timeout */
  332. +    signal(SIGALRM, dummy);
  333. +    alarm(time);
  334. +
  335. +    if (setjmp(env))
  336. +        return 0;
  337. +
  338. +    /* if termcap doesn't use scancodes simply do an ordinary read()
  339. +       then MiNT can convert them for us (XKEY)...
  340. +    */
  341. +    if (!has_KL || *has_KL != '#' || has_KL[1] != 'K' || has_KL[2]) {
  342. +        pos = read(0, buf, (unsigned)len);
  343. +        if (got_winch) {
  344. +            got_winch = 0;
  345. +            if (*o_lines != LINES || *o_columns != COLS) {
  346. +#ifndef CRUNCH
  347. +                *o_nearscroll = 
  348.  #endif
  349. +                *o_lines = LINES;
  350. +                *o_columns = COLS;
  351. +#ifndef CRUNCH
  352. +                if (!wset)
  353. +                {
  354. +                    *o_window = LINES - 1;
  355. +                }
  356. +#endif
  357. +                if (mode != MODE_EX && mode != MODE_COLON)
  358. +                    /* pretend the user hit ^L */
  359. +                    buf[pos++] = ctrl('L');
  360. +            }
  361. +        }
  362. +    }
  363. +
  364. +    /* termcap does use scancodes, do the dos thing... */
  365. +    else do {
  366. +        l = fixkey(*o_stbios ? Bconin(2) : Crawcin());
  367. +
  368. +        if (got_winch) {
  369. +            got_winch = 0;
  370. +            if (*o_lines != LINES || *o_columns != COLS) {
  371. +#ifndef CRUNCH
  372. +                *o_nearscroll = 
  373. +#endif
  374. +                *o_lines = LINES;
  375. +                *o_columns = COLS;
  376. +#ifndef CRUNCH
  377. +                if (!wset)
  378. +                {
  379. +                    *o_window = LINES - 1;
  380. +                }
  381. +#endif
  382. +                if (mode != MODE_EX && mode != MODE_COLON)
  383. +                    /* pretend the user hit ^L */
  384. +                    buf[pos++] = ctrl('L');
  385. +            }
  386. +        }
  387. +        if (l > 0 && (buf[pos++]=l) == '\0')
  388. +        {
  389. +            buf[pos-1] = '#';
  390. +            buf[pos++] = l>>16;
  391. +        }
  392. +    } while (!pos);
  393. +
  394. +    /* cancel the alarm */
  395. +    alarm(0);
  396. +
  397. +    /* return the number of bytes read */
  398. +    return pos;
  399. +}
  400. +
  401. +void ttywrite(buf, len)
  402. +    char    *buf;
  403. +    int    len;
  404. +{
  405. +    if (!*o_stbios) {
  406. +        write(1, buf, (unsigned) len);
  407. +        return;
  408. +    }
  409. +    while (len--)
  410. +        (void) Bconout(2, *buf++);
  411. +}
  412. +#endif /* MINT */
  413. diff -ur ./cmd1.c /local/src/elvis/17/src/cmd1.c
  414. --- ./cmd1.c    Thu Feb  4 12:48:42 1993
  415. +++ /local/src/elvis/17/src/cmd1.c    Thu Mar 25 23:32:20 1993
  416. @@ -30,6 +30,10 @@
  417.  static int        curr_tag = -1;
  418.  #endif /* !NO_TAGSTACK */
  419.  
  420. +#if MINT
  421. +extern    int __mint;
  422. +#endif
  423. +
  424.  #ifdef DEBUG
  425.  /* print the selected lines with info on the blocks */
  426.  /*ARGSUSED*/
  427. @@ -251,7 +255,11 @@
  428.          scan[i++] = '\n';
  429.  
  430.          /* print the line */
  431. +#if MINT
  432. +        if ((*o_crlf ? twrite : write)(fd, scan, i) < i)
  433. +#else
  434.          if (twrite(fd, scan, i) < i)
  435. +#endif
  436.          {
  437.              msg("Write failed");
  438.              break;
  439. @@ -1537,6 +1545,9 @@
  440.      char    *extra;
  441.  {
  442.      BLK    buf;
  443. +#if MINT
  444. +    int    fd, old2, f2 = *REDIRECT == '>' ? 1 : 2;
  445. +#endif
  446.  
  447.      /* if the file hasn't been saved, then complain unless ! */
  448.      if (tstflag(file, MODIFIED) && !bang)
  449. @@ -1546,8 +1557,16 @@
  450.      }
  451.  
  452.      /* build the command */
  453. +#if MINT
  454. +    /* some stupid TOS shells won't grok `2>' :-(  -nox */
  455. +    sprintf(buf.c, "%s %s ", (cmd == CMD_CC ? o_cc : o_make), extra);
  456. +    qaddstr(buf.c);
  457. +    qaddstr(REDIRECT);
  458. +    qaddstr(ERRLIST);
  459. +#else
  460.      sprintf(buf.c, "%s %s %s%s", (cmd == CMD_CC ? o_cc : o_make), extra, REDIRECT, ERRLIST);
  461.      qaddstr(buf.c);
  462. +#endif
  463.      addch('\n');
  464.  
  465.      /* close the old errlist file, if any */
  466. @@ -1566,10 +1585,10 @@
  467.          return;
  468.      }
  469.      suspend_curses();
  470. -    old2 = dup(2);
  471. -    dup2(fd, 2);
  472. +    old2 = dup(f2);
  473. +    dup2(fd, f2);
  474.      system(buf.c);
  475. -    dup2(old2, 2);
  476. +    dup2(old2, f2);
  477.      close(old2);
  478.      close(fd);
  479.  #else
  480. @@ -1877,6 +1896,10 @@
  481.          return;
  482.      }
  483.  #endif
  484. +#if MINT
  485. +    if (!__mint)
  486. +        return;
  487. +#endif
  488.  
  489.      move(LINES - 1, 0);
  490.      if (tstflag(file, MODIFIED))
  491. @@ -1889,7 +1912,12 @@
  492.      refresh();
  493.      suspend_curses();
  494.      func = signal(SIGTSTP, SIG_DFL);
  495. +#if MINT
  496. +    /* earlier versions of MiNT had a problem with kill(0, ...)  -nox */
  497. +    killpg(getpgrp(), SIGTSTP);
  498. +#else
  499.      kill (0, SIGTSTP);
  500. +#endif
  501.  
  502.      /* the process stops and resumes here */
  503.  
  504. diff -ur ./cmd2.c /local/src/elvis/17/src/cmd2.c
  505. --- ./cmd2.c    Thu Feb  4 12:48:44 1993
  506. +++ /local/src/elvis/17/src/cmd2.c    Wed Mar 24 15:45:40 1993
  507. @@ -649,7 +649,11 @@
  508.          add(tomark, "\n");
  509.  
  510.          /* for each chunk of text... */
  511. +#if MINT
  512. +        while ((rc = (*o_crlf ? tread : read)(fd, tmpblk.c, BLKSIZE - 1)) > 0)
  513. +#else
  514.          while ((rc = tread(fd, tmpblk.c, BLKSIZE - 1)) > 0)
  515. +#endif
  516.          {
  517.              /* count newlines, convert NULs, etc. ... */
  518.              for (lines = 0, scan = tmpblk.c; rc > 0; rc--, scan++)
  519. diff -ur ./config.h /local/src/elvis/17/src/config.h
  520. --- ./config.h    Thu Feb  4 12:48:44 1993
  521. +++ /local/src/elvis/17/src/config.h    Wed Mar 24 15:45:44 1993
  522. @@ -85,6 +85,12 @@
  523.  # endif
  524.  #endif
  525.  
  526. +#if MINT
  527. +# ifdef TOS
  528. +#  undef TOS
  529. +# endif
  530. +#endif
  531. +
  532.  /* OS9/68000 */
  533.  #ifdef    OSK
  534.  # define COMPILED_BY    "Microware C V2.3 Edition 40"
  535. @@ -140,6 +146,10 @@
  536.  # define TOS    0        /* Atari ST    */
  537.  #endif
  538.  
  539. +#ifndef    MINT
  540. +# define MINT    0        /* Atari ST, gcc, MiNT    */
  541. +#endif
  542. +
  543.  #ifndef    AMIGA
  544.  # define AMIGA    0        /* Commodore Amiga */
  545.  #endif
  546. @@ -161,7 +171,7 @@
  547.  #endif
  548.  
  549.                  /* Minix has no predefines */
  550. -#if !BSD && !UNIXV && !UNIX7 && !MSDOS && !TOS && !AMIGA && !OSK && !COHERENT && !VMS
  551. +#if !BSD && !UNIXV && !UNIX7 && !MSDOS && !TOS && !AMIGA && !OSK && !COHERENT && !VMS && !MINT
  552.  # define MINIX    1
  553.  #else
  554.  # define MINIX    0
  555. @@ -244,7 +254,7 @@
  556.   * a true function on all systems.  The ttywrite() function is almost always
  557.   * just a macro...
  558.   */
  559. -#if !TOS && !AMIGA
  560. +#if !TOS && !AMIGA && !MINT
  561.  # define ttywrite(buf, len)    write(1, buf, (unsigned)(len))    /* raw write */
  562.  #endif
  563.  
  564. @@ -280,15 +290,22 @@
  565.  extern char *getcwd();
  566.  
  567.  /* text versa binary mode for read/write */
  568. -#if !TOS
  569. +#if !TOS && !MINT
  570.  #define    tread(fd,buf,n)        read(fd,buf,(unsigned)(n))
  571.  #define twrite(fd,buf,n)    write(fd,buf,(unsigned)(n))
  572.  #endif
  573.  
  574. +#if MINT
  575. +extern int read();
  576. +extern int tread();
  577. +extern int write();
  578. +extern int twrite();
  579. +#endif
  580. +
  581.  /**************************** Compiler quirks *********************************/
  582.  
  583.  /* the UNIX version 7 and (some) TOS compilers, don't allow "void" */
  584. -#if UNIX7 || TOS
  585. +#if (UNIX7 || TOS) && !NEWSTYLE
  586.  # define void int
  587.  #endif
  588.  
  589. @@ -427,16 +444,28 @@
  590.  # define gethome(x)    getenv("HOME")
  591.  #endif
  592.  
  593. -#if MSDOS || TOS
  594. +#if MSDOS || TOS || MINT
  595.  /* do not change TMPNAME and SCRATCH*: they MUST begin with '%s\\'! */
  596. -# ifndef TMPDIR
  597. -#  define TMPDIR    "C:\\tmp"    /* directory where temp files live */
  598. -# endif
  599. -# ifndef PRSVDIR
  600. -#  define PRSVDIR    "C:\\preserve"    /* directory where preserved file live */
  601. -# endif
  602. -# ifndef PRSVINDEX
  603. -#  define PRSVINDEX    "C:\\preserve\\Index" /* index of files in PRSVDIR */
  604. +# if !MINT
  605. +#  ifndef TMPDIR
  606. +#   define TMPDIR    "C:\\tmp"    /* directory where temp files live */
  607. +#  endif
  608. +#  ifndef PRSVDIR
  609. +#   define PRSVDIR    "C:\\preserve"    /* directory where preserved file live */
  610. +#  endif
  611. +#  ifndef PRSVINDEX
  612. +#   define PRSVINDEX    "C:\\preserve\\Index" /* index of files in PRSVDIR */
  613. +#  endif
  614. +# else
  615. +#  ifndef TMPDIR
  616. +#   define TMPDIR    "/tmp"        /* directory where temp files live */
  617. +#  endif
  618. +#  ifndef PRSVDIR
  619. +#   define PRSVDIR    "/usr/preserve"    /* directory where preserved file live */
  620. +#  endif
  621. +#  ifndef PRSVINDEX
  622. +#   define PRSVINDEX    "/usr/preserve/Index" /* index of files in PRSVDIR */
  623. +#  endif
  624.  # endif
  625.  # define TMPNAME    "%s\\elv_%x.%x" /* temp file */
  626.  # if MSDOS
  627. @@ -454,16 +483,20 @@
  628.  # endif        /* MSDOS */
  629.  # define SCRATCHIN    "%s\\siXXXXXX"    /* DOS ONLY - output of filter program */
  630.  # define SCRATCHOUT    "%s\\soXXXXXX"    /* temp file used as input to filter */
  631. -# define SLASH        '\\'
  632. +# if !MINT
  633. +#  define SLASH        '\\'
  634. +# else
  635. +#  define SLASH        '/'
  636. +# endif
  637.  # ifndef SHELL
  638. -#  if TOS
  639. +#  if TOS || MINT
  640.  #   define SHELL    "shell.ttp"    /* default shell */
  641.  #  else
  642.  #   define SHELL    "command.com"    /* default shell */
  643.  #  endif
  644.  # endif
  645.  # define NEEDSYNC    TRUE        /* assume ":se sync" by default */
  646. -# if TOS && __GNUC__            /* probably on other systems, too */
  647. +# if (TOS || MINT) && __GNUC__        /* probably on other systems, too */
  648.  #  define REDIRECT    "2>"        /* GNUC reports on 2, others on 1 */
  649.  #  define CC_COMMAND    "gcc -c"
  650.  # else
  651. diff -ur ./ctags.c /local/src/elvis/17/src/ctags.c
  652. --- ./ctags.c    Thu Feb  4 12:48:44 1993
  653. +++ /local/src/elvis/17/src/ctags.c    Mon Apr 26 16:16:34 1993
  654. @@ -85,7 +85,7 @@
  655.      /* try to open the file for reading.  The file must be opened in
  656.       * "binary" mode because otherwise fseek() would misbehave under DOS.
  657.       */
  658. -#if MSDOS || TOS
  659. +#if MSDOS || TOS || MINT
  660.      file_fp = fopen(name, "rb");
  661.  #else
  662.      file_fp = fopen(name, "r");
  663. @@ -129,6 +129,10 @@
  664.          return ch;
  665.      }
  666.  
  667. +    /* if no file is open return EOF */
  668. +    if (!file_fp)
  669. +        return EOF;
  670. +
  671.      /* if previous character was a newline, then we're starting a line */
  672.      if (file_afternl)
  673.      {
  674. @@ -137,8 +141,8 @@
  675.          file_lnum++;
  676.      }
  677.  
  678. -    /* Get a character.  If no file is open, then return EOF */
  679. -    ch = (file_fp ? getc(file_fp) : EOF);
  680. +    /* Get a character */
  681. +    ch = getc(file_fp);
  682.  
  683.      /* if it is a newline, then remember that fact */
  684.      if (ch == '\n')
  685. @@ -217,6 +221,7 @@
  686.  int    cpp_afternl;    /* boolean: look for '#' character? */
  687.  int    cpp_prevch;    /* an ungotten character, if any */
  688.  int    cpp_refsok;    /* boolean: can we echo characters out to "refs"? */
  689. +int    cpp_refsnl;    /* boolean: dup next \n in "refs"? */
  690.  
  691.  /* This function opens the file & resets variables */
  692.  void cpp_open(name)
  693. @@ -242,6 +247,14 @@
  694.          /* try to avoid blank lines */
  695.          if (ch == '\n')
  696.          {
  697. +            /* hack: double \n at end of declarations, to
  698. +               help `ref' find the right starting point...
  699. +            */
  700. +            if (cpp_refsnl)
  701. +            {
  702. +                putc('\n', refs);
  703. +                cpp_refsnl = FALSE;
  704. +            }
  705.              if (wasnl)
  706.              {
  707.                  return;
  708. @@ -507,6 +520,7 @@
  709.              cpp_echo('}');
  710.  
  711.              token = BODY;
  712. +            cpp_refsnl = TRUE;
  713.              break;
  714.  
  715.            case '[':
  716. @@ -764,14 +778,11 @@
  717.      char    **argv;
  718.  {
  719.      int    i, j;
  720. -#if MSDOS || TOS
  721. -    char    **wildexpand();
  722. -#endif
  723.  
  724.      /* build the tables used by the ctype macros */
  725.      _ct_init((uchar *)"");
  726.  
  727. -#if MSDOS || TOS
  728. +#if MSDOS || TOS || MINT
  729.      argv = wildexpand(&argc, argv);
  730.  #endif
  731.  
  732. @@ -845,7 +856,7 @@
  733.      /*NOTREACHED*/
  734.  }
  735.  
  736. -#if MSDOS || TOS
  737. +#if MSDOS || TOS || MINT
  738.  # define WILDCARD_NO_MAIN
  739.  # include "wildcard.c"
  740.  #endif
  741. diff -ur ./curses.c /local/src/elvis/17/src/curses.c
  742. --- ./curses.c    Thu Feb  4 12:48:46 1993
  743. +++ /local/src/elvis/17/src/curses.c    Fri Mar 26 14:42:20 1993
  744. @@ -17,7 +17,7 @@
  745.  #include "config.h"
  746.  #include "vi.h"
  747.  
  748. -#if ANY_UNIX
  749. +#if ANY_UNIX || MINT
  750.  # if UNIXV || COH_386
  751.  #  ifdef TERMIOS
  752.  #   include    <termios.h>
  753. @@ -34,6 +34,9 @@
  754.  #  endif
  755.  # else
  756.  #  include    <sgtty.h>
  757. +#  if MINT
  758. +extern int    __mint;
  759. +#  endif
  760.  # endif
  761.  #endif
  762.  
  763. @@ -145,7 +148,7 @@
  764.  # endif
  765.  #endif
  766.  
  767. -#if ANY_UNIX
  768. +#if ANY_UNIX || MINT
  769.  # if UNIXV || COH_386
  770.  #  ifdef TERMIOS
  771.  static struct termios    oldtermio;    /* original tty mode */
  772. @@ -209,7 +212,7 @@
  773.      if (!termtype)
  774.  #endif
  775.      {
  776. -#if ANY_UNIX
  777. +#if ANY_UNIX || MINT
  778.          write(2, "Environment variable TERM must be set\n", (unsigned)38);
  779.          exit(2);
  780.  #endif
  781. @@ -246,7 +249,7 @@
  782.      stdscr = kbuf;
  783.  
  784.      /* change the terminal mode to cbreak/noecho */
  785. -#if ANY_UNIX
  786. +#if ANY_UNIX || MINT
  787.  # if UNIXV || COH_386
  788.  #  ifdef TERMIOS
  789.      tcgetattr(2, &oldtermio);
  790. @@ -254,6 +257,9 @@
  791.      ioctl(2, TCGETA, &oldtermio);
  792.  #  endif
  793.  # else
  794. +#  if MINT
  795. +    if (__mint)
  796. +#  endif
  797.      ioctl(2, TIOCGETP, &oldsgttyb);
  798.  # endif
  799.  #endif
  800. @@ -287,7 +293,7 @@
  801.  /* Send any required termination strings.  Turn off "raw" mode. */
  802.  void suspend_curses()
  803.  {
  804. -#if ANY_UNIX && !(UNIXV || COH_386)
  805. +#if (ANY_UNIX && !(UNIXV || COH_386)) || MINT
  806.      struct tchars    tbuf;
  807.  # ifdef TIOCSLTC
  808.      struct ltchars    ltbuf;
  809. @@ -314,7 +320,7 @@
  810.      refresh();
  811.  
  812.      /* change the terminal mode back the way it was */
  813. -#if ANY_UNIX
  814. +#if ANY_UNIX || MINT
  815.  # if (UNIXV || COH_386)
  816.  #  ifdef TERMIOS
  817.      tcsetattr(2, TCSADRAIN, &oldtermio);
  818. @@ -322,6 +328,9 @@
  819.      ioctl(2, TCSETAW, &oldtermio);
  820.  #  endif
  821.  # else
  822. +#  if MINT
  823. +    if (__mint) {
  824. +#  endif
  825.      ioctl(2, TIOCSETP, &oldsgttyb);
  826.  
  827.      ioctl(2, TIOCGETC, (struct sgttyb *) &tbuf);
  828. @@ -335,6 +344,9 @@
  829.      ltbuf.t_lnextc = oldquote;
  830.      ioctl(2, TIOCSLTC, <buf);
  831.  #  endif
  832. +#  if MINT
  833. +    }
  834. +#  endif
  835.  # endif
  836.  #endif
  837.  #if OSK
  838. @@ -363,7 +375,7 @@
  839.      if (!curses_active)
  840.      {
  841.          /* change the terminal mode to cbreak/noecho */
  842. -#if ANY_UNIX
  843. +#if ANY_UNIX || MINT
  844.  # if UNIXV || COH_386
  845.          ospeed = (oldtermio.c_cflag & CBAUD);
  846.          ERASEKEY = oldtermio.c_cc[VERASE];
  847. @@ -391,6 +403,9 @@
  848.          struct ltchars    ltbuf;
  849.  #  endif
  850.  
  851. +#  if MINT
  852. +        if (__mint) {
  853. +#  endif
  854.          ospeed = oldsgttyb.sg_ospeed;
  855.          ERASEKEY = oldsgttyb.sg_erase;
  856.          newsgttyb = oldsgttyb;
  857. @@ -413,6 +428,9 @@
  858.          ltbuf.t_lnextc = 0;        /* disable ^V for elvis */
  859.          ioctl(2, TIOCSLTC, <buf);
  860.  #  endif
  861. +#  if MINT
  862. +        }
  863. +#  endif
  864.  
  865.  # endif
  866.  #endif
  867. @@ -737,6 +755,9 @@
  868.  
  869.  }
  870.  
  871. +#if MINT
  872. +int got_winch;
  873. +#endif
  874.  
  875.  /* This function gets the window size.  It uses the TIOCGWINSZ ioctl call if
  876.   * your system has it, or tgetnum("li") and tgetnum("co") if it doesn't.
  877. @@ -760,7 +781,19 @@
  878.      /* get the window size, one way or another. */
  879.      lines = cols = 0;
  880.  #ifdef TIOCGWINSZ
  881. +# if !MINT
  882.      if (ioctl(2, TIOCGWINSZ, &size) >= 0)
  883. +# else
  884. +    if (signo)
  885. +        got_winch = 1;
  886. +
  887. +    /* only MiNT versions >= 0.9 know TIOCGWINSZ; for older versions
  888. +       and when running under vanilla TOS mntlib would return the
  889. +       settings of the ST BIOS screeen driver, and that at least
  890. +       doesn't help when we're not running on the console.  -nox */
  891. +
  892. +    if (__mint >= 9 && ioctl(2, TIOCGWINSZ, &size) >= 0)
  893. +# endif
  894.      {
  895.          lines = size.ws_row;
  896.          cols = size.ws_col;
  897. diff -ur ./curses.h /local/src/elvis/17/src/curses.h
  898. --- ./curses.h    Thu Feb  4 12:48:48 1993
  899. +++ /local/src/elvis/17/src/curses.h    Wed Mar 24 15:45:58 1993
  900. @@ -209,11 +209,19 @@
  901.  #define    do_TI()        VOIDBIOS(;, (void)ttywrite(TI, (unsigned)strlen(TI)))
  902.  #define    do_TE()        VOIDBIOS(;, (void)ttywrite(TE, (unsigned)strlen(TE)))
  903.  #ifndef NO_CURSORSHAPE
  904. -# define do_CQ()    VOIDBIOS(v_cs(), tputs(CQ, 1, faddch))
  905. -# define do_CX()    VOIDBIOS(v_cs(), tputs(CX, 1, faddch))
  906. -# define do_CV()    VOIDBIOS(v_cs(), tputs(CV, 1, faddch))
  907. -# define do_CI()    VOIDBIOS(v_cb(), tputs(CI, 1, faddch))
  908. -# define do_CR()    VOIDBIOS(v_cb(), tputs(CR, 1, faddch))
  909. +# if MINT /* ctputs() knows about #blink / #noblink and calling ST BIOS... */
  910. +#  define do_CQ()    VOIDBIOS(v_cs(), ctputs(CQ, 1, faddch))
  911. +#  define do_CX()    VOIDBIOS(v_cs(), ctputs(CX, 1, faddch))
  912. +#  define do_CV()    VOIDBIOS(v_cs(), ctputs(CV, 1, faddch))
  913. +#  define do_CI()    VOIDBIOS(v_cb(), ctputs(CI, 1, faddch))
  914. +#  define do_CR()    VOIDBIOS(v_cb(), ctputs(CR, 1, faddch))
  915. +# else
  916. +#  define do_CQ()    VOIDBIOS(v_cs(), tputs(CQ, 1, faddch))
  917. +#  define do_CX()    VOIDBIOS(v_cs(), tputs(CX, 1, faddch))
  918. +#  define do_CV()    VOIDBIOS(v_cs(), tputs(CV, 1, faddch))
  919. +#  define do_CI()    VOIDBIOS(v_cb(), tputs(CI, 1, faddch))
  920. +#  define do_CR()    VOIDBIOS(v_cb(), tputs(CR, 1, faddch))
  921. +# endif
  922.  #endif
  923.  #ifndef NO_COLOR
  924.  # define do_aend()    VOIDBIOS((vmode=A_NORMAL), endcolor())
  925. diff -ur ./cut.c /local/src/elvis/17/src/cut.c
  926. --- ./cut.c    Thu Feb  4 12:48:48 1993
  927. +++ /local/src/elvis/17/src/cut.c    Tue Sep 21 19:48:52 1993
  928. @@ -117,7 +117,7 @@
  929.      /* if nobody else needs it, then discard the tmp file */
  930.      if (i < 0)
  931.      {
  932. -#if MSDOS || TOS
  933. +#if MSDOS || TOS || MINT
  934.          strcpy(cutfname, o_directory);
  935.          if ((i = strlen(cutfname)) && !strchr(":/\\", cutfname[i - 1]))
  936.              cutfname[i++] = SLASH;
  937. @@ -181,12 +181,14 @@
  938.  }
  939.  
  940.  /* This function should be called just before termination of vi */
  941. -void cutend()
  942. +void cutend(preserving)
  943. +    int preserving;        /* means `leave current tempfile alone' */
  944.  {
  945.      int    i;
  946.  
  947. -    /* free the anonymous buffers, if they aren't already free */
  948. -    cutswitch();
  949. +    if (!preserving)
  950. +        /* free the anonymous buffers, if they aren't already free */
  951. +        cutswitch();
  952.  
  953.      /* free all named cut buffers, since they might be forcing an older
  954.       * tmp file to be retained.
  955. @@ -196,8 +198,9 @@
  956.          cutfree(&named[i]);
  957.      }
  958.  
  959. -    /* delete the temp file */
  960. -    maybezap(tmpnum);
  961. +    if (!preserving)
  962. +        /* delete the temp file */
  963. +        maybezap(tmpnum);
  964.  }
  965.  
  966.  
  967. @@ -424,7 +427,7 @@
  968.  {
  969.      char        cutfname[50];/* name of an old temp file */
  970.      int        fd;    /* either tmpfd or the result of open() */
  971. -#if MSDOS || TOS
  972. +#if MSDOS || TOS || MINT
  973.      int        i;
  974.  #endif
  975.  
  976. @@ -435,7 +438,7 @@
  977.      }
  978.      else
  979.      {
  980. -#if MSDOS || TOS
  981. +#if MSDOS || TOS || MINT
  982.          strcpy(cutfname, o_directory);
  983.          if ((i = strlen(cutfname)) && !strchr(":/\\", cutfname[i-1]))
  984.              cutfname[i++]=SLASH;
  985. diff -ur ./elvprsv.c /local/src/elvis/17/src/elvprsv.c
  986. --- ./elvprsv.c    Thu Feb  4 12:48:50 1993
  987. +++ /local/src/elvis/17/src/elvprsv.c    Fri Mar 26 00:07:38 1993
  988. @@ -74,12 +74,14 @@
  989.  # undef sprintf
  990.  #endif
  991.  
  992. -#if ANY_UNIX || OSK
  993. +#if ANY_UNIX || OSK || MINT
  994.  # include "prsvunix.c"
  995.  #endif
  996.  
  997. -#if MSDOS || TOS
  998. -# include "prsvdos.c"
  999. +#if MSDOS || TOS || MINT
  1000. +# if !MINT
  1001. +#  include "prsvdos.c"
  1002. +# endif
  1003.  # define WILDCARD_NO_MAIN
  1004.  # include "wildcard.c"
  1005.  #endif
  1006. @@ -275,9 +277,9 @@
  1007.      int    i;
  1008.      char    *when = "the editor went away";
  1009.  
  1010. -#if MSDOS || TOS
  1011. -    /* expand any wildcards in the command line */
  1012. +#if MSDOS || TOS || MINT
  1013.      _ct_init("");
  1014. +    /* expand any wildcards in the command line */
  1015.      argv = wildexpand(&argc, argv);
  1016.  #endif
  1017.  
  1018. @@ -310,4 +312,5 @@
  1019.          preserve(argv[i], when);
  1020.          i++;
  1021.      }
  1022. +    exit(0);
  1023.  }
  1024. diff -ur ./elvrec.c /local/src/elvis/17/src/elvrec.c
  1025. --- ./elvrec.c    Thu Feb  4 12:48:50 1993
  1026. +++ /local/src/elvis/17/src/elvrec.c    Thu Mar 25 13:53:36 1993
  1027. @@ -18,6 +18,10 @@
  1028.  void main P_((int, char **));
  1029.  
  1030.  
  1031. +#if MINT
  1032. +extern    int __mint;
  1033. +#endif
  1034. +
  1035.  void recover(basename, outname)
  1036.      char    *basename;    /* the name of the file to recover */
  1037.      char    *outname;    /* the name of the file to write to */
  1038. @@ -36,7 +40,12 @@
  1039.      if (basename)
  1040.      {
  1041.  #ifndef CRUNCH
  1042. -# if MSDOS || TOS
  1043. +# if MINT
  1044. +        for (ptr = basename; *ptr; ++ptr)
  1045. +            if (*ptr == '\\')
  1046. +                *ptr = '/';
  1047. +# endif
  1048. +# if MSDOS || TOS || MINT
  1049.          if (!basename[0] || basename[1] != ':')
  1050.  # else
  1051.          if (basename[0] != SLASH)
  1052. @@ -48,6 +57,12 @@
  1053.                  strcpy(pathname, ptr);
  1054.              }
  1055.              ptr = pathname + strlen(pathname);
  1056. +# if MINT
  1057. +            if (__mint && *basename == '/' && (*pathname == '/' ||
  1058. +                ((*pathname | 0x20) == 'u' && pathname[1] == ':')))
  1059. +                ptr = pathname;
  1060. +            else
  1061. +# endif
  1062.              *ptr++ = SLASH;
  1063.              strcpy(ptr, basename);
  1064.          }
  1065. @@ -160,6 +175,11 @@
  1066.      fclose(from);
  1067.      setuid(0);
  1068.  #endif
  1069. +#if TOS || MINT
  1070. +    /* GEMDOS doesn't know how to unlink a file thats still open...
  1071. +     *  it might just trash the filesystem instead :-(  -nox */
  1072. +    fclose(from);
  1073. +#endif
  1074.      /* delete the /usr/preserve file */
  1075.      unlink(line);
  1076.  #if OSK
  1077. diff -ur ./ex.c /local/src/elvis/17/src/ex.c
  1078. --- ./ex.c    Thu Feb  4 12:48:50 1993
  1079. +++ /local/src/elvis/17/src/ex.c    Thu Apr 22 00:11:24 1993
  1080. @@ -100,7 +100,7 @@
  1081.      {"cd",        CMD_CD,        cmd_cd,        EXRCOK+BANG+NAMEDF},
  1082.      {"copy",    CMD_COPY,    cmd_move,    RANGE+EXTRA    },
  1083.  #ifndef NO_DIGRAPH
  1084. -    {"digraph",    CMD_DIGRAPH,    cmd_digraph,    EXRCOK+BANG+EXTRA},
  1085. +    {"digraph",    CMD_DIGRAPH,    cmd_digraph,    EXRCOK+BANG+EXTRA+NOBAR},
  1086.  #endif
  1087.  #ifndef NO_ERRLIST
  1088.      {"errlist",    CMD_ERRLIST,    cmd_errlist,    BANG+NAMEDF    },
  1089. @@ -676,6 +676,8 @@
  1090.      int    len;        /* length of the ".exrc" file */
  1091.  
  1092.  #ifdef CRUNCH
  1093. +#undef TINYSTACK
  1094. +#define TINYSTACK 0
  1095.      /* small address space - we need to conserve space */
  1096.  
  1097.      /* !!! kludge: we use U_text as the buffer.  This has the side-effect
  1098. diff -ur ./main.c /local/src/elvis/17/src/main.c
  1099. --- ./main.c    Thu Feb  4 12:48:54 1993
  1100. +++ /local/src/elvis/17/src/main.c    Tue Sep 21 19:15:18 1993
  1101. @@ -27,6 +27,10 @@
  1102.  static init_digraphs();
  1103.  #endif
  1104.  
  1105. +#if MINT
  1106. +extern int    __mint;
  1107. +#endif
  1108. +
  1109.  /*---------------------------------------------------------------------*/
  1110.  
  1111.  #if AMIGA
  1112. @@ -49,8 +53,23 @@
  1113.      char    *str;
  1114.      char    *tag = (char *)0;
  1115.  
  1116. +#if MINT
  1117. +    if (!__mint && isatty(0))
  1118. +        *o_stbios = 1;
  1119. +
  1120. +    /* see if that helps against those strange redraw problems...  -nox */
  1121. +#if 0    /* doesn't seem so... */
  1122. +    _malloczero(1);
  1123. +#endif
  1124. +#endif
  1125. +
  1126.      /* set mode to MODE_VI or MODE_EX depending on program name */
  1127. +#if TOS || MINT
  1128. +    /* some TOS shells know nothing about argv[0]...  -nox */
  1129. +    switch (**argv ? argv[0][strlen(argv[0]) - 1] : 's')
  1130. +#else
  1131.      switch (argv[0][strlen(argv[0]) - 1])
  1132. +#endif
  1133.      {
  1134.        case 'x':            /* "ex" */
  1135.          mode = MODE_EX;
  1136. @@ -91,17 +110,21 @@
  1137.      signal(SIGHUP, deathtrap);
  1138.  # endif
  1139.  # ifndef DEBUG
  1140. -#  ifdef SIGILL
  1141. +#  if !MINT
  1142. +    /* MiNT doesn't have `real' memory protection, so trying to preserve
  1143. +       files after one of these would be a bit risky...  */
  1144. +#   ifdef SIGILL
  1145.      signal(SIGILL, deathtrap);
  1146. -#  endif
  1147. -#  ifdef SIGBUS
  1148. +#   endif
  1149. +#   ifdef SIGBUS
  1150.      signal(SIGBUS, deathtrap);
  1151. -#  endif
  1152. -#  ifdef SIGSEGV
  1153. +#   endif
  1154. +#   ifdef SIGSEGV
  1155.      signal(SIGSEGV, deathtrap);
  1156. -#  endif
  1157. -#  ifdef SIGSYS
  1158. +#   endif
  1159. +#   ifdef SIGSYS
  1160.      signal(SIGSYS, deathtrap);
  1161. +#   endif
  1162.  #  endif
  1163.  # endif /* !DEBUG */
  1164.  # ifdef SIGPIPE
  1165. @@ -170,6 +193,17 @@
  1166.      }
  1167.  # endif
  1168.  #endif
  1169. +#if MINT
  1170. +    if (!strcmp(has_KL, "#K") && !strcmp(has_KR, "#M")) {
  1171. +        *o_keytime = 1;
  1172. +
  1173. +        mapkey("#a", "u", WHEN_VICMD|WHEN_INMV,    "<Undo>");
  1174. +        mapkey("#b", "\\", WHEN_VICMD|WHEN_INMV, "<Help>");
  1175. +        mapkey("#s", "B", WHEN_VICMD|WHEN_INMV,    "^<Left>");
  1176. +        mapkey("#t", "W", WHEN_VICMD|WHEN_INMV,    "^<Right>");
  1177. +        mapkey("#7", "v", WHEN_VICMD|WHEN_INMV,    "sh-<Insrt>");
  1178. +    }
  1179. +#endif
  1180.  
  1181.  #ifndef NO_DIGRAPH
  1182.      init_digraphs();
  1183. @@ -285,7 +319,7 @@
  1184.              strcat(args, " ");
  1185.              strcat(args, argv[i]);
  1186.          }
  1187. -#if MSDOS || TOS
  1188. +#if MSDOS || TOS || MINT
  1189.          /* expand wildcard characters, if necessary */
  1190.          if (strchr(args, '*') || strchr(args, '?'))
  1191.          {
  1192. @@ -405,7 +439,7 @@
  1193.      }
  1194.  
  1195.      /* free up the cut buffers */
  1196. -    cutend();
  1197. +    cutend(0);
  1198.  
  1199.      /* end curses */
  1200.  #ifndef    NO_CURSORSHAPE
  1201. diff -ur ./makefile /local/src/elvis/17/src/makefile
  1202. --- ./makefile    Thu Feb  4 12:48:38 1993
  1203. +++ /local/src/elvis/17/src/makefile    Tue Sep 21 21:30:12 1993
  1204. @@ -364,6 +364,39 @@
  1205.  #DUMMY=
  1206.  #CFG=
  1207.  
  1208. +#---- These settings are recommended for Atari TOS + gcc + MiNT libraries ----
  1209. +OBJ=.o
  1210. +EXE=.ttp
  1211. +COM=.ttp
  1212. +EXTRA=    sysdos$(OBJ) atari$(OBJ)
  1213. +EXTRA2=
  1214. +BIN=    c:\\bin
  1215. +CC=    gcc
  1216. +LIBS=    -lbcurses -lbiio
  1217. +LIBIIO=    -lbiio
  1218. +#CFLAGS=    -O2 -Wall -mbaserel -fomit-frame-pointer \
  1219. +#    -DMINT -DCS_IBMPC -DCS_SPECIAL -DSMOOTHREDRAW -DMAILER=\"rmail\"
  1220. +#debugging:
  1221. +CFLAGS=    -g -O2 -Wall -mbaserel \
  1222. +    -DMINT -DCS_IBMPC -DCS_SPECIAL -DSMOOTHREDRAW -DMAILER=\"rmail\"
  1223. +LFLAGS=    -mbaserel
  1224. +SMALL=
  1225. +LARGE=
  1226. +OF=    -o 
  1227. +RF=    -c
  1228. +MYNAME=    myname.c
  1229. +PROGS=    elvis$(EXE) ex$(COM) vi$(COM) view$(COM) input$(COM) \
  1230. +    ctags$(COM) ref$(COM) elvrec$(COM) wildcard$(COM) \
  1231. +    shell$(COM) fmt$(COM) elvprsv$(COM)
  1232. +#CHMEM=
  1233. +#debugging:
  1234. +CHMEM=    $(CC) $(CFLAGS) -B/usr/lib/sym- $(OF)elvis.sym $(OBJS) $(EXTRA) $(EXTRA2) $(LIBS)
  1235. +SORT=
  1236. +RM=    rm -f
  1237. +CP=    cp
  1238. +SYS=    tos
  1239. +DUMMY=
  1240. +
  1241.  #---- These settings are recommended for OS-9/68K V2.3 ----
  1242.  #OBJ=    .r
  1243.  #EXE=
  1244. @@ -444,7 +477,7 @@
  1245.  ALIAS=    alias$(OBJ)
  1246.  
  1247.  SRC1=    Elvis.lnk Elvis.mak Elvis.prj Makefile.mix alias.c atari.c \
  1248. -    ctags.c pc.c ref.c shell.c sysdos.c
  1249. +    ctags.c pc.c ref.c shell.c sysdos.c myname.c
  1250.  SRC2=    elvrec.c wildcard.c fmt.c profile.sh osk.c osk.h elvprsv.c unix.c \
  1251.      blk.c config.h instman.sh
  1252.  SRC3=    cmd1.c cmd2.c curses.c
  1253. @@ -464,13 +497,13 @@
  1254.      @echo "elvis linked."
  1255.  
  1256.  ctags$(COM): $(CFG) ctags.c wildcard.c
  1257. -    $(CC) $(CFLAGS) $(SMALL) $(SORT) $(OF)ctags$(COM) ctags.c $(EXTRA2)
  1258. +    $(CC) $(CFLAGS) $(SMALL) $(SORT) $(OF)ctags$(COM) ctags.c $(EXTRA2) $(LIBIIO)
  1259.  
  1260.  ref$(COM): $(CFG) ref.c
  1261. -    $(CC) $(CFLAGS) $(SMALL) $(OF)ref$(COM) ref.c
  1262. +    $(CC) $(CFLAGS) $(SMALL) $(OF)ref$(COM) ref.c $(LIBIIO)
  1263.  
  1264.  elvrec$(COM): $(CFG) elvrec.c
  1265. -    $(CC) $(CFLAGS) $(SMALL) $(OF)elvrec$(COM) elvrec.c $(EXTRA2)
  1266. +    $(CC) $(CFLAGS) $(SMALL) $(OF)elvrec$(COM) elvrec.c $(EXTRA2) $(LIBIIO)
  1267.  
  1268.  ex$(COM): linkex.$(SYS)
  1269.      @echo "ex done."
  1270. @@ -485,16 +518,19 @@
  1271.      @echo "input done."
  1272.  
  1273.  shell$(COM): $(CFG) shell.c
  1274. -    $(CC) $(CFLAGS) $(SMALL) $(OF)shell$(COM) shell.c
  1275. +    $(CC) $(CFLAGS) $(SMALL) $(OF)shell$(COM) shell.c $(LIBIIO)
  1276.  
  1277.  wildcard$(COM): $(CFG) wildcard.c ctype.c
  1278. -    $(CC) $(CFLAGS) $(SMALL) $(OF)wildcard$(COM) wildcard.c
  1279. +    $(CC) $(CFLAGS) $(SMALL) $(OF)wildcard$(COM) wildcard.c $(LIBIIO)
  1280.  
  1281.  fmt$(COM): $(CFG) fmt.c
  1282. -    $(CC) $(CFLAGS) $(SMALL) $(OF)fmt$(COM) fmt.c $(EXTRA2)
  1283. +    $(CC) $(CFLAGS) $(SMALL) $(OF)fmt$(COM) fmt.c $(EXTRA2) $(LIBIIO)
  1284.  
  1285.  elvprsv$(COM): $(CFG) elvprsv.c amiprsv.c prsvunix.c prsvdos.c wildcard.c ctype.c
  1286. -    $(CC) $(CFLAGS) $(SMALL) $(OF)elvprsv$(COM) elvprsv.c
  1287. +    $(CC) $(CFLAGS) $(SMALL) $(OF)elvprsv$(COM) elvprsv.c $(LIBIIO)
  1288. +#mntlib30 popen() needs a patch...
  1289. +#elvprsv$(COM): $(CFG) elvprsv.c amiprsv.c prsvunix.c prsvdos.c wildcard.c ctype.c popen.o
  1290. +#    $(CC) $(CFLAGS) $(SMALL) $(OF)elvprsv$(COM) elvprsv.c popen.o $(LIBIIO)
  1291.  
  1292.  ##############################################################################
  1293.  # "It all depends..."
  1294. @@ -548,29 +584,45 @@
  1295.  linkex.ami: alias.o
  1296.      $(LNK) $(LFLAGS) $(OF)ex$(EXE) alias.o $(LIBS)
  1297.  
  1298. -linkex.unx linkex.tos linkex.xdos linkex.dos linkex.vms: $(CFG) alias.c
  1299. +linkex.unx linkex.xdos linkex.dos linkex.vms: $(CFG) alias.c
  1300.      $(CC) $(CFLAGS) $(SMALL) $(OF)ex$(COM) alias.c
  1301.  
  1302. +linkex.tos: $(CFG) alias$(OBJ) $(MYNAME)
  1303. +    $(CC) $(CFLAGS) $(SMALL) -DMYNAME=\"ex\" $(OF)ex$(COM) alias$(OBJ) $(MYNAME) $(LIBIIO)
  1304. +    @touch $@
  1305. +
  1306.  linkex.os9: $(DUMMY)
  1307.      @echo done >/nil
  1308.  
  1309. -linkvi.ami linkvi.unx linkvi.tos linkvi.xdos linkvi.dos linkvi.vms: ex$(COM)
  1310. +linkvi.ami linkvi.unx linkvi.xdos linkvi.dos linkvi.vms: ex$(COM)
  1311.      $(CP) ex$(COM) vi$(COM)
  1312.  
  1313. +linkvi.tos: $(CFG) alias$(OBJ) $(MYNAME)
  1314. +    $(CC) $(CFLAGS) $(SMALL) -DMYNAME=\"vi\" $(OF)vi$(COM) alias$(OBJ) $(MYNAME) $(LIBIIO)
  1315. +    @touch $@
  1316. +
  1317.  linkvi.os9: alias.r
  1318.      $(CC) $(CFLAGS) $(OF)vi$(COM) alias.r
  1319.      @touch $@
  1320.  
  1321. -linkview.ami linkview.unx linkview.tos linkview.xdos linkview.dos linkview.vms: ex$(COM)
  1322. +linkview.ami linkview.unx linkview.xdos linkview.dos linkview.vms: ex$(COM)
  1323.      $(CP) ex$(COM) view$(COM)
  1324.  
  1325. +linkview.tos: $(CFG) alias$(OBJ) $(MYNAME)
  1326. +    $(CC) $(CFLAGS) $(SMALL) -DMYNAME=\"view\" $(OF)view$(COM) alias$(OBJ) $(MYNAME) $(LIBIIO)
  1327. +    @touch $@
  1328. +
  1329.  linkview.os9: alias.r
  1330.      $(CC) $(CFLAGS) $(OF)view$(COM) alias.r
  1331.      @touch $@
  1332.  
  1333. -linkinput.ami linkinput.unx linkinput.tos linkinput.xdos linkinput.dos linkinput.vms: ex$(COM)
  1334. +linkinput.ami linkinput.unx linkinput.xdos linkinput.dos linkinput.vms: ex$(COM)
  1335.      $(CP) ex$(COM) input$(COM)
  1336.  
  1337. +linkinput.tos: $(CFG) alias$(OBJ) $(MYNAME)
  1338. +    $(CC) $(CFLAGS) $(SMALL) -DMYNAME=\"input\" $(OF)input$(COM) alias$(OBJ) $(MYNAME) $(LIBIIO)
  1339. +    @touch $@
  1340. +
  1341.  linkinput.os9: alias.r
  1342.      $(CC) $(CFLAGS) $(OF)input$(COM) alias.r
  1343.      @touch $@
  1344. @@ -629,6 +681,8 @@
  1345.  
  1346.  inst.tos: $(DUMMY)
  1347.      $(CP) $(PROGS) $(BIN)
  1348. +    -mkdir /usr/preserve
  1349. +    (cd $(BIN); xstrip -k $(PROGS))
  1350.  
  1351.  inst.os9: $(DUMMY)
  1352.      $(CP) $(PROGS) -rw=$(BIN)
  1353. @@ -739,3 +793,9 @@
  1354.  
  1355.  elvis8.sh: $(SRC8)
  1356.      shar $(SRC8) >elvis7.sh
  1357. +
  1358. +##############################################################################
  1359. +
  1360. +elvis.tz: $(SRC1) $(SRC2) $(SRC3) $(SRC4) $(SRC5) $(SRC6) $(SRC7) $(SRC8)
  1361. +    tar cfv - $(SRC1) $(SRC2) $(SRC3) $(SRC4) $(SRC5) $(SRC6) $(SRC7) $(SRC8) \
  1362. +    Makefile |gzip >elvis.tz
  1363. diff -ur ./opts.c /local/src/elvis/17/src/opts.c
  1364. --- ./opts.c    Thu Feb  4 12:48:56 1993
  1365. +++ /local/src/elvis/17/src/opts.c    Wed Mar 24 15:46:32 1993
  1366. @@ -128,6 +128,10 @@
  1367.  char    o_tagstack[1] =        {TRUE};
  1368.  #endif
  1369.  
  1370. +#if MINT
  1371. +char    o_stbios[1] =        {FALSE};
  1372. +char    o_crlf[1] =        {TRUE};
  1373. +#endif
  1374.  
  1375.  
  1376.  /* The following describes the names & types of all options */
  1377. @@ -165,6 +169,9 @@
  1378.      { "charattr",    "ca",    BOOL,    CANSET|MR,    o_charattr    },
  1379.  #endif
  1380.      { "columns",    "co",    NUM,    SET|NOSAVE|MR,    o_columns    },
  1381. +#if MINT
  1382. +    { "crlf",    "cr",    BOOL,    CANSET    ,    o_crlf        },
  1383. +#endif
  1384.  #ifndef NO_DIGRAPH
  1385.      { "digraph",    "dig",    BOOL,    CANSET,        o_digraph    },
  1386.  #endif
  1387. @@ -237,6 +244,9 @@
  1388.  #endif
  1389.      { "shiftwidth",    "sw",    NUM,    CANSET,        o_shiftwidth    },
  1390.      { "sidescroll",    "ss",    NUM,    CANSET,        o_sidescroll    },
  1391. +#if MINT
  1392. +    { "stbios",    "st",    BOOL,    RCSET | SET ,    o_stbios    },
  1393. +#endif
  1394.      { "sync",    "sy",    BOOL,    CANSET,        o_sync        },
  1395.      { "tabstop",    "ts",    NUM,    CANSET|MR,    o_tabstop    },
  1396.  #ifndef CRUNCH
  1397. @@ -291,7 +301,7 @@
  1398.      }
  1399.  #endif
  1400.  
  1401. -#if AMIGA || MSDOS || TOS
  1402. +#if AMIGA || MSDOS || TOS || MINT
  1403.      if ((val = getenv("TMP")) /* yes, ASSIGNMENT! */
  1404.      ||  (val = getenv("TEMP")))
  1405.          strcpy(o_directory, val);
  1406. diff -ur ./profile.sh /local/src/elvis/17/src/profile.sh
  1407. --- ./profile.sh    Thu Feb  4 12:48:56 1993
  1408. +++ /local/src/elvis/17/src/profile.sh    Wed Mar 24 15:46:34 1993
  1409. @@ -1,2 +1,3 @@
  1410. -set PATH=.,\bin
  1411. +set TERMCAP=/dev/e/etc/termcap
  1412. +set TERM=st
  1413.  set SHELL=shell.ttp
  1414. diff -ur ./prsvunix.c /local/src/elvis/17/src/prsvunix.c
  1415. --- ./prsvunix.c    Thu Feb  4 12:48:56 1993
  1416. +++ /local/src/elvis/17/src/prsvunix.c    Fri Mar 26 16:53:20 1993
  1417. @@ -75,16 +75,36 @@
  1418.  #if OSK
  1419.      sprintf(cmd, "mail \"-s=%s preserved!\" %s", base, user);
  1420.  #else /* ANY_UNIX */
  1421. +#if MINT
  1422. +    sprintf(cmd, "%s %s >/dev/null 2>/dev/null", MAILER, user);
  1423. +#else
  1424.      sprintf(cmd, "mail %s >/dev/null 2>/dev/null", user);
  1425.  #endif
  1426. +#endif
  1427.      m = popen(cmd, "w");
  1428.      if (!m)
  1429.      {
  1430.          /* Can't send mail!  Hope the user figures it out. */
  1431. +#if MINT
  1432. +        /* if can't send mail on MiNT, do the dos thing... */
  1433. +
  1434. +        printf("A version of your file \"%s%c%s\"\n", file, SLASH, base);
  1435. +        printf("was preserved when %s.\n", when);
  1436. +        printf("To recover this file, do the following:\n");
  1437. +        printf("\n");
  1438. +        printf("     C:\\> cd %s\n", file);
  1439. +        printf("     %s> elvrec %s\n", file, base);
  1440. +        printf("\n");
  1441. +#endif
  1442.          return;
  1443.      }
  1444.  
  1445.      /* Tell the user that the file was preserved */
  1446. +#if MINT
  1447. +    /* well this is not so much #if MINT, more if MAILER doesn't know -s
  1448. +       but can read (and complete) a mail header from input... */
  1449. +    fprintf(m, "Subject: %s preserved!\n\n", base);
  1450. +#endif
  1451.      fprintf(m, "A version of your file \"%s%c%s\"\n", file, SLASH, base);
  1452.      fprintf(m, "was preserved when %s.\n", when);
  1453.      fprintf(m, "To recover this file, do the following:\n");
  1454. diff -ur ./redraw.c /local/src/elvis/17/src/redraw.c
  1455. --- ./redraw.c    Thu Feb  4 12:48:58 1993
  1456. +++ /local/src/elvis/17/src/redraw.c    Thu Apr 22 18:35:48 1993
  1457. @@ -395,6 +395,10 @@
  1458.      tabstop = *o_tabstop;
  1459.      abnormal = FALSE;
  1460.  
  1461. +#ifdef SMOOTHREDRAW
  1462. +#define CRUNCH
  1463. +#endif
  1464. +/* ...or was it meant the other way around? :-)  -nox */
  1465.  #ifndef CRUNCH
  1466.      if (clr)
  1467.          clrtoeol();
  1468. @@ -624,6 +628,9 @@
  1469.      wqrefresh();
  1470.  }
  1471.  
  1472. +#ifdef SMOOTHREDRAW
  1473. +#undef CRUNCH
  1474. +#endif
  1475.  
  1476.  #ifndef CRUNCH
  1477.  static void nudgecursor(same, scan, new, lno)
  1478. @@ -960,8 +967,11 @@
  1479.  
  1480.  #ifndef NO_VISIBLE
  1481.      /* adjustments to hilited area may force extra lines to be redrawn. */
  1482. -    setviz(curs);
  1483. +#ifndef CRUNCH
  1484. +    if (curs == cursor)
  1485.  #endif
  1486. +        setviz(curs);
  1487. +#endif
  1488.  
  1489.      /* figure out which column the cursor will be in */
  1490.      l = markline(curs);
  1491. @@ -1015,11 +1025,21 @@
  1492.              /* blank out the last line */
  1493.              move(LINES - 1, 0);
  1494.              clrtoeol();
  1495. +
  1496. +            /* smartlno still on screen?    -nox */
  1497. +            if (smartlno > botline)
  1498. +                smartlno = 0;
  1499.          }
  1500.          else
  1501.          {
  1502.              topline = l;
  1503.              redrawrange(0L, INFINITY, INFINITY);
  1504. +#ifndef NO_VISIBLE
  1505. +#ifndef CRUNCH
  1506. +            if (V_from && curs != cursor)
  1507. +                return;
  1508. +#endif
  1509. +#endif
  1510.          }
  1511.      }
  1512.      else if (l > topline && l <= botline + NEAR)
  1513. @@ -1035,6 +1055,9 @@
  1514.                  text = fetchline(botline);
  1515.                  drawtext(text, botline, FALSE);
  1516.              }
  1517. +            /* smartlno still on screen?    -nox */
  1518. +            if (topline > smartlno)
  1519. +                smartlno = 0;
  1520.  #ifndef CRUNCH
  1521.              showbottom = l;
  1522.  #endif
  1523. @@ -1043,6 +1066,12 @@
  1524.          {
  1525.              topline = l - (LINES - 2);
  1526.              redrawrange(0L, INFINITY, INFINITY);
  1527. +#ifndef NO_VISIBLE
  1528. +#ifndef CRUNCH
  1529. +            if (V_from && curs != cursor)
  1530. +                return;
  1531. +#endif
  1532. +#endif
  1533.          }
  1534.      }
  1535.      else
  1536. @@ -1055,6 +1084,12 @@
  1537.          }
  1538.          redrawrange(0L, INFINITY, INFINITY);
  1539.          smartlno = 0L;
  1540. +#ifndef NO_VISIBLE
  1541. +#ifndef CRUNCH
  1542. +        if (V_from && curs != cursor)
  1543. +            return;
  1544. +#endif
  1545. +#endif
  1546.          changes++;
  1547.      }
  1548.  
  1549. diff -ur ./ref.c /local/src/elvis/17/src/ref.c
  1550. --- ./ref.c    Thu Feb  4 12:48:58 1993
  1551. +++ /local/src/elvis/17/src/ref.c    Thu Mar 25 01:40:02 1993
  1552. @@ -33,8 +33,12 @@
  1553.  # if ANY_UNIX
  1554.  #  define DEFTAGPATH ".:/usr/include:/usr/include/sys:/usr/src/lib:../lib:/usr/local/lib"
  1555.  # else
  1556. -#  if MSDOS || TOS
  1557. -#   define DEFTAGPATH ".;C:\\include;C:\\include\\sys;C:\\lib;..\\lib"
  1558. +#  if MSDOS || TOS || MINT
  1559. +#   if MINT
  1560. +#    define DEFTAGPATH ".;/usr/include;/usr/include/sys;/usr/src/lib;../lib;/usr/local/lib"
  1561. +#   else
  1562. +#    define DEFTAGPATH ".;C:\\include;C:\\include\\sys;C:\\lib;..\\lib"
  1563. +#   endif
  1564.  #   define SEP ';'
  1565.  #  else
  1566.  #   if AMIGA
  1567. @@ -143,7 +147,7 @@
  1568.  
  1569.      for (bytes = 0, ch = 0; ch != '\n' && --limit > 0 && (ch = getc(fp)) != EOF; bytes++)
  1570.      {
  1571. -#if MSDOS || TOS
  1572. +#if MSDOS || TOS || MINT
  1573.          /* since this is a binary file, we'll need to manually strip CR's */
  1574.          if (ch == '\r')
  1575.          {
  1576. @@ -224,7 +228,7 @@
  1577.       * though we know it is a text file, because ftell() and fseek()
  1578.       * don't work on text files.
  1579.       */
  1580. -#if MSDOS || TOS
  1581. +#if MSDOS || TOS || MINT
  1582.      sfile = fopen(buf, "rb");
  1583.  #else
  1584.  # if AMIGA
  1585. @@ -243,7 +247,7 @@
  1586.          else
  1587.  #endif
  1588.          sprintf(buf, "%s%crefs", dir, SLASH);
  1589. -#if MSDOS || TOS
  1590. +#if MSDOS || TOS || MINT
  1591.          sfile = fopen(buf, "rb");
  1592.  #else
  1593.  # if AMIGA
  1594. diff -ur ./shell.c /local/src/elvis/17/src/shell.c
  1595. --- ./shell.c    Thu Feb  4 12:48:58 1993
  1596. +++ /local/src/elvis/17/src/shell.c    Fri Mar 26 15:18:40 1993
  1597. @@ -21,10 +21,63 @@
  1598.  #include <stdio.h>
  1599.  #include <string.h>
  1600.  #include <osbind.h>
  1601. +#ifdef __STDC__
  1602. +#include <stdlib.h>
  1603. +#else
  1604.  extern char *getenv(), *malloc();
  1605. +#endif
  1606.  extern char **environ;
  1607.  long _stksize=16384;
  1608. +#if MINT
  1609. +/* this is quite a bit MiNT library dependant... (although you
  1610. +   don't want to use this when actually _running_ under MiNT,
  1611. +   there are enough ports of `real' shells available now...) */
  1612.  
  1613. +#define USEARGV 1
  1614. +/* ...especially it depends on system() no relying on $SHELL! */
  1615. +
  1616. +#include <unistd.h>
  1617. +
  1618. +int xsystem(const char *cmd)
  1619. +{
  1620. +    static int ret;
  1621. +    static const char *scmd;
  1622. +
  1623. +    scmd = cmd;
  1624. +
  1625. +    /* GEMDOS redirection bugs department... */
  1626. +    switch (vfork())
  1627. +    {
  1628. +      case -1:                        /* error */
  1629. +        ret = -1;
  1630. +        break;
  1631. +
  1632. +      case 0:                        /* child */
  1633. +        ret = system(scmd);
  1634. +        _exit(0);
  1635. +
  1636. +      default:                        /* parent */
  1637. +        wait((int *) NULL);
  1638. +    }
  1639. +
  1640. +    return ret;
  1641. +}
  1642. +#endif
  1643. +
  1644. +#if USEARGV
  1645. +#define INITBUFSIZ 0x400
  1646. +#include <errno.h>
  1647. +
  1648. +size_t bufsiz = INITBUFSIZ;
  1649. +char *buf = (char *) NULL;
  1650. +
  1651. +#ifndef __STDC__
  1652. +extern char *putenv(), *realloc();
  1653. +#endif
  1654. +
  1655. +#else
  1656. +
  1657.  #define    MAXENV    50
  1658.  
  1659.  struct
  1660. @@ -32,8 +85,10 @@
  1661.      char *name;
  1662.      char *value;
  1663.  } myenv[MAXENV];
  1664. +#endif
  1665.  
  1666. -int cmd_set(), cmd_exit();
  1667. +int cmd_set(), cmd_exit(), cmd_cd(), cmd_pwd();
  1668. +char home[FILENAME_MAX];
  1669.  
  1670.  struct buildins
  1671.  {
  1672. @@ -42,33 +97,116 @@
  1673.  } buildins[]=
  1674.  {    "exit", cmd_exit,
  1675.      "set", cmd_set,
  1676. +    "cd", cmd_cd,
  1677. +    "pwd", cmd_pwd,
  1678.      0,
  1679.  };
  1680. +  
  1681. +#if USEARGV
  1682. +char *getbuf(needed)
  1683. +    size_t needed;
  1684. +{
  1685. +    if (buf && bufsiz >= needed)
  1686. +        return buf;
  1687. +    while (bufsiz < needed)
  1688. +        bufsiz *= 2;
  1689. +    if (!(buf = realloc(buf, bufsiz)))
  1690. +        exit(-ENOMEM);
  1691. +    return buf;
  1692. +}
  1693. +
  1694. +char *bufgets(fp)
  1695. +    FILE *fp;
  1696. +{
  1697. +    int c = EOF;
  1698. +    size_t p = 0, left = bufsiz-1;
  1699. +
  1700. +    while(((c = getc(fp)) != EOF)) {
  1701. +        if (!--left) {
  1702. +            buf = getbuf(bufsiz * 2);
  1703. +            left = bufsiz-p-1;
  1704. +        }
  1705. +        if((buf[p++] = c) == '\n')
  1706. +            break;
  1707. +    }
  1708. +    buf[p] = '\0';
  1709. +    if (!p && c == EOF)
  1710. +        return NULL;
  1711. +    return buf;
  1712. +}
  1713. +#endif
  1714.  
  1715.  main(argc, argv)
  1716.      int argc;
  1717.      char **argv;
  1718.  {
  1719. -    char buf[128];
  1720.      int i;
  1721. +#if USEARGV
  1722. +    size_t p, clen;
  1723. +    int interactive = isatty(0);
  1724. +    char *ch;
  1725.  
  1726. +    (void) getbuf((size_t) 1);
  1727. +#else
  1728. +    char buf[128];
  1729. +
  1730.      for (i=0; environ[i] && strncmp(environ[i],"ARGV=",5); i++)
  1731.          cmd_set(environ[i]);
  1732. -    script("profile.sh");
  1733. +#endif
  1734. +    if (ch = getenv("HOME")) {
  1735. +        strcpy(home, ch);
  1736. +        ch = buf + strlen(strcpy(buf, ch));
  1737. +        if (!strchr("\\/", ch[-1]))
  1738. +            *ch++ = '/';
  1739. +        strcpy(ch, "profile.sh");
  1740. +        script(buf);
  1741. +    } else {
  1742. +        getcwd(home, sizeof(home));
  1743. +        script("profile.sh");
  1744. +    }
  1745.  
  1746.      if (argc>1 && !strcmp(argv[1], "-c"))
  1747.      {
  1748.          buf[0]='\0';
  1749. +#if USEARGV
  1750. +        p = 0;
  1751.          for (i=2; i<argc; i++)
  1752. +        {    if (i>2) {
  1753. +                buf[p++] = ' ';
  1754. +                buf[p] = '\0';
  1755. +            }
  1756. +            strcpy(getbuf(p+(clen=strlen(argv[i]))+2)+p, argv[i]);
  1757. +            p += clen;
  1758. +        }
  1759. +        i = execute(buf);
  1760. +        exit(i>=0 ? i : errno);
  1761. +#else
  1762. +        for (i=2; i<argc; i++)
  1763.          {    if (i>2)
  1764.                  strcat(buf, " ");
  1765.              strcat(buf, argv[i]);
  1766.          }
  1767.          execute(buf);
  1768. +#endif
  1769.      }
  1770.      else
  1771. +#if USEARGV
  1772. +        while ((interactive ? fputs("$ ", stdout) : 0),
  1773. +               bufgets(stdin)) {
  1774. +            if ((ch=strchr(buf, '\n')) != 0)
  1775. +                *ch='\0';
  1776. +            errno = 0;
  1777. +            if (execute(buf) == -1 && interactive) {
  1778. +                if (errno == ENOENT)
  1779. +                    printf("%s: not found\n", strtok(buf, " "));
  1780. +                else if (errno == ENOEXEC)
  1781. +                    printf("%s: unable to exec\n", strtok(buf, " "));
  1782. +            }
  1783. +        }
  1784. +#else
  1785.          while (fputs("$ ", stdout), gets(buf))
  1786.              execute(buf);
  1787. +#endif
  1788.      exit(0);
  1789.  }
  1790.  
  1791. @@ -76,9 +214,11 @@
  1792.      char *buf;
  1793.  {
  1794.      char *scan=buf;
  1795. -    char cmd[80];
  1796. +#if !USEARGV
  1797. +    char cmd[FILENAME_MAX];
  1798.      char line[128];
  1799.      char env[4096], *ep=env;
  1800. +#endif
  1801.      int i;
  1802.  
  1803.      while (*scan==' ')
  1804. @@ -94,6 +234,11 @@
  1805.          if (!strcmp(buf, buildins[i].name))
  1806.              return (*buildins[i].func)(scan);
  1807.  
  1808. +#if USEARGV
  1809. +    if (*scan && !scan[-1])
  1810. +        scan[-1] = ' ';
  1811. +    return xsystem(buf);
  1812. +#else
  1813.      if (!searchpath(buf, cmd))
  1814.      {    printf("%s: not found\n", buf);
  1815.          return -1;
  1816. @@ -111,8 +256,10 @@
  1817.      *ep='\0';
  1818.  
  1819.      return Pexec(0, cmd, line, env);
  1820. +#endif
  1821.  }
  1822.  
  1823. +#if !USEARGV
  1824.  searchpath(from, to)
  1825.      char *from, *to;
  1826.  {
  1827. @@ -163,6 +310,30 @@
  1828.          return 0;
  1829.      return 1;
  1830.  }
  1831. +#endif
  1832. +
  1833. +cmd_cd(line)
  1834. +    char *line;
  1835. +{
  1836. +    if (!*line)
  1837. +        line = home;
  1838. +    else
  1839. +        line = strtok(line, " ");
  1840. +    if (chdir(line) < 0) {
  1841. +        perror(line);
  1842. +        return 1;
  1843. +    }
  1844. +    return 0;
  1845. +}
  1846. +
  1847. +cmd_pwd()
  1848. +{
  1849. +    char cwd[FILENAME_MAX];
  1850. +
  1851. +    getcwd(cwd, (int) sizeof(cwd));
  1852. +    puts(cwd);
  1853. +    return 0;
  1854. +}
  1855.  
  1856.  cmd_exit()
  1857.  {
  1858. @@ -173,12 +344,24 @@
  1859.      char *line;
  1860.  {
  1861.      char *value;
  1862. +#if USEARGV
  1863. +    char **ep;
  1864. +#else
  1865.      int i;
  1866. +#endif
  1867.  
  1868.      if (!*line)
  1869.      {
  1870. +#if USEARGV
  1871. +        if (environ)
  1872. +            for (ep = environ; *ep; ++ep) {
  1873. +                fputs(*ep, stdout);
  1874. +                fputs("\n", stdout);
  1875. +            }
  1876. +#else
  1877.          for (i=0; i<MAXENV && myenv[i].name; i++)
  1878.              printf("%s=%s\n", myenv[i].name, myenv[i].value);
  1879. +#endif
  1880.          return 0;
  1881.      }
  1882.  
  1883. @@ -188,10 +371,17 @@
  1884.      {    printf("Usage: set name=var\n");
  1885.          return -1;
  1886.      }
  1887. +#if USEARGV
  1888. +    if (!(line = strdup(line)))
  1889. +        exit(-ENOMEM);
  1890. +    return putenv(line);
  1891. +#else
  1892.      *value++='\0';
  1893.      return doset(line, value);
  1894. +#endif
  1895.  }
  1896.  
  1897. +#if !USEARGV
  1898.  doset(line, value)
  1899.      char *line, *value;
  1900.  {
  1901. @@ -213,16 +403,25 @@
  1902.      strcpy(myenv[i].value, value);
  1903.      return 0;
  1904.  }
  1905. +#endif
  1906.  
  1907.  script(name)
  1908.      char *name;
  1909.  {
  1910.      FILE *fp;
  1911. +#if USEARGV
  1912. +    char *p;
  1913. +#else
  1914.      char buf[128], *p;
  1915. +#endif
  1916.  
  1917.      if ((fp=fopen(name, "r"))==0)
  1918.          return;
  1919. -    while (fgets(buf, sizeof buf, fp))
  1920. +#if USEARGV
  1921. +    while (bufgets(fp))
  1922. +#else
  1923. +    while (fgets(buf, (int) sizeof buf, fp))
  1924. +#endif
  1925.      {
  1926.          if ((p=strchr(buf, '\n'))!=0)
  1927.              *p='\0';
  1928. diff -ur ./sysdos.c /local/src/elvis/17/src/sysdos.c
  1929. --- ./sysdos.c    Thu Feb  4 12:48:58 1993
  1930. +++ /local/src/elvis/17/src/sysdos.c    Wed Mar 24 15:46:50 1993
  1931. @@ -41,9 +41,14 @@
  1932.  #if TOS
  1933.  #include <osbind.h>
  1934.  #endif
  1935. +#if MINT
  1936. +#include <process.h>
  1937. +#include <osbind.h>
  1938. +#include <stdio.h>
  1939. +#endif
  1940.  
  1941.  
  1942. -#if MSDOS || TOS
  1943. +#if MSDOS || TOS || MINT
  1944.  #include <string.h>
  1945.  
  1946.  /*
  1947. @@ -60,11 +65,59 @@
  1948.  int system(cmd)
  1949.      const char    *cmd;
  1950.  {
  1951. -#if MSDOS
  1952. +#if MSDOS || MINT
  1953. +# if MINT
  1954. +    static char *extensions[] = { "ttp", "prg", "tos", NULL };
  1955. +    extern char *findfile (char *, char *, char **);
  1956. +    extern char *getenv();
  1957. +
  1958. +    char **argv = 0, *cmdcopy = 0, **argp, *path, *p;
  1959. +    int ret;
  1960. +    size_t clen;
  1961. +    static char cmdpath[FILENAME_MAX];
  1962. +
  1963. +    long    ssp;
  1964. +    int    (*shell)();
  1965. +
  1966. +    if (cmd == o_shell)
  1967. +        return spawnlp(P_WAIT, o_shell, o_shell, (char *)0);
  1968. +
  1969. +    if (!getenv("NO_SHELLP")) {
  1970. +        ssp = Super(0L);
  1971. +        shell = *((int (**)())0x4F6);
  1972. +        (void) Super(ssp);
  1973. +        if (shell)
  1974. +            return (*shell)(cmd);
  1975. +    }
  1976. +
  1977. +    /* see if cmd is simple enough so that we don't need a shell */
  1978. +    if ((path = getenv("PATH")) && (clen = strlen(cmd)) &&
  1979. +        !strpbrk(cmd, "'\"`><;$~[*?&|(){}") &&
  1980. +        (argv = (char **) malloc((clen/2+2) * sizeof(char *))) &&
  1981. +        (cmdcopy = strdup(cmd)) &&
  1982. +        (p = findfile(strtok(cmdcopy, " \t"), path, extensions))) {
  1983. +        argp = argv;
  1984. +        *argp++ = strcpy(cmdpath, p);
  1985. +        while (*argp++ = strtok((char *) NULL, " \t"))
  1986. +            ;
  1987. +        errno = 0;
  1988. +        ret = spawnv(P_WAIT, p, argv);
  1989. +        free(argv);
  1990. +        free(cmdcopy);
  1991. +        if (ret != -1 || errno != ENOEXEC)
  1992. +            return ret;
  1993. +    }
  1994. +    if (argv)
  1995. +        free(argv);
  1996. +    if (cmdcopy)
  1997. +        free(cmdcopy);
  1998. +    return spawnlp(P_WAIT, o_shell, o_shell, "-c", cmd, (char *)0);
  1999. +# else
  2000.      char *cmdswitch="/c";
  2001.      if (_osmajor<4)
  2002.          cmdswitch[0]=switchar();
  2003.      return spawnle(P_WAIT, o_shell, o_shell, cmdswitch, cmd, (char *)0, environ);
  2004. +# endif
  2005.  #else
  2006.      long    ssp;
  2007.      int    (*shell)();
  2008. @@ -109,7 +162,12 @@
  2009.  static int cmdstate;
  2010.  static char output[80];
  2011.  
  2012. +#if MINT
  2013. +/* MiNT uses real pipes if it can... (wich means unless running vanilla TOS.) */
  2014. +int trpipe(cmd, in)
  2015. +#else
  2016.  int rpipe(cmd, in)
  2017. +#endif
  2018.      char    *cmd;    /* the filter command to use */
  2019.      int    in;    /* the fd to use for stdin */
  2020.  {
  2021. @@ -131,12 +189,19 @@
  2022.      /* save and redirect stdin, stdout, and stderr */
  2023.      old0=dup(0);
  2024.      old1=dup(1);
  2025. +#if MINT
  2026. +    /* ... and stderr :-) */
  2027. +    old2=dup(2);
  2028. +#endif
  2029.      if (in)
  2030.      {
  2031.          dup2(in, 0);
  2032.          close(in);
  2033.      }
  2034.      dup2(fd, 1);
  2035. +#if MINT
  2036. +    dup2(fd, 2);
  2037. +#endif
  2038.  
  2039.      /* call command */
  2040.      cmdstate=system(cmd);
  2041. @@ -144,18 +209,29 @@
  2042.      /* restore old std... */
  2043.      dup2(old0, 0); close(old0);
  2044.      dup2(old1, 1); close(old1);
  2045. +#if MINT
  2046. +    dup2(old2, 2); close(old2);
  2047. +#endif
  2048.  
  2049.      /* rewind command output */
  2050. +#if TOS || MINT
  2051. +    /* GEMDOS redirection bugs department... */
  2052. +    close(fd);
  2053. +    fd=open(output, O_RDWR);
  2054. +#else
  2055.      lseek(fd, 0L, 0);
  2056. +#endif
  2057.      return fd;
  2058.  }
  2059.  
  2060.  /* This function closes the pipe opened by rpipe(), and returns 0 for success */
  2061. +#if MINT
  2062. +int trpclose(fd)
  2063. +#else
  2064.  int rpclose(fd)
  2065. +#endif
  2066.      int    fd;
  2067.  {
  2068. -    int    status;
  2069. -
  2070.      close(fd);
  2071.      unlink(output);
  2072.      return cmdstate;
  2073. diff -ur ./system.c /local/src/elvis/17/src/system.c
  2074. --- ./system.c    Thu Feb  4 12:49:00 1993
  2075. +++ /local/src/elvis/17/src/system.c    Wed Mar 24 15:46:54 1993
  2076. @@ -25,9 +25,14 @@
  2077.  #ifndef XDOS
  2078.  extern char    **environ;
  2079.  #endif
  2080. +#if MINT
  2081. +#include "ctype.h"
  2082. +extern int __mint;
  2083. +#endif
  2084.  
  2085. -#if ANY_UNIX
  2086. +#if ANY_UNIX || MINT
  2087.  
  2088. +#if !MINT
  2089.  /* This is a new version of the system() function.  The only difference
  2090.   * between this one and the library one is: this one uses the o_shell option.
  2091.   */
  2092. @@ -83,6 +88,7 @@
  2093.  
  2094.      return status;
  2095.  }
  2096. +#endif
  2097.  
  2098.  /* This private function opens a pipe from a filter.  It is similar to the
  2099.   * system() function above, and to popen(cmd, "r").
  2100. @@ -93,6 +99,25 @@
  2101.  {
  2102.      int    r0w1[2];/* the pipe fd's */
  2103.  
  2104. +#if MINT
  2105. +/* maximum commandline length that we try to parse ourselves */
  2106. +#define MAXCMDLEN 0x400
  2107. +
  2108. +    static char *extensions[] = { "ttp", "prg", "tos", (char *) NULL};
  2109. +    extern char *findfile (char *, char *, char **);
  2110. +    extern char *getenv();
  2111. +
  2112. +    static char *argv[MAXCMDLEN/2+2];
  2113. +    static char cmdcopy[MAXCMDLEN+2];
  2114. +    static char cmdpath[FILENAME_MAX];
  2115. +    char **argp, *path, *p;
  2116. +    size_t clen;
  2117. +
  2118. +    /* if MiNT is not running, we have to use a tempfile */
  2119. +    if (!__mint)
  2120. +        return trpipe(cmd, in);
  2121. +#endif
  2122. +
  2123.      /* make the pipe */
  2124.      if (pipe(r0w1) < 0)
  2125.      {
  2126. @@ -105,6 +130,25 @@
  2127.       */
  2128.      signal(SIGINT, SIG_IGN);
  2129.  
  2130. +#if MINT
  2131. +    /* MiNT <= 0.8 had a problem with broken pipes...  */
  2132. +    if (__mint <= 8) {
  2133. +        signal(SIGTTIN, SIG_IGN);
  2134. +        signal(SIGTTOU, SIG_IGN);
  2135. +    }
  2136. +
  2137. +    /* see if cmd is simple enough so that we don't need a shell */
  2138. +    if ((path = getenv("PATH")) && (clen = strlen(cmd)) &&
  2139. +        clen < MAXCMDLEN && !strpbrk(cmd, "'\"`><;$~[*?&|(){}") &&
  2140. +        (p = findfile(strtok(strcpy(cmdcopy, cmd), " \t"), path, extensions))) {
  2141. +        argp = argv;
  2142. +        *argp++ = strcpy(cmdpath, p);
  2143. +        while (*argp++ = strtok((char *) NULL, " \t"))
  2144. +            ;
  2145. +    } else
  2146. +        p = 0;
  2147. +#endif
  2148. +
  2149.      switch (fork())
  2150.      {
  2151.        case -1:                        /* error */
  2152. @@ -115,6 +159,19 @@
  2153.          close(r0w1[0]);
  2154.  
  2155.          /* redirect stdout to go to the "write" end of the pipe */
  2156. +#if MINT
  2157. +        /* GEMDOS redirection bugs department...  */
  2158. +        dup2(r0w1[1], 1);
  2159. +        dup2(r0w1[1], 2);
  2160. +        close(r0w1[1]);
  2161. +
  2162. +        /* redirect stdin */
  2163. +        if (in != 0)
  2164. +        {
  2165. +            dup2(in, 0);
  2166. +            close(in);
  2167. +        }
  2168. +#else
  2169.          close(1);
  2170.          dup(r0w1[1]);
  2171.          close(2);
  2172. @@ -128,12 +185,19 @@
  2173.              dup(in);
  2174.              close(in);
  2175.          }
  2176. +#endif
  2177.  
  2178.          /* the filter should accept SIGINT signals */
  2179.          signal(SIGINT, SIG_DFL);
  2180.  
  2181.          /* exec the shell to run the command */
  2182. +#if MINT
  2183. +        errno = 0;
  2184. +        if (!p || (execv(p, argv) == -1 && errno == ENOEXEC))
  2185. +            execlp(o_shell, o_shell, "-c", cmd, (char *)0);
  2186. +#else
  2187.          execle(o_shell, o_shell, "-c", cmd, (char *)0, environ);
  2188. +#endif
  2189.          exit(1); /* if we get here, exec failed */
  2190.  
  2191.        default:                        /* parent */
  2192. @@ -159,7 +223,7 @@
  2193.  }    
  2194.  #endif
  2195.  
  2196. -#if ANY_UNIX || OSK
  2197. +#if ANY_UNIX || OSK || MINT
  2198.  
  2199.  /* This function closes the pipe opened by rpipe(), and returns 0 for success */
  2200.  int rpclose(fd)
  2201. @@ -167,6 +231,10 @@
  2202.  {
  2203.      int    status;
  2204.  
  2205. +#if MINT
  2206. +    if (!__mint)
  2207. +        return trpclose(fd);
  2208. +#endif
  2209.      close(fd);
  2210.      wait(&status);
  2211.      signal(SIGINT, trapint);
  2212. @@ -210,6 +278,11 @@
  2213.      int    i, j, fd;
  2214.      REG char *s, *d;
  2215.  
  2216. +#if 1
  2217. +    /* before we do anything, see if there are wildcards at all  -nox */
  2218. +    if (!strpbrk(names, "*?[`{$~"))
  2219. +        return names;
  2220. +#endif
  2221.  
  2222.      /* build the echo command */
  2223.      if (names != tmpblk.c)
  2224. @@ -243,7 +316,14 @@
  2225.      /* successful? */
  2226.      if (rpclose(fd) == 0 && j == 0 && i < BLKSIZE && i > 0)
  2227.      {
  2228. +#if MINT
  2229. +        /* strange shells doing strange things... */
  2230. +        while (isspace(tmpblk.c[--i]))
  2231. +            ;
  2232. +        tmpblk.c[++i] = '\0';
  2233. +#else
  2234.          tmpblk.c[i-1] = '\0'; /* "i-1" so we clip off the newline */
  2235. +#endif
  2236.          return tmpblk.c;
  2237.      }
  2238.      else
  2239. @@ -275,7 +355,7 @@
  2240.      if (to)
  2241.      {
  2242.          /* we have lines */
  2243. -#if MSDOS || TOS
  2244. +#if MSDOS || TOS || MINT
  2245.          strcpy(scrout, o_directory);
  2246.          if ((i=strlen(scrout)) && !strchr("\\/:", scrout[i-1]))
  2247.              scrout[i++]=SLASH;
  2248. diff -ur ./tmp.c /local/src/elvis/17/src/tmp.c
  2249. --- ./tmp.c    Thu Feb  4 12:49:02 1993
  2250. +++ /local/src/elvis/17/src/tmp.c    Tue Sep 21 19:45:30 1993
  2251. @@ -30,6 +30,18 @@
  2252.  # include <process.h>
  2253.  #endif
  2254.  
  2255. +/* a quick hack 'cause close(-1) wasn't a no-op on early versions of MiNT  -nox */
  2256. +#if MINT
  2257. +int mclose(fd)
  2258. +    int fd;
  2259. +{
  2260. +    if (fd >= 0)
  2261. +        return close(fd);
  2262. +    return 0;
  2263. +}
  2264. +#define close mclose
  2265. +#endif
  2266. +
  2267.  #ifndef NO_MODELINES
  2268.  static void do_modelines(l, stop)
  2269.      long    l;    /* line number to start at */
  2270. @@ -156,7 +168,7 @@
  2271.              if (*o_readonly || (statb.st_mode & S_IJRON))
  2272.  # endif
  2273.  #endif
  2274. -#if ANY_UNIX
  2275. +#if ANY_UNIX || MINT
  2276.              if (*o_readonly || !(statb.st_mode &
  2277.                    ((geteuid() == 0) ? 0222 :
  2278.                    ((statb.st_uid != geteuid() ? 0022 : 0200)))))
  2279. @@ -185,7 +197,7 @@
  2280.      do
  2281.      {
  2282.          tmpnum++;
  2283. -#if MSDOS || TOS
  2284. +#if MSDOS || TOS || MINT
  2285.          /* MS-Dos doesn't allow multiple slashes, but supports drives
  2286.           * with current directories.
  2287.           * This relies on TMPNAME beginning with "%s\\"!!!!
  2288. @@ -214,7 +226,7 @@
  2289.       */
  2290.  
  2291.      /* create the temp file */
  2292. -#if ANY_UNIX
  2293. +#if ANY_UNIX || MINT
  2294.      close(creat(tmpname, 0600));        /* only we can read it */
  2295.  #else
  2296.      close(creat(tmpname, FILEPERMS));    /* anybody body can read it, alas */
  2297. @@ -284,7 +296,12 @@
  2298.              this = next;
  2299.  
  2300.              /* read [more] text into this block */
  2301. +#if MINT
  2302. +            nread = (*o_crlf ? tread : read)
  2303. +                (origfd, &this->c[inbuf], BLKSIZE - 1 - inbuf);
  2304. +#else
  2305.              nread = tread(origfd, &this->c[inbuf], BLKSIZE - 1 - inbuf);
  2306. +#endif
  2307.              if (nread < 0)
  2308.              {
  2309.                  close(origfd);
  2310. @@ -332,7 +349,7 @@
  2311.                  goto FoundEOF;
  2312.              }
  2313.  
  2314. -#if MSDOS || TOS
  2315. +#if MSDOS || TOS || MINT
  2316.  /* BAH! MS text mode read fills inbuf, then compresses eliminating \r
  2317.     but leaving garbage at end of buf. The same is true for TURBOC. GB. */
  2318.  
  2319. @@ -404,7 +421,10 @@
  2320.              nbytes = 1;
  2321.          }
  2322.  
  2323. -#if MSDOS || TOS
  2324. +#if MSDOS || TOS || MINT
  2325. +# if MINT
  2326. +        if (*o_crlf)
  2327. +# endif
  2328.          /* each line has an extra CR that we didn't count yet */
  2329.          nbytes += nlines;
  2330.  #endif
  2331. @@ -547,7 +567,11 @@
  2332.          for (len = 0; len < BLKSIZE && this->c[len]; len++)
  2333.          {
  2334.          }
  2335. +#if MINT
  2336. +        if ((*o_crlf ? twrite : write)(fd, this->c, len) < len)
  2337. +#else
  2338.          if (twrite(fd, this->c, len) < len)
  2339. +#endif
  2340.          {
  2341.              msg("Trouble writing to \"%s\"", filename);
  2342.              if (!strcmp(filename, origname))
  2343. @@ -569,7 +593,10 @@
  2344.      }
  2345.  
  2346.      /* report lines & characters */
  2347. -#if MSDOS || TOS
  2348. +#if MSDOS || TOS || MINT
  2349. +# if MINT
  2350. +    if (*o_crlf)
  2351. +# endif
  2352.      bytes += nlines; /* for the inserted carriage returns */
  2353.  #endif
  2354.      msg("Wrote \"%s\"  %ld lines, %ld characters", filename, nlines, bytes);
  2355. @@ -644,7 +671,7 @@
  2356.   * changes to be written to the disk, so that the tmp file will survive a
  2357.   * system crash or power failure.
  2358.   */
  2359. -#if AMIGA || MSDOS || TOS
  2360. +#if AMIGA || MSDOS || TOS || MINT
  2361.  sync()
  2362.  {
  2363.      /* MS-DOS and TOS don't flush their buffers until the file is closed,
  2364. @@ -707,6 +734,12 @@
  2365.          strncpy(U_text, *name ? name : "foo", BLKSIZE);
  2366.      }
  2367.  
  2368. +#if MINT
  2369. +    for (ptr=U_text; *ptr && ptr < U_text+BLKSIZE; ++ptr) {
  2370. +        if (*ptr == '\\')
  2371. +            *ptr = '/';
  2372. +    }
  2373. +#endif
  2374.      if (tmpfd >= 0)
  2375.      {
  2376.          /* write the name out to second block of the temp file */
  2377. @@ -784,7 +817,11 @@
  2378.      }
  2379.  
  2380.      /* delete any old temp files */
  2381. -    cutend();
  2382. +    /* ..but not the current one because its closed and elvprsv just
  2383. +       unlinked it already. (-> `Error stuffing name into tempfile'...)
  2384. +       also if elvprsv just failed/got killed somehow and did not
  2385. +       unlink it you don't want it removed.  -nox */
  2386. +    cutend(1);
  2387.  
  2388.      /* exit with the proper exit status */
  2389.      exit(sig);
  2390. diff -ur ./vars.c /local/src/elvis/17/src/vars.c
  2391. --- ./vars.c    Thu Feb  4 12:49:02 1993
  2392. +++ /local/src/elvis/17/src/vars.c    Wed Mar 24 15:47:06 1993
  2393. @@ -106,7 +106,7 @@
  2394.  
  2395.  /* Bigger stack req'ed for TOS and TURBOC */
  2396.  
  2397. -#if TOS
  2398. +#if TOS || MINT
  2399.  long    _stksize = 16384;
  2400.  #endif
  2401.  
  2402. diff -ur ./vi.h /local/src/elvis/17/src/vi.h
  2403. --- ./vi.h    Thu Feb  4 12:49:04 1993
  2404. +++ /local/src/elvis/17/src/vi.h    Tue Sep 21 20:53:02 1993
  2405. @@ -57,7 +57,7 @@
  2406.  # include <string.h>    /* for str* prototypes            */
  2407.  # include <stdlib.h>    /* for atoi, system, malloc, free    */
  2408.  # include <stdarg.h>    /* for vararg definitions        */
  2409. -# if ANY_UNIX
  2410. +# if ANY_UNIX || MINT
  2411.  #  include <unistd.h>    /* for read, write, ... prototypes    */
  2412.  # include <sys/wait.h>    /* for wait prototype            */
  2413.  # endif
  2414. @@ -202,6 +202,11 @@
  2415.  extern char    o_pcbios[1];
  2416.  #endif
  2417.  
  2418. +#if MINT
  2419. +extern char    o_stbios[1];
  2420. +extern char    o_crlf[1];
  2421. +#endif
  2422. +
  2423.  #ifndef NO_SHOWMATCH
  2424.  extern char    o_showmatch[1];
  2425.  #endif
  2426. @@ -316,7 +321,7 @@
  2427.  extern void    savecolor P_((int));        /* save current color settings (if any) to fd */
  2428.  extern void    cutname P_((int));        /* select cut buffer for next cut/paste */
  2429.  extern void    initopts P_((void));        /* initialize options */
  2430. -extern void    cutend P_((void));        /* free all cut buffers & delete temp files */
  2431. +extern void    cutend P_((int));        /* free all cut buffers & delete temp files */
  2432.  extern int    storename P_((char *));        /* stamp temp file with pathname of text file */
  2433.  extern int    tmpstart P_((char *));        /* load a text file into edit buffer */
  2434.  extern int    tmpsave P_((char *, int));    /* write edit buffer out to text file */
  2435. diff -ur ./wildcard.c /local/src/elvis/17/src/wildcard.c
  2436. --- ./wildcard.c    Thu Feb  4 12:49:06 1993
  2437. +++ /local/src/elvis/17/src/wildcard.c    Tue Sep 21 17:27:34 1993
  2438. @@ -63,7 +63,7 @@
  2439.  #endif
  2440.  
  2441.  /* Atari TOS, GNU-C */
  2442. -#ifdef __m68k__
  2443. +#if defined(MINT) || defined(__m68k__)
  2444.  #include <stat.h>
  2445.  #include <osbind.h>
  2446.  #define    findfirst(a,b,c)    (Fsetdta(b), (Fsfirst(a,c)))
  2447. @@ -121,7 +121,7 @@
  2448.  {
  2449.      char *filespec;
  2450.      int wildcard=0;
  2451. -#if defined(M68000) || defined(__m68k__)
  2452. +#if defined(M68000) || defined(MINT) || defined(__m68k__)
  2453.      DMABUFFER findbuf;
  2454.  #else
  2455.      struct ffblk findbuf;
  2456.