[logos] preprocess could not handle comment outed braces correctly.
When I recently update theos and all submodules to latest commit, some my project will display logos preprocessing error.
What are the steps to reproduce this issue?
- put this two lines in source code.
/*// }}}*/
/*// }}}*/
- build it
- logos preprocessing will failed.
This is reproducable project. https://github.com/r-plus/logos_issue_576
What happens?
logos preprocessing will failed.
$ gmake
> Making all for tweak test…
==> Preprocessing Tweak.x…
Tweak.x:2: error: fell off the face of the planet when we found a '}'
gmake[3]: *** [/opt/theos/makefiles/instance/rules.mk:258: /private/tmp/test/.theos/obj/debug/arm64/Tweak.x.m] Error 255
==> Preprocessing Tweak.x…
Tweak.x:2: error: fell off the face of the planet when we found a '}'
gmake[3]: *** [/opt/theos/makefiles/instance/rules.mk:258: /private/tmp/test/.theos/obj/debug/armv7/Tweak.x.m] Error 255
rm /private/tmp/test/.theos/obj/debug/arm64/Tweak.x.m
rm /private/tmp/test/.theos/obj/debug/armv7/Tweak.x.m
gmake[2]: *** [/opt/theos/makefiles/instance/library.mk:52: /private/tmp/test/.theos/obj/debug/armv7/test.dylib] Error 2
gmake[2]: *** Waiting for unfinished jobs....
gmake[2]: *** [/opt/theos/makefiles/instance/library.mk:52: /private/tmp/test/.theos/obj/debug/arm64/test.dylib] Error 2
==> Preprocessing Tweak.x…
Tweak.x:2: error: fell off the face of the planet when we found a '}'
gmake[3]: *** [/opt/theos/makefiles/instance/rules.mk:258: /private/tmp/test/.theos/obj/debug/arm64e/Tweak.x.m] Error 255
rm /private/tmp/test/.theos/obj/debug/arm64e/Tweak.x.m
gmake[2]: *** [/opt/theos/makefiles/instance/library.mk:52: /private/tmp/test/.theos/obj/debug/arm64e/test.dylib] Error 2
gmake[1]: *** [/opt/theos/makefiles/instance/library.mk:37: internal-library-all_] Error 2
gmake: *** [/opt/theos/makefiles/master/rules.mk:117: test.all.tweak.variables] Error 2
What were you expecting to happen?
success logos preprocess.
Any logs, error output, etc?
already pasted.
Any other comments?
preprocess succeeded before updating theos.
What versions of software are you using?
Operating System: … macOS 11.2.1
Toolchain Version: … Xcode 12.3
SDK Version: … iOS 14.x
using theos and logos current latest commit point.
theos: https://github.com/theos/theos/commit/bad20b2d02c6a08988cda972fbe3a2aeda326ff9 logos: https://github.com/theos/logos/commit/a733c99539ed9ef2a3914528d8c5522dc2396789
Before updating theos and logos I'm using https://github.com/theos/logos/commit/b336e3f4f8120b8d7c4a0a9e4d121de0ac440f42 commit point of logos. That logos version will not display error.
This issue will occur using after https://github.com/theos/logos/commit/ed22e75b10dbee6bea6b000893731822f8bd3874 commit point.
Maybe we should actually use a preprocessor to handle comments, as logos works line-by-line and that's just bad.
Something like this could be ran before parsing the logos file:
sed -e 's/#/_#_/g' input.ext | clang -E -P - | sed -e 's/_#_/#/g' > output.ext
This is the side by side comparison:
➤ pr -m -t input.ext output.ext
#include <stdio.h> #include <stdio.h>
1 1
2 2
// 3
4 4
5 5
//6/*
7 // 3 7
9 */ 9 */
0 0
#define A(a) #a #define A(a) #a
A(aa) A(aa)
int main(int c, char ** v) { int main(int c, char ** v) {
return 0; return 0;
} }
Fixed in #96