Skip to content

Commit

Permalink
Fixes in long integer handling in printf.c
Browse files Browse the repository at this point in the history
- Doc comment fixed: now it correctly says that the modifier
  for integers is "u" (not "ud" or "ui") and for unsigned long
  is "lu" (not "ul")

- Fixed the "l" modifier, it was skipping the next character
  • Loading branch information
Konamiman committed Nov 19, 2023
1 parent 8a104a6 commit b9a0176
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions source/tools/C/printf.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Supported format specifiers:
%d or %i: signed int
%ud or %ui: unsigned int
%u: unsigned int
%x: hexadecimal int
%c: character
%s: string
Expand All @@ -20,7 +20,7 @@
Also if SUPPORT_LONG is defined:
%l: signed long
%ul: unsigned long
%lu: unsigned long
%lx: hexadecimal long
*/

Expand Down Expand Up @@ -160,7 +160,12 @@ static int format_string(const char* buf, const char *fmt, va_list ap)
else if(theChar == 'x') {
base = 16;
}
else if(theChar != 'd' && theChar != 'i') {
#ifdef SUPPORT_LONG
else if(isLong) {
fmtPnt--;
} else
#endif
if(theChar != 'd' && theChar != 'i') {
do_char_inc(theChar);
continue;
}
Expand Down

0 comments on commit b9a0176

Please sign in to comment.