You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by je...@apache.org on 2015/09/25 20:55:16 UTC

thrift git commit: THRIFT-3354 Fix word-extraction substr bug in initialism code Client: Go Author: Prashant Varanasi

Repository: thrift
Updated Branches:
  refs/heads/master c623197d3 -> 0621e1fc9


THRIFT-3354 Fix word-extraction substr bug in initialism code
Client: Go
Author: Prashant Varanasi <pr...@uber.com>

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 <je...@apache.org>
Authored: Fri Sep 25 20:52:57 2015 +0200
Committer: Jens Geyer <je...@apache.org>
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);