3 ms·
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; i
by loeg 1y ago
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.html https://en.cppreference.com/w/c/language/operator_precedence... .
- augustk 1y agoBetter stick to a single point of exit. https://news.ycombinator.com/item?id=20311080 https://news.ycombinator.com/item?id=20311080
- foofoo12 1y agoThere is nothing wrong with early exit, but you have to be sensible. Just like there's nothing wrong with the ternary operator if you are sensible. I've seen nested ?: abominations that would make Jesus give you a funny look.
- loeg 1y agoWell, maybe. Could also just use psrc directly instead of doing the manipulation in src.
- 1718627440 1y agoThe discussion you linked to convinces me of the opposite.
- SAI_Peregrinus 1y agoI disagree, I think returns should either be at the very start (checking inputs should be able to return before anything happens based on invalid inputs) or at the very end. Proceeding to do a bunch of stuff & then try to undo it because an input was invalid is error-prone.
- augustk 1y agoIf the input parameters are invalid there is an error in the program so it makes more sense to use the assert function. Why would you need to undo something due to the restriction of a single point of exit?