344 PRAGMA_DIAG_PUSH |
344 PRAGMA_DIAG_PUSH |
345 PRAGMA_FORMAT_NONLITERAL_IGNORED |
345 PRAGMA_FORMAT_NONLITERAL_IGNORED |
346 // ------------------------------------------------------------------ |
346 // ------------------------------------------------------------------ |
347 void xmlStream::va_done(const char* format, va_list ap) { |
347 void xmlStream::va_done(const char* format, va_list ap) { |
348 char buffer[200]; |
348 char buffer[200]; |
349 guarantee(strlen(format) + 10 < sizeof(buffer), "bigger format buffer"); |
349 size_t format_len = strlen(format); |
|
350 guarantee(format_len + 10 < sizeof(buffer), "bigger format buffer"); |
350 const char* kind = format; |
351 const char* kind = format; |
351 const char* kind_end = strchr(kind, ' '); |
352 const char* kind_end = strchr(kind, ' '); |
352 size_t kind_len = (kind_end != NULL) ? (kind_end - kind) : strlen(kind); |
353 size_t kind_len = (kind_end != NULL) ? (kind_end - kind) : format_len; |
353 strncpy(buffer, kind, kind_len); |
354 strncpy(buffer, kind, kind_len); |
354 strcpy(buffer + kind_len, "_done"); |
355 strcpy(buffer + kind_len, "_done"); |
355 strcat(buffer, format + kind_len); |
356 if (kind_end != NULL) { |
|
357 strncat(buffer, format + kind_len, sizeof(buffer) - (kind_len + 5 /* _done */) - 1); |
|
358 } |
356 // Output the trailing event with the timestamp. |
359 // Output the trailing event with the timestamp. |
357 va_begin_elem(buffer, ap); |
360 va_begin_elem(buffer, ap); |
358 stamp(); |
361 stamp(); |
359 end_elem(); |
362 end_elem(); |
360 // Output the tail-tag of the enclosing element. |
363 // Output the tail-tag of the enclosing element. |