MCPcopy Create free account
hub / github.com/F-Stack/f-stack / xo_printable

Function xo_printable

tools/libxo/libxo/libxo.c:496–526  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

494#define XO_SMBUFSZ 128
495
496static const char *
497xo_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
528static int
529xo_depth_check (xo_handle_t *xop, int depth)

Callers 6

xo_dgettextFunction · 0.85
xo_dngettextFunction · 0.85
xo_parse_rolesFunction · 0.85
xo_parse_fieldsFunction · 0.85
xo_do_emit_fieldsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected