To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.cadOpen lugnet.cad in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 CAD / 14523
  Re: how does a line ends?
 
(...) OK, as promised, here it my fgets replacement: char *myFgets(char *buf, int bufSize, FILE *file) int i; for (i = 0; i < bufSize - 1; i++) int char1 = fgetc(file); if (feof(file)) bufi = 0; if (i > 0) return buf; else return NULL; if (char1 == (...) (17 years ago, 7-Apr-07, to lugnet.cad, FTX)
 
  Re: how does a line ends?
 
(...) That was quick! Thanks for taking the time to indulge me... (...) It is interesting that it was that much time difference. Are these the total load times, or just profiling of the time spent inside the fgets() routines? I see one or two things (...) (17 years ago, 7-Apr-07, to lugnet.cad, FTX)
 
  Re: how does a line ends?
 
(...) I timed the file reading/parsing portion of the model load. It would have been more difficult to time the actual amount of time spent inside fgets/myFgets, so realistically it's likely that myFgets is even slower in comparison to fgets. The (...) (17 years ago, 7-Apr-07, to lugnet.cad, FTX)
 
  Re: how does a line ends?
 
(...) Quick question. I was in a hurry, and wanted to play it safe, so I call feof instead of checking to see if char1 == EOF. Any idea what gets returned for extended ASCII characters (>= 128)? Does the int contain positive numbers greater than (...) (17 years ago, 7-Apr-07, to lugnet.cad, FTX)
 
  Re: how does a line ends?
 
(...) (URL) Google to the rescue>. ROSCO (17 years ago, 7-Apr-07, to lugnet.cad, FTX)
 
  Re: how does a line ends?
 
(...) Just as a proof of the value of disk caching, loading the same model using the system fgets after a fresh reboot, the same loading portion took 3300ms. Also, I switched the feof calls out for a check of the value against EOF just to see if it (...) (17 years ago, 7-Apr-07, to lugnet.cad, FTX)
 
  Re: how does a line ends?
 
(...) Thanks, ROSCO. I took that code and modified it to use char instead of _TCHAR, and got timings of 720-750ms, compared to the 750-780ms I got with my original one. I then modified it to support CR and LF interchangeably, and got back to the (...) (17 years ago, 7-Apr-07, to lugnet.cad, FTX)
 
  Re: how does a line ends?
 
(...) Interesting. I looked at the C runtime library sources that came with MSVC++ 6.0. The fgets() function there is definitely a little different than either yours or the one ROSCO linked. It does have a couple calls for thread safety, but (...) (17 years ago, 7-Apr-07, to lugnet.cad, FTX)
 
  Re: how does a line ends?
 
(...) As long as you only have one character to 'unget' you could probably speed it up by introducing a static char which holds the 'ungetted' char (or null), instead of going through ungetc() -- fgetc(). OTOH, the if-statement to check if there is (...) (17 years ago, 8-Apr-07, to lugnet.cad)
 
  Re: how does a line ends?
 
(...) I thought about using a static instead of ungetc() in the first version of readLine() that I posted. This means that you can only read from one open file at a time, but that is usually an OK restriction as long as the programmer is aware of (...) (17 years ago, 8-Apr-07, to lugnet.cad, FTX)
 
  Re: how does a line ends?
 
(...) Now that I'm at work, I'm able to look at Microsoft's implementation of fgets for Visual Studio 2005. They do a lock on the file prior to their loop, then call _fgetc_nolock to get each character, instead of fgetc or fread. (That's an (...) (17 years ago, 9-Apr-07, to lugnet.cad, FTX)

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