diff options
author | Michi Henning <michi@zeroc.com> | 2006-02-21 05:54:04 +0000 |
---|---|---|
committer | Michi Henning <michi@zeroc.com> | 2006-02-21 05:54:04 +0000 |
commit | 3dc2d66f150de985aa43b88f9b2638f581c05aa4 (patch) | |
tree | 12dbc5d94d18026254ea73025a0c5e5198d375c0 | |
parent | Bug 857. (diff) | |
download | ice-3dc2d66f150de985aa43b88f9b2638f581c05aa4.tar.bz2 ice-3dc2d66f150de985aa43b88f9b2638f581c05aa4.tar.xz ice-3dc2d66f150de985aa43b88f9b2638f581c05aa4.zip |
Bug 716.
-rw-r--r-- | cpp/src/Slice/Scanner.l | 26 |
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) { |