On 02 Nov 1999 11:08:54 +0100, Jean-Marc Lasgouttes wrote:

>>>>>> "Lars" == Lars Gullik Bj°nnes <[EMAIL PROTECTED]> writes:
>
>Lars> First of all I wonder what we want to achieve with this
>Lars> functions. I understand that we want to avoid characters that
>Lars> can give us problems with filenames on different systems.
>
>I wanted to post exactly the same kind of message today... From what I
>understand, we do not care in SpaceLess about file systems: we have
>the name of a lyx document, and we can assume that this is a correct
>file name. SpaceLess() is only useful for LaTeX. We could have another
>function which checks whether a file name is correct for a given file
>system, but this is not the point here.
>
>Lars> On linux/unix I know of only one char: '/'
>
>So for LaTeX, the answer is clear: we only want characters which
>\catcode is either 11 (letter) or 12 (other).
>
>11: abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
>
>12: ^^J@!"'()*+,-./0123456789:;<=>?[]`|
>
>Of course, 8bit chars and control characters other than ^^J (aka \n)
>are out.
>
>Thoughts?

When I changed the function I had only LaTeX in mind. IMHO local file
system names are not a LyX problem. However, as I used isalnum()
macro/inline fn, I had to make sure it works as expected even with
multi-byte charsets (which is not guaranteed). So I agreed with Shigeru
Miyata to first cut off bits > 7.

--- lyx-1.0.4/src/filetools.C   Tue Aug 31 04:45:08 1999
+++ lyx-1.0.x/src/filetools.C   Tue Oct  5 14:10:12 1999
@@ -79,11 +79,17 @@ LString SpaceLess(LString const & file)
        LString name = OnlyFilename(file);
        LString path = OnlyPath(file);
        
-       for (int i=0; i<name.length(); i++) {
-               name[i] &= 0x7f;
-               if (!isalnum(name[i]) && name[i] != '.')
+       for (int i = 0; i < name.length(); i++) {
+
+       // cut off bits>7, because some ctype.h implementations
of'isalnum' 
+       // are broken with certain non-7-bit characters! (AHanses)
+               name[i] &= 0x7f; 
+               if (!isalnum(name[i]) && name[i] != '.' && name[i] !=
'-'
+                 && name[i] != '+' && name[i] != '=' && name[i] !=
'_')
+
                        name[i] = '_';
        }
+
        LString temp = AddName(path, name);


If you bother about OS/2-FS: It's a bit complicated. HPFS has not much
restrictions, even spaces are allowed with recent implementations (I'm
not sure about very old and buggy driver versions, though). Only you
have to take into account the old DOS compatibility system FAT, if you
want to support that; installing OS/2 on FAT means asking for serious
trouble, for XFree you need HPFS anyway, FAT is not supported. So you
have the restrictions known for DOS on a FAT partition. (I still only
use FAT as a shared partition for data exchange among different OS's.)
Then, you never know which hex number is which character/glyph: OS/2
uses dozends of completely different single and double-byte
NLS-charsets in file systems and I have absolutely no idea how 0x20 in
a file name will look like with NLS in Malaysia or Ethiopia ;-).

But I doubt that LyX should want to care at all about that.

Greets,

        Arnd

Reply via email to