fix wrong result for putc variants due to operator precedence

the internal putc_unlocked macro was wrongly returning a meaningless
boolean result rather than the written character or EOF.

bug was found by reading (very surprising) asm.
This commit is contained in:
Rich Felker
2018-10-18 13:36:43 -04:00
parent 9dd1912256
commit a21a6092cf
+1 -1
View File
@@ -105,7 +105,7 @@ hidden void __getopt_msg(const char *, const char *, const char *, size_t);
( ((f)->rpos != (f)->rend) ? *(f)->rpos++ : __uflow((f)) ) ( ((f)->rpos != (f)->rend) ? *(f)->rpos++ : __uflow((f)) )
#define putc_unlocked(c, f) \ #define putc_unlocked(c, f) \
( ((unsigned char)(c)!=(f)->lbf && (f)->wpos!=(f)->wend) \ ( (((unsigned char)(c)!=(f)->lbf && (f)->wpos!=(f)->wend)) \
? *(f)->wpos++ = (c) : __overflow((f),(c)) ) ? *(f)->wpos++ = (c) : __overflow((f),(c)) )
/* Caller-allocated FILE * operations */ /* Caller-allocated FILE * operations */