On Sun, 29 Aug 1999 10:06:38 +0900, Shigeru Miyata wrote:

>Lars, some of the discussion between me and Arnd was actually
>intended for the official version of LyX 1.0  Sorry we didn't
>make the distinction very clear.
>Please apply the patch below and replace lib/configure.cmd
>or 1.0.4 won't work here.

Just some suggestions:
This version is clear and simple:

+++ filetools.C Sat Aug 28 16:46:56 1999
@@ -78,26 +78,16 @@
 {
[...]   
+       for (int i=0; i<name.length(); i++) {
+               name[i] &= 0x7f;
+               if (!isalnum(name[i]) && name[i] != '.')
+                       name[i] = '_';
+       }
        LString temp = AddName(path, name);
        // Replace spaces with underscores, also in directory
-       temp.subst(' ','_');
+       // No!!! I checked it that it is not necessary.
+       // temp.subst(' ','_');
 
        return temp;
 }

Nevertheless I would like to ask Jean-Marc (once recovered from holiday
stress ;), if it weren't more convenient to provide some configure
support for a more generic solution, where sysadmins can easily adapt
to their needs (shells and latex version, encoding, headers, libraries,
etc.). 

My general problem with hiding 'magic' deep down in the code is
bug-fixing and extension to special needs: Things are unnecessarily
complicated if you don't have all the 'magic' nicely collected at your
disposal in a table in config.h, etc. Well written code should be
flexible.

Please note: 
The pre-processor can spit out something closely typed, so that you
don't lose type checks, if you are careful. Many systems (like emx)
provide special inline functions instead of macros for the purpose;
sysadmins should be able to choose which is optimal for their boxes:

                CUT_TO_ASCII(name[i]);  // make test foreseeable
                if (NO_FOE(name[i]))
                ;       /* Let pass friend of LaTeX & Co. */
                else    /* Stop foe bound to sabotage */ 
                        name[i] = REPLACER;

        This line (IIRC) was introduced to fix some linux print script
problem (not connected to emx):

        // No!!! I checked it that it is not necessary.
        // temp.subst(' ','_');

Did you check Linux printer configuration scripts? Certainly this hack
always was misplaced here! IMHO it is something for configure, too!



Eventually you'd find something like this in your os_config.h:

/ Let pass through NO_FOE of LaTeX & shell; stop the foe:
// He's bound to sabotage... So replace him with REPLACER.
/* SMiyata: AND 0x7f a string bitwise is more efficient than subst();
   ISO-8859-x and EUC (Extended Unix Code) works just fine with this.
   The only remaining problem is that Microsoft/IBM codepages, 
   Shift-JIS and Big5 utilizes the region 0x80-0x9f which will be 
   converted to non-printable control characters. 
   AHanses: Used in 'toAsciiAlnum()'
   */
#define MASK_RANGE        127 /* LaTeX as such is '7-bit clean' */
#define CUT_TO_ASCII(i)   (i &= MASK_RANGE)
#define EXTENSION_MARKER  '.' /* Let pass through the 'full-stop' */
#define BLANK_MARKER      '_' /* Let through the 'underscore' */
#define NO_FOE(c) (isalnum(c)||c==BLANK_MARKER||c==EXTENSION_MARKER)
#define REPLACER          'x'   /* Which is your favourite? */

Greets,
        Arnd

Reply via email to