diff options
author | 2017-02-01 15:58:26 -0800 | |
---|---|---|
committer | 2017-02-01 16:11:44 -0800 | |
commit | 3b5224be092da6dbbad6cf1bcc3d329a42286365 (patch) | |
tree | ef51b06f0fd20d7a4e68e0932ee1833441a526be | |
parent | 3e5af0c7b100886a23cf9c3930b29c1a4271dca8 (diff) |
Fix bug with doc updates for ops with renames in the C++ API.
Change: 146301808
-rw-r--r-- | tensorflow/core/framework/op_gen_lib.cc | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/tensorflow/core/framework/op_gen_lib.cc b/tensorflow/core/framework/op_gen_lib.cc index 95ad0d4bec..da36171b95 100644 --- a/tensorflow/core/framework/op_gen_lib.cc +++ b/tensorflow/core/framework/op_gen_lib.cc @@ -91,8 +91,21 @@ Status OpGenOverrideMap::LoadFile(Env* env, const string& filename) { } static void StringReplace(const string& from, const string& to, string* s) { - std::vector<string> rest = str_util::Split(*s, from); - *s = str_util::Join(rest, to.c_str()); + // Split *s into pieces delimited by `from`. + std::vector<string> split; + string::size_type pos = 0; + while (pos < s->size()) { + auto found = s->find(from, pos); + if (found == string::npos) { + split.push_back(s->substr(pos)); + break; + } else { + split.push_back(s->substr(pos, found - pos)); + pos = found + from.size(); + } + } + // Join the pieces back together with a new delimiter. + *s = str_util::Join(split, to.c_str()); } static void RenameInDocs(const string& from, const string& to, OpDef* op_def) { @@ -120,7 +133,7 @@ static void RenameInDocs(const string& from, const string& to, OpDef* op_def) { StringReplace(from_quoted, to_quoted, op_def->mutable_summary()); } if (!op_def->description().empty()) { - StringReplace(from_quoted, to_quoted, op_def->mutable_summary()); + StringReplace(from_quoted, to_quoted, op_def->mutable_description()); } } |