Repository: thrift Updated Branches: refs/heads/master c623197d3 -> 0621e1fc9
THRIFT-3354 Fix word-extraction substr bug in initialism code Client: Go Author: Prashant Varanasi <[email protected]> This closes #625 Project: http://git-wip-us.apache.org/repos/asf/thrift/repo Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/0621e1fc Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/0621e1fc Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/0621e1fc Branch: refs/heads/master Commit: 0621e1fc949a7e67c418b465f7f10ee082ea4a93 Parents: c623197 Author: Jens Geyer <[email protected]> Authored: Fri Sep 25 20:52:57 2015 +0200 Committer: Jens Geyer <[email protected]> Committed: Fri Sep 25 20:54:45 2015 +0200 ---------------------------------------------------------------------- compiler/cpp/src/generate/t_go_generator.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/thrift/blob/0621e1fc/compiler/cpp/src/generate/t_go_generator.cc ---------------------------------------------------------------------- diff --git a/compiler/cpp/src/generate/t_go_generator.cc b/compiler/cpp/src/generate/t_go_generator.cc index 806614f..f04bc48 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);
