tinycpp
tinycpp copied to clipboard
Don't print newline on trailing #endif
tinycpp <<EOF
#if x
#endif
EOF
Prints a newline. Should it? During my examination of the code, I wasn't able to find a non-intrusive change that does not require peeking forward, which it seems you intentionally avoid.
hmm, for some reason i wasn't "watching" my own repo, so i wasn't notified of your report. i don't know the answer off the top of my head but the README specifically mentions that tinycpp preserves whitespace, however it's questionable whether it should in this case. does this break something, or is it a theoretical question?
Another example where it becomes clearer that an extra newline is printed would be:
tcpp <<EOF
#if x
a
#endif
b
EOF
This prints "\nb\n", where the first newline is superfluous. To answer your question, it for sure does not break the intended use case (being a C preprocessor).
For context, I was investigating lightweight alternatives to m5, and tinycpp could in my opinion be a good general-purpose preprocessor.
m5? are you refering to https://compilers.iecc.com/comparch/article/92-10-076 which i couldn't find any more information about, or did you mean to say m4?
Yes, I meant to say m4. Interesting find!