| 63 | } |
| 64 | |
| 65 | char* SubstituteToBuffer(StringPiece format, |
| 66 | const SubstituteArg* const* args_array, |
| 67 | char* target) { |
| 68 | for (int i = 0; i < format.size(); i++) { |
| 69 | if (format[i] == '$') { |
| 70 | if (ascii_isdigit(format[i+1])) { |
| 71 | const SubstituteArg* src = args_array[format[i+1] - '0']; |
| 72 | memcpy(target, src->data(), src->size()); |
| 73 | target += src->size(); |
| 74 | ++i; // Skip next char. |
| 75 | } else if (format[i+1] == '$') { |
| 76 | *target++ = '$'; |
| 77 | ++i; // Skip next char. |
| 78 | } |
| 79 | } else { |
| 80 | *target++ = format[i]; |
| 81 | } |
| 82 | } |
| 83 | return target; |
| 84 | } |
| 85 | |
| 86 | } // namespace internal |
| 87 |
no test coverage detected