Supplemental line feed(0x0A) and end of file(EOF) not logical

This forum is for general developer support questions.
Post Reply
User avatar
gdridi
Posts: 42
Joined: Sat Aug 11, 2012 10:17 am

Supplemental line feed(0x0A) and end of file(EOF) not logical

Post by gdridi »

Hello,

When I´m creating a file like (supposed to be an empty file) :
> cat >file.txt
Ctrl-\

And close immediately with Ctrl-\ (0x1C on Amiga)
The file.txt is not empty file but contains a line feed char (0x0A).

This is illogic like the test program joined (and this can lead to hard to find behavior "in programmer life also").

Code: Select all

#include <stdio.h>

// Close the input stream just after with Ctrl-\
// and it will NOT print that it is EndOfFile !
// We think this is due to a linefeed(LF) insertion before close of the DOS stream in : con-handler
int main() {
	int c = getchar();
	if ( c == EOF ) printf ("*** End Of File ***\n");
	else printf("char %d\n", c); 
}
Best regards,
DGILLES

Post scriptum : if the bug is in con-handler it can be a rapid fix to upload the separated file I.e. con-handler on a place where everyone can download it(expecting a new update of AmigaOS).
Post Reply