stdio, ape/stdio: fix order of operations in putc
When calling putc, we need to return either EOF or the character returned. To distinguish the two, we need to avoid sign extending 0xff. The code attempted to do this, but the order of operations was wrong, so we ended up masking, setting a character, and then sign extending the character. This fixes things so we mask after assignment.
This commit is contained in:
parent
ad26dc48a6
commit
1987cc69c8
2 changed files with 2 additions and 2 deletions
|
@ -106,7 +106,7 @@ extern int getchar(void);
|
|||
#define getchar() getc(stdin)
|
||||
extern char *gets(char *);
|
||||
extern int putc(int, FILE *);
|
||||
#define putc(c, f) ((f)->wp>=(f)->rp?_IO_putc(c, f):(*(f)->wp++=(c)&_IO_CHMASK))
|
||||
#define putc(c, f) ((f)->wp>=(f)->rp?_IO_putc(c, f):((*(f)->wp++=(c))&_IO_CHMASK))
|
||||
extern int _IO_putc(int, FILE *);
|
||||
extern int putchar(int);
|
||||
#define putchar(c) putc(c, stdout)
|
||||
|
|
|
@ -92,7 +92,7 @@ int getchar(void);
|
|||
#define getchar() getc(stdin)
|
||||
char *gets(char *);
|
||||
int putc(int, FILE *);
|
||||
#define putc(c, f) ((f)->wp>=(f)->rp?_IO_putc(c, f):(*(f)->wp++=(c)&_IO_CHMASK))
|
||||
#define putc(c, f) ((f)->wp>=(f)->rp?_IO_putc(c, f):((*(f)->wp++=(c))&_IO_CHMASK))
|
||||
int _IO_putc(int, FILE *);
|
||||
int putchar(int);
|
||||
#define putchar(c) putc(c, stdout)
|
||||
|
|
Loading…
Reference in a new issue