From 09a80f013841e294301e2a174622264b2527cd40 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 20 Jul 2016 10:47:16 +0200 Subject: Sanitize library name-derived macro for illegal characters ('-', etc) --- build2/cxx/link.cxx | 17 +++++++++++------ 1 file 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; -- cgit v1.1