From d068c62aac1825a0da5619dc4ca50ce3186bc37a Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 5 Jan 2023 09:53:18 +0200 Subject: [PATCH] Make sure the name of the build macro is valid Component names are arbitrary strings, so non-alphanumeric characters must be dealt with. --- source/lib/component.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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; -- 2.45.2