Subject:
|
Re: how does a line ends?
|
Newsgroups:
|
lugnet.cad
|
Date:
|
Sat, 7 Apr 2007 04:21:58 GMT
|
Viewed:
|
1544 times
|
| |
| |
In lugnet.cad, Chris Phillips wrote:
|
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 LDRAW files, resulting in files that do not have consistent
line termination. Changing the specification will not fix all the files that
are already wrong, and it wont fix all the possible text editors, either.
A better solution, in my opinion, is for all tools to be able to handle any
combination of LF or CR characters as a proper line feed. (And the spec
should spell this out.) This is not all that hard to do, and it makes life
easier for your users. The amount of programming effort to code defensively
is probably less than the effort just one of your users will go through if
they have to work around this problem.
|
I dont fully agree with this. In the nearly seven years since I released
LDView 0.1, Ive never once run into an LDraw file that LDView couldnt handle
due to line terminations, and it requires the newline character to be present at
the end of each line. (The preceding carriage return is optional.) Im not
saying such files dont exist, but if so, theyre exceedingly rare.
Additionally, I suspect that they wont work with any of the major LDraw editors
(although they might work with Bricksmith).
Consequently, I feel that fgets is perfectly legitimate for reading lines, as
long as the program can deal with both DOS and Unix line endings. I dont
actually know for sure, but it was my understanding that fgetc is slow.
Additionally, ungetc is documented to not be guaranteed to work, although in
practice this appears to only be a problem if you call it twice in a row without
an intervening read.
--Travis
|
|
Message has 2 Replies: | | 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)
|
Message is in Reply To:
| | 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)
|
24 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
|
|
|
|