3 ms·
Instead of just gazing at the sea of terse variable names in awe, try actually reading it! There's only about a dozen variables and they're all documented at th
by dTal 7y ago
Instead of just gazing at the sea of terse variable names in awe, try actually reading it! There's only about a dozen variables and they're all documented at the top - the actual code is actually amazingly clear for what it does. There's not a lot of gratuitous cleverness.
For example, just picking a random segment, you don't have to squint very hard to see that this is a number literal parser:
else if (tk >= '0' && tk <= '9') {
if (ival = tk - '0') { while (*p >= '0' && *p <= '9') ival = ival * 10 + *p++ - '0'; }
else if (*p == 'x' || *p == 'X') {
[...goes on to handle the hexadecimal case...]
(aside - I love the conversion from string to decimal by subtracting the string value of '0', as this will work for any text encoding where the decimal digits are monotonic and contiguous - so ASCII and EBDIC at least...)
- aasasd 7y ago> I love the conversion from string to decimal by subtracting the string value of '0' That's how everyone did character arithmetic since forever, though, especially with the letters. Wouldn't be surprised if it's in K&R. And it probably became a subtle source of errors when environments changed, as mixing semantics and implementation tends to do.
- edflsafoiewq 7y ago>as this will work for any text encoding where the decimal digits are monotonic and contiguous The C spec requires this be the case for both the source and execution basic character sets.