The fix wasn't easy, or C precedence bites

https://news.ycombinator.com/rss Hits: 8
Summary

For the past decade now, I've done a Christmas release for mod_blog (only missing the years 2019 and 2023), just beacuse. I was poking around the codebase looking for changes I could make for Christmas this year, and well, I got a bit impatient and have just now released a version in time for Halloween. And it's scary—I'm removing features! I've removed features in the past, like no longer supporting “ping servers” when it became clear it wasn't worth it, or automatically updating Linked­Tik­Face­My­Insta­Pin­Me­Gram­We­Tok­In­Book­Space­Trest when Insta­Pin­Tik­My­Linked­Face­Me­Trest­Book­Gram­We­In­Space­Tok changed how it works often enough to make it annoying for me to continue. But this time … this time it's different. This is removing functionality that has existed in the code base since the beginning! To make it easier to write entries, I had code within mod_blog to process the input—mostly what existed was to convert sequences like ``quoted'' to “quoted” and “...” to “…”, but with an option to add <P> tags around logical paragraphs. But given that I now use my own markup language, I rarely used the web interface (like, I can count on my fingers the number of times I've used it and still have a few left over should give an indication of how little I use it) and the code just sat there, unused. So unused that in fixing one bug I introduced another bug in the code I fixed! To recap, here's the original code: char UrlDecodeChar(char **psrc) { char *src; char c; assert(psrc != NULL); assert(*psrc != NULL); src = *psrc; c = *src++; if (c == '+') c = ' '; else if (c == '%') { assert(isxdigit(*src)); assert(isxdigit(*(src+1))); c = ctohex(*src) * 16 + ctohex(*(src+1)); src += 2; } *psrc = src; return(c); } and the “fixed” version: char UrlDecodeChar(char **psrc) { char *src; char c; assert(psrc != NULL); assert(*psrc != NULL); src = *psrc; c = *src++; if (c == '+') c = ' '; else if (c == '%') { if (!isxdigit(*src)) return '\0'; if (!isxdigit(*src+1)) return '\0'; c...

First seen: 2025-10-25 04:52

Last seen: 2025-10-25 12:17