This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Printf stops calling write() syscall after encountering a line feed


On Nov 24 20:48, Anthony DeRosa wrote:
> Hi,
> 
> I am having trouble with printf, and I am positive that its not my
> terminal's fault or a buffering problem.? First I'll explain the
> problem, and second why I think it's not my terminal's fault.
> 
> The problem is that printf stops calling the write() syscall after
> encountering a line feed character ('\n').? Below is some code and
> corresponding output to demonstrate.
> 
> The code:
> 
> ??? printf("line 0\n");
> ??? printf("line 1\nline 2\n");
> ??? printf("line 3");
> ??? printf("\nline 4\n");
> ??? printf("line 5\n");
> ??? fflush(stdout);
> 
> The expected output:
> 
> line 0
> line 1
> line 2
> line 3
> line 4
> line 5
> 
> (my broken) Newlib's output:
> 
> line 0
> line 1? // stops printing line 2 after line feed
> line 3? // stops printing line 4 after line feed
> line 5
> 
> 
> The reason I don't blame my terminal is because if I replace all calls
> to printf with calls to write(1, text, textlen), then everything works
> as expected with regards to line feeds.? Things also work as expected
> if I use sprintf() followed by a call to write().

I don't know whom to blame in your case, but the above testcase works
fine on Cygwin, which is using newlib as well.  I think you will have
to put more debugging effort into this, like, say, running your testcase
in a debugger.


Corinna

-- 
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]