Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: replace "\\" with "\" in raw string
in Python, a raw string is created using 'r' or 'R' prefix. when creating the regex using Python string, sometimes, we have to use "\" to escape the parenthesis so the tools like "sed" can consider the parenthesis as a capture group. but "\" is also used to escape strings in Python, in order to put "\" as it is, we use "\" instead of escaping "\" with "\\" which is obscure. turns out in CPython 3.12, it loyally generates "\\" if "\\" is in a raw string. so "sed" is confused when executing the generated build rule, like: ``` [3/36] ANTLR3 alternator/expressions.g FAILED: build/debug/gen/alternator/expressionsLexer.cpp build/debug/gen/alternator/expressionsLexer.hpp build/debug/gen/alternator/expressionsParser.cpp build/debug/gen/alternator/expressionsParser.hpp sed -e '/^#if 0/,/^#endif/d' alternator/expressions.g > build/debug/gen/alternator/expressions.g && antlr3 build/debug/gen/alternator/expressions.g && sed -i -e '/^.*On :.*$/d' build/debug/gen/alternator/expressionsLexer.hpp && sed -i -e '/^.*On :.*$/d' build/debug/gen/alternator/expressionsLexer.cpp && sed -i -e '/^.*On :.*$/d' build/debug/gen/alternator/expressionsParser.hpp && sed -i -e 's/^\\( *\)\\(ImplTraits::CommonTokenType\\* [a-zA-Z0-9_]* = NULL;\)$/\1const \2/' -e '/^.*On :.*$/d' -e '1i using ExceptionBaseType = int;' -e 's/^{/{ ExceptionBaseType\* ex = nullptr;/; s/ExceptionBaseType\* ex = new/ex = new/; s/exceptions::syntax_exception e/exceptions::syntax_exception\& e/' build/debug/gen/alternator/expressionsParser.cpp sed: -e expression #1, char 80: Unmatched ) or \) ``` in this change, we replace "\\" with "\" in raw string where we intend to put a single "\" in the created string. this is accepted by both Python 3.11 shipped along with Fedora 38 and Python 3.12 shipped along with Fedora 39. Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
- Loading branch information