summaryrefslogtreecommitdiff
path: root/lib/tiny-printf.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tiny-printf.c')
-rw-r--r--lib/tiny-printf.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/tiny-printf.c b/lib/tiny-printf.c
index b8fc8355c4a..2a7a4d286c0 100644
--- a/lib/tiny-printf.c
+++ b/lib/tiny-printf.c
@@ -211,6 +211,7 @@ static int _vprintf(struct printf_info *info, const char *fmt, va_list va)
bool lz = false;
int width = 0;
bool islong = false;
+ bool force_char = false;
ch = *(fmt++);
if (ch == '-')
@@ -284,6 +285,7 @@ static int _vprintf(struct printf_info *info, const char *fmt, va_list va)
islong = true;
fallthrough;
case 'x':
+ case 'X':
if (islong) {
num = va_arg(va, unsigned long);
div = 1UL << (sizeof(long) * 8 - 4);
@@ -300,6 +302,8 @@ static int _vprintf(struct printf_info *info, const char *fmt, va_list va)
break;
case 'c':
out(info, (char)(va_arg(va, int)));
+ /* For the case when it's \0 char */
+ force_char = true;
break;
case 's':
p = va_arg(va, char*);
@@ -317,8 +321,10 @@ static int _vprintf(struct printf_info *info, const char *fmt, va_list va)
while (width-- > 0)
info->putc(info, lz ? '0' : ' ');
if (p) {
- while ((ch = *p++))
+ while ((ch = *p++) || force_char) {
info->putc(info, ch);
+ force_char = false;
+ }
}
}
}