Skip to content(if available)orjump to list(if available)

The fix wasn't easy, or C precedence bites

loeg

There's another bug, where you don't update psrc in those error return cases. The parser will be stuck at the malformed % forever. Or maybe that is desired; it's hard to tell.

The precedence stuff here is pretty basic. When in doubt, using parentheses to make order explicit is never wrong. Or consult https://en.cppreference.com/w/c/language/operator_precedence... .

bsder

Even as someone who doesn't mind writing in C, I would absolutely flag that function as way, way, way, way too terse for no good reason.

The code gets ridiculously easier to read if you write src[0] and src[1] instead of (*src) and (*(src+1)). And, as a bonus, the precedence problem disappears.

I really don't understand people why write C code like the original code. It's just asking for a bug.

null

[deleted]

shash

In general avoid frivolous use of pointer arithmetic. foo[k] and *(foo+k) will usually generate identical asm, and the former is just easier to read…

spyrja

And for the love of God, please don't do 0[src].