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 / 325
324  |  326
Subject: 
Re: L3P v1.3 for Mac OSX
Newsgroups: 
lugnet.cad.dev.mac
Date: 
Wed, 11 Dec 2002 11:05:26 GMT
Viewed: 
1402 times
  
In lugnet.cad.dev.mac, Erik Olson writes:
Lars, I used L3P this weekend. Since this is my first time using it, I
tested only very simple uses. No problems found, unless you consider it a
bug that it behaves badly with CR line endings

I do consider it an error.
I have now made an L3fgets that can handle any line ending.
I have uploaded an update http://www.hassings.dk/l3/l3p/l3pmacosx.zip
Please try it on the original problem files.
/Lars
PS. Here is L3fgets, You can use it in ldglite if you like.

As Paul DiLascia says:
/* If this code works, it was written by Lars C. Hassing. */
/* If not, I don't know who wrote it.                     */

/* 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) */
char *L3fgets(char *Str, int n, FILE *fp)
{
   register int   c;
   int            nextc;
   register char *s = Str;

   while (--n > 0)
   {
      if ((c = getc(fp)) == EOF)
         break;
      if (c == '\032')
         continue;              /* Skip CTRL+Z                               */
      if (c == '\r' || c == '\n')
      {
         *s++ = '\n';
         /* We got CR or LF, eat next character if LF or CR respectively */
         if ((nextc = getc(fp)) == EOF)
            break;
         if (nextc == c || (nextc != '\r' && nextc != '\n'))
            ungetc(nextc, fp);  /* CR-CR or LF-LF or ordinary character      */
         break;
      }
      *s++ = c;
   }
   *s = 0;

   /* if (ferror(fp)) return NULL; if (s == Str) return NULL; */
   if (s == Str)
      return NULL;

   return Str;
}



Message has 2 Replies:
  Re: L3P v1.3 for Mac OSX
 
(...) Hey, thanks Lars. Where should I put it? L3Input.cpp, or a separate file like platform.c? Don (22 years ago, 11-Dec-02, to lugnet.cad.dev.mac)
  Re: L3P v1.3 for Mac OSX
 
(...) 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 (...) (22 years ago, 11-Dec-02, to lugnet.cad.dev.mac)

Message is in Reply To:
  Re: L3P v1.3 for Mac OSX
 
Lars, I used L3P this weekend. Since this is my first time using it, I tested only very simple uses. No problems found, unless you consider it a bug that it behaves badly with CR line endings. It's hard to tell which input file it is complaining (...) (22 years ago, 4-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