[Vm-dev] [OpenSmalltalk/opensmalltalk-vm] Add accurate check for console stdio + add associated primitive (#254)

Ben Coman btc at openinworld.com
Fri Apr 27 08:51:47 UTC 2018


On 27 April 2018 at 15:16, akgrant43 <notifications at github.com> wrote:

>
>
> Hi Vincent & Eliot,
>
> Ugh. I didn't realize one couldn't use the same code in both :-(. I guess
> we have to test to find out what the context is and use dread in one and
> ReadConsole in the other.
>
> I think it is worse than that. If I use the following test code in a
> cygwin terminal:
>
> #include <stdio.h>
> #include <stdlib.h>
>
>
> int main()
> {
> char	buf[1024];
> char	*bufp;
> int	cread;
> int	count = 0;
>
> bufp = &buf[0];
> do {
>     cread = fread(bufp, 1, 1, stdin);
>     count += cread;
>     bufp += cread;
>     if (count > 16) break; }
> while (cread > 0);
> buf[count] = 0;
>
> if (! feof(stdin))
>     fprintf(stderr, "Error, not at end of file\n");
>
> printf("--\n");
> printf("%s\n", buf);
> printf("--\n");
> printf("Read %d characters\n", count);
> exit(0);
> }
>
> And compile it with mingw:
>
> $ i686-w64-mingw32-gcc -m32 consolestdio.c
>
> It won't recognise EOF (Control-D).
>

Try Ctrl-Z
"In a non-Cygwin Windows program, Ctrl-Z on input triggers an end-of-file
condition."

https://stackoverflow.com/questions/39327818/reading-till-eof-in-java-on-cygwin-on-windows-10

cheers -ben
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20180427/9851f157/attachment.html>


More information about the Vm-dev mailing list