Просмотр исходного кода

stdio: fix %a formatting of inf and nan

Don't output `0x` in front of `inf` or `nan` with %a.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Max Filippov 1 месяц назад
Родитель
Сommit
bb92002881
1 измененных файлов с 2 добавлено и 1 удалено
  1. 2 1
      libc/stdio/_fpmaxtostr.c

+ 2 - 1
libc/stdio/_fpmaxtostr.c

@@ -636,7 +636,8 @@ ssize_t _fpmaxtostr(FILE * fp, __fpmax_t x, struct printf_info *info,
 		ppc[2] = (intptr_t) sign_str;
 
 #ifdef __UCLIBC_HAS_HEXADECIMAL_FLOATS__
-		if (((mode|0x20) == 'a') && (pc_fwi[3] >= 16)) { /* Hex sign handling. */
+		if (((mode|0x20) == 'a') && (pc_fwi[3] >= 16) &&
+		    (pc_fwi[3] != FPO_STR_PREC)) { /* Hex sign handling. */
 			/* Hex and not inf or nan, so prefix with 0x. */
 			char *h = sign_str + i;
 			*h = '0';