1 /* |
1 /* |
2 * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
351 char buffer[200]; |
351 char buffer[200]; |
352 size_t format_len = strlen(format); |
352 size_t format_len = strlen(format); |
353 guarantee(format_len + 10 < sizeof(buffer), "bigger format buffer"); |
353 guarantee(format_len + 10 < sizeof(buffer), "bigger format buffer"); |
354 const char* kind = format; |
354 const char* kind = format; |
355 const char* kind_end = strchr(kind, ' '); |
355 const char* kind_end = strchr(kind, ' '); |
356 size_t kind_len = (kind_end != NULL) ? (kind_end - kind) : format_len; |
356 size_t kind_len; |
357 strncpy(buffer, kind, kind_len); |
|
358 strcpy(buffer + kind_len, "_done"); |
|
359 if (kind_end != NULL) { |
357 if (kind_end != NULL) { |
360 strncat(buffer, format + kind_len, sizeof(buffer) - (kind_len + 5 /* _done */) - 1); |
358 kind_len = kind_end - kind; |
|
359 int n = snprintf(buffer, sizeof(buffer), "%.*s_done", (int)kind_len, kind); |
|
360 assert((size_t)n < sizeof(buffer), "Unexpected number of characters in string"); |
|
361 } else { |
|
362 kind_len = format_len; |
|
363 int n = snprintf(buffer, sizeof(buffer), "%s_done%s", kind, kind + kind_len); |
|
364 assert((size_t)n < sizeof(buffer), "Unexpected number of characters in string"); |
361 } |
365 } |
362 // Output the trailing event with the timestamp. |
366 // Output the trailing event with the timestamp. |
363 va_begin_elem(buffer, ap); |
367 va_begin_elem(buffer, ap); |
364 stamp(); |
368 stamp(); |
365 end_elem(); |
369 end_elem(); |