From: Mikko Rasa Date: Thu, 5 Jan 2023 07:53:18 +0000 (+0200) Subject: Make sure the name of the build macro is valid X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=d068c62aac1825a0da5619dc4ca50ce3186bc37a;p=builder.git Make sure the name of the build macro is valid Component names are arbitrary strings, so non-alphanumeric characters must be dealt with. --- diff --git a/source/lib/component.cpp b/source/lib/component.cpp index 2763909..f6ef96c 100644 --- a/source/lib/component.cpp +++ b/source/lib/component.cpp @@ -27,7 +27,11 @@ void Component::prepare() void Component::create_build_info() { BuildInfo final_build_info; - final_build_info.defines[toupper(name)+"_BUILD"] = "1"; + string build_macro = toupper(name)+"_BUILD"; + for(char &c: build_macro) + if(!isalnum(static_cast(c))) + c = '_'; + final_build_info.defines[build_macro] = "1"; const Package::Requirements &pkg_reqs = package.get_required_packages(); Package::Requirements direct_reqs = requires;