FidoNet Echomail Archive

<<< Previous Index Next >>>

From: Paul Edwards
To: Frank Adam
Date: 1997-03-02 12:33:06
Subject: Re: Borland C bug ?!?

FA> -=> Quoting Paul Edwards to Frank Adam <=-
FA>> But if the file is corrupt or missing \n on the last line, s will indeed
FA>> be junk or unterminated.
PE>> No, only if there is some ERROR will that happen, not if it 
PE>> reaches EOF.  So if there is an error, fgets() will return 
PE>> NULL, and that program would process junk.  BFN.  Paul.
FA> You're right, i though a missing 0d0a would cause an error. 
FA> Apparently not.
FA> Then in "paranoid mode" it'd have to be..

FA> while(NULL != fgets(buf,80,in))
FA> ((p = strrchr(buf,'\n')) != NULL) ? *p = '\0' : panic();

Why bother panicing?  Personally I just delete the '\n' if it is present,
otherwise, carry on with the rest of the processing.  BFN.  Paul.

 * Origin: X (3:711/934.9)
SEEN-BY: 633/267 270
@PATH: 711/934 712/624 50/99 635/728 633/267

<<< Previous Index Next >>>