diff options
author | Jens Geyer <jensg@apache.org> | 2015-09-25 20:52:57 +0200 |
---|---|---|
committer | Jens Geyer <jensg@apache.org> | 2015-09-25 20:54:45 +0200 |
commit | 0621e1fc949a7e67c418b465f7f10ee082ea4a93 (patch) | |
tree | b013878bce7c7ecf06f09359c3d91f637d652acc | |
parent | c623197d37be470307c70c54d600ce8e74ed1373 (diff) | |
download | thrift-0621e1fc949a7e67c418b465f7f10ee082ea4a93.tar.gz |
THRIFT-3354 Fix word-extraction substr bug in initialism code
Client: Go
Author: Prashant Varanasi <prashant@uber.com>
This closes #625
-rw-r--r-- | compiler/cpp/src/generate/t_go_generator.cc | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/cpp/src/generate/t_go_generator.cc b/compiler/cpp/src/generate/t_go_generator.cc index 806614fbe..f04bc48ed 100644 --- a/compiler/cpp/src/generate/t_go_generator.cc +++ b/compiler/cpp/src/generate/t_go_generator.cc @@ -446,7 +446,11 @@ std::string t_go_generator::camelcase(const std::string& value) const { // and if so replaces it with the upper case version of the word. void t_go_generator::fix_common_initialism(std::string& value, int i) const { if (!ignore_initialisms_) { - std::string word = value.substr(i, value.find('_', i)); + size_t wordLen = value.find('_', i); + if (wordLen != std::string::npos) { + wordLen -= i; + } + std::string word = value.substr(i, wordLen); std::transform(word.begin(), word.end(), word.begin(), ::toupper); if (commonInitialisms.find(word) != commonInitialisms.end()) { value.replace(i, word.length(), word); |