Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / tools / gn / string_utils.cc
index 60e4e8c..1aa1081 100644 (file)
@@ -21,11 +21,13 @@ Err ErrInsideStringToken(const Token& token, size_t offset, size_t size,
   int int_offset = static_cast<int>(offset);
   Location begin_loc(token.location().file(),
                      token.location().line_number(),
-                     token.location().char_offset() + int_offset + 1);
-  Location end_loc(token.location().file(),
-                   token.location().line_number(),
-                   token.location().char_offset() + int_offset + 1 +
-                   static_cast<int>(size));
+                     token.location().char_offset() + int_offset + 1,
+                     token.location().byte() + int_offset + 1);
+  Location end_loc(
+      token.location().file(),
+      token.location().line_number(),
+      token.location().char_offset() + int_offset + 1 + static_cast<int>(size),
+      token.location().byte() + int_offset + 1 + static_cast<int>(size));
   return Err(LocationRange(begin_loc, end_loc), msg, help);
 }
 
@@ -168,3 +170,10 @@ std::string RemovePrefix(const std::string& str, const std::string& prefix) {
         str.compare(0, prefix.size(), prefix) == 0);
   return str.substr(prefix.size());
 }
+
+void TrimTrailingSlash(std::string* str) {
+  if (!str->empty()) {
+    DCHECK((*str)[str->size() - 1] == '/');
+    str->resize(str->size() - 1);
+  }
+}