Attachment "fileeventthing.c" to
ticket [412504ffff]
added by
andreas_kupries
2001-04-12 04:44:45.
#include <stdio.h>
int i;
main(argc,argv)
int argc;
char *argv[];
{
printf("\nfileeventthing\n");
printf("\nThis is a program to exercise and illustrate what might possibly be a\n");
printf("tcl fileevent bug. It is designed to be run from an accompanying tcl\n");
printf("script, fileeventthing-tclsh . If you run this program directly it\n");
printf("isn't anything very special.\n");
printf("\nWhen fileevent (in translation mode \"auto\") sees a CR, it apparently\n");
printf("waits to see if the next character is a LF before it proclaims EOL. It\n");
printf("is looking one character ahead. In this way it avoids proclaiming two\n");
printf("EOL's for one CRLF sequence.\n");
printf("\nWould it not be better for fileevent to look one character behind\n");
printf("instead? In this mode, when it sees a CR, it could immediately proclaim\n");
printf("EOL. Also, when it sees a LF, immediately proclaim EOL, *unless* the\n");
printf("previous character was CR, in which case the LF could just be\n");
printf("discarded.\n");
printf("\nThis program will now print out a series of numbers, 1-10, using an\n");
printf("increment of one. Note how long it takes to see the last number, 10,\n");
printf("even though this program doesn't take any longer to print it out than\n");
printf("any of the previous numbers. This is because fileevent is waiting to\n");
printf("see if there will be a LF after the last CR, but it never comes.\n\n");
i=1;
while ( i <= 10 ) {
printf("\r...and the number is: %d",i);
fflush(stdout);
sleep(1);
i++;
}
sleep(20);
exit(0);
}