From 12e09f9f85ac48ff891adf92f3b2c9a5fea27273 Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Sat, 4 Dec 2021 14:10:21 -0800 Subject: Chore(REMOVE): finished deprecation of old io functions. The old methods were simple wrappers of C standard library functions. We've moved (painfully) over to a new interface that allows for files to live on the stack. All users of the functionality are ported over. --- src/base/string/itoa.c | 23 +++++++++++++++++++++++ src/base/string/rules.mk | 1 + 2 files changed, 24 insertions(+) create mode 100644 src/base/string/itoa.c (limited to 'src/base/string') diff --git a/src/base/string/itoa.c b/src/base/string/itoa.c new file mode 100644 index 0000000..a2910f4 --- /dev/null +++ b/src/base/string/itoa.c @@ -0,0 +1,23 @@ +#include "internal.h" + +static char * +kernel(char *s, int x) +{ + if(x/10) + s = kernel(s, x/10); + *s++ = x%10 + '0'; + return s; +} + +char * +strĀ·itoa(char *s, int x) +{ + if(x<0){ + *s++ = '-'; + x=-x; + } + s = kernel(s, x); + *s = '0'; + + return s; +} diff --git a/src/base/string/rules.mk b/src/base/string/rules.mk index 0352f54..5fa6c5e 100644 --- a/src/base/string/rules.mk +++ b/src/base/string/rules.mk @@ -1,5 +1,6 @@ SRCS_$(d)+=\ $(d)/string/atoi.c\ + $(d)/string/itoa.c\ $(d)/string/append.c\ $(d)/string/appendf.c\ $(d)/string/clear.c\ -- cgit v1.2.1