LDraw.org Discussion Forums

Full Version: Leading or trailing white space characters in file names
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6
Since the whitespace is out of the door I'd like resume this:

Travis Cobbs Wrote:In addition to the above, I also feel we should codify MLCad's behavior, since it appears to be the de-facto standard. This can be done by adding the following sentence to the end of that paragraph in the spec:

Proposed LDraw Specification Addition Wrote:Furthermore, filenames must not contain leading or trailing white space characters.

However, if there's any disagreement about the above at all, then I think we should vote on the first two changes immediately, and temporarily table discussion of leading and trailing whitespace in the same way I'm proposing we temporarily table discussion of Roland's point.
I don't see any valid reason for allowing leading and or trailing white spaces.

But if we do allow it, we need to think about introducing quotes as-well so parsers know where the start and end.

Backwards compatibility will break with quotes (in means of software failing to find the referenced file) but so does using leading/trailing white spaces.

Also when we declare leading and or trailing white spaces 'invalid' then we must also define exactly what 'white spaces' are.
I'm against supporting quoted filenames purely on the basis that they aren't supported by most (any?) current LDraw software. They probably would have been a better solution, had that been done back when spaces first started appearing in filenames in LDraw files, but since things have been the way they are right now for so long, I think giving an official stamp of approval to the behavior as I described is the best thing to do.
Travis Cobbs Wrote:In addition to the above, I also feel we should codify MLCad's behavior, since it appears to be the de-facto standard. This can be done by adding the following sentence to the end of that paragraph in the spec:

Proposed LDraw Specification Addition Wrote:Furthermore, filenames must not contain leading or trailing white space characters.

I strongly support codifying a restriction against leading and trailing whitespace for Line Type 1 file references. Leading whitespace is technically impossible without breaking backward compatibility. Trailing whitespace is technically possible, but the de facto standard behavior of parsers is to ignore it. Unfortunately, that is tribal knowledge. I think it needs to be in the spec.

I oppose mandating any restrictions on freestanding files (unreferenced by any Type 1 lines). This is because users have name control outside of LDraw software, so they can easily create filenames using any characters or arrangements permissible on the filesystem. I think it would be weird to mandate that an editor reject files for any reason other than an internal syntax error.

I happily support any non-binding warnings in the spec advising against doing such a thing for freestanding files due to the impossibility of eventually referencing them in another file. Editor authors would then be free to convey that warning to users as well. I just think it inadvisable to mandate it.

Allen
That makes sense. How about the following wording as a replacement for what I said above:
Proposed LDraw Specification Addition Wrote:Furthermore, filenames that contain leading or trailing white space characters cannot be referenced from other LDraw files, so they are discouraged.

In addition to the above, update the <file> specification for type 1 lines to be as follows (adding the second sentence):

Proposed LDraw Specification Change Wrote:<file> is the filename of the sub-file referenced and must be a valid LDraw filename. Any leading and trailing white space around the filename will be ignored.
I agree with this, but it also needs a definition of what 'white spaces' are. e.g. (\t, \r, \n, \0, ' ')
Good point. I just looked at LDView's code, and it's actually inconsistent (in other words, broken). For finding spaces prior to the filename it uses the C library function isspace(). For spaces after the filename, it only treats space and tab and white space characters.

According to here, isspace() considers the following to be white space:
  • space
  • horizontal tab
  • newline
  • vertical tab
  • form feed
  • carriage return

The newline and carriage return characters are already excluded, since they have special meaning in an LDraw file. I'm not real sure about form feed and vertical tab, though.
Roland Melkert Wrote:I agree with this, but it also needs a definition of what 'white spaces' are. e.g. (\t, \r, \n, \0, ' ')

The spec already explicitly defines the valid field-delimiting whitespace to be '\t' and ' '. I would expect the definition of "whitespace" in reference to part names would be identical to the field-delimiting values.

\0 is a pathological case, and anyone who has managed to insert one into his file deserves exactly what he's going to get.

Allen
Change to:

Proposed LDraw Specification Change Wrote:<file> is the filename of the sub-file referenced and must be a valid LDraw filename. In addition, any leading and trailing white space around the filename will be ignored.
That seems reasonable.
Pages: 1 2 3 4 5 6