mirror of
https://github.com/ondra-novak/gates_of_skeldal.git
synced 2025-07-05 06:00:33 -04:00
trying to debug, additional rewrites
This commit is contained in:
parent
378b5586ab
commit
42f780a729
87 changed files with 1771 additions and 529 deletions
30
platform/int2ascii.c
Normal file
30
platform/int2ascii.c
Normal 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;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue