To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.cad.dev.macOpen lugnet.cad.dev.mac in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 CAD / Development / Macintosh / 333
332  |  334
Subject: 
Re: L3P v1.3 for Mac OSX
Newsgroups: 
lugnet.cad.dev.mac
Date: 
Wed, 11 Dec 2002 17:55:54 GMT
Viewed: 
1589 times
  
In lugnet.cad.dev.mac, Lars C. Hassing writes:
/* Like fgets, except that 1) any line ending is accepted (\n (unix),
\r\n (DOS/Windows), \r (Mac (OS9)) and 2) Str is ALWAYS zero terminated
(even if no line ending was found) */

Umm, fgets already does what 2) says above (unless you mean when end of file
is reached and the function returns NULL).  I'm not actually sure what goes
into the string when fgets returns NULL.  If no line ending is found (either
due to EOF during--but not before--the read, or reading n - 1 bytes), then
the returned string doesn't end with \n, but does have NULL termination.

One other thing.  If you're not already doing so, make sure to open your
files in binary mode.  There is a bug in fseek that can occur when you fseek
in a text file in Windows (based on the location returned by ftell).  It
appears to happen when you fseek to a location that Windows thinks is
already in the FILE buffer.  It then seeks to the wrong location due to the
fact that the CRs were stripped out of the buffered data.  I don't think
ungetc uses fseek, but I'm also not sure it's guaranteed not to.

--Travis Cobbs (tcobbs@REMOVE.halibut.com)



Message has 1 Reply:
  Re: L3P v1.3 for Mac OSX
 
(...) Right! I must have been sleeping or thinking of strncpy...? Please delete 2) from the comment. (...) According to the CRT source ungetc doesn't use fseek, but with L3fgets the need to open in text mode has gone, so I might as well open in (...) (22 years ago, 12-Dec-02, to lugnet.cad.dev.mac)

Message is in Reply To:
  Re: L3P v1.3 for Mac OSX
 
(...) I do consider it an error. I have now made an L3fgets that can handle any line ending. I have uploaded an update (URL) try it on the original problem files. /Lars PS. Here is L3fgets, You can use it in ldglite if you like. As Paul DiLascia (...) (22 years ago, 11-Dec-02, to lugnet.cad.dev.mac)

42 Messages in This Thread:














Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR