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

Function ksprintn

lib/ff_subr_prf.c:120–134  ·  view source on GitHub ↗

* Put a NUL-terminated ASCII number (base <= 36) in a buffer in reverse * order; return an optional length and a pointer to the last character * written in the buffer (i.e., the first character of the string). * The buffer pointed to by `nbuf' must have length >= MAXNBUF. */

Source from the content-addressed store, hash-verified

118 * The buffer pointed to by `nbuf' must have length >= MAXNBUF.
119 */
120static char *
121ksprintn(char *nbuf, uintmax_t num, int base, int *lenp, int upper)
122{
123 char *p, c;
124
125 p = nbuf;
126 *p = '\0';
127 do {
128 c = hex2ascii(num % base);
129 *++p = upper ? toupper(c) : c;
130 } while (num /= base);
131 if (lenp)
132 *lenp = p - nbuf;
133 return (p);
134}
135
136static void
137putbuf(int c, struct putchar_arg *ap)

Callers 1

kvprintfFunction · 0.70

Calls 2

hex2asciiFunction · 0.85
toupperFunction · 0.85

Tested by

no test coverage detected