Reading lexer.c, in order to find out what's causing me problems on my PowerMac, I came across this snippet, and I'd like to point out that it is not reliable:

            case '\r':
                p++;
if (*p != '\n') // if CR stands by itself
                    endOfLine();
continue; // skip white space

            case '\n':
                p++;
                endOfLine();
continue; // skip white space


-The problem is that on some hosts,
\r gives you the character code 13, while \n gives you the character code 10,
on other hosts,
\r gives you the character code 10, while \n gives you the character code 13.

This is crazy, yes, but in order to be sure, that things will always work, I suggest always using hexadecimal numbers.

This is why picture formats, such as PNG and GIF do not specify their identifier as ASCII characters but in hex-codes. PPM is an image format, that's supposed to be portable, but unfortunately, they did not know about this problem. This causes some platforms to write PPM formats, that can not be read on other platforms.

Usually, I prefer using enum or #define to create constants that translate to hexadecimal numbers.

Reply via email to