aboutsummaryrefslogtreecommitdiff
path: root/libpsn00b/libc/vsprintf.c
diff options
context:
space:
mode:
authorJohn "Lameguy" Wilbert Villamor <lameguy64@gmail.com>2021-11-22 14:40:59 +0800
committerGitHub <noreply@github.com>2021-11-22 14:40:59 +0800
commit45123e1b968d1883fed9b8526157ce2c4bffc4a7 (patch)
treed20c80fbd4f5a5d1d3972669625972cea6b3684d /libpsn00b/libc/vsprintf.c
parent538f28cfbbbb8163ab8a96de77d6887123856c81 (diff)
parent9b00e5f7ff163a8fc6f341dbf237d90c61dadddc (diff)
downloadpsn00bsdk-45123e1b968d1883fed9b8526157ce2c4bffc4a7.tar.gz
Merge pull request #43 from spicyjpeg/cmake
Even more CMake fixes, submodules, pads example
Diffstat (limited to 'libpsn00b/libc/vsprintf.c')
-rw-r--r--libpsn00b/libc/vsprintf.c14
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;