Skip to content
Permalink
Browse files

prf.c: implement the "hh" length modifier

For completeness.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
  • Loading branch information...
Nicolas Pitre authored and nashif committed Jun 18, 2019
1 parent e9b1cc5 commit e1d8c1f8ca83f5176bb16968e1aa86277f749c1b
Showing with 9 additions and 0 deletions.
  1. +9 −0 lib/libc/minimal/source/stdout/prf.c
@@ -548,6 +548,7 @@ int z_prf(int (*func)(), void *dest, const char *format, va_list vargs)
* This implementation only supports the following
* length modifiers:
* h: short
* hh: char
* l: long
* ll: long long
* z: size_t or ssize_t
@@ -560,6 +561,9 @@ int z_prf(int (*func)(), void *dest, const char *format, va_list vargs)
i == 'l' && c == 'l') {
i = 'L';
c = *format++;
} else if (i == 'h' && c == 'h') {
i = 'H';
c = *format++;
}
}

@@ -588,6 +592,7 @@ int z_prf(int (*func)(), void *dest, const char *format, va_list vargs)
val = va_arg(vargs, ssize_t);
break;
case 'h':
case 'H':
default:
val = va_arg(vargs, int);
break;
@@ -643,6 +648,9 @@ int z_prf(int (*func)(), void *dest, const char *format, va_list vargs)
case 'h':
*va_arg(vargs, short *) = count;
break;
case 'H':
*va_arg(vargs, char *) = count;
break;
case 'l':
*va_arg(vargs, long *) = count;
break;
@@ -705,6 +713,7 @@ int z_prf(int (*func)(), void *dest, const char *format, va_list vargs)
val = va_arg(vargs, size_t);
break;
case 'h':
case 'H':
default:
val = va_arg(vargs, unsigned int);
break;

0 comments on commit e1d8c1f

Please sign in to comment.
You can’t perform that action at this time.