| 494 | #define XO_SMBUFSZ 128 |
| 495 | |
| 496 | static const char * |
| 497 | xo_printable (const char *str) |
| 498 | { |
| 499 | static THREAD_LOCAL(char) bufset[XO_NUMBUFS][XO_SMBUFSZ]; |
| 500 | static THREAD_LOCAL(int) bufnum = 0; |
| 501 | |
| 502 | if (str == NULL) |
| 503 | return ""; |
| 504 | |
| 505 | if (++bufnum == XO_NUMBUFS) |
| 506 | bufnum = 0; |
| 507 | |
| 508 | char *res = bufset[bufnum], *cp, *ep; |
| 509 | |
| 510 | for (cp = res, ep = res + XO_SMBUFSZ - 1; *str && cp < ep; cp++, str++) { |
| 511 | if (*str == '\n') { |
| 512 | *cp++ = '\\'; |
| 513 | *cp = 'n'; |
| 514 | } else if (*str == '\r') { |
| 515 | *cp++ = '\\'; |
| 516 | *cp = 'r'; |
| 517 | } else if (*str == '\"') { |
| 518 | *cp++ = '\\'; |
| 519 | *cp = '"'; |
| 520 | } else |
| 521 | *cp = *str; |
| 522 | } |
| 523 | |
| 524 | *cp = '\0'; |
| 525 | return res; |
| 526 | } |
| 527 | |
| 528 | static int |
| 529 | xo_depth_check (xo_handle_t *xop, int depth) |
no outgoing calls
no test coverage detected