]> git.tdb.fi Git - builder.git/commitdiff
Make sure the name of the build macro is valid
authorMikko Rasa <tdb@tdb.fi>
Thu, 5 Jan 2023 07:53:18 +0000 (09:53 +0200)
committerMikko Rasa <tdb@tdb.fi>
Thu, 5 Jan 2023 08:03:11 +0000 (10:03 +0200)
Component names are arbitrary strings, so non-alphanumeric characters
must be dealt with.

source/lib/component.cpp

index 2763909a441f5f7053997f1e4cb641505fee9106..f6ef96cf824d4a13008d7f09f63248f6953753cc 100644 (file)
@@ -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<unsigned char>(c)))
+                       c = '_';
+       final_build_info.defines[build_macro] = "1";
 
        const Package::Requirements &pkg_reqs = package.get_required_packages();
        Package::Requirements direct_reqs = requires;