_IONBF drops all newlines
Mon Jun 7 21:10:00 GMT 2004
Nick THOMPSON wrote:
> Hi all,
> newlib-1.12.0, gcc 3.4 for arm-elf, custom OS.
> I'm new to newlib and am trying to embed it on an ARM946. I have my code
> booting nicely now with stdin/out as default settings (line buffered??).
> However, my code is interactive (i.e. command line editing) and I need
> stdio to be unbuffered so I can use getchar for real time char input and
> putchar/printf output to control a VT100 cursor. So I added...
> setvbuf(stdin, NULL, _IONBF, 0);
> setvbuf(stdout, NULL, _IONBF, 0);
> ...early in my code (no output so far), but this seem to make puts not
> output a \n and printf also seems to ignore any \n in the format string.
> putchar('\n') works fine and my serial driver does the conversion to
> CR/LR for the terminal.
> I don't use crt0 and have a custom boot sequence, that sets .data and
> .bss correctly. It doesn't call any kind of newlib init routines, as
> there don't seem to be any (stdio initialised on the fly for example).
> Have I missed something obvious?
> Thanks in advance,
The puts() should work as follows: first the original string will be written
via a _write call, then the "\n" will be written by a _write call. I have
included a simple test case which I used to verify on an mn10300 simulator.
Have you replaced the newlib syscalls? Can you confirm with a debugger what
happens with the test case?
-- Jeff J.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
More information about the Newlib