[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

BUG in MiNT: character not read from tty



I think I found a bug in MiNT (still using 4.14.6):
read() doesn't return control-o when reading from stdin.
It does return that character when reading from a file.

I compiled a testprogram that will be given below with two different
compilers:
- gcc 2.5.8.pl1, gas 1.3.8 pl4, mintlibs pl46 (KGMD environment)
- my old MWC

Both executables didn't return control-o. So I think it isn't a fault in the
libs.

I started various shells and tried to start up just MiNT (so not KGMD). No
difference. Even the original version of MiNT which came with KGMD (1.12.x)
shows this bug.

But after starting MiNT 1.09 both executables didn't show that bug.

Any ideas?

Hans

#include <stdio.h>
#include <fcntl.h>

#define CTRL(c)	((c)&037)

char filename[] = "in";

main()
{
int nchars;
char buf[100];
int i, fd;
FILE *fp;

fp = fopen(filename, "wb");
putc(CTRL('N'), fp);
putc(CTRL('O'), fp);
putc(CTRL('P'), fp);
fclose(fp);

fd = open(filename, 0);
nchars = read(fd, buf, sizeof(buf));
if( nchars<0 ) {
	printf("read failed\n");
	exit(1);
}
close(fd);

printf("%d characters read\n", nchars);
printf("output should be here: 16, 17, 20\n");
for(i=0; i<nchars; i++) {
	printf("%o\n", buf[i]);
}

printf("Enter characters - end with control-D\n");
for(;;) {
		nchars = read(0, buf, sizeof(buf));
		if( nchars < 0 ) {
			printf("error in read\n");
			exit(1);
		}
		if( nchars==0 || *buf == CTRL('D') )
			break;
		nchars--;	/* don't count \n */
		printf("%d characters read.", nchars);
		if( nchars > 0 )
			printf(" First is: %o\n", *buf);
		else
			putc('\n', stdout);
}

}