Bug in putc
Steve Harris
vsh at pixdoc.UUCP
Thu Mar 27 09:57:13 AEST 1986
There is a bug in the putc macro, in stdio.h.
Putc returns an int which contains the char you have just "put".
However, (at least on both a Pixel and a Sun), the result is sign extended;
if the 8th bit of the char is set, the return value from putc does not equal
the character you put! To fix, replace the putc macro with the following:
#define putc(x,p) ((int) ((--(p)->_cnt>=0? ((unsigned char)(*(p)->_ptr++=(x))):(unsigned char)_flsbuf((x),p))))
--
Steve Harris | {allegra|ihnp4|cbosgd|ima|genrad|amd|harvard}\
xePIX, Inc. | !wjh12!pixel!pixdoc!vsh
51 Lake Street |
Nashua, NH 03060 | +1 603 881 8791
More information about the Net.bugs
mailing list