aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bdep/new.cxx26
-rw-r--r--bdep/utility.hxx1
2 files changed, 11 insertions, 16 deletions
diff --git a/bdep/new.cxx b/bdep/new.cxx
index 3a79486..681cc18 100644
--- a/bdep/new.cxx
+++ b/bdep/new.cxx
@@ -470,12 +470,7 @@ namespace bdep
case lang::c:
case lang::cxx:
{
- auto sanitize = [] (char c)
- {
- return (c == '-' || c == '+' || c == '.') ? '_' : c;
- };
-
- transform (s.begin (), s.end (), back_inserter (id), sanitize);
+ id = sanitize_identifier (const_cast<const string&> (s));
break;
}
}
@@ -1380,15 +1375,14 @@ namespace bdep
{
string ip (d.posix_representation ()); // Include prefix.
- string mp; // Macro prefix.
- transform (
- ip.begin (), ip.end () - 1, back_inserter (mp),
- [] (char c)
- {
- return (c == '-' || c == '+' || c == '.' || c == '/')
- ? '_'
- : ucase (c);
- });
+ // Macro prefix.
+ //
+ string mp (
+ sanitize_identifier (ucase (const_cast<const string&> (ip))));
+
+ // Strip the trailing underscore (produced from slash).
+ //
+ mp.pop_back ();
string apih; // API header name.
string exph; // Export header name (empty if binless).
@@ -1409,7 +1403,7 @@ namespace bdep
<< endl
<< "#include <stdio.h>" << endl
<< endl
- << "#include <" << ip << exph << ">" << endl
+ << "#include <" << ip << exph << ">" << endl
<< endl
<< "// Print a greeting for the specified name into the specified" << endl
<< "// stream. On success, return the number of character printed." << endl
diff --git a/bdep/utility.hxx b/bdep/utility.hxx
index c4cdef5..6121593 100644
--- a/bdep/utility.hxx
+++ b/bdep/utility.hxx
@@ -49,6 +49,7 @@ namespace bdep
using butl::trim;
using butl::next_word;
+ using butl::sanitize_identifier;
using butl::reverse_iterate;