From owner-freebsd-bugs Wed Jan 15 08:30:04 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.4/8.8.4) id IAA09739 for bugs-outgoing; Wed, 15 Jan 1997 08:30:04 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.8.4/8.8.4) id IAA09731; Wed, 15 Jan 1997 08:30:01 -0800 (PST) Date: Wed, 15 Jan 1997 08:30:01 -0800 (PST) Message-Id: <199701151630.IAA09731@freefall.freebsd.org> To: freebsd-bugs Cc: From: "John S. Dyson" Subject: Re: bin/2502: Unable to sscanf first integer value. Reply-To: "John S. Dyson" Sender: owner-bugs@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk The following reply was made to PR bin/2502; it has been noted by GNATS. From: "John S. Dyson" To: scrutchfield@ifusion.com Cc: freebsd-gnats-submit@FreeBSD.ORG Subject: Re: bin/2502: Unable to sscanf first integer value. Date: Wed, 15 Jan 1997 11:21:26 -0500 (EST) > I am unable to sscanf correctly 2 integers from a string. A Sample > program that recreates the problem is shown below. This is a problem > in both libc and libc_r. > > #include > #include > #include > > main() > { > char *tmp = "999 12346"; > char *ptr; > unsigned short x; > unsigned short y; > unsigned short z; > unsigned int a; > int result; > > result = sscanf ( tmp, "%d %d", &x, &y ); > z = strtol ( tmp, &ptr, 0 ); > a = atoi ( tmp ); > (void)fprintf ( stderr, "x(%d)y(%d)z(%d)a(%d)\n", x, y, z, a ); > exit ( 0 ); > } > > >How-To-Repeat: > Run the above program. > >Fix: > The problem that you are seeing is due to passing a pointer to a "short" instead of a pointer to an "int." If you change the declarations of (x,y) to be "unsigned int", then things will work well. John