Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Side by Side Diff: third_party/protobuf/src/google/protobuf/stubs/substitute.cc

Issue 2495533002: third_party/protobuf: Update to HEAD (83d681ee2c) (Closed)
Patch Set: Make chrome settings proto generated file a component Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Protocol Buffers - Google's data interchange format 1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved. 2 // Copyright 2008 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/ 3 // https://developers.google.com/protocol-buffers/
4 // 4 //
5 // Redistribution and use in source and binary forms, with or without 5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are 6 // modification, are permitted provided that the following conditions are
7 // met: 7 // met:
8 // 8 //
9 // * Redistributions of source code must retain the above copyright 9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer. 10 // notice, this list of conditions and the following disclaimer.
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 106
107 if (size == 0) return; 107 if (size == 0) return;
108 108
109 // Build the string. 109 // Build the string.
110 int original_size = output->size(); 110 int original_size = output->size();
111 STLStringResizeUninitialized(output, original_size + size); 111 STLStringResizeUninitialized(output, original_size + size);
112 char* target = string_as_array(output) + original_size; 112 char* target = string_as_array(output) + original_size;
113 for (int i = 0; format[i] != '\0'; i++) { 113 for (int i = 0; format[i] != '\0'; i++) {
114 if (format[i] == '$') { 114 if (format[i] == '$') {
115 if (ascii_isdigit(format[i+1])) { 115 if (ascii_isdigit(format[i+1])) {
116 const SubstituteArg* src = args_array[format[i+1] - '0']; 116 unsigned int index = format[i+1] - '0';
117 assert(index < 10);
118 const SubstituteArg* src = args_array[index];
117 memcpy(target, src->data(), src->size()); 119 memcpy(target, src->data(), src->size());
118 target += src->size(); 120 target += src->size();
119 ++i; // Skip next char. 121 ++i; // Skip next char.
120 } else if (format[i+1] == '$') { 122 } else if (format[i+1] == '$') {
121 *target++ = '$'; 123 *target++ = '$';
122 ++i; // Skip next char. 124 ++i; // Skip next char.
123 } 125 }
124 } else { 126 } else {
125 *target++ = format[i]; 127 *target++ = format[i];
126 } 128 }
127 } 129 }
128 130
129 GOOGLE_DCHECK_EQ(target - output->data(), output->size()); 131 GOOGLE_DCHECK_EQ(target - output->data(), output->size());
130 } 132 }
131 133
132 } // namespace strings 134 } // namespace strings
133 } // namespace protobuf 135 } // namespace protobuf
134 } // namespace google 136 } // namespace google
OLDNEW
« no previous file with comments | « third_party/protobuf/src/google/protobuf/stubs/strutil.cc ('k') | third_party/protobuf/src/google/protobuf/stubs/time.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698