On Sat, 24 Jul 1999 13:35:03 -0500, Richard E. Hawkins wrote:

> 
>> Well, and this one:
>> 
>> >+           p->s[i] |= 0x20; /* fill dwarf bits to 32 and */
>> >+           p->s[i] &= 0x7f; /* decapitate all giants ... */
>> 
>> This is efficient but random toggles many ascci chars... A bloody
>> massacre of many innocent bits...
> 
>
>XOR them all and let the processor sort them out :)

You mean a toggle of all set bits of the mask, so that you can almost
be sure, that at least one non-printable or non-ASCCI will result:
Those file name picky versions of LaTeX will never run, your work will
never be printed...
Although this may be a desirable perspective for some, this is not what
I want at this moment... :)

Problematic are ascii 0-47, 58-64, 91-94, 96, >=123. Did I forget one?

Let's put hacking aside for a moment. Safer is the following method


LString& LString::toAsciiAlnum():
{
        for (int i=0; i<length(); i++) {

[...]
LString.C:              LString.h:
---------               ---------
p->s[i] &= MASK_RANGE;  #define MASK_RANGE 0x7f /* or use
enum */
                        /* make sure, test result is foreseeable */
if (!isalnum(p->s[i]))
  p->s[i] = REPLACER;   #define REPLACER _       /* or whatever */

[...]

        }
        return *this;
}

filetools.C:
-----------
// Substitute chars that LaTeX or shell can't handle with safe ones
LString SpaceLess(LString const & file)
{
        LString temp = file;
        temp.toAsciiAlnum();    /* AHanses:  if >127, subtract
                                        ** 127, 255 etc., put REPLACER
*/
        return temp;
}



Magic numbers, etc. don't go into the program body, so LString.h is the
right place.

Still a bit complicated, though.

Greets,
        Arnd

Reply via email to