home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3162 < prev    next >
Encoding:
Internet Message Format  |  1991-04-03  |  39.0 KB

  1. From: mark@unix386.Convergent.COM (Mark Nudelman)
  2. Newsgroups: alt.sources
  3. Subject: less version 170, Patch #2
  4. Message-ID: <7152@unix386.Convergent.COM>
  5. Date: 3 Apr 91 05:14:25 GMT
  6.  
  7. This is a set of patches to less version 170.
  8.  
  9. Most of the patches included here are bug fixes and
  10. improvements to the documentation (man page and help file).
  11. There are just a few changes to functionality:
  12.  
  13. 1. The N command now reverses the direction of the last search
  14.    initiated by a / or ? command.  In version 170, N reversed
  15.    the direction of the last search, even if the last search
  16.    was initiated by an N command.  The new behavior matches 
  17.    that of vi.
  18.  
  19. 2. The | command now pipes data between the top line on the
  20.    screen and the marked line, inclusive.  This may be less
  21.    than the current screen.  Version 170 did not include the
  22.    marked line, and forced the piped data to include the 
  23.    current screen at a minimum.
  24.  
  25. 3. The LESSBINFMT variable has been extended to allow changing or
  26.    disabling the blinking mode used to display binary characters.
  27.  
  28. 4. A new variable LESSHELP has been added to specify an
  29.    alternate help file.
  30.  
  31. This set of patches INCLUDES patch #1 which was previously 
  32. posted to fix a bug in the -? option.
  33. To minimize the size of this patch, changes to the man page 
  34. nroff source "less.nro" are included, but the corresponding 
  35. changes to the formatted man page "less.man" are not.
  36.  
  37. Mark Nudelman
  38. {uunet,sun,decwrl,hplabs}!pyramid!ctnews!unix386!mark
  39.  
  40. ------------------------- cut here ------------------------- 
  41.  
  42. *** less.170/ch.c    Wed Mar  6 12:16:40 1991
  43. --- less/ch.c    Tue Apr  2 23:38:26 1991
  44. ***************
  45. *** 34,40 ****
  46.    * simply re-reading the file, but a pipe cannot be re-read.
  47.    */
  48.   
  49. ! static struct filestate {
  50.       struct buf *next, *prev;   /* Must be first to match struct buf */
  51.       POSITION fpos;
  52.       int nbufs;
  53. --- 34,40 ----
  54.    * simply re-reading the file, but a pipe cannot be re-read.
  55.    */
  56.   
  57. ! struct filestate {
  58.       struct buf *next, *prev;   /* Must be first to match struct buf */
  59.       POSITION fpos;
  60.       int nbufs;
  61. ***************
  62. *** 65,70 ****
  63. --- 65,71 ----
  64.   extern int sigs;
  65.   #if LOGFILE
  66.   extern int logfile;
  67. + extern char *namelogfile;
  68.   #endif
  69.   
  70.   static int ch_addbuf();
  71. ***************
  72. *** 167,173 ****
  73.        * If we have a log file, write the new data to it.
  74.        */
  75.       if (logfile >= 0 && n > 0)
  76. !         write(logfile, &bp->data[bp->datasize], n);
  77.   #endif
  78.   
  79.       bp->datasize += n;
  80. --- 168,174 ----
  81.        * If we have a log file, write the new data to it.
  82.        */
  83.       if (logfile >= 0 && n > 0)
  84. !         write(logfile, (char *) &bp->data[bp->datasize], n);
  85.   #endif
  86.   
  87.       bp->datasize += n;
  88. ***************
  89. *** 242,247 ****
  90. --- 243,249 ----
  91.       }
  92.       close(logfile);
  93.       logfile = -1;
  94. +     namelogfile = NULL;
  95.   }
  96.   
  97.   /*
  98. ***************
  99. *** 261,267 ****
  100.           for (bp = buf_head;  bp != END_OF_CHAIN;  bp = bp->next)
  101.               if (bp->block == block)
  102.               {
  103. !                 write(logfile, bp->data, bp->datasize);
  104.                   break;
  105.               }
  106.   }
  107. --- 263,269 ----
  108.           for (bp = buf_head;  bp != END_OF_CHAIN;  bp = bp->next)
  109.               if (bp->block == block)
  110.               {
  111. !                 write(logfile, (char *) bp->data, bp->datasize);
  112.                   break;
  113.               }
  114.   }
  115. *** less.170/charset.c    Wed Mar  6 12:16:50 1991
  116. --- less/charset.c    Wed Apr  3 00:50:41 1991
  117. ***************
  118. *** 23,28 ****
  119. --- 23,29 ----
  120.   
  121.   static char chardef[256];
  122.   static char *binfmt = "\\%o";
  123. + public int binattr = BLINK;
  124.   
  125.   extern char *getenv();
  126.   
  127. ***************
  128. *** 147,153 ****
  129.   
  130.       s = getenv("LESSBINFMT");
  131.       if (s != NULL && *s != '\0')
  132. !         binfmt = s;
  133.   }
  134.   
  135.   /*
  136. --- 148,168 ----
  137.   
  138.       s = getenv("LESSBINFMT");
  139.       if (s != NULL && *s != '\0')
  140. !     {
  141. !         if (*s == '*')
  142. !         {
  143. !             switch (s[1])
  144. !             {
  145. !             case 'd':  binattr = BOLD;      break;
  146. !             case 'k':  binattr = BLINK;     break;
  147. !             case 'u':  binattr = UNDERLINE; break;
  148. !             default:   binattr = NORMAL;    break;
  149. !             }
  150. !             s += 2;
  151. !         }
  152. !         if (*s != '\0')
  153. !             binfmt = s;
  154. !     }
  155.   }
  156.   
  157.   /*
  158. *** less.170/command.c    Wed Mar  6 12:16:41 1991
  159. --- less/command.c    Tue Apr  2 20:02:18 1991
  160. ***************
  161. *** 80,86 ****
  162.    * Set up the display to start a new search command.
  163.    */
  164.       static void
  165. ! search_mca()
  166.   {
  167.       switch (SRCH_DIR(search_type))
  168.       {
  169. --- 80,86 ----
  170.    * Set up the display to start a new search command.
  171.    */
  172.       static void
  173. ! mca_search()
  174.   {
  175.       switch (SRCH_DIR(search_type))
  176.       {
  177. ***************
  178. *** 97,116 ****
  179.   
  180.       if (search_type & SRCH_FIRST_FILE)
  181.           cmd_putstr("@");
  182. -     else
  183. -         cmd_putstr(" ");
  184.   
  185.       if (search_type & SRCH_PAST_EOF)
  186.           cmd_putstr("*");
  187. -     else
  188. -         cmd_putstr(" ");
  189.   
  190. -     cmd_putstr(" ");
  191.       if (search_type & SRCH_NOMATCH)
  192.           cmd_putstr("!");
  193. -     else
  194. -         cmd_putstr(" ");
  195.   
  196.       switch (SRCH_DIR(search_type))
  197.       {
  198. --- 97,108 ----
  199. ***************
  200. *** 338,344 ****
  201.           if (flag != 0)
  202.           {
  203.               search_type ^= flag;
  204. !             search_mca();
  205.               return (MCA_MORE);
  206.           }
  207.           break;
  208. --- 330,336 ----
  209.           if (flag != 0)
  210.           {
  211.               search_type ^= flag;
  212. !             mca_search();
  213.               return (MCA_MORE);
  214.           }
  215.           break;
  216. ***************
  217. *** 541,547 ****
  218.       register int nomore;
  219.       char *curr_filename;
  220.       int changed_file;
  221. -     struct scrpos scrpos;
  222.   
  223.       changed_file = 0;
  224.       curr_filename = get_filename(curr_ifile);
  225. --- 533,538 ----
  226. ***************
  227. *** 619,624 ****
  228. --- 610,616 ----
  229.       register int c;
  230.       register int action;
  231.       register char *cbuf;
  232. +     int save_search_type;
  233.       char *s;
  234.       char tbuf[2];
  235.       PARG parg;
  236. ***************
  237. *** 816,822 ****
  238. --- 808,816 ----
  239.                * Forward forever, ignoring EOF.
  240.                */
  241.               cmd_exec();
  242. +             jump_forw();
  243.               ignore_eoi = 1;
  244. +             hit_eof = 0;
  245.               while (sigs == 0)
  246.                   forward(1, 0, 0);
  247.               ignore_eoi = 0;
  248. ***************
  249. *** 928,981 ****
  250.                */
  251.               quit(0);
  252.   
  253. !         case A_B_SEARCH:
  254. !             search_type = SRCH_BACK;
  255. !             goto do_search;
  256.           case A_F_SEARCH:
  257.               search_type = SRCH_FORW;
  258. !         do_search:
  259.               /*
  260. !              * Search for a pattern.
  261.                * Get the first char of the pattern.
  262.                */
  263.               if (number <= 0)
  264.                   number = 1;
  265. !             search_mca();
  266.               c = getcc();
  267.               goto again;
  268.   
  269. !         case A_T_REVERSE_SEARCH:
  270.               search_type |= SRCH_PAST_EOF;
  271. !             /* FALLTHRU */
  272.   
  273.           case A_REVERSE_SEARCH:
  274.               /*
  275.                * Repeat previous search, in reverse direction.
  276.                */
  277. !             c = SRCH_FLAG(search_type);
  278. !             if (SRCH_DIR(search_type) == SRCH_BACK)
  279. !                 search_type = SRCH_FORW;
  280. !             else
  281. !                 search_type = SRCH_BACK;
  282. !             search_type |= c;
  283. !             goto do_again_search;
  284.   
  285. !         case A_T_AGAIN_SEARCH:
  286. !             search_type |= SRCH_PAST_EOF;
  287. !             goto do_again_search;
  288. !         case A_AGAIN_SEARCH:
  289. !             /*
  290. !              * Repeat previous search.
  291.                */
  292. !         do_again_search:
  293. !             if (number <= 0)
  294. !                 number = 1;
  295. !             search_mca();
  296. !             cmd_exec();
  297. !             multi_search((char *)NULL, number);
  298.               break;
  299. !         
  300.           case A_HELP:
  301.               /*
  302.                * Help.
  303. --- 922,997 ----
  304.                */
  305.               quit(0);
  306.   
  307. ! /*
  308. !  * Define abbreviation for a commonly used sequence below.
  309. !  */
  310. ! #define    DO_SEARCH()    if (number <= 0) number = 1;    \
  311. !             mca_search();            \
  312. !             cmd_exec();            \
  313. !             multi_search((char *)NULL, number);
  314.           case A_F_SEARCH:
  315. +             /*
  316. +              * Search forward for a pattern.
  317. +              * Get the first char of the pattern.
  318. +              */
  319.               search_type = SRCH_FORW;
  320. !             if (number <= 0)
  321. !                 number = 1;
  322. !             mca_search();
  323. !             c = getcc();
  324. !             goto again;
  325. !         case A_B_SEARCH:
  326.               /*
  327. !              * Search backward for a pattern.
  328.                * Get the first char of the pattern.
  329.                */
  330. +             search_type = SRCH_BACK;
  331.               if (number <= 0)
  332.                   number = 1;
  333. !             mca_search();
  334.               c = getcc();
  335.               goto again;
  336.   
  337. !         case A_AGAIN_SEARCH:
  338. !             /*
  339. !              * Repeat previous search.
  340. !              */
  341. !             DO_SEARCH();
  342. !             break;
  343. !         
  344. !         case A_T_AGAIN_SEARCH:
  345. !             /*
  346. !              * Repeat previous search, multiple files.
  347. !              */
  348.               search_type |= SRCH_PAST_EOF;
  349. !             DO_SEARCH();
  350. !             break;
  351.   
  352.           case A_REVERSE_SEARCH:
  353.               /*
  354.                * Repeat previous search, in reverse direction.
  355.                */
  356. !             save_search_type = search_type;
  357. !             search_type = SRCH_REVERSE(search_type);
  358. !             DO_SEARCH();
  359. !             search_type = save_search_type;
  360. !             break;
  361.   
  362. !         case A_T_REVERSE_SEARCH:
  363. !             /* 
  364. !              * Repeat previous search, 
  365. !              * multiple files in reverse direction.
  366.                */
  367. !             save_search_type = search_type;
  368. !             search_type = SRCH_REVERSE(search_type);
  369. !             search_type |= SRCH_PAST_EOF;
  370. !             DO_SEARCH();
  371. !             search_type = save_search_type;
  372.               break;
  373.           case A_HELP:
  374.               /*
  375.                * Help.
  376. *** less.170/edit.c    Wed Mar  6 12:16:47 1991
  377. --- less/edit.c    Wed Apr  3 01:14:52 1991
  378. ***************
  379. *** 12,18 ****
  380.   extern int new_file;
  381.   extern int errmsgs;
  382.   extern int quit_at_eof;
  383. - extern int hit_eof;
  384.   extern int file;
  385.   extern int cbufs;
  386.   extern char *every_first_cmd;
  387. --- 12,17 ----
  388. ***************
  389. *** 41,47 ****
  390.       int just_looking;
  391.   {
  392.       register int f;
  393. !     register char *m;
  394.       int answer;
  395.       int no_display;
  396.       struct scrpos scrpos;
  397. --- 40,46 ----
  398.       int just_looking;
  399.   {
  400.       register int f;
  401. !     char *s;
  402.       int answer;
  403.       int no_display;
  404.       struct scrpos scrpos;
  405. ***************
  406. *** 74,80 ****
  407.           error("%s", &parg);
  408.           free(parg.p_string);
  409.           return (1);
  410. !     } else if (!force_open && !just_looking && binary_file(f))
  411.       {
  412.           parg.p_string = filename;
  413.           answer = query("\"%s\" may be a binary file.  Continue? ",
  414. --- 73,79 ----
  415.           error("%s", &parg);
  416.           free(parg.p_string);
  417.           return (1);
  418. !     } else if (!force_open && !just_looking && bin_file(f))
  419.       {
  420.           parg.p_string = filename;
  421.           answer = query("\"%s\" may be a binary file.  Continue? ",
  422. ***************
  423. *** 107,114 ****
  424.       }
  425.   
  426.   #if LOGFILE
  427. !     if (f >= 0 && ISPIPE(f) && namelogfile != NULL && is_tty)
  428. !         use_logfile();
  429.   #endif
  430.   
  431.       /*
  432. --- 106,115 ----
  433.       }
  434.   
  435.   #if LOGFILE
  436. !     s = namelogfile;
  437. !     end_logfile();
  438. !     if (f >= 0 && ISPIPE(f) && s != NULL && is_tty)
  439. !         use_logfile(s);
  440.   #endif
  441.   
  442.       /*
  443. ***************
  444. *** 364,381 ****
  445.    * We take care not to blindly overwrite an existing file.
  446.    */
  447.       public void
  448. ! use_logfile()
  449.   {
  450.       register int exists;
  451.       register int answer;
  452.       PARG parg;
  453.   
  454. -     end_logfile();
  455.       /*
  456.        * {{ We could use access() here. }}
  457.        */
  458. !     exists = open(namelogfile, 0);
  459.       close(exists);
  460.       exists = (exists >= 0);
  461.   
  462. --- 365,381 ----
  463.    * We take care not to blindly overwrite an existing file.
  464.    */
  465.       public void
  466. ! use_logfile(filename)
  467. !     char *filename;
  468.   {
  469.       register int exists;
  470.       register int answer;
  471.       PARG parg;
  472.   
  473.       /*
  474.        * {{ We could use access() here. }}
  475.        */
  476. !     exists = open(filename, 0);
  477.       close(exists);
  478.       exists = (exists >= 0);
  479.   
  480. ***************
  481. *** 394,400 ****
  482.           /*
  483.            * Ask user what to do.
  484.            */
  485. !         parg.p_string = namelogfile;
  486.           answer = query("Warning: \"%s\" exists; Overwrite, Append or Don't log? ", &parg);
  487.       }
  488.   
  489. --- 394,400 ----
  490.           /*
  491.            * Ask user what to do.
  492.            */
  493. !         parg.p_string = filename;
  494.           answer = query("Warning: \"%s\" exists; Overwrite, Append or Don't log? ", &parg);
  495.       }
  496.   
  497. ***************
  498. *** 405,411 ****
  499.           /*
  500.            * Overwrite: create the file.
  501.            */
  502. !         logfile = creat(namelogfile, 0644);
  503.           break;
  504.       case 'A': case 'a':
  505.           /*
  506. --- 405,411 ----
  507.           /*
  508.            * Overwrite: create the file.
  509.            */
  510. !         logfile = creat(filename, 0644);
  511.           break;
  512.       case 'A': case 'a':
  513.           /*
  514. ***************
  515. *** 412,420 ****
  516.            * Append: open the file and seek to the end.
  517.            */
  518.   #if __MSDOS__
  519. !         logfile = open(namelogfile, O_APPEND|O_WRONLY);
  520.   #else
  521. !         logfile = open(namelogfile, 1);
  522.   #endif
  523.           if (lseek(logfile, (offset_t)0, 2) == BAD_LSEEK)
  524.           {
  525. --- 412,420 ----
  526.            * Append: open the file and seek to the end.
  527.            */
  528.   #if __MSDOS__
  529. !         logfile = open(filename, O_APPEND|O_WRONLY);
  530.   #else
  531. !         logfile = open(filename, 1);
  532.   #endif
  533.           if (lseek(logfile, (offset_t)0, 2) == BAD_LSEEK)
  534.           {
  535. ***************
  536. *** 443,449 ****
  537.           /*
  538.            * Error in opening logfile.
  539.            */
  540. !         parg.p_string = namelogfile;
  541.           error("Cannot write to \"%s\"", &parg);
  542.       }
  543.   }
  544. --- 443,449 ----
  545.           /*
  546.            * Error in opening logfile.
  547.            */
  548. !         parg.p_string = filename;
  549.           error("Cannot write to \"%s\"", &parg);
  550.       }
  551.   }
  552. *** less.170/filename.c    Wed Mar  6 12:16:50 1991
  553. --- less/filename.c    Wed Apr  3 01:14:44 1991
  554. ***************
  555. *** 62,67 ****
  556. --- 62,68 ----
  557.       public char *
  558.   find_helpfile()
  559.   {
  560. +     register char *helpfile;
  561.   #if __MSDOS__
  562.       extern char *searchpath();
  563.   
  564. ***************
  565. *** 78,85 ****
  566.           helpfile = HELPFILE;
  567.       else
  568.           helpfile++;
  569. !     return (searchpath(helpfile));
  570.   #else
  571.       return (save(HELPFILE));
  572.   #endif
  573.   }
  574. --- 79,88 ----
  575.           helpfile = HELPFILE;
  576.       else
  577.           helpfile++;
  578. !     return (save(searchpath(helpfile)));
  579.   #else
  580. +     if ((helpfile = getenv("LESSHELP")) != NULL)
  581. +         return (save(helpfile));
  582.       return (save(HELPFILE));
  583.   #endif
  584.   }
  585. ***************
  586. *** 154,160 ****
  587.    * This is just a guess, and we need not try too hard to make it accurate.
  588.    */
  589.       int
  590. ! binary_file(f)
  591.       int f;
  592.   {
  593.       int i;
  594. --- 157,163 ----
  595.    * This is just a guess, and we need not try too hard to make it accurate.
  596.    */
  597.       int
  598. ! bin_file(f)
  599.       int f;
  600.   {
  601.       int i;
  602. *** less.170/forwback.c    Wed Mar  6 12:16:52 1991
  603. --- less/forwback.c    Sun Mar 10 17:47:17 1991
  604. ***************
  605. *** 44,49 ****
  606. --- 44,51 ----
  607.   {
  608.       POSITION pos;
  609.   
  610. +     if (ignore_eoi)
  611. +         return;
  612.       if (sigs)
  613.           return;
  614.       /*
  615. ***************
  616. *** 213,219 ****
  617.           put_line();
  618.       }
  619.   
  620. !     if (eof && !sigs)
  621.           hit_eof++;
  622.       else
  623.           eof_check();
  624. --- 215,223 ----
  625.           put_line();
  626.       }
  627.   
  628. !     if (ignore_eoi)
  629. !         hit_eof = 0;
  630. !     else if (eof && !sigs)
  631.           hit_eof++;
  632.       else
  633.           eof_check();
  634. *** less.170/funcs.h    Wed Mar  6 12:17:02 1991
  635. --- less/funcs.h    Tue Apr  2 18:48:25 1991
  636. ***************
  637. *** 172,178 ****
  638.       public HANDLER winch ();
  639.       public void init_signals ();
  640.       public void psignals ();
  641. !     public int findtag ();
  642.       public int tagsearch ();
  643.       public void open_getchr ();
  644.       public int getchr ();
  645. --- 172,178 ----
  646.       public HANDLER winch ();
  647.       public void init_signals ();
  648.       public void psignals ();
  649. !     public void findtag ();
  650.       public int tagsearch ();
  651.       public void open_getchr ();
  652.       public int getchr ();
  653. *** less.170/ifile.c    Wed Mar  6 12:16:52 1991
  654. --- less/ifile.c    Wed Mar  6 11:56:31 1991
  655. ***************
  656. *** 153,158 ****
  657. --- 153,160 ----
  658.   get_filename(ifile)
  659.       IFILE ifile;
  660.   {
  661. +     if (ifile == NULL)
  662. +         return (NULL);
  663.       return (int_ifile(ifile)->h_filename);
  664.   }
  665.   
  666. *** less.170/jump.c    Wed Mar  6 12:16:52 1991
  667. --- less/jump.c    Fri Mar 15 22:44:16 1991
  668. ***************
  669. *** 17,22 ****
  670. --- 17,24 ----
  671.       public void
  672.   jump_forw()
  673.   {
  674. +     POSITION pos;
  675.       if (ch_end_seek())
  676.       {
  677.           error("Cannot seek to end of file", NULL_PARG);
  678. ***************
  679. *** 24,31 ****
  680.       }
  681.       /*
  682.        * Position the last line in the file at the last screen line.
  683.        */
  684. !     jump_loc(back_line(ch_tell()), sc_height-1);
  685.   }
  686.   
  687.   /*
  688. --- 26,39 ----
  689.       }
  690.       /*
  691.        * Position the last line in the file at the last screen line.
  692. +      * Go back one line from the end of the file
  693. +      * to get to the beginning of the last line.
  694.        */
  695. !     pos = back_line(ch_tell());
  696. !     if (pos == NULL_POSITION)
  697. !         jump_loc((POSITION)0, sc_height-1);
  698. !     else
  699. !         jump_loc(pos, sc_height-1);
  700.   }
  701.   
  702.   /*
  703. *** less.170/less.h    Wed Mar  6 12:16:38 1991
  704. --- less/less.h    Sun Mar 17 22:49:59 1991
  705. ***************
  706. *** 89,96 ****
  707.   #define    SRCH_PAST_EOF    0200    /* Search past end-of-file, into next file */
  708.   #define    SRCH_FIRST_FILE    0400    /* Search starting at the first file */
  709.   
  710. ! #define    SRCH_DIR(t)    ((t) & 077)
  711. ! #define    SRCH_FLAG(t)    ((t) & 07700)
  712.   
  713.   /* Special chars used to tell put_line() to do something special */
  714.   #define    NORMAL        (0)
  715. --- 89,96 ----
  716.   #define    SRCH_PAST_EOF    0200    /* Search past end-of-file, into next file */
  717.   #define    SRCH_FIRST_FILE    0400    /* Search starting at the first file */
  718.   
  719. ! #define    SRCH_DIR(t)    ((t) & 01)
  720. ! #define    SRCH_REVERSE(t)    ((t) ^ 01)
  721.   
  722.   /* Special chars used to tell put_line() to do something special */
  723.   #define    NORMAL        (0)
  724. *** less.170/less.hlp    Wed Mar  6 12:16:54 1991
  725. --- less/less.hlp    Thu Mar 28 15:07:17 1991
  726. ***************
  727. *** 24,34 ****
  728.   
  729.     /pattern          *  Search forward for (N-th) matching line.
  730.     ?pattern          *  Search backward for (N-th) matching line.
  731. -   ESC-/pattern      *  Search all files for (N-th) matching line.
  732.   
  733. !   /!pattern         *  Search forward for (N-th) NON-matching line.
  734. !   ?!pattern         *  Search backward for (N-th) NON-matching line.
  735. !   ESC-/!pattern     *  Search from all files for (N-th) NON-matching line.
  736.   
  737.     n                 *  Repeat previous search (for N-th occurrence).
  738.     N                 *  Repeat previous search in reverse direction.
  739. --- 24,34 ----
  740.   
  741.     /pattern          *  Search forward for (N-th) matching line.
  742.     ?pattern          *  Search backward for (N-th) matching line.
  743.   
  744. !   NOTE: search commands may be modified by one or more of:
  745. !         !  search for NON-matching lines.
  746. !         *  search multiple files.
  747. !         @  start search at first file (for /) or last file (for ?).
  748.   
  749.     n                 *  Repeat previous search (for N-th occurrence).
  750.     N                 *  Repeat previous search in reverse direction.
  751. ***************
  752. *** 38,49 ****
  753.     g  <  ESC-<       *  Go to first line in file (or line N).
  754.     G  >  ESC->       *  Go to last line in file (or line N).
  755.     p  %              *  Go to beginning of file (or N percent into file).
  756. !   {                 *  Go to the } which matches the (N-th) { in the top line.
  757. !   }                 *  Go to the { which matches the (N-th) } in the top line.
  758. !   (                 *  Go to the ) which matches the (N-th) ( in the top line.
  759. !   )                 *  Go to the ( which matches the (N-th) ) in the top line.
  760. !   [                 *  Go to the ] which matches the (N-th) [ in the top line.
  761. !   ]                 *  Go to the [ which matches the (N-th) ] in the top line.
  762.     m<letter>            Mark the current position with <letter>.
  763.     '<letter>            Go to a previously marked position.
  764.     ''                   Go to the previous position.
  765. --- 38,51 ----
  766.     g  <  ESC-<       *  Go to first line in file (or line N).
  767.     G  >  ESC->       *  Go to last line in file (or line N).
  768.     p  %              *  Go to beginning of file (or N percent into file).
  769. !   {                 *  Go to the } matching the (N-th) { in the top line.
  770. !   }                 *  Go to the { matching the (N-th) } in the bottom line.
  771. !   (                 *  Go to the ) matching the (N-th) ( in the top line.
  772. !   )                 *  Go to the ( matching the (N-th) ) in the bottom line.
  773. !   [                 *  Go to the ] matching the (N-th) [ in the top line.
  774. !   ]                 *  Go to the [ matching the (N-th) ] in the bottom line.
  775. !   ESC-^F <c1> <c2>  *  Go to the c1 matching the (N-th) c2 in the top line
  776. !   ESC-^B <c1> <c2>  *  Go to the c2 matching the (N-th) c1 in the bottom line.
  777.     m<letter>            Mark the current position with <letter>.
  778.     '<letter>            Go to a previously marked position.
  779.     ''                   Go to the previous position.
  780. ***************
  781. *** 70,75 ****
  782. --- 72,78 ----
  783.           Most flags may be changed either on the command line,
  784.           or from within less by using the - command.
  785.   
  786. +   -?            Display help (from command line).
  787.     -a            Set forward search starting location.
  788.     -b [N]        Number of buffers.
  789.     -B            Automatically allocate buffers.
  790. ***************
  791. *** 81,94 ****
  792.     -i            Ignore case in searches.
  793.     -j [N]        Screen position of target lines.
  794.     -k [file]     Use a lesskey file.
  795. -   -l [file]     Log file.
  796. -   -L [file]     Log file (unconditionally overwrite).
  797.     -m  -M        Set prompt style.
  798.     -n  -N        Use line numbers.
  799.     -P [prompt]   Define new prompt.
  800.     -q  -Q        Quiet the terminal bell.
  801. !   -r  -R        Translate control characters.
  802.     -s            Squeeze multiple blank lines.
  803.     -t [tag]      Find a tag.
  804.     -T [tagsfile] Use an alternate tags file.
  805.     -u  -U        Change handling of backspaces.
  806. --- 84,99 ----
  807.     -i            Ignore case in searches.
  808.     -j [N]        Screen position of target lines.
  809.     -k [file]     Use a lesskey file.
  810.     -m  -M        Set prompt style.
  811.     -n  -N        Use line numbers.
  812. +   -o [file]     Log file.
  813. +   -O [file]     Log file (unconditionally overwrite).
  814. +   -p [pattern]  Start at pattern (from command line).
  815.     -P [prompt]   Define new prompt.
  816.     -q  -Q        Quiet the terminal bell.
  817. !   -r            Translate control characters.
  818.     -s            Squeeze multiple blank lines.
  819. +   -S            Chop long lines.
  820.     -t [tag]      Find a tag.
  821.     -T [tagsfile] Use an alternate tags file.
  822.     -u  -U        Change handling of backspaces.
  823. *** less.170/less.nro    Wed Mar  6 12:16:35 1991
  824. --- less/less.nro    Wed Apr  3 01:00:20 1991
  825. ***************
  826. *** 4,14 ****
  827.   .SH SYNOPSIS
  828.   .B "less -?"
  829.   .br
  830. ! .B "less [-[+]aABcCdeEfimMnNqQrsSuUw] [-b\fIN\fP] [-x\fIN\fP] [-[z]\fIN\fP]"
  831.   .br
  832. ! .B "     [-h\fIN\fP] [-y\fIN\fP] [-P[mM=]\fIstring\fP] [-[oO]\fIlogfile\fP] [-k\fIkeyfile\fP]"
  833.   .br
  834. ! .B "     [-t\fItag\fP] [-T\fItagsfile\fP] [+\fIcmd\fP] [\fIfilename\fP]..."
  835.   
  836.   .SH DESCRIPTION
  837.   .I Less
  838. --- 4,18 ----
  839.   .SH SYNOPSIS
  840.   .B "less -?"
  841.   .br
  842. ! .B "less [-[+]aBcCdeEfHimMnNqQrsSuUw]"
  843.   .br
  844. ! .B "     [-b \fIbufs\fP] [-h \fIlines\fP] [-j \fIline\fP] [-k \fIkeyfile\fP]"
  845.   .br
  846. ! .B "     [-{oO} \fIlogfile\fP] [-p \fIpattern\fP] [-P \fIprompt\fP] [-t \fItag\fP]"
  847. ! .br
  848. ! .B "     [-T \fItagfile\fP] [-x \fItab\fP] [-y \fIlines\fP] [-[z] \fIlines\fP]"
  849. ! .br
  850. ! .B "     [+[+]\fIcmd\fP] [\fIfilename\fP]..."
  851.   
  852.   .SH DESCRIPTION
  853.   .I Less
  854. ***************
  855. *** 350,360 ****
  856.   .IP "| <m> shell-command"
  857.   <m> represents any mark letter.
  858.   Pipes a section of the input file to the given shell command.
  859. ! The section of the file to be piped is between the current position and 
  860. ! the position marked by the letter.
  861.   <m> may also be ^ or $ to indicate beginning or end of file respectively.
  862.   If <m> is . or newline, the current screen is piped.
  863. - The current screen is the minimum amount piped in any case.
  864.   .PP
  865.   .SH OPTIONS
  866.   Command line options are described below.
  867. --- 354,363 ----
  868.   .IP "| <m> shell-command"
  869.   <m> represents any mark letter.
  870.   Pipes a section of the input file to the given shell command.
  871. ! The section of the file to be piped is between the first line on
  872. ! the current screen and the position marked by the letter.
  873.   <m> may also be ^ or $ to indicate beginning or end of file respectively.
  874.   If <m> is . or newline, the current screen is piped.
  875.   .PP
  876.   .SH OPTIONS
  877.   Command line options are described below.
  878. ***************
  879. *** 727,732 ****
  880. --- 730,742 ----
  881.   This octal format can be changed by 
  882.   setting the LESSBINFMT environment variable
  883.   to a printf-style format string; the default is '\\%o'.
  884. + The blinking mode display of control and binary characters can
  885. + be changed or disabled by preceding the LESSBINFMT format 
  886. + string with a "*" and one character to select the mode:
  887. + "*k" is blinking, "*d" is bold, "*u" is underlined,
  888. + and "*n" is normal (no special display attribute).
  889. + For example, if LESSBINFMT is "*u[%x]", binary characters
  890. + are displayed in underlined hexadecimal surrounded by brackets.
  891.   
  892.   .SH "PROMPTS"
  893.   The -P option allows you to tailor the prompt to your preference.
  894. ***************
  895. *** 907,912 ****
  896. --- 917,924 ----
  897.   .IP LESSEDIT
  898.   Editor prototype string (used for the v command).
  899.   See discussion under PROMPTS.
  900. + .IP LESSHELP
  901. + Name of the help file.
  902.   .IP LINES
  903.   Sets the number of lines on the screen.
  904.   Takes precedence over the number of lines specified by the TERM variable.
  905. *** less.170/lesskey.c    Wed Mar  6 12:16:40 1991
  906. --- less/lesskey.c    Thu Mar 14 13:09:10 1991
  907. ***************
  908. *** 307,312 ****
  909. --- 307,313 ----
  910.           perror(outfile);
  911.       else
  912.           fwrite((char *)usertable, 1, up-usertable, out);
  913. +     exit(0);
  914.   }
  915.   
  916.   /*
  917. *** less.170/line.c    Wed Mar  6 12:16:44 1991
  918. --- less/line.c    Wed Apr  3 00:45:15 1991
  919. ***************
  920. *** 15,25 ****
  921. --- 15,28 ----
  922.   static int is_null_line;    /* There is no current line */
  923.   static char pendc;
  924.   
  925. + static int do_append();
  926.   extern int bs_mode;
  927.   extern int tabstop;
  928.   extern int linenums;
  929.   extern int ctldisp;
  930.   extern int twiddle;
  931. + extern int binattr;
  932.   extern int auto_wrap, ignaw;
  933.   extern int bo_s_width, bo_e_width;
  934.   extern int ul_s_width, ul_e_width;
  935. ***************
  936. *** 332,338 ****
  937.                * Output in the (blinking) ^X format.
  938.                */
  939.               s = prchar(c);  
  940. !             a = BLINK;
  941.   
  942.               /*
  943.                * Make sure we can get the entire representation
  944. --- 335,341 ----
  945.                * Output in the (blinking) ^X format.
  946.                */
  947.               s = prchar(c);  
  948. !             a = binattr;
  949.   
  950.               /*
  951.                * Make sure we can get the entire representation
  952. ***************
  953. *** 360,367 ****
  954.   pdone(endline)
  955.       int endline;
  956.   {
  957. -     register char c;
  958.       if (pendc && (pendc != '\r' || !endline))
  959.           /*
  960.            * If we had a pending character, put it in the buffer.
  961. --- 363,368 ----
  962. ***************
  963. *** 374,380 ****
  964.        * Add a newline if necessary,
  965.        * and append a '\0' to the end of the line.
  966.        */
  967. !     if (column < sc_width || !auto_wrap || ignaw)
  968.       {
  969.           linebuf[curr] = '\n';
  970.           attr[curr] = NORMAL;
  971. --- 375,381 ----
  972.        * Add a newline if necessary,
  973.        * and append a '\0' to the end of the line.
  974.        */
  975. !     if (column < sc_width || !auto_wrap || ignaw || ctldisp == 0)
  976.       {
  977.           linebuf[curr] = '\n';
  978.           attr[curr] = NORMAL;
  979. *** less.170/linstall    Wed Mar  6 12:16:34 1991
  980. --- less/linstall    Thu Mar 28 14:42:41 1991
  981. ***************
  982. *** 143,158 ****
  983.    * 0 if it does not.
  984.    */
  985.   #define    VOID        $x
  986. - #if VOID
  987. - #define    VOID_POINTER    void *
  988. - #else
  989. - #define    VOID_POINTER    char *
  990. - #endif
  991.   
  992.   EOF
  993.   
  994.   
  995.   
  996.   def=long
  997.   if [ $alldefault = 0 ]
  998.   then
  999. --- 143,175 ----
  1000.    * 0 if it does not.
  1001.    */
  1002.   #define    VOID        $x
  1003.   
  1004.   EOF
  1005.   
  1006.   
  1007.   
  1008. + def=yes
  1009. + x="void *"
  1010. + if [ $alldefault = 0 ]
  1011. + then
  1012. +     $ECHO "Does your C compiler support the \"void *\" type? [$def] \c"
  1013. +     read ans
  1014. +     case "X$ans" in
  1015. +     X[yY]*) x="void *" ;;
  1016. +     X[nN]*) x="char *" ;;
  1017. +     esac
  1018. +     $ECHO ""
  1019. + fi
  1020. + cat >>defines.h <<EOF
  1021. + /*
  1022. +  * VOID_POINTER is the definition of a pointer to any object.
  1023. +  */
  1024. + #define    VOID_POINTER    $x
  1025. + EOF
  1026.   def=long
  1027.   if [ $alldefault = 0 ]
  1028.   then
  1029. ***************
  1030. *** 370,375 ****
  1031. --- 387,421 ----
  1032.   
  1033.   EOF
  1034.   
  1035. + if [ "$sys" = "sys5" -a "$xenix" = "0" ]
  1036. + then
  1037. +     def=yes; x=1
  1038. + else
  1039. +     def=no; x=0
  1040. + fi
  1041. + if [ $alldefault = 0 ]
  1042. + then
  1043. +     $ECHO "Some SCO System V systems need sys/ptem.h included to get"
  1044. +     $ECHO "the size of the screen (struct winsize)."
  1045. +     $ECHO "Does your system need sys/ptem.h? [$def] \c"
  1046. +     read ans
  1047. +     case "X$ans" in
  1048. +     X[yY]*) x=1 ;;
  1049. +     X[nN]*) x=0 ;;
  1050. +     esac
  1051. +     $ECHO ""
  1052. + fi
  1053. + cat >>defines.h <<EOF
  1054. + /*
  1055. +  * NEED_PTEM_H is 1 if your system needs sys/ptem.h to declare struct winsize.
  1056. +  * This is normally the case only for SCOs System V.
  1057. +  */
  1058. + #define    NEED_PTEM_H    $x
  1059. + EOF
  1060.   
  1061.   
  1062.   if [ "$sys" = "bsd" ]
  1063. *** less.170/lsystem.c    Wed Mar  6 12:16:51 1991
  1064. --- less/lsystem.c    Tue Apr  2 23:54:18 1991
  1065. ***************
  1066. *** 205,218 ****
  1067.       tpos = position(TOP);
  1068.       if (tpos == NULL_POSITION)
  1069.           tpos = ch_zero();
  1070. !     bpos = position(BOTTOM_PLUS_ONE);
  1071.   
  1072. !     if (mpos <= tpos)
  1073. !         return (pipe_data(cmd, mpos, bpos));
  1074. !     else if (bpos == NULL_POSITION || mpos <= bpos)
  1075. !         return (pipe_data(cmd, tpos, bpos));
  1076. !     else
  1077. !         return (pipe_data(cmd, tpos, mpos));
  1078.   }
  1079.   
  1080.   /*
  1081. --- 205,220 ----
  1082.       tpos = position(TOP);
  1083.       if (tpos == NULL_POSITION)
  1084.           tpos = ch_zero();
  1085. !     bpos = position(BOTTOM);
  1086.   
  1087. !      if (c == '.') 
  1088. !          return (pipe_data(cmd, tpos, bpos));
  1089. !      else if (mpos <= tpos)
  1090. !          return (pipe_data(cmd, mpos, tpos));
  1091. !      else if (bpos == NULL_POSITION)
  1092. !          return (pipe_data(cmd, tpos, bpos));
  1093. !      else
  1094. !          return (pipe_data(cmd, tpos, mpos));
  1095.   }
  1096.   
  1097.   /*
  1098. ***************
  1099. *** 227,233 ****
  1100.   {
  1101.       register FILE *f;
  1102.       register int c;
  1103. -     int inp;
  1104.       extern FILE *popen();
  1105.   
  1106.       /*
  1107. --- 229,234 ----
  1108. ***************
  1109. *** 257,264 ****
  1110.       flush();
  1111.       raw_mode(0);
  1112.       init_signals(0);
  1113.   
  1114. !     while (epos == NULL_POSITION || spos++ < epos)
  1115.       {
  1116.           /*
  1117.            * Read a character from the file and give it to the pipe.
  1118. --- 258,268 ----
  1119.       flush();
  1120.       raw_mode(0);
  1121.       init_signals(0);
  1122. + #ifdef SIGPIPE
  1123. +     SIGNAL(SIGPIPE, SIG_IGN);
  1124. + #endif
  1125.   
  1126. !     while (epos == NULL_POSITION || spos++ <= epos)
  1127.       {
  1128.           /*
  1129.            * Read a character from the file and give it to the pipe.
  1130. ***************
  1131. *** 266,275 ****
  1132.           c = ch_forw_get();
  1133.           if (c == EOI)
  1134.               break;
  1135. !         putc(c, f);
  1136.       }
  1137.       pclose(f);
  1138.   
  1139.       init_signals(1);
  1140.       raw_mode(1);
  1141.       init();
  1142. --- 270,296 ----
  1143.           c = ch_forw_get();
  1144.           if (c == EOI)
  1145.               break;
  1146. !         if (putc(c, f) == EOF)
  1147. !             break;
  1148.       }
  1149. +     /*
  1150. +      * Finish up the last line.
  1151. +      */
  1152. +      while (c != '\n' && c != EOI ) 
  1153. +      {
  1154. +          c = ch_forw_get();
  1155. +          if (c == EOI)
  1156. +              break;
  1157. +          if (putc(c, f) == EOF)
  1158. +              break;
  1159. +      }
  1160.       pclose(f);
  1161.   
  1162. + #ifdef SIGPIPE
  1163. +     SIGNAL(SIGPIPE, SIG_DFL);
  1164. + #endif
  1165.       init_signals(1);
  1166.       raw_mode(1);
  1167.       init();
  1168. *** less.170/main.c    Wed Mar  6 12:16:46 1991
  1169. --- less/main.c    Thu Mar 14 15:23:09 1991
  1170. ***************
  1171. *** 19,25 ****
  1172.   
  1173.   extern int    file;
  1174.   extern int    quit_at_eof;
  1175. - extern int    hit_eof;
  1176.   extern int    cbufs;
  1177.   extern int    errmsgs;
  1178.   extern int    screen_trashed;
  1179. --- 19,24 ----
  1180. ***************
  1181. *** 157,162 ****
  1182. --- 156,162 ----
  1183.               quit(1);
  1184.           if (edit(tagfile, 0) || tagsearch())
  1185.               quit(1);
  1186. +         nofiles = 0;
  1187.       } else
  1188.   #endif
  1189.       if (nifile() == 0)
  1190. *** less.170/optfunc.c    Wed Mar  6 12:16:49 1991
  1191. --- less/optfunc.c    Mon Mar 18 18:29:43 1991
  1192. ***************
  1193. *** 76,82 ****
  1194.           namelogfile = glob(s);
  1195.           if (namelogfile == NULL)
  1196.               namelogfile = save(s);
  1197. !         use_logfile();
  1198.           sync_logfile();
  1199.           break;
  1200.       case QUERY:
  1201. --- 76,82 ----
  1202.           namelogfile = glob(s);
  1203.           if (namelogfile == NULL)
  1204.               namelogfile = save(s);
  1205. !         use_logfile(s);
  1206.           sync_logfile();
  1207.           break;
  1208.       case QUERY:
  1209. *** less.170/option.c    Wed Mar  6 12:16:48 1991
  1210. --- less/option.c    Tue Apr  2 20:59:39 1991
  1211. ***************
  1212. *** 15,20 ****
  1213. --- 15,21 ----
  1214.   
  1215.   static char *propt();
  1216.   static char *optstring();
  1217. + static int flip_triple();
  1218.   
  1219.   extern int screen_trashed;
  1220.   extern char *every_first_cmd;
  1221. ***************
  1222. *** 82,88 ****
  1223.               plusoption = 1;
  1224.               if (*s == '+')
  1225.                   every_first_cmd = save(++s);
  1226. !             ungetsc(s);
  1227.               s = optstring(s, c);
  1228.               continue;
  1229.           case '0':  case '1':  case '2':  case '3':  case '4':
  1230. --- 83,90 ----
  1231.               plusoption = 1;
  1232.               if (*s == '+')
  1233.                   every_first_cmd = save(++s);
  1234. !             else
  1235. !                 ungetsc(s);
  1236.               s = optstring(s, c);
  1237.               continue;
  1238.           case '0':  case '1':  case '2':  case '3':  case '4':
  1239. ***************
  1240. *** 122,128 ****
  1241.               if (set_default)
  1242.                   *(o->ovar) = o->odefault;
  1243.               else
  1244. !                 *(o->ovar) = toggle_triple(o->odefault,
  1245.                           (o->oletter == c));
  1246.               break;
  1247.           case STRING:
  1248. --- 124,130 ----
  1249.               if (set_default)
  1250.                   *(o->ovar) = o->odefault;
  1251.               else
  1252. !                 *(o->ovar) = flip_triple(o->odefault,
  1253.                           (o->oletter == c));
  1254.               break;
  1255.           case STRING:
  1256. ***************
  1257. *** 244,250 ****
  1258.               switch (how_toggle)
  1259.               {
  1260.               case OPT_TOGGLE:
  1261. !                 *(o->ovar) = toggle_triple(*(o->ovar), 
  1262.                           o->oletter == c);
  1263.                   break;
  1264.               case OPT_UNSET:
  1265. --- 246,252 ----
  1266.               switch (how_toggle)
  1267.               {
  1268.               case OPT_TOGGLE:
  1269. !                 *(o->ovar) = flip_triple(*(o->ovar), 
  1270.                           o->oletter == c);
  1271.                   break;
  1272.               case OPT_UNSET:
  1273. ***************
  1274. *** 251,257 ****
  1275.                   *(o->ovar) = o->odefault;
  1276.                   break;
  1277.               case OPT_SET:
  1278. !                 *(o->ovar) = toggle_triple(o->odefault,
  1279.                           o->oletter == c);
  1280.                   break;
  1281.               }
  1282. --- 253,259 ----
  1283.                   *(o->ovar) = o->odefault;
  1284.                   break;
  1285.               case OPT_SET:
  1286. !                 *(o->ovar) = flip_triple(o->odefault,
  1287.                           o->oletter == c);
  1288.                   break;
  1289.               }
  1290. ***************
  1291. *** 335,341 ****
  1292.    * "Toggle" a triple-valued option.
  1293.    */
  1294.       static int
  1295. ! toggle_triple(val, lc)
  1296.       int val;
  1297.       int lc;
  1298.   {
  1299. --- 337,343 ----
  1300.    * "Toggle" a triple-valued option.
  1301.    */
  1302.       static int
  1303. ! flip_triple(val, lc)
  1304.       int val;
  1305.       int lc;
  1306.   {
  1307. *** less.170/screen.c    Wed Mar  6 12:16:55 1991
  1308. --- less/screen.c    Wed Apr  3 01:14:08 1991
  1309. ***************
  1310. *** 31,37 ****
  1311. --- 31,46 ----
  1312.   #endif
  1313.   #endif
  1314.   
  1315. + #if NEED_PTEM_H && defined(TIOCGWINSZ)
  1316.   /*
  1317. +  * All this just to get struct winsize.  Sigh.
  1318. +  */
  1319. + #include <sys/types.h>
  1320. + #include <sys/stream.h>
  1321. + #include <sys/ptem.h>
  1322. + #endif
  1323. + /*
  1324.    * Strings passed to tputs() to do various terminal functions.
  1325.    */
  1326.   static char
  1327. ***************
  1328. *** 199,205 ****
  1329.    * Get size of the output screen.
  1330.    */
  1331.       public void
  1332. ! get_scrsize(p_height, p_width)
  1333.       int *p_height;
  1334.       int *p_width;
  1335.   {
  1336. --- 208,214 ----
  1337.    * Get size of the output screen.
  1338.    */
  1339.       public void
  1340. ! scrsize(p_height, p_width)
  1341.       int *p_height;
  1342.       int *p_width;
  1343.   {
  1344. ***************
  1345. *** 277,283 ****
  1346.       /*
  1347.        * Get size of the screen.
  1348.        */
  1349. !     get_scrsize(&sc_height, &sc_width);
  1350.       pos_init();
  1351.       if (swindow < 0)
  1352.           swindow = sc_height - 1;
  1353. --- 286,292 ----
  1354.       /*
  1355.        * Get size of the screen.
  1356.        */
  1357. !     scrsize(&sc_height, &sc_width);
  1358.       pos_init();
  1359.       if (swindow < 0)
  1360.           swindow = sc_height - 1;
  1361. ***************
  1362. *** 448,478 ****
  1363.   }
  1364.   
  1365.   /*
  1366. -  * Return the "best" of the two given termcap strings.
  1367. -  * The best, if both exist, is the one with the lower 
  1368. -  * cost (see cost() function).
  1369. -  */
  1370. -     static char *
  1371. - cheaper(t1, t2, doit, def)
  1372. -     char *t1, *t2;
  1373. -     char *doit;
  1374. -     char *def;
  1375. - {
  1376. -     if (*t1 == '\0' && *t2 == '\0')
  1377. -     {
  1378. -         cannot(doit);
  1379. -         return (def);
  1380. -     }
  1381. -     if (*t1 == '\0')
  1382. -         return (t2);
  1383. -     if (*t2 == '\0')
  1384. -         return (t1);
  1385. -     if (cost(t1) < cost(t2))
  1386. -         return (t1);
  1387. -     return (t2);
  1388. - }
  1389. - /*
  1390.    * Return the cost of displaying a termcap string.
  1391.    * We use the trick of calling tputs, but as a char printing function
  1392.    * we give it inc_costcount, which just increments "costcount".
  1393. --- 457,462 ----
  1394. ***************
  1395. *** 496,501 ****
  1396. --- 480,510 ----
  1397.       costcount = 0;
  1398.       tputs(t, sc_height, inc_costcount);
  1399.       return (costcount);
  1400. + }
  1401. + /*
  1402. +  * Return the "best" of the two given termcap strings.
  1403. +  * The best, if both exist, is the one with the lower 
  1404. +  * cost (see cost() function).
  1405. +  */
  1406. +     static char *
  1407. + cheaper(t1, t2, doit, def)
  1408. +     char *t1, *t2;
  1409. +     char *doit;
  1410. +     char *def;
  1411. + {
  1412. +     if (*t1 == '\0' && *t2 == '\0')
  1413. +     {
  1414. +         cannot(doit);
  1415. +         return (def);
  1416. +     }
  1417. +     if (*t1 == '\0')
  1418. +         return (t2);
  1419. +     if (*t2 == '\0')
  1420. +         return (t1);
  1421. +     if (cost(t1) < cost(t2))
  1422. +         return (t1);
  1423. +     return (t2);
  1424.   }
  1425.   
  1426.   
  1427. *** less.170/search.c    Wed Mar  6 12:16:53 1991
  1428. --- less/search.c    Tue Apr  2 16:01:20 1991
  1429. ***************
  1430. *** 10,20 ****
  1431.   
  1432.   extern int sigs;
  1433.   extern int how_search;
  1434. - extern int top_scroll;
  1435. - extern int back_scroll;
  1436.   extern int caseless;
  1437.   extern int linenums;
  1438. - extern int sc_height;
  1439.   extern int jump_sline;
  1440.   
  1441.   /*
  1442. --- 10,17 ----
  1443. ***************
  1444. *** 32,38 ****
  1445.       char *pattern;
  1446.       int n;
  1447.   {
  1448. !     POSITION pos, linepos;
  1449.       register char *p;
  1450.       register char *q;
  1451.       register int goforw;
  1452. --- 29,35 ----
  1453.       char *pattern;
  1454.       int n;
  1455.   {
  1456. !     POSITION pos, linepos, oldpos;
  1457.       register char *p;
  1458.       register char *q;
  1459.       register int goforw;
  1460. ***************
  1461. *** 64,70 ****
  1462.       goforw = (SRCH_DIR(search_type) == SRCH_FORW);
  1463.       want_match = !(search_type & SRCH_NOMATCH);
  1464.   
  1465. !     if (pattern != NULL && (is_caseless = caseless))
  1466.       {
  1467.           /*
  1468.            * Search will ignore case, unless
  1469. --- 61,67 ----
  1470.       goforw = (SRCH_DIR(search_type) == SRCH_FORW);
  1471.       want_match = !(search_type & SRCH_NOMATCH);
  1472.   
  1473. !     if (pattern != NULL && *pattern != '\0' && (is_caseless = caseless))
  1474.       {
  1475.           /*
  1476.            * Search will ignore case, unless
  1477. ***************
  1478. *** 213,218 ****
  1479. --- 210,216 ----
  1480.       }
  1481.   
  1482.       linenum = find_linenum(pos);
  1483. +     oldpos = pos;
  1484.       for (;;)
  1485.       {
  1486.           /*
  1487. ***************
  1488. *** 260,268 ****
  1489.            * If we're using line numbers, we might as well
  1490.            * remember the information we have now (the position
  1491.            * and line number of the current line).
  1492.            */
  1493. !         if (linenums)
  1494.               add_lnum(linenum, pos);
  1495.   
  1496.           if (is_caseless)
  1497.           {
  1498. --- 258,272 ----
  1499.            * If we're using line numbers, we might as well
  1500.            * remember the information we have now (the position
  1501.            * and line number of the current line).
  1502. +          * Don't do it for every line because it slows down
  1503. +          * the search.  Remember the line number only if
  1504. +          * we're "far" from the last place we remembered it.
  1505.            */
  1506. !         if (linenums && abs(pos - oldpos) > 1024)
  1507. !         {
  1508.               add_lnum(linenum, pos);
  1509. +             oldpos = pos;
  1510. +         }
  1511.   
  1512.           if (is_caseless)
  1513.           {
  1514. ***************
  1515. *** 300,306 ****
  1516.           line_match = (re_exec(line) == 1);
  1517.   #else
  1518.   #if REGCOMP
  1519. !         linematch = regexec(regpattern, line);
  1520.   #else
  1521.           line_match = match(pattern, line);
  1522.   #endif
  1523. --- 304,310 ----
  1524.           line_match = (re_exec(line) == 1);
  1525.   #else
  1526.   #if REGCOMP
  1527. !         line_match = regexec(regpattern, line);
  1528.   #else
  1529.           line_match = match(pattern, line);
  1530.   #endif
  1531. *** less.170/tags.c    Wed Mar  6 12:17:00 1991
  1532. --- less/tags.c    Tue Apr  2 18:47:35 1991
  1533. ***************
  1534. *** 20,26 ****
  1535.    * and "tagpattern" to the search pattern which should be used
  1536.    * to find the tag.
  1537.    */
  1538. !     public int
  1539.   findtag(tag)
  1540.       register char *tag;
  1541.   {
  1542. --- 20,26 ----
  1543.    * and "tagpattern" to the search pattern which should be used
  1544.    * to find the tag.
  1545.    */
  1546. !     public void
  1547.   findtag(tag)
  1548.       register char *tag;
  1549.   {
  1550. *** less.170/ttyin.c    Wed Mar  6 12:17:01 1991
  1551. --- less/ttyin.c    Thu Mar 28 14:36:51 1991
  1552. ***************
  1553. *** 26,35 ****
  1554.       tty = open("CON", O_RDONLY|O_BINARY);
  1555.   #else
  1556.       /*
  1557. !      * Just use file descriptor 2, which in Unix
  1558. !      * is usually attached to the screen and keyboard.
  1559.        */
  1560. !     tty = 2;
  1561.   #endif
  1562.   }
  1563.   
  1564. --- 26,39 ----
  1565.       tty = open("CON", O_RDONLY|O_BINARY);
  1566.   #else
  1567.       /*
  1568. !      * Try /dev/tty.
  1569. !      * If that doesn't work, use file descriptor 2,
  1570. !      * which in Unix is usually attached to the screen,
  1571. !      * but also usually lets you read from the keyboard.
  1572.        */
  1573. !     tty = open("/dev/tty", 0);
  1574. !     if (tty < 0)
  1575. !         tty = 2;
  1576.   #endif
  1577.   }
  1578.   
  1579. *** less.170/version.c    Wed Mar  6 12:17:01 1991
  1580. --- less/version.c    Tue Apr  2 20:11:21 1991
  1581. ***************
  1582. *** 251,257 ****
  1583.    *    v141: Add edit_list for editing >1 file.    2/8/90   mark
  1584.    *    v142: Add :x command.                2/10/90  mark
  1585.    *    v143: Add * and @ modifies to search cmds.    2/11/90  mark
  1586. !  *          Change ESC-/ cmd from /@* to /*.
  1587.    *    v144: Messed around with ch_zero;         3/1/90   mark
  1588.    *          no real change.
  1589.    *    v145: Added -R and -v/-V for MSDOS;        3/2/90   mark
  1590. --- 251,257 ----
  1591.    *    v141: Add edit_list for editing >1 file.    2/8/90   mark
  1592.    *    v142: Add :x command.                2/10/90  mark
  1593.    *    v143: Add * and @ modifies to search cmds.    2/11/90  mark
  1594. !  *          Change ESC-/ cmd from /@* to / *.
  1595.    *    v144: Messed around with ch_zero;         3/1/90   mark
  1596.    *          no real change.
  1597.    *    v145: Added -R and -v/-V for MSDOS;        3/2/90   mark
  1598. ***************
  1599. *** 290,295 ****
  1600.    *    v170: Add optimization for BSD _setjmp;        1/17/91  mark
  1601.    *          fix #include ioctl.h TERMIO problem.
  1602.    *          (thanks to Paul Eggert)
  1603.    */
  1604.   
  1605. ! char version[] = "@(#) less  version 170";
  1606. --- 290,315 ----
  1607.    *    v170: Add optimization for BSD _setjmp;        1/17/91  mark
  1608.    *          fix #include ioctl.h TERMIO problem.
  1609.    *          (thanks to Paul Eggert)
  1610. +  *        Posted to USENET.
  1611. +  *    -----------------------------------------------------------------
  1612. +  *    v171: Fix -? bug in get_filename.        3/6/91    mark
  1613. +  *    v172: Fix G bug in empty file.            3/15/91   mark
  1614. +  *          Fix bug with ?\n and -i and uppercase
  1615. +  *          pattern at EOF!
  1616. +  *          (thanks to Paul Eggert)
  1617. +  *    v173: Change N cmd to not permanently change    3/17/91   mark
  1618. +  *          direction. (thanks to Brian Matthews)
  1619. +  *    v174: Fix bug with namelogfile not getting    3/18/91   mark
  1620. +  *          cleared when change files.
  1621. +  *    v175: Fix bug with ++cmd on command line.    3/18/91   mark
  1622. +  *          (thanks to Jim Meyering)
  1623. +  *    v176: Change | to not force current screen,    4/2/91    mark
  1624. +  *          include marked line, start/end from 
  1625. +  *          top of screen.  Improve search speed.
  1626. +  *          (thanks to Don Mears)
  1627. +  *    v177: Add LESSHELP variable.            4/2/91    mark
  1628. +  *          Fix bug with F command with -e.
  1629. +  *          Try /dev/tty for input before using fd 2.
  1630.    */
  1631.   
  1632. ! char version[] = "@(#) less  version 177";
  1633.