trying to debug, additional rewrites

This commit is contained in:
Ondřej Novák 2025-01-26 21:36:03 +01:00
parent 378b5586ab
commit 42f780a729
87 changed files with 1771 additions and 529 deletions

30
platform/int2ascii.c Normal file
View file

@ -0,0 +1,30 @@
#include "platform.h"
static char *render_int(char *where, int i, int radix) {
if (i == 0) return where;
char *r = render_int(where, i/radix, radix);
int p = i % radix;
if (p<=0) {
*r = p + '0';
} else {
*r = p + 'A' - 10;
}
return r+1;
}
const char * int2ascii(int i, char *c, int radix) {
if (i == 0) {
c[0] = '0';
c[1] = 0;
return c;
}
if (i<0) {
c[0] = '-';
*render_int(c+1,-i,radix) = 0;
} else {
*render_int(c,i,radix) = 0;
}
return c;
}