home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / less2912.zip / patches.os2 < prev    next >
Text File  |  1995-11-09  |  49KB  |  1,925 lines

  1. Only in new: zfiles.c
  2. diff -cbr orig/ch.c new/ch.c
  3. *** orig/ch.c    Thu Nov 09 10:35:26 1995
  4. --- new/ch.c    Mon Apr 10 10:05:52 1995
  5. ***************
  6. *** 707,713 ****
  7.            * But don't really close it if it was opened via popen(),
  8.            * because pclose() wants to close it.
  9.            */
  10. !         if (!(ch_flags & CH_POPENED))
  11.               close(ch_file);
  12.           ch_file = -1;
  13.       } else
  14. --- 707,715 ----
  15.            * But don't really close it if it was opened via popen(),
  16.            * because pclose() wants to close it.
  17.            */
  18. !             if (ch_flags & CH_COMPRESSED)
  19. !               Zclose(ch_file);
  20. !         else if (!(ch_flags & CH_POPENED))
  21.               close(ch_file);
  22.           ch_file = -1;
  23.       } else
  24. diff -cbr orig/charset.c new/charset.c
  25. *** orig/charset.c    Wed Feb 01 01:55:28 1995
  26. --- new/charset.c    Thu Nov 09 10:36:38 1995
  27. ***************
  28. *** 211,229 ****
  29.   {
  30.       register char *s;
  31.   
  32. !     s = getenv("LESSBINFMT");
  33.       setbinfmt(s);
  34.       
  35.       /*
  36.        * See if environment variable LESSCHARSET is defined.
  37.        */
  38. !     s = getenv("LESSCHARSET");
  39.       if (icharset(s))
  40.           return;
  41.       /*
  42.        * LESSCHARSET is not defined: try LESSCHARDEF.
  43.        */
  44. !     s = getenv("LESSCHARDEF");
  45.       if (s != NULL && *s != '\0')
  46.       {
  47.           ichardef(s);
  48. --- 211,229 ----
  49.   {
  50.       register char *s;
  51.   
  52. !     s = lgetenv("LESSBINFMT");
  53.       setbinfmt(s);
  54.       
  55.       /*
  56.        * See if environment variable LESSCHARSET is defined.
  57.        */
  58. !     s = lgetenv("LESSCHARSET");
  59.       if (icharset(s))
  60.           return;
  61.       /*
  62.        * LESSCHARSET is not defined: try LESSCHARDEF.
  63.        */
  64. !     s = lgetenv("LESSCHARDEF");
  65.       if (s != NULL && *s != '\0')
  66.       {
  67.           ichardef(s);
  68. diff -cbr orig/cmd.h new/cmd.h
  69. *** orig/cmd.h    Wed Feb 01 01:55:28 1995
  70. --- new/cmd.h    Thu Nov 09 10:36:38 1995
  71. ***************
  72. *** 115,117 ****
  73. --- 115,119 ----
  74.   #define    EC_NOHISTORY    02
  75.   #define    EC_NOCOMPLETE    04
  76.   
  77. + /* Environment variable stuff */
  78. + #define    EV_OK        01
  79. diff -cbr orig/decode.c new/decode.c
  80. *** orig/decode.c    Thu Mar 09 00:04:14 1995
  81. --- new/decode.c    Thu Nov 09 10:36:40 1995
  82. ***************
  83. *** 195,200 ****
  84. --- 195,201 ----
  85.    */
  86.   static struct tablelist *list_fcmd_tables = NULL;
  87.   static struct tablelist *list_ecmd_tables = NULL;
  88. + static struct tablelist *list_var_tables = NULL;
  89.   
  90.   
  91.   /*
  92. ***************
  93. *** 208,214 ****
  94.        */
  95.       add_fcmd_table((char*)cmdtable, sizeof(cmdtable));
  96.       add_ecmd_table((char*)edittable, sizeof(edittable));
  97. -     get_editkeys();
  98.   #if USERFILE
  99.       /*
  100.        * Try to add the tables in the standard lesskey file "$HOME/.less".
  101. --- 209,214 ----
  102. ***************
  103. *** 271,276 ****
  104. --- 271,318 ----
  105.   }
  106.   
  107.   /*
  108. +  * Insert a command table in the proper place - after default, but before
  109. +  * any .less file table.
  110. +  */
  111. +     public void
  112. + insert_fcmd_table(buf, len)
  113. +     char *buf;
  114. +     int len;
  115. + {
  116. +         if (list_fcmd_tables == NULL || list_fcmd_tables->t_next == NULL)
  117. +             add_fcmd_table(buf,len);
  118. +     else if (add_cmd_table(&(list_fcmd_tables->t_next), buf, len) < 0)
  119. +         error("Warning: some commands may be disabled", NULL_PARG);
  120. + }
  121. + /*
  122. +  * Insert an editing command table in the proper place - after default, but
  123. +  * before any .less file table.
  124. +  */
  125. +     public void
  126. + insert_ecmd_table(buf, len)
  127. +     char *buf;
  128. +     int len;
  129. + {
  130. +         if (list_ecmd_tables == NULL || list_ecmd_tables->t_next == NULL)
  131. +            add_ecmd_table(buf,len);
  132. +     else if (add_cmd_table(&(list_ecmd_tables->t_next), buf, len) < 0)
  133. +            error("Warning: some edit commands may be disabled", NULL_PARG);
  134. + }
  135. + /*
  136. +  * Add an environment variable table.
  137. +  */
  138. +     public void
  139. + add_var_table(buf, len)
  140. +     char *buf;
  141. +     int len;
  142. + {
  143. +     if (add_cmd_table(&list_var_tables, buf, len) < 0)
  144. +         error("Warning: environment variables from lesskey file unavailable", NULL_PARG);
  145. + }
  146. + /*
  147.    * Search a single command table for the command string in cmd.
  148.    */
  149.       public int
  150. ***************
  151. *** 403,409 ****
  152. --- 445,473 ----
  153.       return (cmd_decode(list_ecmd_tables, cmd, sp));
  154.   }
  155.   
  156. + /*
  157. +  * Get the value of an environment variable.
  158. +  * Looks first in the lesskey file, then in the real environment.
  159. +  */
  160. +     public char *
  161. + lgetenv(var)
  162. +     char *var;
  163. + {
  164. +     int a;
  165. +     char *s;
  166. +     a = cmd_decode(list_var_tables, var, &s);
  167. +     if (a == EV_OK)
  168. +         return (s);
  169. +     return (getenv(var));
  170. + }
  171.   #if USERFILE
  172. + /*
  173. +  * Get an "integer" from a lesskey file.
  174. +  * Integers are stored in a funny format: 
  175. +  * two bytes, low order first, in radix KRADIX.
  176. +  */
  177.       static int
  178.   gint(sp)
  179.       char **sp;
  180. ***************
  181. *** 415,420 ****
  182. --- 479,487 ----
  183.       return (n);
  184.   }
  185.   
  186. + /*
  187. +  * Process an old (pre-v241) lesskey file.
  188. +  */
  189.       static int
  190.   old_lesskey(buf, len)
  191.       char *buf;
  192. ***************
  193. *** 433,438 ****
  194. --- 500,508 ----
  195.       return (0);
  196.   }
  197.   
  198. + /* 
  199. +  * Process a new (post-v241) lesskey file.
  200. +  */
  201.       static int
  202.   new_lesskey(buf, len)
  203.       char *buf;
  204. ***************
  205. *** 440,446 ****
  206.   {
  207.       char *p;
  208.       register int c;
  209. -     register int done;
  210.       register int n;
  211.   
  212.       /*
  213. --- 510,515 ----
  214. ***************
  215. *** 452,459 ****
  216.           buf[len-1] != C2_END_LESSKEY_MAGIC)
  217.           return (-1);
  218.       p = buf + 4;
  219. !     done = 0;
  220. !     while (!done)
  221.       {
  222.           c = *p++;
  223.           switch (c)
  224. --- 521,527 ----
  225.           buf[len-1] != C2_END_LESSKEY_MAGIC)
  226.           return (-1);
  227.       p = buf + 4;
  228. !     for (;;)
  229.       {
  230.           c = *p++;
  231.           switch (c)
  232. ***************
  233. *** 468,482 ****
  234.               add_ecmd_table(p, n);
  235.               p += n;
  236.               break;
  237. !         case END_SECTION:
  238. !             done = 1;
  239.               break;
  240.           default:
  241. !             free(buf);
  242.               return (-1);
  243.           }
  244.       }
  245. -     return (0);
  246.   }
  247.   
  248.   /*
  249. --- 536,555 ----
  250.               add_ecmd_table(p, n);
  251.               p += n;
  252.               break;
  253. !         case VAR_SECTION:
  254. !             n = gint(&p);
  255. !             add_var_table(p, n);
  256. !             p += n;
  257.               break;
  258. +         case END_SECTION:
  259. +             return (0);
  260.           default:
  261. !             /*
  262. !              * Unrecognized section type.
  263. !              */
  264.               return (-1);
  265.           }
  266.       }
  267.   }
  268.   
  269.   /*
  270. ***************
  271. *** 641,647 ****
  272.            * This does NOT include the original character that was 
  273.            * passed in as a parameter.
  274.            */
  275. !         while (nch > 1) {
  276.               ungetcc(usercmd[--nch]);
  277.           }
  278.       } else
  279. --- 714,721 ----
  280.            * This does NOT include the original character that was 
  281.            * passed in as a parameter.
  282.            */
  283. !         while (nch > 1) 
  284. !         {
  285.               ungetcc(usercmd[--nch]);
  286.           }
  287.       } else
  288. diff -cbr orig/defines.dos new/defines.dos
  289. *** orig/defines.dos    Fri Feb 24 22:25:42 1995
  290. --- new/defines.dos    Thu Nov 09 10:36:40 1995
  291. ***************
  292. *** 195,213 ****
  293.   #define HAVE_VOID 1
  294.   
  295.   /* Define HAVE_TIME_T if your system supports the "time_t" type. */
  296. ! #define HAVE_TIME_T 0
  297.   
  298.   /* Define HAVE_STRERROR if you have the strerror() function. */
  299. ! #define HAVE_STRERROR 0
  300.   
  301.   /* Define HAVE_FILENO if you have the fileno() macro. */
  302. ! #define HAVE_FILENO 0
  303.   
  304.   /* Define HAVE_ERRNO if you have the errno variable */
  305.   #define HAVE_ERRNO 0
  306.   
  307.   /* Define HAVE_SYS_ERRLIST if you have the sys_errlist[] variable */
  308. ! #define HAVE_SYS_ERRLIST 0
  309.   
  310.   /* Define HAVE_OSPEED if your termcap library has the ospeed variable */
  311.   #define HAVE_OSPEED 0
  312. --- 195,213 ----
  313.   #define HAVE_VOID 1
  314.   
  315.   /* Define HAVE_TIME_T if your system supports the "time_t" type. */
  316. ! #define HAVE_TIME_T 1
  317.   
  318.   /* Define HAVE_STRERROR if you have the strerror() function. */
  319. ! #define HAVE_STRERROR 1
  320.   
  321.   /* Define HAVE_FILENO if you have the fileno() macro. */
  322. ! #define HAVE_FILENO 1
  323.   
  324.   /* Define HAVE_ERRNO if you have the errno variable */
  325.   #define HAVE_ERRNO 0
  326.   
  327.   /* Define HAVE_SYS_ERRLIST if you have the sys_errlist[] variable */
  328. ! #define HAVE_SYS_ERRLIST 1
  329.   
  330.   /* Define HAVE_OSPEED if your termcap library has the ospeed variable */
  331.   #define HAVE_OSPEED 0
  332. ***************
  333. *** 216,222 ****
  334.   #define MUST_DEFINE_OSPEED 0
  335.   
  336.   /* Define HAVE_LOCALE if you have locale.h and setlocale. */
  337. ! #define HAVE_LOCALE 0
  338.   
  339.   /* Define HAVE_TERMIOS_FUNCS if you have tcgetattr/tcsetattr */
  340.   #define HAVE_TERMIOS_FUNCS 0
  341. --- 216,222 ----
  342.   #define MUST_DEFINE_OSPEED 0
  343.   
  344.   /* Define HAVE_LOCALE if you have locale.h and setlocale. */
  345. ! #define HAVE_LOCALE 1
  346.   
  347.   /* Define HAVE_TERMIOS_FUNCS if you have tcgetattr/tcsetattr */
  348.   #define HAVE_TERMIOS_FUNCS 0
  349. ***************
  350. *** 243,249 ****
  351.   #define HAVE_CTYPE_H 1
  352.   
  353.   /* Define if you have the <errno.h> header file.  */
  354. ! #define HAVE_ERRNO_H 0
  355.   
  356.   /* Define if you have the <fcntl.h> header file.  */
  357.   #define HAVE_FCNTL_H 1
  358. --- 243,249 ----
  359.   #define HAVE_CTYPE_H 1
  360.   
  361.   /* Define if you have the <errno.h> header file.  */
  362. ! #define HAVE_ERRNO_H 1
  363.   
  364.   /* Define if you have the <fcntl.h> header file.  */
  365.   #define HAVE_FCNTL_H 1
  366. ***************
  367. *** 261,279 ****
  368.   #define HAVE_SYS_STREAM_H    0
  369.   
  370.   /* Define if you have the <termcap.h> header file.  */
  371. ! /* #undef HAVE_TERMCAP_H */
  372.   
  373.   /* Define if you have the <termio.h> header file.  */
  374.   #define HAVE_TERMIO_H    0
  375.   
  376.   /* Define if you have the <termios.h> header file.  */
  377. ! #define HAVE_TERMIOS_H 1
  378.   
  379.   /* Define if you have the <time.h> header file.  */
  380.   #define HAVE_TIME_H 1
  381.   
  382.   /* Define if you have the <unistd.h> header file.  */
  383. ! #define HAVE_UNISTD_H 1
  384.   
  385.   /* Define if you have the <values.h> header file.  */
  386.   #define HAVE_VALUES_H 0
  387. --- 261,298 ----
  388.   #define HAVE_SYS_STREAM_H    0
  389.   
  390.   /* Define if you have the <termcap.h> header file.  */
  391. ! #define HAVE_TERMCAP_H    0
  392.   
  393.   /* Define if you have the <termio.h> header file.  */
  394.   #define HAVE_TERMIO_H    0
  395.   
  396.   /* Define if you have the <termios.h> header file.  */
  397. ! #define HAVE_TERMIOS_H 0
  398.   
  399.   /* Define if you have the <time.h> header file.  */
  400.   #define HAVE_TIME_H 1
  401.   
  402.   /* Define if you have the <unistd.h> header file.  */
  403. ! #define HAVE_UNISTD_H 0
  404.   
  405.   /* Define if you have the <values.h> header file.  */
  406.   #define HAVE_VALUES_H 0
  407. + #if _MSC_VER >= 700
  408. + /*
  409. +  * The names of these things changed in Microsoft C version 7.0.
  410. +  */
  411. + #define videoconfig    _videoconfig
  412. + #define rccoord        _rccoord
  413. + #define off_t        _off_t
  414. + #define O_RDONLY    _O_RDONLY
  415. + #define O_WRONLY    _O_WRONLY
  416. + #define O_APPEND    _O_APPEND
  417. + #define O_BINARY    _O_BINARY
  418. + #define O_TEXT        _O_TEXT
  419. + #define find_t        _find_t
  420. + #define stat        _stat
  421. + #define S_IFMT        _S_IFMT
  422. + #define S_IFDIR        _S_IFDIR
  423. + #define S_IFREG        _S_IFREG
  424. + #endif
  425. diff -cbr orig/defines.h new/defines.h
  426. *** orig/defines.h    Fri Feb 24 22:25:50 1995
  427. --- new/defines.h    Thu Nov 09 10:36:40 1995
  428. ***************
  429. *** 75,81 ****
  430.    * EDIT_PGM is the name of the (default) editor to be invoked.
  431.    */
  432.   #define    EDITOR        (!SECURE)
  433. ! #define    EDIT_PGM    "me"
  434.   
  435.   /*
  436.    * TAGS is 1 if you wish to support tag files.
  437. --- 75,81 ----
  438.    * EDIT_PGM is the name of the (default) editor to be invoked.
  439.    */
  440.   #define    EDITOR        (!SECURE)
  441. ! #define    EDIT_PGM    "emacs"
  442.   
  443.   /*
  444.    * TAGS is 1 if you wish to support tag files.
  445. diff -cbr orig/doscreen.c new/doscreen.c
  446. *** orig/doscreen.c    Wed Feb 01 01:55:36 1995
  447. --- new/doscreen.c    Thu Nov 09 10:36:42 1995
  448. ***************
  449. *** 49,54 ****
  450. --- 49,55 ----
  451.   public int ul_s_width, ul_e_width;    /* Printing width of underline seq */
  452.   public int so_s_width, so_e_width;    /* Printing width of standout seq */
  453.   public int bl_s_width, bl_e_width;    /* Printing width of blink seq */
  454. + public int can_goto_line;        /* Can move cursor to any line */
  455.   
  456.   public int nm_fg_color = 7;            /* Color of normal text */
  457.   public int nm_bg_color = 0;
  458. ***************
  459. *** 69,75 ****
  460.   extern int know_dumb;        /* Don't complain about a dumb terminal */
  461.   extern int back_scroll;
  462.   extern int swindow;
  463. - extern char *getenv();
  464.   
  465.   /*
  466.    * Change terminal to "raw mode", or restore to "normal" mode.
  467. --- 70,75 ----
  468. ***************
  469. *** 110,123 ****
  470.   
  471.       if (w.numtextrows)
  472.           *p_height = w.numtextrows;
  473. !     else if ((s = getenv("LINES")) != NULL && *s != '\0')
  474.           *p_height = atoi(s);
  475.       if (*p_height <= 0)
  476.           *p_height = 24;
  477.           
  478.       if (w.numtextcols > 0)
  479.           *p_width = w.numtextcols;
  480. !     else if ((s = getenv("COLUMNS")) != NULL)
  481.           *p_width = atoi(s);
  482.       if (*p_width <= 0)
  483.             *p_width = 80;
  484. --- 110,123 ----
  485.   
  486.       if (w.numtextrows)
  487.           *p_height = w.numtextrows;
  488. !     else if ((s = lgetenv("LINES")) != NULL && *s != '\0')
  489.           *p_height = atoi(s);
  490.       if (*p_height <= 0)
  491.           *p_height = 24;
  492.           
  493.       if (w.numtextcols > 0)
  494.           *p_width = w.numtextcols;
  495. !     else if ((s = lgetenv("COLUMNS")) != NULL)
  496.           *p_width = atoi(s);
  497.       if (*p_width <= 0)
  498.             *p_width = 80;
  499. ***************
  500. *** 181,186 ****
  501. --- 181,211 ----
  502.   
  503.   
  504.   /*
  505. +  * Initialize the screen to the correct color at startup.
  506. +  */
  507. +     static void
  508. + initcolor()
  509. + {
  510. +     struct videoconfig w;
  511. +     char *blanks;
  512. +     int row;
  513. +     int col;
  514. +     
  515. +     /*
  516. +      * Create a complete, blank screen using "normal" colors.
  517. +      */
  518. +     _settextcolor(nm_fg_color);
  519. +     _setbkcolor(nm_bg_color);
  520. +     _getvideoconfig(&w);
  521. +     blanks = (char *) ecalloc(w.numtextcols, sizeof(char));
  522. +     for (col = 0;  col < w.numtextcols;  col++)
  523. +         blanks[col] = ' ';
  524. +     for (row = w.numtextrows;  row > 0;  row--)
  525. +         _outmem(blanks, w.numtextcols);
  526. +     free(blanks);
  527. + }
  528. + /*
  529.    * Initialize terminal
  530.    */
  531.       public void
  532. ***************
  533. *** 189,194 ****
  534. --- 214,220 ----
  535.       /* {{ What could we take no_init (-X) to mean? }} */
  536.       sy_bg_color = _getbkcolor();
  537.       sy_fg_color = _gettextcolor();
  538. +     initcolor();
  539.       flush();
  540.       init_done = 1;
  541.   }
  542. ***************
  543. *** 273,278 ****
  544. --- 299,315 ----
  545.   {
  546.       flush();
  547.       _settextposition(sc_height,1);
  548. + }
  549. + /*
  550. +  * Goto a specific line on the screen.
  551. +  */
  552. +     public void
  553. + goto_line(slinenum)
  554. +     int slinenum;
  555. + {
  556. +     flush();
  557. +     _settextposition(slinenum, 1);
  558.   }
  559.   
  560.   /*
  561. diff -cbr orig/edit.c new/edit.c
  562. *** orig/edit.c    Thu Nov 09 10:35:26 1995
  563. --- new/edit.c    Mon Apr 10 10:05:54 1995
  564. ***************
  565. *** 276,281 ****
  566. --- 276,291 ----
  567.            */
  568.           (void) edit_ifile(was_curr_ifile);
  569.           return (1);
  570. +         } else if ((answer = isZfile(filename)) >= 0)
  571. +     {
  572. +         if ((f = Zopen(filename, answer)) < 0)
  573. +         {
  574. +                         parg.p_string = errno_message(filename);
  575. +             error("%s", &parg);
  576. +             free(parg.p_string);
  577. +             return (1);
  578. +                 }
  579. +         chflags |= CH_COMPRESSED;
  580.       } else if ((f = open(open_filename, OPEN_READ)) < 0)
  581.       {
  582.           /*
  583. diff -cbr orig/filename.c new/filename.c
  584. *** orig/filename.c    Thu Nov 09 11:12:22 1995
  585. --- new/filename.c    Thu Nov 09 10:36:42 1995
  586. ***************
  587. *** 92,105 ****
  588.       /*
  589.        * Try $HOME/filename.
  590.        */
  591. !     pathname = dirfile(getenv("HOME"), filename);
  592.       if (pathname != NULL)
  593.           return (pathname);
  594.   #if OS2
  595.       /*
  596.        * Try $INIT/filename.
  597.        */
  598. !     pathname = dirfile(getenv("INIT"), filename);
  599.       if (pathname != NULL)
  600.           return (pathname);
  601.   #endif
  602. --- 92,105 ----
  603.       /*
  604.        * Try $HOME/filename.
  605.        */
  606. !     pathname = dirfile(lgetenv("HOME"), filename);
  607.       if (pathname != NULL)
  608.           return (pathname);
  609.   #if OS2
  610.       /*
  611.        * Try $INIT/filename.
  612.        */
  613. !     pathname = dirfile(lgetenv("INIT"), filename);
  614.       if (pathname != NULL)
  615.           return (pathname);
  616.   #endif
  617. ***************
  618. *** 124,130 ****
  619.   {
  620.       register char *helpfile;
  621.       
  622. !     if ((helpfile = getenv("LESSHELP")) != NULL)
  623.           return (save(helpfile));
  624.   #if MSOFTC || OS2
  625.       return (homefile(HELPFILE));
  626. --- 124,130 ----
  627.   {
  628.       register char *helpfile;
  629.       
  630. !     if ((helpfile = lgetenv("LESSHELP")) != NULL)
  631.           return (save(helpfile));
  632.   #if MSOFTC || OS2
  633.       return (homefile(HELPFILE));
  634. ***************
  635. *** 134,141 ****
  636.   }
  637.   
  638.   /*
  639. !  * Expand a string, substituting any "%" with the current filename,
  640. !  * and any "#" with the previous filename.
  641.    * {{ This is a lot of work just to support % and #. }}
  642.    */
  643.       public char *
  644. --- 134,143 ----
  645.   }
  646.   
  647.   /*
  648. !  * Expand a string, substituting any single "%" with the current filename,
  649. !  * and any single "#" with the previous filename.
  650. !  * "#" and "%" are self quoting.  Any sequence of 2 or more of them
  651. !  * inserts the sequence - 1 of "%" or "#" chars into the command line.
  652.    * {{ This is a lot of work just to support % and #. }}
  653.    */
  654.       public char *
  655. ***************
  656. *** 145,178 ****
  657.       register char *fr, *to;
  658.       register int n;
  659.       register char *e;
  660.   
  661.       /*
  662.        * Make one pass to see how big a buffer we 
  663.        * need to allocate for the expanded string.
  664.        */
  665.       n = 0;
  666.       for (fr = s;  *fr != '\0';  fr++)
  667.       {
  668.           switch (*fr)
  669.           {
  670.           case '%':
  671. !             if (curr_ifile == NULL_IFILE)
  672.               {
  673. !                 /* error("No current file", NULL_PARG); */
  674. !                 return (save(s));
  675.               }
  676.               n += strlen(get_filename(curr_ifile));
  677.               break;
  678.           case '#':
  679. !             if (old_ifile == NULL_IFILE)
  680.               {
  681. !                 /* error("No previous file", NULL_PARG); */
  682. !                 return (save(s));
  683.               }
  684.               n += strlen(get_filename(old_ifile));
  685.               break;
  686.           default:
  687.               n++;
  688.               break;
  689.           }
  690.       }
  691. --- 147,210 ----
  692.       register char *fr, *to;
  693.       register int n;
  694.       register char *e;
  695. +     int percent_quote = FALSE;  /* Set initial state of machine to */      
  696. +     int hash_quote = FALSE;     /* no sequence in progress. */
  697.   
  698.       /*
  699.        * Make one pass to see how big a buffer we 
  700.        * need to allocate for the expanded string.
  701.        */
  702. +     /*
  703. +      * The self quoting system is a state machine.  We look ahead
  704. +      * one character to put ourselves into one or the other self
  705. +      * quote states, and when we get a different character, we
  706. +      * turn the previous quote state off.  We count and later
  707. +      * insert, 1 less than the actual sequence of special
  708. +      * characters into the output buffer, if there is a sequence.
  709. +      * If there is a file error condition, we no longer bug out,
  710. +      * we just do not count the unexpanded character or place it
  711. +      * in the output buffer and we continue to check the rest of
  712. +      * the string for single "%" or "#"s to expand or sequences to
  713. +      * insert.  
  714. +      */
  715.       n = 0;
  716.       for (fr = s;  *fr != '\0';  fr++)
  717.       {
  718.           switch (*fr)
  719.           {
  720.           case '%':
  721. !                 if (hash_quote)
  722. !                     hash_quote = FALSE;
  723. !                 if (*(fr+1) == '%' || percent_quote)
  724.               {
  725. !                     if (!percent_quote)
  726. !                         percent_quote = TRUE;
  727. !                 else
  728. !                         n++;
  729.               }
  730. +             else if (curr_ifile != NULL_IFILE)
  731.               n += strlen(get_filename(curr_ifile));
  732.               break;
  733.           case '#':
  734. !             if (percent_quote)
  735. !                     percent_quote = FALSE;
  736. !                 if (*(fr+1) == '#' || hash_quote)
  737.               {
  738. !                     if (!hash_quote)
  739. !                         hash_quote = TRUE;
  740. !                 else
  741. !                         n++;
  742.               }
  743. +             else if (old_ifile != NULL_IFILE)
  744.               n += strlen(get_filename(old_ifile));
  745.               break;
  746.           default:
  747.               n++;
  748. +             if (percent_quote || hash_quote)
  749. +             {
  750. +                      percent_quote = FALSE;
  751. +                      hash_quote = FALSE;
  752. +             }
  753.               break;
  754.           }
  755.       }
  756. ***************
  757. *** 183,202 ****
  758. --- 215,269 ----
  759.        * Now copy the string, expanding any "%" or "#".
  760.        */
  761.       to = e;
  762. +     /*
  763. +      * Reset the state machine in case we ended on a sequence 
  764. +      * of "%" or "#" characters.
  765. +      */
  766. +     percent_quote = FALSE;
  767. +     hash_quote = FALSE;
  768.       for (fr = s;  *fr != '\0';  fr++)
  769.       {
  770.           switch (*fr)
  771.           {
  772.           case '%':
  773. +             if (hash_quote)
  774. +                     hash_quote = FALSE;
  775. +                 if (*(fr+1) == '%' || percent_quote)
  776. +             {
  777. +                     if (!percent_quote)
  778. +                         percent_quote = TRUE;
  779. +                 else
  780. +                         *to++ = *fr;
  781. +             }                       
  782. +             else if (curr_ifile != NULL_IFILE)
  783. +                 {
  784.               strcpy(to, get_filename(curr_ifile));
  785.               to += strlen(to);
  786. +             }
  787.               break;
  788.           case '#':
  789. +             if (percent_quote)
  790. +                     percent_quote = FALSE;
  791. +                 if (*(fr+1) == '#' || hash_quote)
  792. +             {
  793. +                     if (!hash_quote)
  794. +                         hash_quote = TRUE;
  795. +                 else
  796. +                         *to++ = *fr;
  797. +             }                       
  798. +             else if (old_ifile != NULL_IFILE)
  799. +             {
  800.               strcpy(to, get_filename(old_ifile));
  801.               to += strlen(to);
  802. +             }
  803.               break;
  804.           default:
  805.               *to++ = *fr;
  806. +             if (percent_quote || hash_quote)
  807. +             {
  808. +                      percent_quote = FALSE;
  809. +                      hash_quote = FALSE;
  810. +             }
  811.               break;
  812.           }
  813.       }
  814. ***************
  815. *** 360,366 ****
  816.       scmd = (char *) ecalloc(len, sizeof(char));
  817.       sprintf(scmd, cmd, s1, s2);
  818.   #if HAVE_SHELL
  819. !     shell = getenv("SHELL");
  820.       if (shell != NULL && *shell != '\0')
  821.       {
  822.           /*
  823. --- 427,433 ----
  824.       scmd = (char *) ecalloc(len, sizeof(char));
  825.       sprintf(scmd, cmd, s1, s2);
  826.   #if HAVE_SHELL
  827. !     shell = lgetenv("SHELL");
  828.       if (shell != NULL && *shell != '\0')
  829.       {
  830.           /*
  831. ***************
  832. *** 395,407 ****
  833.       int length;
  834.   
  835.       list = _fnexplode(filename);
  836. !     length = 1;
  837.       for (cnt = 0;  list[cnt] != NULL;  cnt++)
  838.             length += strlen(list[cnt]) + 1;
  839.       gfilename = (char *) ecalloc(length, sizeof(char));
  840.       for (cnt = 0;  list[cnt] != NULL;  cnt++)
  841.       {
  842.           strcat(gfilename, list[cnt]);
  843.             strcat(gfilename, " ");
  844.       }
  845.       _fnexplodefree(list);
  846. --- 462,477 ----
  847.       int length;
  848.   
  849.       list = _fnexplode(filename);
  850. !     if (list == NULL)
  851. !         return (filename);
  852. !     length = 0;
  853.       for (cnt = 0;  list[cnt] != NULL;  cnt++)
  854.             length += strlen(list[cnt]) + 1;
  855.       gfilename = (char *) ecalloc(length, sizeof(char));
  856.       for (cnt = 0;  list[cnt] != NULL;  cnt++)
  857.       {
  858.           strcat(gfilename, list[cnt]);
  859. +         if (list[cnt+1] != NULL)
  860.             strcat(gfilename, " ");
  861.       }
  862.       _fnexplodefree(list);
  863. ***************
  864. *** 452,458 ****
  865.       FILE *fd;
  866.       
  867.       ch_ungetchar(-1);
  868. !     if ((lessopen = getenv("LESSOPEN")) == NULL)
  869.           return (NULL);
  870.       if (strcmp(filename, "-") == 0)
  871.           return (NULL);
  872. --- 522,528 ----
  873.       FILE *fd;
  874.       
  875.       ch_ungetchar(-1);
  876. !     if ((lessopen = lgetenv("LESSOPEN")) == NULL)
  877.           return (NULL);
  878.       if (strcmp(filename, "-") == 0)
  879.           return (NULL);
  880. ***************
  881. *** 525,531 ****
  882.       
  883.       if (pipefd != NULL)
  884.           pclose((FILE*) pipefd);
  885. !     if ((lessclose = getenv("LESSCLOSE")) == NULL)
  886.                return;
  887.       fd = shellcmd(lessclose, filename, altfilename);
  888.       pclose(fd);
  889. --- 595,601 ----
  890.       
  891.       if (pipefd != NULL)
  892.           pclose((FILE*) pipefd);
  893. !     if ((lessclose = lgetenv("LESSCLOSE")) == NULL)
  894.                return;
  895.       fd = shellcmd(lessclose, filename, altfilename);
  896.       pclose(fd);
  897. diff -cbr orig/forwback.c new/forwback.c
  898. *** orig/forwback.c    Thu Nov 09 10:35:26 1995
  899. --- new/forwback.c    Mon Apr 17 20:00:02 1995
  900. ***************
  901. *** 36,41 ****
  902. --- 36,42 ----
  903.   public int hit_eof;    /* Keeps track of how many times we hit end of file */
  904.   public int screen_trashed;
  905.   public int squished;
  906. + public int no_back_scroll = 0;
  907.   
  908.   extern int sigs;
  909.   extern int top_scroll;
  910. ***************
  911. *** 390,395 ****
  912. --- 391,398 ----
  913.       public int
  914.   get_back_scroll()
  915.   {
  916. +       if (no_back_scroll)
  917. +               return (0);
  918.       if (back_scroll >= 0)
  919.           return (back_scroll);
  920.       if (top_scroll)
  921. diff -cbr orig/funcs.h new/funcs.h
  922. *** orig/funcs.h    Thu Mar 09 22:34:20 1995
  923. --- new/funcs.h    Thu Nov 09 10:36:42 1995
  924. ***************
  925. *** 68,76 ****
  926. --- 68,78 ----
  927.       public void init_cmds ();
  928.       public void add_fcmd_table ();
  929.       public void add_ecmd_table ();
  930. +     public void add_var_table ();
  931.       public int cmd_search ();
  932.       public int fcmd_decode ();
  933.       public int ecmd_decode ();
  934. +     public char * lgetenv ();
  935.       public int lesskey ();
  936.       public void add_hometable ();
  937.       public int editchar ();
  938. diff -cbr orig/less.h new/less.h
  939. *** orig/less.h    Thu Nov 09 10:35:26 1995
  940. --- new/less.h    Mon Apr 10 10:05:54 1995
  941. ***************
  942. *** 244,252 ****
  943.   #define    QUIT_SAVED_STATUS (-1)
  944.   
  945.   /* filestate flags */
  946. ! #define    CH_CANSEEK    001
  947. ! #define    CH_KEEPOPEN    002
  948. ! #define    CH_POPENED    004
  949.   
  950.   #define    ch_zero()    ((POSITION)0)
  951.   
  952. --- 244,253 ----
  953.   #define    QUIT_SAVED_STATUS (-1)
  954.   
  955.   /* filestate flags */
  956. ! #define    CH_CANSEEK    0x01
  957. ! #define    CH_KEEPOPEN    0x02
  958. ! #define    CH_POPENED    0x04
  959. ! #define    CH_COMPRESSED    0x08
  960.   
  961.   #define    ch_zero()    ((POSITION)0)
  962.   
  963. diff -cbr orig/less.nro new/less.nro
  964. *** orig/less.nro    Thu Mar 02 23:15:00 1995
  965. --- new/less.nro    Thu Nov 09 10:36:42 1995
  966. ***************
  967. *** 113,122 ****
  968.   .IP "p or %"
  969.   Go to a position N percent into the file.
  970.   N should be between 0 and 100.
  971. - (This works if standard input is being read, but only if
  972. - .I less
  973. - has already read to the end of the file.
  974. - It is always fast, but not always useful.)
  975.   .PP
  976.   .IP "{"
  977.   If a left curly bracket appears in the top line displayed
  978. --- 113,118 ----
  979. ***************
  980. *** 1164,1169 ****
  981. --- 1160,1169 ----
  982.   changed to modify this default.
  983.   
  984.   .SH "ENVIRONMENT VARIABLES"
  985. + Environment variables may be specified either in the system environment
  986. + as usual, or in a 
  987. + .I lesskey
  988. + (1) file.
  989.   .IP COLUMNS
  990.   Sets the number of columns on the screen.
  991.   Takes precedence over the number of columns specified by the TERM variable.
  992. diff -cbr orig/lesskey.c new/lesskey.c
  993. *** orig/lesskey.c    Thu Nov 09 10:35:28 1995
  994. --- new/lesskey.c    Thu Nov 09 10:36:44 1995
  995. ***************
  996. *** 63,70 ****
  997. --- 63,74 ----
  998.    *
  999.    *    Blank lines and lines which start with # are ignored, 
  1000.    *    except for the special control lines:
  1001. +  *        #command    Signals the beginning of the command
  1002. +  *                keys section.
  1003.    *        #line-edit    Signals the beginning of the line-editing
  1004.    *                keys section.
  1005. +  *        #env        Signals the beginning of the environment
  1006. +  *                variable section.
  1007.    *        #stop        Stops command parsing in less;
  1008.    *                causes all default keys to be disabled.
  1009.    *
  1010. ***************
  1011. *** 96,101 ****
  1012. --- 100,106 ----
  1013.   #include "less.h"
  1014.   #include "lesskey.h"
  1015.   #include "cmd.h"
  1016. + #include <ctype.h>
  1017.   
  1018.   struct cmdname
  1019.   {
  1020. ***************
  1021. *** 190,195 ****
  1022. --- 195,201 ----
  1023.   
  1024.   struct table cmdtable;
  1025.   struct table edittable;
  1026. + struct table vartable;
  1027.   struct table *currtable = &cmdtable;
  1028.   
  1029.   char fileheader[] = {
  1030. ***************
  1031. *** 205,210 ****
  1032. --- 211,217 ----
  1033.   };
  1034.   char cmdsection[1] =    { CMD_SECTION };
  1035.   char editsection[1] =    { EDIT_SECTION };
  1036. + char varsection[1] =    { VAR_SECTION };
  1037.   char endsection[1] =    { END_SECTION };
  1038.   
  1039.   char *infile = NULL;
  1040. ***************
  1041. *** 308,313 ****
  1042. --- 315,323 ----
  1043.   
  1044.       edittable.names = editnames;
  1045.       edittable.pbuffer = edittable.buffer;
  1046. +     vartable.names = NULL;
  1047. +     vartable.pbuffer = vartable.buffer;
  1048.   }
  1049.   
  1050.   /*
  1051. ***************
  1052. *** 450,455 ****
  1053. --- 460,470 ----
  1054.           currtable = &cmdtable;
  1055.           return (1);
  1056.       }
  1057. +     if (PREFIX(s, "#env"))
  1058. +     {
  1059. +         currtable = &vartable;
  1060. +         return (1);
  1061. +     }
  1062.       if (PREFIX(s, "#stop"))
  1063.       {
  1064.           add_cmd_char('\0');
  1065. ***************
  1066. *** 528,561 ****
  1067.   }
  1068.   
  1069.   
  1070. - /*
  1071. -  * Parse a line from the lesskey file.
  1072. -  */
  1073.       void
  1074. ! parse_line(line)
  1075. !     char *line;
  1076. ! {
  1077.       char *p;
  1078.       int cmdlen;
  1079.       char *actname;
  1080.       int action;
  1081.       int c;
  1082.   
  1083.       /*
  1084. -      * See if it is a control line.
  1085. -      */
  1086. -     if (control_line(line))
  1087. -         return;
  1088. -     /*
  1089. -      * Skip leading white space.
  1090. -      * Replace the final newline with a null byte.
  1091. -      * Ignore blank lines and comments.
  1092. -      */
  1093. -     p = clean_line(line);
  1094. -     if (*p == '\0')
  1095. -         return;
  1096. -     /*
  1097.        * Parse the command string and store it in the current table.
  1098.        */
  1099.       cmdlen = 0;
  1100. --- 543,558 ----
  1101.   }
  1102.   
  1103.   
  1104.       void
  1105. ! parse_cmdline(p)
  1106.       char *p;
  1107. + {
  1108.       int cmdlen;
  1109.       char *actname;
  1110.       int action;
  1111.       int c;
  1112.   
  1113.       /*
  1114.        * Parse the command string and store it in the current table.
  1115.        */
  1116.       cmdlen = 0;
  1117. ***************
  1118. *** 614,619 ****
  1119. --- 611,679 ----
  1120.       }
  1121.   }
  1122.   
  1123. +     void
  1124. + parse_varline(p)
  1125. +     char *p;
  1126. + {
  1127. +     int c;
  1128. +     do
  1129. +     {
  1130. +         c = tchar(&p);
  1131. +         add_cmd_char(toupper(c));
  1132. +     } while (*p != ' ' && *p != '\t' && *p != '=' && *p != '\0');
  1133. +     /*
  1134. +      * Terminate the variable name with a null byte.
  1135. +      */
  1136. +     add_cmd_char('\0');
  1137. +     p = skipsp(p);
  1138. +     if (*p++ != '=')
  1139. +     {
  1140. +         error("missing =");
  1141. +         return;
  1142. +     }
  1143. +     add_cmd_char(EV_OK|A_EXTRA);
  1144. +     p = skipsp(p);
  1145. +     while (*p != '\0')
  1146. +     {
  1147. +         c = tchar(&p);
  1148. +         add_cmd_char(c);
  1149. +     }
  1150. +     add_cmd_char('\0');
  1151. + }
  1152. + /*
  1153. +  * Parse a line from the lesskey file.
  1154. +  */
  1155. +     void
  1156. + parse_line(line)
  1157. +     char *line;
  1158. + {
  1159. +     char *p;
  1160. +     /*
  1161. +      * See if it is a control line.
  1162. +      */
  1163. +     if (control_line(line))
  1164. +         return;
  1165. +     /*
  1166. +      * Skip leading white space.
  1167. +      * Replace the final newline with a null byte.
  1168. +      * Ignore blank lines and comments.
  1169. +      */
  1170. +     p = clean_line(line);
  1171. +     if (*p == '\0')
  1172. +         return;
  1173. +     if (currtable == &vartable)
  1174. +         parse_varline(p);
  1175. +     else
  1176. +         parse_cmdline(p);
  1177. + }
  1178.   main(argc, argv)
  1179.       int argc;
  1180.       char *argv[];
  1181. ***************
  1182. *** 622,627 ****
  1183. --- 682,692 ----
  1184.       FILE *out;
  1185.       char line[200];
  1186.   
  1187. + #ifdef OS2
  1188. +         if (argc == 1)
  1189. +           usage();
  1190. + #endif
  1191.       /*
  1192.        * Process command line arguments.
  1193.        */
  1194. ***************
  1195. *** 679,684 ****
  1196. --- 744,754 ----
  1197.       fputbytes(out, editsection, sizeof(editsection));
  1198.       fputint(out, edittable.pbuffer - edittable.buffer);
  1199.       fputbytes(out, (char *)edittable.buffer, edittable.pbuffer-edittable.buffer);
  1200. +     /* Environment variable section */
  1201. +     fputbytes(out, varsection, sizeof(varsection)); 
  1202. +     fputint(out, vartable.pbuffer - vartable.buffer);
  1203. +     fputbytes(out, (char *)vartable.buffer, vartable.pbuffer-vartable.buffer);
  1204.   
  1205.       /* File trailer */
  1206.       fputbytes(out, endsection, sizeof(endsection));
  1207. diff -cbr orig/lesskey.h new/lesskey.h
  1208. *** orig/lesskey.h    Wed Feb 01 01:55:52 1995
  1209. --- new/lesskey.h    Thu Nov 09 10:36:44 1995
  1210. ***************
  1211. *** 18,23 ****
  1212. --- 18,24 ----
  1213.   
  1214.   #define    CMD_SECTION        'c'
  1215.   #define    EDIT_SECTION        'e'
  1216. + #define    VAR_SECTION        'v'
  1217.   #define    END_SECTION        'x'
  1218.   
  1219.   #define    C0_END_LESSKEY_MAGIC    'E'
  1220. diff -cbr orig/lesskey.nro new/lesskey.nro
  1221. *** orig/lesskey.nro    Wed Feb 01 01:55:56 1995
  1222. --- new/lesskey.nro    Thu Nov 09 10:36:46 1995
  1223. ***************
  1224. *** 19,25 ****
  1225.   .I lesskey
  1226.   will overwrite it.
  1227.   .PP
  1228. ! The input file consists of lines of the form:
  1229.   .sp
  1230.       \fIstring\fP <whitespace> \fIaction\fP [extra-string] <newline>
  1231.   .sp
  1232. --- 19,51 ----
  1233.   .I lesskey
  1234.   will overwrite it.
  1235.   .PP
  1236. ! The -V flag causes
  1237. ! .I lesskey
  1238. ! to print its version number and immediately exit.  
  1239. ! If -V is present, other flags and arguments are ignored.
  1240. ! .PP
  1241. ! The input file consists of one or more
  1242. ! .I sections.
  1243. ! Each section starts with a line that identifies the type of section.
  1244. ! Possible sections are:
  1245. ! .IP #command
  1246. ! Defines new command keys.
  1247. ! .IP #line-edit
  1248. ! Defines new line-editing keys.
  1249. ! .IP #env
  1250. ! Defines environment variables.
  1251. ! .PP
  1252. ! Blank lines and lines which start with a pound sign (#) are ignored,
  1253. ! except for the special section header lines.
  1254. ! .SH "COMMAND SECTION"
  1255. ! The command section begins with the line
  1256. ! .sp
  1257. ! #command
  1258. ! .sp
  1259. ! If the command section is the first section in the file,
  1260. ! this line may be omitted.
  1261. ! The command section consists of lines of the form:
  1262.   .sp
  1263.       \fIstring\fP <whitespace> \fIaction\fP [extra-string] <newline>
  1264.   .sp
  1265. ***************
  1266. *** 37,43 ****
  1267.   to be taken literally.
  1268.   Characters which must be preceded by backslash include
  1269.   caret, space, tab and the backslash itself.
  1270. - Blank lines and lines which start with a pound sign (#) are ignored.
  1271.   .PP
  1272.   An action may be followed by an "extra" string.
  1273.   When such a command is entered while running
  1274. --- 63,68 ----
  1275. ***************
  1276. *** 48,64 ****
  1277.   This feature can be used in certain cases to extend
  1278.   the functionality of a command.
  1279.   For example, see the "{" and ":t" commands in the example below.
  1280. - .PP
  1281. - The -V flag causes
  1282. - .I lesskey
  1283. - to print its version number and immediately exit.  
  1284. - Other flags and arguments are ignored.
  1285.   
  1286.   .SH EXAMPLE
  1287.   The following input file describes the set of
  1288.   default command keys used by less:
  1289.   .sp
  1290.   .nf
  1291.       \er        forw-line 
  1292.       \en        forw-line 
  1293.       e        forw-line 
  1294. --- 73,85 ----
  1295.   This feature can be used in certain cases to extend
  1296.   the functionality of a command.
  1297.   For example, see the "{" and ":t" commands in the example below.
  1298.   
  1299.   .SH EXAMPLE
  1300.   The following input file describes the set of
  1301.   default command keys used by less:
  1302.   .sp
  1303.   .nf
  1304. +     #command
  1305.       \er        forw-line 
  1306.       \en        forw-line 
  1307.       e        forw-line 
  1308. ***************
  1309. *** 164,170 ****
  1310.   .sp
  1311.   This will cause all default commands to be ignored.
  1312.   The #stop line should be the last line in that section of the file.
  1313. - (Another section, introduced by #line-edit, may follow the #stop line.)
  1314.   .PP
  1315.   Be aware that #stop can be dangerous.  
  1316.   Since all default commands are disabled, 
  1317. --- 185,190 ----
  1318. ***************
  1319. *** 172,186 ****
  1320.   to enable all necessary actions.
  1321.   For example, failure to provide a "quit" command can lead to frustration.
  1322.   
  1323. ! .SH "LINE EDITING"
  1324. ! New key bindings may be specified for the line editing commands,
  1325. ! in a manner similar to the way key bindings for 
  1326. ! ordinary commands are specified.
  1327. ! This control line marks the beginning of a section of line-editing commands:
  1328.   .sp
  1329.   #line-edit
  1330.   .sp
  1331. ! Following this line is a list of keys and actions,
  1332.   one per line as in the example below.
  1333.   
  1334.   .SH EXAMPLE
  1335. --- 192,206 ----
  1336.   to enable all necessary actions.
  1337.   For example, failure to provide a "quit" command can lead to frustration.
  1338.   
  1339. ! .SH "LINE EDITING SECTION"
  1340. ! The line-editing section begins with the line:
  1341.   .sp
  1342.   #line-edit
  1343.   .sp
  1344. ! This section specifies new key bindings for the line editing commands,
  1345. ! in a manner similar to the way key bindings for 
  1346. ! ordinary commands are specified in the #command section.
  1347. ! The line-editing section consists of a list of keys and actions,
  1348.   one per line as in the example below.
  1349.   
  1350.   .SH EXAMPLE
  1351. ***************
  1352. *** 209,216 ****
  1353. --- 229,273 ----
  1354.   .fi
  1355.   .sp
  1356.   
  1357. + .SH "LESS ENVIRONMENT VARIABLES"
  1358. + The environment variable section begins with the line
  1359. + .sp
  1360. + #env
  1361. + .sp
  1362. + Following this line is a list of environment variable assignments.
  1363. + Each line consists of an environment variable name, an equals sign (=)
  1364. + and the value to be assigned to the environment variable.
  1365. + White space before and after the equals sign is ignored.
  1366. + Variables assigned in this way are visible only to
  1367. + .I less.
  1368. + If a variable is specified in the system environment and also in a
  1369. + lesskey file, the value in the lesskey file takes precedence.
  1370. + Although the lesskey file can be used to override variables set in the
  1371. + environment, the main purpose of assigning variables in the lesskey file
  1372. + is simply to have all 
  1373. + .I less
  1374. + configuration information stored in one file.
  1375. + .SH EXAMPLE
  1376. + The following input file sets the -i flag whenever 
  1377. + .I less
  1378. + is run, and specifies the character set to be "latin1":
  1379. + .sp
  1380. + .nf
  1381. +     #env
  1382. +     LESS = -i
  1383. +     LESSCHARSET = latin1
  1384. + .fi
  1385. + .sp
  1386.   .SH "SEE ALSO"
  1387.   less(1)
  1388. + .SH WARNINGS
  1389. + It is not possible to specify special keys, such as uparrow, 
  1390. + in a keyboard-independent manner.
  1391. + The only way to specify such keys is to specify the escape sequence
  1392. + which a particular keyboard sends when such a keys is pressed.
  1393.   
  1394.   .SH COPYRIGHT
  1395.   Copyright (c) 1984,1985,1989,1994,1995  Mark Nudelman
  1396. diff -cbr orig/lsystem.c new/lsystem.c
  1397. *** orig/lsystem.c    Wed Feb 01 01:55:58 1995
  1398. --- new/lsystem.c    Thu Nov 09 10:36:46 1995
  1399. ***************
  1400. *** 110,116 ****
  1401.        */
  1402.   #if HAVE_SHELL
  1403.       p = NULL;
  1404. !     if ((shell = getenv("SHELL")) != NULL && *shell != '\0')
  1405.       {
  1406.           if (*cmd == '\0')
  1407.               p = save(shell);
  1408. --- 110,116 ----
  1409.        */
  1410.   #if HAVE_SHELL
  1411.       p = NULL;
  1412. !     if ((shell = lgetenv("SHELL")) != NULL && *shell != '\0')
  1413.       {
  1414.           if (*cmd == '\0')
  1415.               p = save(shell);
  1416. diff -cbr orig/main.c new/main.c
  1417. *** orig/main.c    Thu Nov 09 10:35:28 1995
  1418. --- new/main.c    Thu Nov 09 10:27:08 1995
  1419. ***************
  1420. *** 78,86 ****
  1421. --- 78,98 ----
  1422.   {
  1423.       IFILE ifile;
  1424.   
  1425. + #if OS2
  1426.   #ifdef __EMX__
  1427.       _response(&argc, &argv);
  1428.       _wildcard(&argc, &argv);
  1429. + #endif
  1430. +     if (isatty(0) && argc == 1)
  1431. +     {
  1432. +       extern char version[];
  1433. +       printf("\nless  version %s.\n", version);
  1434. +       printf("\nUsage: less [-[+]aABcCdeEfgimMnNqQruUsw] [-bN] [-hN] [-xN] [-[z]N]"
  1435. +              "\n            [-P[mM=]string] [-[lL]logfile] [-kkeyfile]"
  1436. +              "\n            [+cmd] [-ttag] [filename]...\n"
  1437. +              "\n   or: less -?\n", progname);
  1438. +       exit(1);
  1439. +     }
  1440.   #endif
  1441.   
  1442.       progname = *argv++;
  1443. diff -cbr orig/Makefile.dos new/makefile.dos
  1444. *** orig/Makefile.dos    Wed Feb 01 01:55:16 1995
  1445. --- new/makefile.dos    Thu Nov 09 10:36:46 1995
  1446. ***************
  1447. *** 6,21 ****
  1448.   CC = cl
  1449.   LIBDIR = \msc6.0\lib
  1450.   
  1451. ! CFLAGS = -O /Alfw
  1452.   LDFLAGS = -O
  1453. ! LIBS = ${LIBDIR}\llibce.lib ${LIBDIR}\graphics.lib
  1454.   
  1455.   #### End of system configuration section. ####
  1456.   
  1457.   # This rule allows us to supply the necessary -D options
  1458.   # in addition to whatever the user asks for.
  1459.   .c.obj:
  1460. !     ${CC} -c -I. ${CPPFLAGS} ${CFLAGS} $<
  1461.   
  1462.   SRC =    main.c doscreen.c brac.c ch.c charset.c cmdbuf.c command.c \
  1463.       decode.c edit.c filename.c forwback.c help.c ifile.c \
  1464. --- 6,21 ----
  1465.   CC = cl
  1466.   LIBDIR = \msc6.0\lib
  1467.   
  1468. ! CFLAGS = -O -Alfw
  1469.   LDFLAGS = -O
  1470. ! LIBS = $(LIBDIR)\llibce.lib $(LIBDIR)\graphics.lib
  1471.   
  1472.   #### End of system configuration section. ####
  1473.   
  1474.   # This rule allows us to supply the necessary -D options
  1475.   # in addition to whatever the user asks for.
  1476.   .c.obj:
  1477. !     $(CC) -c -I. $(CPPFLAGS) $(CFLAGS) $<
  1478.   
  1479.   SRC =    main.c doscreen.c brac.c ch.c charset.c cmdbuf.c command.c \
  1480.       decode.c edit.c filename.c forwback.c help.c ifile.c \
  1481. ***************
  1482. *** 30,48 ****
  1483.       position.obj prompt.obj search.obj signal.obj tags.obj \
  1484.       ttyin.obj version.obj
  1485.   
  1486. ! all: less lesskey
  1487.   
  1488.   # This is really horrible, but the command line is too long for 
  1489.   # MS-DOS if we try to link $(OBJ).
  1490. ! less: $(OBJ)
  1491. !     -del lesskey.obj
  1492.       $(CC) $(LDFLAGS) -o $@ *.obj $(LIBS)
  1493.   
  1494. ! lesskey: lesskey.obj version.obj
  1495.       $(CC) $(LDFLAGS) -o $@ lesskey.obj version.obj $(LIBS)
  1496.   
  1497.   defines.h: defines.dos
  1498. -     -del defines.h
  1499.       -copy defines.dos defines.h
  1500.   
  1501.   $(OBJ): less.h defines.h
  1502. --- 30,48 ----
  1503.       position.obj prompt.obj search.obj signal.obj tags.obj \
  1504.       ttyin.obj version.obj
  1505.   
  1506. ! all: less.exe lesskey.exe
  1507.   
  1508.   # This is really horrible, but the command line is too long for 
  1509.   # MS-DOS if we try to link $(OBJ).
  1510. ! less.exe: $(OBJ)
  1511. !     -ren lesskey.obj lesskey.obo
  1512.       $(CC) $(LDFLAGS) -o $@ *.obj $(LIBS)
  1513. +     -ren lesskey.obo lesskey.obj
  1514.   
  1515. ! lesskey.exe: lesskey.obj version.obj
  1516.       $(CC) $(LDFLAGS) -o $@ lesskey.obj version.obj $(LIBS)
  1517.   
  1518.   defines.h: defines.dos
  1519.       -copy defines.dos defines.h
  1520.   
  1521.   $(OBJ): less.h defines.h
  1522. diff -cbr orig/Makefile.in new/makefile.in
  1523. *** orig/Makefile.in    Mon Mar 13 23:41:54 1995
  1524. --- new/makefile.in    Thu Nov 09 10:36:46 1995
  1525. ***************
  1526. *** 116,123 ****
  1527.   lint:
  1528.       lint -I. ${CPPFLAGS} ${SRC}
  1529.   newfuncs:
  1530. !     mv -f funcs.h funcs.h.old
  1531. !     awk -f mkfuncs.awk ${SRC} >funcs.h
  1532.   clean:
  1533.       rm -f *.${O} core less lesskey
  1534.   
  1535. --- 116,123 ----
  1536.   lint:
  1537.       lint -I. ${CPPFLAGS} ${SRC}
  1538.   newfuncs:
  1539. !     mv -f ${srcdir}/funcs.h ${srcdir}/funcs.h.old
  1540. !     awk -f ${srcdir}/mkfuncs.awk ${SRC:%=${srcdir}/%} >${srcdir}/funcs.h
  1541.   clean:
  1542.       rm -f *.${O} core less lesskey
  1543.   
  1544. diff -cbr orig/Makefile.os2 new/makefile.os2
  1545. *** orig/Makefile.os2    Thu Nov 09 10:35:28 1995
  1546. --- new/makefile.os2    Thu Nov 09 10:36:46 1995
  1547. ***************
  1548. *** 11,20 ****
  1549.   
  1550.   #### End of system configuration section. ####
  1551.   
  1552. - .SUFFIXES: .c .$(O)
  1553.   # This rule allows us to supply the necessary -D options
  1554.   # in addition to whatever the user asks for.
  1555.   .c.$(O):
  1556.       ${CC} -c ${CPPFLAGS} ${CFLAGS} $<
  1557.   
  1558. --- 11,20 ----
  1559.   
  1560.   #### End of system configuration section. ####
  1561.   
  1562.   # This rule allows us to supply the necessary -D options
  1563.   # in addition to whatever the user asks for.
  1564. + .SUFFIXES: .c .$(O)
  1565.   .c.$(O):
  1566.       ${CC} -c ${CPPFLAGS} ${CFLAGS} $<
  1567.   
  1568. ***************
  1569. *** 23,29 ****
  1570.       help.$(O) ifile.$(O) input.$(O) jump.$(O) line.$(O) linenum.$(O) \
  1571.       lsystem.$(O) mark.$(O) optfunc.$(O) option.$(O) opttbl.$(O) os.$(O) \
  1572.       output.$(O) position.$(O) prompt.$(O) search.$(O) signal.$(O) \
  1573. !     tags.$(O) ttyin.$(O) version.$(O)  regexp.$(O)
  1574.   
  1575.   all:    less.exe lesskey.exe
  1576.   
  1577. --- 23,29 ----
  1578.       help.$(O) ifile.$(O) input.$(O) jump.$(O) line.$(O) linenum.$(O) \
  1579.       lsystem.$(O) mark.$(O) optfunc.$(O) option.$(O) opttbl.$(O) os.$(O) \
  1580.       output.$(O) position.$(O) prompt.$(O) search.$(O) signal.$(O) \
  1581. !     tags.$(O) ttyin.$(O) version.$(O) regexp.$(O) zfiles.$(O)
  1582.   
  1583.   all:    less.exe lesskey.exe
  1584.   
  1585. ***************
  1586. *** 31,37 ****
  1587.       $(CC) $(OBJ) -o $@ $(LDFLAGS) $(LIBS)
  1588.   
  1589.   lesskey.exe: lesskey.$(O) version.$(O)
  1590. !     $(CC) $(CFLAGS) lesskey.$(O) version.$(O) -o $@ $(LDFLAGS)
  1591.   
  1592.   $(OBJ): defines.h less.h
  1593.   
  1594. --- 31,37 ----
  1595.       $(CC) $(OBJ) -o $@ $(LDFLAGS) $(LIBS)
  1596.   
  1597.   lesskey.exe: lesskey.$(O) version.$(O)
  1598. !     $(CC) lesskey.$(O) version.$(O) -o $@ $(LDFLAGS)
  1599.   
  1600.   $(OBJ): defines.h less.h
  1601.   
  1602. diff -cbr orig/NEWS new/news
  1603. *** orig/NEWS    Sat Mar 11 03:46:58 1995
  1604. --- new/news    Thu Nov 09 10:36:48 1995
  1605. ***************
  1606. *** 1,3 ****
  1607. --- 1,12 ----
  1608. +     Major changes between "less" versions 290 and 291
  1609. + * Less environment variables can be specified in lesskey files.
  1610. + * Fixed MS-DOS build.
  1611. + ======================================================================
  1612.       Major changes between "less" versions 278 and 290
  1613.   
  1614.   * Accepts GNU-style options "--help" and "--version".
  1615. diff -cbr orig/os.c new/os.c
  1616. *** orig/os.c    Wed Feb 01 01:56:06 1995
  1617. --- new/os.c    Thu Nov 09 10:36:48 1995
  1618. ***************
  1619. *** 177,183 ****
  1620. --- 177,187 ----
  1621.       register char *p;
  1622.       register char *m;
  1623.   #if HAVE_ERRNO
  1624. + #if MSOFTC
  1625. +     /* errno is declared in errno.h */
  1626. + #else
  1627.       extern int errno;
  1628. + #endif
  1629.       p = strerror(errno);
  1630.   #else
  1631.       p = "cannot open";
  1632. diff -cbr orig/README new/readme
  1633. *** orig/README    Tue Apr 18 09:34:36 1995
  1634. --- new/readme    Thu Nov 09 10:37:20 1995
  1635. ***************
  1636. *** 1,5 ****
  1637.   =======================================================================
  1638. ! ===        NOTE: THIS IS A DISTRIBUTION OF less (version 290)       ===
  1639.   ===    PLEASE REPORT ANY PROBLEMS TO THE AUTHOR AT markn@3do.com.   ===
  1640.   =======================================================================
  1641.   
  1642. --- 1,5 ----
  1643.   =======================================================================
  1644. ! ===        NOTE: THIS IS A DISTRIBUTION OF less (version 291)       ===
  1645.   ===    PLEASE REPORT ANY PROBLEMS TO THE AUTHOR AT markn@3do.com.   ===
  1646.   =======================================================================
  1647.   
  1648. ***************
  1649. *** 125,127 ****
  1650. --- 125,132 ----
  1651.      lesskey.exe and less.hlp in a directory which is included in 
  1652.      your PATH.
  1653.   
  1654. + 9. Make sure, you have the emx runtime installed. You need the emx DLL's
  1655. +    emx.dll and emxlibcs.dll an also the termcap database, termcap.dat.
  1656. +    Make sure you have termcap.dat either in the default location or
  1657. +    or somewhere in a directory listed in the PATH or INIT environment 
  1658. +    variables.
  1659. diff -cbr orig/screen.c new/screen.c
  1660. *** orig/screen.c    Thu Nov 09 10:35:44 1995
  1661. --- new/screen.c    Thu Nov 09 10:46:12 1995
  1662. ***************
  1663. *** 133,139 ****
  1664.   
  1665.   extern int quiet;        /* If VERY_QUIET, use visual bell for bell */
  1666.   extern int know_dumb;        /* Don't complain about a dumb terminal */
  1667. ! extern int back_scroll;
  1668.   extern int swindow;
  1669.   extern int no_init;
  1670.   #if HILITE_SEARCH
  1671. --- 133,139 ----
  1672.   
  1673.   extern int quiet;        /* If VERY_QUIET, use visual bell for bell */
  1674.   extern int know_dumb;        /* Don't complain about a dumb terminal */
  1675. ! extern int no_back_scroll;
  1676.   extern int swindow;
  1677.   extern int no_init;
  1678.   #if HILITE_SEARCH
  1679. ***************
  1680. *** 461,467 ****
  1681.       else
  1682.   #endif
  1683.   #endif
  1684. !     if ((s = getenv("LINES")) != NULL)
  1685.           sc_height = atoi(s);
  1686.       else
  1687.            sc_height = tgetnum("li");
  1688. --- 461,467 ----
  1689.       else
  1690.   #endif
  1691.   #endif
  1692. !     if ((s = lgetenv("LINES")) != NULL)
  1693.           sc_height = atoi(s);
  1694.       else
  1695.            sc_height = tgetnum("li");
  1696. ***************
  1697. *** 479,485 ****
  1698.       else
  1699.   #endif
  1700.   #endif
  1701. !     if ((s = getenv("COLUMNS")) != NULL)
  1702.           sc_width = atoi(s);
  1703.       else
  1704.            sc_width = tgetnum("co");
  1705. --- 479,485 ----
  1706.       else
  1707.   #endif
  1708.   #endif
  1709. !     if ((s = lgetenv("COLUMNS")) != NULL)
  1710.           sc_width = atoi(s);
  1711.       else
  1712.            sc_width = tgetnum("co");
  1713. ***************
  1714. *** 575,580 ****
  1715. --- 575,581 ----
  1716.       sp = tbuf;
  1717.       if ((s = tgetstr("kh", &sp)) != NULL) 
  1718.       {
  1719. +         put_fcmd(s, A_GOLINE);
  1720.           put_ecmd(s, EC_HOME);
  1721.       }
  1722.   
  1723. ***************
  1724. *** 582,587 ****
  1725. --- 583,589 ----
  1726.       sp = tbuf;
  1727.       if ((s = tgetstr("@7", &sp)) != NULL) 
  1728.       {
  1729. +         put_fcmd(s, A_GOEND);
  1730.           put_ecmd(s, EC_END);
  1731.       }
  1732.   
  1733. ***************
  1734. *** 613,620 ****
  1735.       /*
  1736.        * Register the two tables.
  1737.        */
  1738. !     add_fcmd_table(kfcmdtable, sz_kfcmdtable);
  1739. !     add_ecmd_table(kecmdtable, sz_kecmdtable);
  1740.   }
  1741.   
  1742.   #if DEBUG
  1743. --- 615,622 ----
  1744.       /*
  1745.        * Register the two tables.
  1746.        */
  1747. !     insert_fcmd_table(kfcmdtable, sz_kfcmdtable);
  1748. !     insert_ecmd_table(kecmdtable, sz_kecmdtable);
  1749.   }
  1750.   
  1751.   #if DEBUG
  1752. ***************
  1753. *** 664,675 ****
  1754.       char termbuf[2048];
  1755.   
  1756.       static char sbuf[1024];
  1757.   
  1758.   #ifdef OS2
  1759.       /*
  1760.        * Make sure the termcap database is available.
  1761.        */
  1762. !     sp = getenv("TERMCAP");
  1763.       if (sp == NULL || *sp == '\0')
  1764.       {
  1765.           char *termcap;
  1766. --- 666,678 ----
  1767.       char termbuf[2048];
  1768.   
  1769.       static char sbuf[1024];
  1770. +     PARG parg;
  1771.   
  1772.   #ifdef OS2
  1773.       /*
  1774.        * Make sure the termcap database is available.
  1775.        */
  1776. !     sp = lgetenv("TERMCAP");
  1777.       if (sp == NULL || *sp == '\0')
  1778.       {
  1779.           char *termcap;
  1780. ***************
  1781. *** 685,695 ****
  1782.       /*
  1783.        * Find out what kind of terminal this is.
  1784.        */
  1785. !      if ((term = getenv("TERM")) == NULL)
  1786.            term = DEFAULT_TERM;
  1787. !      if (tgetent(termbuf, term) <= 0)
  1788.            strcpy(termbuf, "dumb:hc:");
  1789.   
  1790.        hard = tgetflag("hc");
  1791.   
  1792.       /*
  1793. --- 688,708 ----
  1794.       /*
  1795.        * Find out what kind of terminal this is.
  1796.        */
  1797. !      if ((term = lgetenv("TERM")) == NULL)
  1798.            term = DEFAULT_TERM;
  1799. !     /*Borrow "hard" here to output error messages */
  1800. !      if ((hard = tgetent(termbuf, term)) <= 0)
  1801.            strcpy(termbuf, "dumb:hc:");
  1802.   
  1803. +     if (hard == 0 && !know_dumb)
  1804. +     {
  1805. +       parg.p_string = term;      
  1806. +       error("WARNING: terminal \"%s\" not found in termcap database.",&parg);
  1807. +     }
  1808. +     else if (hard == -1 && !know_dumb)
  1809. +       error("WARNING: The termcap database was not found.",NULL_PARG);
  1810. +          
  1811. +     /* hard now goes back to its original purpose.... */
  1812.        hard = tgetflag("hc");
  1813.   
  1814.       /*
  1815. ***************
  1816. *** 910,916 ****
  1817.           /*
  1818.            * Force repaint on any backward movement.
  1819.            */
  1820. !         back_scroll = 0;
  1821.       }
  1822.   }
  1823.   
  1824. --- 923,929 ----
  1825.           /*
  1826.            * Force repaint on any backward movement.
  1827.            */
  1828. !               no_back_scroll = 1;
  1829.       }
  1830.   }
  1831.   
  1832. diff -cbr orig/ttyin.c new/ttyin.c
  1833. *** orig/ttyin.c    Thu Nov 09 10:35:44 1995
  1834. --- new/ttyin.c    Mon Apr 10 10:06:00 1995
  1835. ***************
  1836. *** 83,93 ****
  1837.               return (READ_INTR);
  1838.   #else
  1839.   #if OS2
  1840.           flush();
  1841. !         while (_read_kbd(0, 0, 0) != -1)
  1842. !             continue;
  1843.           if ((c = _read_kbd(0, 1, 0)) == -1)
  1844. !             return (READ_INTR);
  1845.           result = 1;
  1846.   #else
  1847.           result = iread(tty, &c, sizeof(char));
  1848. --- 83,104 ----
  1849.               return (READ_INTR);
  1850.   #else
  1851.   #if OS2
  1852. +           static int scan = -1;
  1853.           flush();
  1854. !         if (scan != -1)
  1855. !         {
  1856. !             c = scan;
  1857. !             scan = -1;
  1858. !         }
  1859. !         else
  1860. !         {
  1861. !               /* while ( _read_kbd(0, 0, 0) != -1)
  1862. !                    continue; */
  1863.           if ((c = _read_kbd(0, 1, 0)) == -1)
  1864. !                   return READ_INTR;
  1865. !             if (c == 0 && (scan = _read_kbd(0, 0, 0)) != -1)
  1866. !                   c = 0xE0;
  1867. !         }
  1868.           result = 1;
  1869.   #else
  1870.           result = iread(tty, &c, sizeof(char));
  1871. diff -cbr orig/version.c new/version.c
  1872. *** orig/version.c    Tue Mar 14 00:07:06 1995
  1873. --- new/version.c    Thu Nov 09 10:36:50 1995
  1874. ***************
  1875. *** 507,513 ****
  1876.           hilite_line more than once.
  1877.   v290   3/9/95    Make configure automatically.  Fix Sequent problem
  1878.           with incompatible sigsetmask().
  1879.   
  1880.   */
  1881.   
  1882. ! char version[] = "290";
  1883. --- 507,516 ----
  1884.           hilite_line more than once.
  1885.   v290   3/9/95    Make configure automatically.  Fix Sequent problem
  1886.           with incompatible sigsetmask().
  1887. +         Posted to prep.ai.mit.edu
  1888. + -----------------------------------------------------------------
  1889. + v291   3/21/95    Add #env to lesskey.  Fix MS-DOS build.
  1890.   
  1891.   */
  1892.   
  1893. ! char version[] = "291";
  1894.