summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp')
-rw-r--r--cpp/src/Slice/Scanner.l26
1 files changed, 25 insertions, 1 deletions
diff --git a/cpp/src/Slice/Scanner.l b/cpp/src/Slice/Scanner.l
index b7541770978..cb7ef274978 100644
--- a/cpp/src/Slice/Scanner.l
+++ b/cpp/src/Slice/Scanner.l
@@ -431,8 +431,32 @@ checkIdentifier(const string& id)
unit->error("illegal underscore in identifier `" + id + "'");
}
+ //
+ // Apparently on some platforms, [:alpha:] includes characters outside
+ // the ASCII range (such as the copyright sign). We add an extra scan
+ // here to print a meaningful error message for such platforms.
+ //
+ static const string legalChars = "0123456789abcdefghijklmnopqrstuvwxyz"; // Sorted in increasing ASCII order.
+
+ size_t i;
+
+ for(i = 0; i < id.size(); ++i)
+ {
+ if(!binary_search(legalChars.begin(), legalChars.end(), ::tolower(id[i])))
+ {
+ stringstream s;
+ s.width(3);
+ s.fill('0');
+ s << oct << static_cast<unsigned int>(static_cast<unsigned char>(id[i]));
+ unit->error("illegal character in identifier: '\\" + s.str() + "'");
+ }
+ }
+
+ //
+ // Weed out identifiers with reserved suffixes.
+ //
static const string suffixBlacklist[] = { "Helper", "Holder", "Prx", "Ptr" };
- for(size_t i = 0; i < sizeof(suffixBlacklist) / sizeof(*suffixBlacklist); ++i)
+ for(i = 0; i < sizeof(suffixBlacklist) / sizeof(*suffixBlacklist); ++i)
{
if(id.find(suffixBlacklist[i], id.size() - suffixBlacklist[i].size()) != string::npos)
{