home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / os2 / less / patches.os2 < prev    next >
Encoding:
Text File  |  1991-06-27  |  19.2 KB  |  934 lines

  1. Only in new: README.OS2
  2. Only in new: Makefile
  3. Only in new: Defines.h
  4. Only in new: Patches.os2
  5. Only in new: pipe.c
  6. Only in new: regerror.c
  7. Only in new: regexp.c
  8. Only in new: regexp.h
  9. Only in new: regmagic.h
  10. Only in new: regsub.c
  11. Only in new: termcap.c
  12. Only in new: termcap.dat
  13. Only in new: less.cs
  14. Only in new: less.bad
  15. Only in new: less.def
  16. Only in new: lesskey.cs
  17. Only in new: less.ini
  18. Only in new: lesskey.inp
  19. diff -cbBw orig/charset.c new/charset.c
  20. *** orig/charset.c    Thu Apr 04 06:43:56 1991
  21. --- new/charset.c    Thu Jun 27 14:37:22 1991
  22. ***************
  23. *** 15,20 ****
  24. --- 15,21 ----
  25.   } charsets[] = {
  26.       { "ascii",    "8bcccbcc18b95.b"    },
  27.       { "latin1",    "8bcccbcc18b95.33b."    },
  28. +     { "pc8",    "8bcccbcc18b95.b128."    },
  29.       { NULL }
  30.   };
  31.   
  32. ***************
  33. *** 144,150 ****
  34. --- 145,155 ----
  35.           return;
  36.       }
  37.   
  38. + #ifdef OS2
  39. +     (void) icharset("pc8");
  40. + #else
  41.       (void) icharset("ascii");
  42. + #endif
  43.   
  44.       s = getenv("LESSBINFMT");
  45.       if (s != NULL && *s != '\0')
  46. diff -cbBw orig/decode.c new/decode.c
  47. *** orig/decode.c    Thu Apr 04 06:43:16 1991
  48. --- new/decode.c    Thu Jun 27 14:42:38 1991
  49. ***************
  50. *** 25,30 ****
  51. --- 25,34 ----
  52.   #include <io.h>
  53.   #include <stdlib.h>
  54.   #endif
  55. + #ifdef OS2
  56. + #include <io.h>
  57. + #include <fcntl.h>
  58. + #endif
  59.   
  60.   /*
  61.    * Command table is ordered roughly according to expected
  62. ***************
  63. *** 281,287 ****
  64.        * Try to open the lesskey file.
  65.        * If we can't, return an error.
  66.        */
  67. !     f = open(filename, 0);
  68.       if (f < 0)
  69.           return (-1);
  70.   
  71. --- 285,291 ----
  72.        * Try to open the lesskey file.
  73.        * If we can't, return an error.
  74.        */
  75. !         f = open(filename, O_RDONLY | O_BINARY);
  76.       if (f < 0)
  77.           return (-1);
  78.   
  79. ***************
  80. *** 308,314 ****
  81.           close(f);
  82.           return (-1);
  83.       }
  84. !     if ((t->t_start = (char *) calloc(len, sizeof(char))) == NULL)
  85.       {
  86.           free((char *)t);
  87.           close(f);
  88. --- 312,318 ----
  89.           close(f);
  90.           return (-1);
  91.       }
  92. !     if ((t->t_start = (char *) calloc((int) len, sizeof(char))) == NULL)
  93.       {
  94.           free((char *)t);
  95.           close(f);
  96. ***************
  97. *** 352,361 ****
  98. --- 356,369 ----
  99.   {
  100.       char *filename;
  101.   
  102. + #ifdef OS2
  103. +     filename = homefile("less.ini");
  104. + #else
  105.   #if __MSDOS__
  106.       filename = homefile("_less");
  107.   #else
  108.       filename = homefile(".less");
  109. + #endif
  110.   #endif
  111.       if (filename == NULL)
  112.           return;
  113. diff -cbBw orig/edit.c new/edit.c
  114. *** orig/edit.c    Thu Apr 04 06:43:56 1991
  115. --- new/edit.c    Thu Jun 27 14:43:40 1991
  116. ***************
  117. *** 7,14 ****
  118.   #include <io.h>
  119.   #endif
  120.   
  121.   #define    ISPIPE(fd)    ((fd)==0)
  122. ! extern int ispipe;
  123.   extern int new_file;
  124.   extern int errmsgs;
  125.   extern int quit_at_eof;
  126. --- 7,22 ----
  127.   #include <io.h>
  128.   #endif
  129.   
  130. + #ifdef OS2
  131. + #include <stdio.h>
  132. + #include <fcntl.h>
  133. + #include <io.h>
  134. + #endif
  135. + extern FILE *popen();
  136.   #define    ISPIPE(fd)    ((fd)==0)
  137. ! extern int ispipe, iscompressed, wascompressed;
  138.   extern int new_file;
  139.   extern int errmsgs;
  140.   extern int quit_at_eof;
  141. ***************
  142. *** 22,27 ****
  143. --- 30,38 ----
  144.   extern IFILE old_ifile;
  145.   extern struct scrpos initial_scrpos;
  146.   
  147. + extern FILE *   compress;
  148. + extern FILE *   oldcompr;
  149.   #if LOGFILE
  150.   extern int logfile;
  151.   extern int force_logfile;
  152. ***************
  153. *** 63,73 ****
  154. --- 74,105 ----
  155.           error("%s", &parg);
  156.           free(parg.p_string);
  157.           return (1);
  158. +         } else if (isZfile(filename))
  159. +     {
  160. +                 char cmd[255];
  161. +                 sprintf(cmd, "compress -dc <%s", filename);
  162. +         compress = popen(cmd, "r");
  163. +                 f = fileno(compress);
  164. +         if ( compress == NULL || f < 0 )
  165. +         {
  166. +                         s = errno_message(filename);
  167. +                         error(s);
  168. +                         free(s);
  169. +             return (1);
  170. +                 }
  171. +         iscompressed = 1;
  172.   #if __MSDOS__
  173.       } else if ((f = open(filename, O_RDONLY|O_BINARY)) < 0)
  174.   #else
  175. + #ifdef OS2
  176. +     } else if ((f = open(filename, O_RDONLY|O_BINARY)) < 0)
  177. + #else
  178.       } else if ((f = open(filename, 0)) < 0)
  179.   #endif
  180. + #endif
  181.       {
  182.           parg.p_string = errno_message(filename);
  183.           error("%s", &parg);
  184. ***************
  185. *** 98,105 ****
  186. --- 130,142 ----
  187.   #else
  188.           parg.p_string = "less -\\?";
  189.   #endif
  190. + #ifdef OS2
  191. +                 usage();
  192. +         error("\nCannot take input from a terminal.");
  193. + #else
  194.           error("Cannot take input from a terminal (\"%s\" for help)",
  195.               &parg);
  196. + #endif
  197.           if (!ISPIPE(f))
  198.               close(f);
  199.           return (1);
  200. ***************
  201. *** 133,141 ****
  202. --- 170,182 ----
  203.       /*
  204.        * Close the current file, unless it is a pipe.
  205.        */
  206. +         if (wascompressed)
  207. +             pclose(oldcompr);
  208. +         else
  209.       if (!ISPIPE(file))
  210.           close(file);
  211.       file = f;
  212. +         oldcompr = compress;
  213.   
  214.       if (f < 0)
  215.           return (1);
  216. ***************
  217. *** 148,154 ****
  218.       curr_ifile = get_ifile(filename, curr_ifile);
  219.       get_pos(curr_ifile, &initial_scrpos);
  220.   
  221. !     ispipe = ISPIPE(f);
  222.       if (ispipe)
  223.           ch_pipe();
  224.       else
  225. --- 189,197 ----
  226.       curr_ifile = get_ifile(filename, curr_ifile);
  227.       get_pos(curr_ifile, &initial_scrpos);
  228.   
  229. !     ispipe = ISPIPE(f) || iscompressed;
  230. !         wascompressed = iscompressed;
  231. !         iscompressed = 0;
  232.       if (ispipe)
  233.           ch_pipe();
  234.       else
  235. diff -cbBw orig/filename.c new/filename.c
  236. *** orig/filename.c    Thu Apr 04 06:43:58 1991
  237. --- new/filename.c    Thu Jun 27 14:40:34 1991
  238. ***************
  239. *** 45,50 ****
  240. --- 45,63 ----
  241.           sprintf(pathname, "%s\\%s", homedir, filename);
  242.       }
  243.   #else
  244. + #ifdef OS2
  245. +         pathname = (char *) calloc(256, sizeof(char));
  246. +     if (pathname == NULL)
  247. +         return NULL;
  248. +         _searchenv(filename, "INIT", pathname);
  249. +         if ( pathname[0] == 0 )
  250. +           _searchenv(filename, "PATH", pathname);
  251. +         if ( pathname[0] == 0 )
  252. +         {
  253. +           free(pathname);
  254. +           return NULL;
  255. +         }
  256. + #else
  257.       if (homedir == NULL)
  258.           return (NULL);
  259.       pathname = (char *) calloc(strlen(homedir)+strlen(filename)+2,
  260. ***************
  261. *** 53,58 ****
  262. --- 66,72 ----
  263.           return (NULL);
  264.       sprintf(pathname, "%s/%s", homedir, filename);
  265.   #endif
  266. + #endif
  267.       return (pathname);
  268.   }
  269.   
  270. ***************
  271. *** 70,76 ****
  272.        * Look in current directory.
  273.        */
  274.       if (access(HELPFILE,0) == 0)
  275. !         return (HELPFILE);
  276.       /*
  277.        * Find the basename of HELPFILE,
  278.        * and look for it in each directory in the search path.
  279. --- 84,90 ----
  280.        * Look in current directory.
  281.        */
  282.       if (access(HELPFILE,0) == 0)
  283. !             return (save(HELPFILE));
  284.       /*
  285.        * Find the basename of HELPFILE,
  286.        * and look for it in each directory in the search path.
  287. ***************
  288. *** 83,89 ****
  289. --- 97,107 ----
  290.   #else
  291.       if ((helpfile = getenv("LESSHELP")) != NULL)
  292.           return (save(helpfile));
  293. + #ifdef OS2
  294. +     return (homefile(HELPFILE));
  295. + #else
  296.       return (save(HELPFILE));
  297. + #endif
  298.   #endif
  299.   }
  300.   
  301. diff -cbBw orig/help.c new/help.c
  302. *** orig/help.c    Thu Apr 04 06:43:16 1991
  303. --- new/help.c    Thu Jun 27 14:37:30 1991
  304. ***************
  305. *** 9,14 ****
  306. --- 9,18 ----
  307.   
  308.   #include  "less.h"
  309.   
  310. + #ifndef HELPFILE
  311. + #define HELPFILE "less.hlp"
  312. + #endif
  313.   #if __MSDOS__
  314.   #include <io.h>
  315.   #include <dir.h>
  316. ***************
  317. *** 43,51 ****
  318. --- 47,61 ----
  319.   #else
  320.       cmd = (char *) ecalloc(strlen(helpfile) + strlen(progname) + 150,
  321.                   sizeof(char));
  322. + #ifdef OS2
  323. +     sprintf(cmd,
  324. +      "-%s -m -H -+E -+s \"-PmHELP -- ?eEND -- Press g to see it again:Press RETURN for more., or q when done \" %s",
  325. +         progname, helpfile);
  326. + #else
  327.       sprintf(cmd,
  328.        "-%s -m -H -+E -+s '-PmHELP -- ?eEND -- Press g to see it again:Press RETURN for more., or q when done ' %s",
  329.           progname, helpfile);
  330. + #endif
  331.   #endif
  332.       free(helpfile);
  333.       lsystem(cmd);
  334. diff -cbBw orig/less.h new/less.h
  335. *** orig/less.h    Thu Apr 04 06:44:00 1991
  336. --- new/less.h    Thu Jun 27 14:37:32 1991
  337. ***************
  338. *** 107,113 ****
  339. --- 107,117 ----
  340.   /* Library function declarations */
  341.   offset_t lseek();
  342.   #define    BAD_LSEEK    ((offset_t)-1)
  343. + #ifdef OS2
  344. + VOID_POINTER calloc(unsigned, unsigned);
  345. + #else
  346.   VOID_POINTER calloc();
  347. + #endif
  348.   
  349.   #define    ch_zero()    ((POSITION)0)
  350.   #include "funcs.h"
  351. diff -cbBw orig/lesskey.c new/lesskey.c
  352. *** orig/lesskey.c    Thu Apr 04 06:44:02 1991
  353. --- new/lesskey.c    Thu Jun 27 14:37:34 1991
  354. ***************
  355. *** 128,133 ****
  356. --- 128,134 ----
  357.        * Process command line arguments.
  358.        */
  359.       outfile = NULL;
  360. +         p =argv[0];
  361.       while (--argc > 0 && **(++argv) == '-')
  362.       {
  363.           switch (argv[0][1])
  364. ***************
  365. *** 137,152 ****
  366.               if (*outfile == '\0')
  367.               {
  368.                   if (--argc <= 0)
  369. !                     usage();
  370.                   outfile = *(++argv);
  371.               }
  372.               break;
  373.           default:
  374. !             usage();
  375.           }
  376.       }
  377.       if (argc > 1)
  378. !         usage();
  379.   
  380.   
  381.       /*
  382. --- 138,153 ----
  383.               if (*outfile == '\0')
  384.               {
  385.                   if (--argc <= 0)
  386. !                                         usage(p);
  387.                   outfile = *(++argv);
  388.               }
  389.               break;
  390.           default:
  391. !                         usage(p);
  392.           }
  393.       }
  394.       if (argc > 1)
  395. !                 usage(p);
  396.   
  397.   
  398.       /*
  399. ***************
  400. *** 160,165 ****
  401. --- 161,169 ----
  402.               exit(1);
  403.           }
  404.       } else
  405. +             if ( isatty(fileno(stdin)) )
  406. +                 usage(p);
  407. +             else
  408.           desc = stdin;
  409.   
  410.       /*
  411. ***************
  412. *** 283,288 ****
  413. --- 287,300 ----
  414.        */
  415.       if (outfile == NULL)
  416.       {
  417. + #ifdef OS2
  418. +                 if ( p = getenv("INIT") )
  419. +                   strcpy(line, p);
  420. +                 else
  421. +                   strcpy(line, ".");
  422. +                 strcat(line, "\\less.ini");
  423. + #else
  424.           p = getenv("HOME");
  425.           if (p == NULL || *p == '\0')
  426.           {
  427. ***************
  428. *** 302,307 ****
  429. --- 314,320 ----
  430.   #endif
  431.           }
  432.           outfile = line;
  433. + #endif
  434.       }
  435.       if ((out = fopen(outfile, "w")) == NULL)
  436.           perror(outfile);
  437. ***************
  438. *** 353,360 ****
  439.       return (*p);
  440.   }
  441.   
  442. ! usage()
  443.   {
  444. !     fprintf(stderr, "usage: lesskey [-o output] [input]\n");
  445.       exit(1);
  446.   }
  447. --- 366,374 ----
  448.       return (*p);
  449.   }
  450.   
  451. ! usage(name)
  452. ! char *name;
  453.   {
  454. !         fprintf(stderr, "\nUsage: %s [-o output] [input]\n", name);
  455.       exit(1);
  456.   }
  457. diff -cbBw orig/line.c new/line.c
  458. *** orig/line.c    Thu Apr 04 06:44:02 1991
  459. --- new/line.c    Thu Jun 27 14:37:36 1991
  460. ***************
  461. *** 29,34 ****
  462. --- 29,38 ----
  463.   extern int bl_s_width, bl_e_width;
  464.   extern int sc_width, sc_height;
  465.   
  466. + #ifdef OS2
  467. + static int do_append();
  468. + #endif
  469.   /*
  470.    * Rewind the line buffer.
  471.    */
  472. ***************
  473. *** 320,326 ****
  474.           {
  475.               STOREC(' ', NORMAL);
  476.           } while ((column % tabstop) != 0);
  477. !     } else if (control_char(c))
  478.       {
  479.       do_control_char:
  480.           if (ctldisp == 0)
  481. --- 324,333 ----
  482.           {
  483.               STOREC(' ', NORMAL);
  484.           } while ((column % tabstop) != 0);
  485. !     }
  486. !         /* else if (c == '\r')
  487. !           return(0); */
  488. !         else if (control_char(c))
  489.       {
  490.       do_control_char:
  491.           if (ctldisp == 0)
  492. diff -cbBw orig/lsystem.c new/lsystem.c
  493. *** orig/lsystem.c    Thu Apr 04 06:44:02 1991
  494. --- new/lsystem.c    Thu Jun 27 14:37:38 1991
  495. ***************
  496. *** 25,30 ****
  497. --- 25,36 ----
  498.   void swchar_to_unix();
  499.   #endif
  500.   
  501. + #ifdef OS2
  502. + #include <process.h>
  503. + extern int _osmode;
  504. + #define DOS_MODE 0
  505. + #endif
  506.   extern char *getenv();
  507.   
  508.   extern int screen_trashed;
  509. ***************
  510. *** 93,99 ****
  511. --- 99,109 ----
  512.   #else
  513.       inp = dup(0);
  514.       close(0);
  515. + #ifdef OS2
  516. +         if (open("con", 0) < 0)
  517. + #else
  518.       if (open("/dev/tty", 0) < 0)
  519. + #endif
  520.           dup(inp);
  521.   #endif
  522.   
  523. ***************
  524. *** 118,123 ****
  525. --- 128,144 ----
  526.   }
  527.   #else
  528.       p = NULL;
  529. + #ifdef OS2
  530. +         if ( *cmd == 0 )
  531. +         {
  532. +           if ( (p = getenv("COMSPEC")) == NULL )
  533. +             p = (_osmode == DOS_MODE) ? "COMMAND" : "CMD";
  534. +           spawnlp(P_WAIT, p, p, NULL);
  535. +         }
  536. +         else
  537. +           system(cmd);
  538. + #else
  539.       if ((shell = getenv("SHELL")) != NULL && *shell != '\0')
  540.       {
  541.           if (*cmd == '\0')
  542. ***************
  543. *** 139,144 ****
  544. --- 160,166 ----
  545.   
  546.       system(p);
  547.       free(p);
  548. + #endif
  549.   #endif
  550.   
  551.       /*
  552. diff -cbBw orig/main.c new/main.c
  553. *** orig/main.c    Thu Apr 04 06:44:04 1991
  554. --- new/main.c    Thu Jun 27 14:37:40 1991
  555. ***************
  556. *** 5,11 ****
  557.   #include "less.h"
  558.   #include "position.h"
  559.   
  560. ! public int    ispipe;
  561.   public char *    every_first_cmd = NULL;
  562.   public int    new_file;
  563.   public int    is_tty;
  564. --- 5,16 ----
  565.   #include "less.h"
  566.   #include "position.h"
  567.   
  568. ! #ifdef OS2
  569. ! #include <stdio.h>
  570. ! #include <fcntl.h>
  571. ! #endif
  572. ! public int      ispipe, iscompressed, wascompressed;
  573.   public char *    every_first_cmd = NULL;
  574.   public int    new_file;
  575.   public int    is_tty;
  576. ***************
  577. *** 24,29 ****
  578. --- 29,37 ----
  579.   extern int    screen_trashed;
  580.   extern int    force_open;
  581.   
  582. + public FILE *   compress;
  583. + public FILE *   oldcompr;
  584.   #if LOGFILE
  585.   public int    logfile = -1;
  586.   public int    force_logfile = 0;
  587. ***************
  588. *** 41,46 ****
  589. --- 49,87 ----
  590.   extern int    tagoption;
  591.   #endif
  592.   
  593. + char *myname;
  594. + extern char version[];
  595. + extern char *strchr();
  596. + usage()
  597. + {
  598. +   int x = strlen(myname);
  599. +   printf("\nThis is %s.\n", version + 5);
  600. +   printf("\nUsage: %s [-[+]aABcCdeEfgimMnNqQruUsw] [-bN] [-hN] [-xN] [-[z]N]", myname);
  601. +   printf("\n       %*s [-P[mM=]string] [-[lL]logfile] [-kkeyfile]", x, "");
  602. +   printf("\n       %*s [+cmd] [-ttag] [filename]...\n", x, "");
  603. +   printf("\n   or: %s -?\n", myname);
  604. + }
  605. + int isZfile(name)
  606. + char *name;
  607. + {
  608. +   int res, magic, file;
  609. + #ifdef OS2
  610. +   file = open(name, O_RDONLY | O_BINARY);
  611. + #else
  612. +   file = open(name, O_RDONLY);
  613. + #endif
  614. +   res = read(file, &magic, 2);
  615. +   close(file);
  616. +   return (res == 2) && (magic == 0x9D1F);
  617. + }
  618.   
  619.   
  620.   /*
  621. ***************
  622. *** 54,59 ****
  623. --- 95,101 ----
  624.       int nofiles;
  625.       extern char *getenv();
  626.   
  627. +         myname = argv[0];
  628.       progname = *argv++;
  629.   
  630.       /*
  631. ***************
  632. *** 257,262 ****
  633. --- 299,310 ----
  634.       {
  635.           lower_left();
  636.           clear_eol();
  637. +           if (file > 0)
  638. +             if (wascompressed)
  639. +               pclose(oldcompr);
  640. +             else
  641. +               close(file);
  642.       }
  643.       deinit();
  644.       flush();
  645. diff -cbBw orig/option.c new/option.c
  646. *** orig/option.c    Thu Apr 04 06:44:04 1991
  647. --- new/option.c    Thu Jun 27 14:37:42 1991
  648. ***************
  649. *** 20,25 ****
  650. --- 20,29 ----
  651.   extern int screen_trashed;
  652.   extern char *every_first_cmd;
  653.   
  654. + #ifdef OS2
  655. + static int toggle_triple();
  656. + #endif
  657.   /*
  658.    * Scan an argument (either from the command line or from the
  659.    * LESS environment variable) and process it.
  660. diff -cbBw orig/screen.c new/screen.c
  661. *** orig/screen.c    Thu Apr 04 06:44:04 1991
  662. --- new/screen.c    Thu Jun 27 14:37:44 1991
  663. ***************
  664. *** 5,10 ****
  665. --- 5,13 ----
  666.    * {{ Someday this should be rewritten to use curses. }}
  667.    */
  668.   
  669. + #include <stdio.h>
  670. + #include <stdlib.h>
  671.   #include "less.h"
  672.   #if XENIX
  673.   #include <sys/types.h>
  674. ***************
  675. *** 11,21 ****
  676. --- 14,32 ----
  677.   #include <sys/ioctl.h>
  678.   #endif
  679.   
  680. + #ifdef OS2
  681. + #undef VOID
  682. + #undef CONTROL
  683. + #define INCL_SUB
  684. + #define INCL_NOPM
  685. + #include <os2.h>
  686. + #else
  687.   #if TERMIO
  688.   #include <termio.h>
  689.   #else
  690.   #include <sgtty.h>
  691.   #endif
  692. + #endif
  693.   
  694.   #if !TERMIO && defined(TIOCGWINSZ)
  695.   #include <sys/ioctl.h>
  696. ***************
  697. *** 76,81 ****
  698. --- 87,93 ----
  699.   public int bl_s_width, bl_e_width;    /* Printing width of blink seq */
  700.   
  701.   static char *cheaper();
  702. + static int cost();
  703.   
  704.   /*
  705.    * These two variables are sometimes defined in,
  706. ***************
  707. *** 113,118 ****
  708. --- 125,135 ----
  709.   
  710.       if (on == curr_on)
  711.           return;
  712. + #ifdef OS2
  713. +         signal(SIGINT, SIG_IGN);
  714. +     erase_char = '\b';
  715. +     kill_char = '\033';
  716. + #else
  717.   #if TERMIO
  718.       {
  719.       struct termio s;
  720. ***************
  721. *** 185,190 ****
  722. --- 202,208 ----
  723.       ioctl(2, TIOCSETN, &s);
  724.       }
  725.   #endif
  726. + #endif
  727.       curr_on = on;
  728.   }
  729.   
  730. ***************
  731. *** 212,217 ****
  732. --- 230,254 ----
  733.       int *p_height;
  734.       int *p_width;
  735.   {
  736. + #ifdef OS2
  737. +         if ( _osmode == DOS_MODE )
  738. +         {
  739. +           *p_width  = (* (char far *) 0x0040004A);
  740. +           *p_height = (* (char far *) 0x00400084) + 1;
  741. +       if ( (*p_height < 25) || (*p_height > 75) )
  742. +         *p_height = 25;
  743. +         }
  744. +         else
  745. +         {
  746. +           VIOMODEINFO mi;
  747. +           mi.cb = sizeof(mi);
  748. +           VioGetMode(&mi, 0);
  749. +           *p_width = mi.col;
  750. +           *p_height = mi.row;
  751. +         }
  752. + #else
  753.       register char *s;
  754.   #ifdef TIOCGWINSZ
  755.       struct winsize w;
  756. ***************
  757. *** 254,259 ****
  758. --- 291,297 ----
  759.           *p_width = atoi(s);
  760.       else
  761.            *p_width = tgetnum("co");
  762. + #endif /* OS2 */
  763.   
  764.        if (*p_width <= 0)
  765.             *p_width = 80;
  766. ***************
  767. *** 277,283 ****
  768. --- 315,325 ----
  769.        * Find out what kind of terminal this is.
  770.        */
  771.        if ((term = getenv("TERM")) == NULL)
  772. + #ifdef OS2
  773. +                 term = "ansi";
  774. + #else
  775.            term = "unknown";
  776. + #endif
  777.        if (tgetent(termbuf, term) <= 0)
  778.            strcpy(termbuf, "dumb:hc:");
  779.   
  780. ***************
  781. *** 446,452 ****
  782. --- 488,500 ----
  783.       t2 = tgetstr("sr", &sp);
  784.       if (hard || t2 == NULL)
  785.           t2 = "";
  786. + #ifdef OS2
  787. +         if (*t1 == '\0' && *t2 == '\0')
  788. +            sc_addline = "";
  789. +         else
  790. + #endif
  791.       sc_addline = cheaper(t1, t2, "scroll backwards", "");
  792.       if (*sc_addline == '\0')
  793.       {
  794.           /*
  795. diff -cbBw orig/ttyin.c new/ttyin.c
  796. *** orig/ttyin.c    Thu Apr 04 06:44:06 1991
  797. --- new/ttyin.c    Thu Jun 27 14:37:46 1991
  798. ***************
  799. *** 10,15 ****
  800. --- 10,26 ----
  801.   #include <signal.h>
  802.   #endif
  803.   
  804. + #ifdef OS2
  805. + #undef NULL
  806. + #undef VOID
  807. + #undef CONTROL
  808. + #define INCL_DOSPROCESS
  809. + #define INCL_SUB
  810. + #define INCL_NOPM
  811. + #include <os2.h>
  812. + #include <stdio.h>
  813. + #endif
  814.   static int tty;
  815.   
  816.   /*
  817. ***************
  818. *** 18,24 ****
  819.       public void
  820.   open_getchr()
  821.   {
  822. ! #if __MDDOS__
  823.       /*
  824.        * Open a new handle to CON: in binary mode
  825.        * for unbuffered keyboard read.
  826. --- 29,35 ----
  827.       public void
  828.   open_getchr()
  829.   {
  830. ! #if __MSDOS__
  831.       /*
  832.        * Open a new handle to CON: in binary mode
  833.        * for unbuffered keyboard read.
  834. ***************
  835. *** 43,56 ****
  836.       public int
  837.   getchr()
  838.   {
  839. !     char c;
  840.       int result;
  841.   
  842.       do
  843.       {
  844.           result = iread(tty, &c, sizeof(char));
  845.           if (result == READ_INTR)
  846.               return (READ_INTR);
  847.           if (result < 0)
  848.           {
  849.               /*
  850. --- 54,93 ----
  851.       public int
  852.   getchr()
  853.   {
  854. !         int c;
  855.       int result;
  856.   
  857. +         flush();
  858.       do
  859.       {
  860. + #ifdef OS2
  861. +                 static int ext, scan;
  862. +                 KBDKEYINFO ki;
  863. +                 if ( ext )
  864. +                 {
  865. +                   ext = 0;
  866. +                   c = scan;
  867. +                 }
  868. +                 else
  869. +                 {
  870. +                   KbdCharIn(&ki, IO_WAIT, 0);
  871. +                   c = ki.chChar;
  872. +                   if ( c == 0 || c == 0xE0 )
  873. +                   {
  874. +                     c = 0xE0;
  875. +                     ext = 1;
  876. +                     scan = ki.chScan;
  877. +                   }
  878. +                 }
  879. +                 result = 1;
  880. + #else
  881.           result = iread(tty, &c, sizeof(char));
  882.           if (result == READ_INTR)
  883.               return (READ_INTR);
  884. + #endif
  885.           if (result < 0)
  886.           {
  887.               /*
  888. ***************
  889. *** 77,79 ****
  890. --- 114,125 ----
  891.   
  892.       return (c);
  893.   }
  894. + #ifdef OS2
  895. + sleep(x)
  896. + int x;
  897. + {
  898. +   DosSleep(1000L * x);
  899. + }
  900. + #endif
  901.