diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2016-07-20 10:47:16 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2016-07-20 10:47:16 +0200 |
commit | 09a80f013841e294301e2a174622264b2527cd40 (patch) | |
tree | 3af0757a956be4119a90d6b5b4870f0d5f4550f4 | |
parent | 3239bc2435ddcd9dae0a177360a3644d85008c42 (diff) |
Sanitize library name-derived macro for illegal characters ('-', etc)
-rw-r--r-- | build2/cxx/link.cxx | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/build2/cxx/link.cxx b/build2/cxx/link.cxx index b80fc8b..88181aa 100644 --- a/build2/cxx/link.cxx +++ b/build2/cxx/link.cxx @@ -459,18 +459,23 @@ namespace build2 // string d ("-DLIB"); - //@@ CASE - - auto upcase = [] (char c) + auto upcase_sanitize = [] (char c) -> char { - const unsigned char shift ('a' - 'A'); - return c >= 'a' && c <='z' ? c - shift : c; + if (c >= 'a' && c <='z') + { + const unsigned char shift ('a' - 'A'); + return c - shift; + } + else if (c == '-' || c == '+' || c == '.') + return '_'; + else + return c; }; transform (t.name.begin (), t.name.end (), back_inserter (d), - upcase); + upcase_sanitize); d += '_'; d += suffix; |