瀏覽代碼

don't suppress sign output for NANs in printf

formally, it seems a sign is only required when the '+' modifier
appears in the format specifier, in which case either '+' or '-' must
be present in the output. but the specification is written such that
an optional negative sign is part of the output format anyway, and the
simplest approach to fixing the problem is removing the code that was
suppressing the sign.
Rich Felker 10 年之前
父節點
當前提交
0f859fc993
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      src/stdio/vfprintf.c

+ 1 - 1
src/stdio/vfprintf.c

@@ -225,7 +225,7 @@ static int fmt_fp(FILE *f, long double y, int w, int p, int fl, int t)
 
 	if (!isfinite(y)) {
 		char *s = (t&32)?"inf":"INF";
-		if (y!=y) s=(t&32)?"nan":"NAN", pl=0;
+		if (y!=y) s=(t&32)?"nan":"NAN";
 		pad(f, ' ', w, 3+pl, fl&~ZERO_PAD);
 		out(f, prefix, pl);
 		out(f, s, 3);