home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / editor / less / patches.os2 < prev    next >
Encoding:
Text File  |  1994-01-31  |  19.3 KB  |  940 lines

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