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]

Scanf bug


Somehow or other, sscanf() has gotten messed up in recent Cygwin
installations.

Test program, with output:

/xemacs/test 2391% cat testscanf.c
int
main (int argc, char **argv)
{
  int ret, cp1, cp2, endcount;
  char *p = "0x7d   0x000E  ";
  ret = sscanf (p, "%i %i%n", &cp1, &cp2, &endcount);
  printf ("ret: %d cp1: %d cp2: %d endcount: %d\n", ret, cp1, cp2,
endcount);
  printf ("%d\n", endcount + strspn (p + endcount, " \t\n\r\f"));
  return 0;
}
/xemacs/test 2392% gcc --verbose testscanf.c
Reading specs from /usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/specs
Configured with: /gcc/gcc-3.3.3-3/configure --verbose --prefix=/usr
--exec-prefi
x=/usr --sysconfdir=/etc --libdir=/usr/lib --libexecdir=/usr/lib
--mandir=/usr/s
hare/man --infodir=/usr/share/info
--enable-languages=c,ada,c++,d,f77,java,objc,
pascal --enable-nls --without-included-gettext --enable-libgcj
--with-system-zli
b --enable-interpreter --enable-threads=posix --enable-java-gc=boehm
--enable-sj
lj-exceptions --disable-version-specific-runtime-libs
--disable-win32-registry
Thread model: posix
gcc version 3.3.3 (cygwin special)
 /usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/cc1.exe -quiet -v -D__GNUC__=3
-D__GNUC_M
INOR__=3 -D__GNUC_PATCHLEVEL__=3 -D__CYGWIN32__ -D__CYGWIN__ -Dunix
-D__unix__ -
D__unix -idirafter
/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/../../../../include/w32
api -idirafter
/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/../../../../i686-pc-cygwin/
lib/../../include/w32api testscanf.c -quiet -dumpbase testscanf.c -auxbase
tests
canf -version -o /DOCUME~1/BENWIN~1/LOCALS~1/Temp/cco65aDq.s
GNU C version 3.3.3 (cygwin special) (i686-pc-cygwin)
        compiled by GNU C version 3.3.3 (cygwin special).
GGC heuristics: --param ggc-min-expand=82 --param ggc-min-heapsize=98244
ignoring nonexistent directory "/usr/i686-pc-cygwin/include"
ignoring duplicate directory "/usr/i686-pc-cygwin/lib/../../include/w32api"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/include
 /usr/include
 /usr/include/w32api
End of search list.
 /usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/../../../../i686-pc-cygwin/bin/as.exe
--t
raditional-format -o /DOCUME~1/BENWIN~1/LOCALS~1/Temp/ccSaWKvo.o
/DOCUME~1/BENWI
N~1/LOCALS~1/Temp/cco65aDq.s
 /usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/collect2.exe -Bdynamic
--dll-search-prefi
x=cyg /usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/../../../crt0.o
/usr/lib/gcc-lib/i68
6-pc-cygwin/3.3.3/crtbegin.o -L/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3
-L/usr/lib/
gcc-lib/i686-pc-cygwin/3.3.3/../../..
/DOCUME~1/BENWIN~1/LOCALS~1/Temp/ccSaWKvo.
o -lgcc -lcygwin -luser32 -lkernel32 -ladvapi32 -lshell32 -lgcc
/usr/lib/gcc-lib
/i686-pc-cygwin/3.3.3/crtend.o
/xemacs/test 2393% a
ret: 2 cp1: 125 cp2: 14 endcount: 11
11


The value of endcount should be 13, not 11.  The problem is with hex numbers
with more than one leading 0.  Change 0x000E to 0x0FFE or 0xFFFE and you get
13.  Change it to 0x00EE and you get 12.  In all cases cp2 is correct.

This used to work.  I know because the above code is part of XEmacs and we
are getting lots of warnings as a result of this bug, which didn't used to
be there, and the code hasn't changed.



--
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]