[1739] in Athena Bugs

home help back first fref pref prev next nref lref last post

No subject found in mail header

daemon@ATHENA.MIT.EDU (don@ATHENA.MIT.EDU)
Fri Feb 3 22:51:46 1989

From: <don@ATHENA.MIT.EDU>
Date: Fri, 3 Feb 89 22:51:35 EST
To: bugs@ATHENA.MIT.EDU, kaufer@ATHENA.MIT.EDU
/* here's a bug in vax saber 2.0.4. see K&R, 1st ed., p 148-9.
 * it's possible that sscanf() is wrong, and saber is right,
 * depending upon on which page you read the description of %1s.
 */
#include <stdio.h>
main() {
    int a = 0xffff; char b = 'b';
    printf("a = %x, b = %c\n", a, b);

    sscanf("x", "%c", &b);         
    printf("a = %x, b = %c\n", a, b);

    sscanf(" x ", "%1s", &b);         
    printf("a = %x, b = %c\n", a, b);
}
/* here's what happens with pcc on the vax:

 tartaros 88% a.out
 a = ffff, b = b
 a = ffff, b = x
 a = ff00, b = x

 * this was a bitch to find,
 * because saber doesn't trash a's contents in the 2nd sscanf, as it should.
 */

home help back first fref pref prev next nref lref last post