[comp.sys.amiga.tech] Another Manx 5.0 bug

barrett@jhunix.HCF.JHU.EDU (Dan Barrett) (03/10/90)

	scanf() and sscanf() do not work properly with Manx C 5.0a.
I have not tested fscanf().

	The problems are:

(1)	The functions do not return the correct value on bad inpu.
(2)	scanf() does not see EOF until you send it TWICE.

Test program:

#include <stdio.h>

main()
{
	int i, result;

	result = scanf("%d", &i);
	printf("%d %d\n", result, i);
}

Compile:	cc t.c
Link:		ln t.o -lc
Run:		t

Give the input 'z' and scanf incorrectly returns 1, instead of 0.  Type
EOF (^\) and scanf ignores it.  Type a second ^\ and scanf() sees it.

How the HELL did a big error like this one get out?????????!?!?!?!
Or am I doing something TOTALLY stupid???

I have submitted a bug report to Manx.

                                                        Dan

 //////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
| Dan Barrett, Department of Computer Science      Johns Hopkins University |
| INTERNET:   barrett@cs.jhu.edu           |                                |
| COMPUSERVE: >internet:barrett@cs.jhu.edu | UUCP:   barrett@jhunix.UUCP    |
 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/////////////////////////////////////