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 / 14510
  how does a line ends?
 
In the LDraw File Format ((URL) it is written that "LDraw files are plain text." and "Each line in the file is a single command.". Also in the LDraw.org File Format Version 1.0.0 ((URL) there is no more specification. I found some parts that do not (...) (18 years ago, 6-Apr-07, to lugnet.cad)
 
  Re: how does a line ends?
 
(...) Hi Mike, This thread ((URL) contains various bits of discussion about the issue. Given that all software works with DOS newlines (cr+lf) and some doesn't work with the other varieties I personally think that cr+lf should be forced on all (...) (18 years ago, 6-Apr-07, to lugnet.cad)
 
  Re: how does a line ends?
 
(...) There was some discussion about this issue recently. Unfortunately, this is not the kind of problem that can be solved by tightening up the spec. The problem is that people use different text editors on different operating systems to create (...) (18 years ago, 6-Apr-07, to lugnet.cad, FTX)
 
  Re: how does a line ends?
 
(...) I don't fully agree with this. In the nearly seven years since I released LDView 0.1, I've never once run into an LDraw file that LDView couldn't handle due to line terminations, and it requires the newline character to be present at the end (...) (18 years ago, 7-Apr-07, to lugnet.cad, FTX)
 
  Re: how does a line ends?
 
Travis Cobbs schrieb: (...) It seems that all of you are programming in C. As I am always programming in VB it is much work to implement a new 'Line Input' as VB assume a CRLF at the end of each line. I have just run a little prog against the parts (...) (18 years ago, 7-Apr-07, to lugnet.cad)
 
  Re: how does a line ends?
 
(...) I've been writing text parsing programs for over 20 years, and have found that the approach I've suggested works very well at detecting line ends in a consistent manner. Counting lines in a file by this method agrees with every compiler and (...) (18 years ago, 7-Apr-07, to lugnet.cad, FTX)
 
  Re: how does a line end?
 
(...) 1. I always use alt. b. "printf("Hello, world!n");" But as a self-made hobby programmer not knowing all the tweeks and geeks, I wouldn't be surprised if the interpretation of this may vary from one IDE to another, or if there is an .ini file (...) (18 years ago, 7-Apr-07, to lugnet.cad, FTX)
 
  Re: how does a line end?
 
(...) (For some unknown reason, all my backslashes disappeared in previous message.) /Tore (18 years ago, 7-Apr-07, to lugnet.cad)
 
  Re: how does a line end?
 
(...) Slight correction - "0x0D 0x0A" And this is kind of my point. The string you pass to printf() has \n only, which is only one byte. Offhand I don't remember if this is because of the Borland libraries, the operating system, or the fact that (...) (18 years ago, 7-Apr-07, to lugnet.cad, FTX)
 
  Re: how does a line end?
 
Tore Eriksson schrieb: (...) After read all this and also after I have had a look at (URL) I think that Tore is right by saying "read all and save secure". Do avoid for future discussions this should be mentioned also in the LDraw Specification. (...) (18 years ago, 7-Apr-07, to lugnet.cad)
 
  Re: how does a line end?
 
(...) Aaah, that's one of my most common mistakes. C is the third letter, so I think of it as 13 and not 12. (...) At last, someone agrees with me. :) There will still be a theoretical risk that problems will occur, "anything that can go wrong will (...) (18 years ago, 7-Apr-07, to lugnet.cad)
 
  Re: how does a line ends?
 
(...) You'll note that I didn't really say that there was anything wrong with your parsing routine (other than some personaly negative feelings about fgetc and ungetc). After fixing the bugs, it will do exactly what you say it will do. It's just (...) (18 years ago, 7-Apr-07, to lugnet.cad, FTX)
 
  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 == (...) (18 years ago, 7-Apr-07, to lugnet.cad, FTX)
 
  Re: how does a line ends?
 
(...) Yes, sorry that my post sounded overly defensive. I have something of a chip on my shoulder from years of working alongside programmers who want to take shortcuts at the expense of their users. Very few seem to appreciate that it is worth a (...) (18 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 (...) (18 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 (...) (18 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 (...) (18 years ago, 7-Apr-07, to lugnet.cad, FTX)
 
  Re: how does a line ends?
 
(...) (URL) Google to the rescue>. ROSCO (18 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 (...) (18 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 (...) (18 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 (...) (18 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 (...) (18 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 (...) (18 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 (...) (18 years ago, 9-Apr-07, to lugnet.cad, FTX)

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