From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 28-APR-1989 00:46
To:	MRGATE::"ARISIA::EVERHART"
Subj:	Re: MORE utility for VMS

Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Thu, 27 APR 89 15:43:22 PDT
Received: from hac2arpa.hac.com by KL.SRI.COM with TCP; Thu, 27 Apr 89 15:36:36 PDT
Received: from [128.152.60.8] by hac2arpa.hac.com (5.59/SMI-DDN)
	id AA04791; Thu, 27 Apr 89 15:37:37 PDT
Received: by pyxis id <2600C0EB861@pyxis.HAC.COM> ;
       Thu, 27 Apr 89 15:35:33 PDT
Date: Thu, 27 Apr 89 15:35:27 PDT
From: Mike Kimura <MNK@pyxis.hac.com>
Subject: Re: MORE utility for VMS
To: info-vax%kl.sri.com@hac2arpa.hac.com
X-Vms-Mail-To: exos%"info-vax%kl.sri.com@hac2arpa.hac.com"
Message-Id: <890427153527.2600C0EB861@pyxis.HAC.COM>

Tal Barnea writes...

> Does anyone out there happen to have a MORE utility (as in Unix) for VMS?
> I have one written by Shan Xuning and it is great, except that now that we
> have upgraded to VMS 5.0, it refuses to work (even after recompiling/linking)
> If some good soul has a version that works, and cares to post it/email it,
> or else point me in the direction where it can be found, I would be grateful.

The problem with "more" and any other C program that uses fseek in V5.x 
VAXCRTL, is that when eof is reached the indicator is not cleared by
fseek-ing to another position.  You must explicitly clear the eof
indicator with "clearer(fp)".

Since "more" (called LESS.C in Info-VAX, written by Shan Xuning, modified
by, modified by M.  Warner Losh) has already been posted to Info-VAX;  and
since I can not reach the author or the modifiers by E-mail;  and since the
fseek problem is a generic VAXC problem;  I am posting the explanation of
the problem and fix to "more".  If anyone needs the source to "more", I'd be
glad to send you out a version fixed for VMS V5.x even though I'm not the
author or one of the  "major" modifiers of "more".

Mike
----------------------------------------------------------------------------
Michael Kimura			Internet:	mnk%draco@hac2arpa.hac.com
Hughes Aircraft Company (RSG)	BITnet:		mnk@draco.hac.com
P.O. Box 92426	  MS: R2/A159	EDEN:		draco::mnk
Los Angeles,  CA  90009		Telephone:	(213) 615-9775
----------------------------------------------------------------------------

===========================================================================
Here's how to fix "more"

In subroutine "more" add "clearerr(fp)" after the lines:

---------------------------------------------------------------------
  fseek(fp, (long)0, 2);
  file_size = ftell(fp);
  fseek(fp, win[0], 0);

  clearerr(fp);		/***** ADD THIS LINE *****/
---------------------------------------------------------------------

Also in subroutine "more" add "clearerr(fp)" after the lines:

---------------------------------------------------------------------
      case 'n':
        wc_save = wc;
        fgets(a_line, BUFSIZ, fp);
        line_count = 1;
        while ((pat_found=find(pattern, a_line)) < 0) {
            if (fgets(a_line, BUFSIZ, fp) == NULL) {
              wc = wc_save;
	      clearerr(fp);	/***** ADD THIS LINE *****/
              fseek(fp, win[wc], 0); 
              standout();
              fputs("\nPattern not found.\n", stdout);
              standend();
              break;
            } 
---------------------------------------------------------------------

