This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

unsigned char in getc()?


I'm getting an int value of -80 returned by getc(), whereas fgetc()
returns 176 for the same input character.  This seems to be caused by
the definition of getc() in cygwin/usr/include/mingw/stdio.h, which
is:

__CRT_INLINE int __cdecl getc (FILE* __F)
{
  return (--__F->_cnt >= 0)
    ?  (int) *__F->_ptr++
    : _filbuf (__F);
}

The _ptr field is of type char* (not unsigned char*).

A definition of getc() I found elsewhere is:

#define getc(_stream)     (--(_stream)->_cnt >= 0 \
                ? 0xff & *(_stream)->_ptr++ : _filbuf(_stream))

which and's in the 0xff to get the unsigned value.

This seems to have become broken in a recent gcc.  Shouldn't this be
fixed, or am I misunderstanding something?

-David S. Warren
XSB, Inc.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]