diff options
| author | spicyjpeg <88942473+spicyjpeg@users.noreply.github.com> | 2021-11-18 17:25:58 +0100 |
|---|---|---|
| committer | spicyjpeg <88942473+spicyjpeg@users.noreply.github.com> | 2021-11-18 17:25:58 +0100 |
| commit | 853fa4eed241cdd87b8c2d2e60cf755509d9a184 (patch) | |
| tree | 0fbd0201df56b95ff6ca6362692236b7d7e9b5bf /libpsn00b/libc/vsprintf.c | |
| parent | 619fa016bbc4ddd8d4a670cf3f8aa63617473b2f (diff) | |
| download | psn00bsdk-853fa4eed241cdd87b8c2d2e60cf755509d9a184.tar.gz | |
sprintf improvements, added new _mem_init, GetSystemInfo
Diffstat (limited to 'libpsn00b/libc/vsprintf.c')
| -rw-r--r-- | libpsn00b/libc/vsprintf.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libpsn00b/libc/vsprintf.c b/libpsn00b/libc/vsprintf.c index 361b24e..0a99dcc 100644 --- a/libpsn00b/libc/vsprintf.c +++ b/libpsn00b/libc/vsprintf.c @@ -58,6 +58,15 @@ pad_quantity = (pad_quantity - 1) - last; \ if(pad_quantity < 0) pad_quantity = 0; +#define calculate_real_padding_bin() \ + last = 0; \ + for (x = 0; x < 32; x++) \ + if((arg >> x) & 1) \ + last = x; \ + \ + pad_quantity = (pad_quantity - 1) - last; \ + if(pad_quantity < 0) pad_quantity = 0; + #define write_padding() \ if(!(flags & SPRINTF_NEGFIELD_FLAG)) \ for(x = 0; x < pad_quantity; x++) \ @@ -703,6 +712,9 @@ int vsnprintf(char *string, unsigned int size, const char *fmt, va_list ap) //else // arg = va_arg(ap, unsigned long long); + calculate_real_padding_bin(); + write_padding(); + for(x=31;x>=0;x--) { y = (arg >> x); @@ -715,6 +727,8 @@ int vsnprintf(char *string, unsigned int size, const char *fmt, va_list ap) put_in_string(string, ssz, y + '0', string_pos++); } + write_neg_padding(); + directive_coming = 0; break; |
