diff options
Diffstat (limited to 'src/user/lib/libc/std')
-rw-r--r-- | src/user/lib/libc/std/stdio.c | 40 | ||||
-rw-r--r-- | src/user/lib/libc/std/string.c | 40 |
2 files changed, 40 insertions, 40 deletions
diff --git a/src/user/lib/libc/std/stdio.c b/src/user/lib/libc/std/stdio.c index 3595622..da2f094 100644 --- a/src/user/lib/libc/std/stdio.c +++ b/src/user/lib/libc/std/stdio.c @@ -20,46 +20,6 @@ void fprintf(FILE f, char* format, ...) { va_end(ap); } -// INTERNAL, FOR FORMATTING - -static char* format_int(char* buf, int number) { - if (number == 0) { - *(buf++) = '0'; - return buf; - } - if (number < 0) { - *(buf++) = '-'; - number = 0 - number; - } - - int order = 0, temp = number, i; - char numbers[] = "0123456789"; - while (temp > 0) { - order++; - temp /= 10; - } - - for (i = order; i > 0; i--) { - buf[i - 1] = numbers[number % 10]; - number /= 10; - } - return buf + order; -} - -static char* format_hex(char *buf, unsigned v) { - *(buf++) = '0'; - *(buf++) = 'x'; - - int i; - char hexdigits[] = "0123456789ABCDEF"; - for (i = 0; i < 8; i++) { - *(buf++) = hexdigits[v >> 28]; - v = v << 4; - } - return buf; -} - - // FUNCTIONS void fprint(FILE f, char *s) { diff --git a/src/user/lib/libc/std/string.c b/src/user/lib/libc/std/string.c index 5a41b7e..d8e4a48 100644 --- a/src/user/lib/libc/std/string.c +++ b/src/user/lib/libc/std/string.c @@ -79,3 +79,43 @@ uint16_t *memsetw(uint16_t *dest, uint16_t val, int count) { } return dest; } + + +// Formatting + +char* format_int(char* buf, int number) { + if (number == 0) { + *(buf++) = '0'; + return buf; + } + if (number < 0) { + *(buf++) = '-'; + number = 0 - number; + } + + int order = 0, temp = number, i; + char numbers[] = "0123456789"; + while (temp > 0) { + order++; + temp /= 10; + } + + for (i = order; i > 0; i--) { + buf[i - 1] = numbers[number % 10]; + number /= 10; + } + return buf + order; +} + +char* format_hex(char *buf, unsigned v) { + *(buf++) = '0'; + *(buf++) = 'x'; + + int i; + char hexdigits[] = "0123456789ABCDEF"; + for (i = 0; i < 8; i++) { + *(buf++) = hexdigits[v >> 28]; + v = v << 4; + } + return buf; +} |