Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Weird I/O bug

Reply
Thread Tools

Weird I/O bug

 
 
Tom Anderson
Guest
Posts: n/a
 
      09-06-2008
On Sat, 6 Sep 2008, Spencer Rugaber wrote:

> In article <(E-Mail Removed)> ,
> Tom Anderson <(E-Mail Removed)> wrote:
>
>> I think what this is is the shell (or possibly the terminal driver, or
>> maybe even the java binary) echoing "^D" to the screen when you type that
>> escape sequence - that's standard behaviour. When the app then prints that
>> 0, it overwrites the ^, and you see 0D.
>>
>> If you modify the program to print the empty string, then what you see on
>> screen is "^D". If you modify it to print 99, you just see the 99. If you
>> modify it not to call print at all, then you very briefly see ^D, but this
>> is then overwritten by the prompt that appears after the program
>> terminates (or at least, i do - your console may be faster than mine!). If
>> you run the unmodified program, but redirect the output to a file, it just
>> contains 0. All this fits with the explanation i give above.

>
> This sounds reasonable, but why don't I see the ^D when I talk to the
> shell directly, as with the command "cat" (by itself taking input from
> the command line). If that input is only ^D, then nothing is echoed.
>
> So Java's behavior still seems weird to me. Is this what I should
> expect from Java? I could find no justification for it in the API
> description.


Got a C compiler? Try this:

#include <stdio.h>
int main(int argc, char **argv) {
char buf[100] ;
gets(buf) ;
printf("%i\n", 0) ;
return 0 ;
}

tom

--
Ed editor textorum probatissimus est -- Cicero, De officiis IV.7
 
Reply With Quote
 
 
 
 
John B. Matthews
Guest
Posts: n/a
 
      09-06-2008
In article <(E-Mail Removed)> ,
Tom Anderson <(E-Mail Removed)> wrote:

> On Sat, 6 Sep 2008, Spencer Rugaber wrote:
>
> > In article <(E-Mail Removed)> ,
> > Tom Anderson <(E-Mail Removed)> wrote:
> >
> >> I think what this is is the shell (or possibly the terminal driver, or
> >> maybe even the java binary) echoing "^D" to the screen when you type that
> >> escape sequence - that's standard behaviour. When the app then prints that
> >> 0, it overwrites the ^, and you see 0D.
> >>
> >> If you modify the program to print the empty string, then what you see on
> >> screen is "^D". If you modify it to print 99, you just see the 99. If you
> >> modify it not to call print at all, then you very briefly see ^D, but this
> >> is then overwritten by the prompt that appears after the program
> >> terminates (or at least, i do - your console may be faster than mine!). If
> >> you run the unmodified program, but redirect the output to a file, it just
> >> contains 0. All this fits with the explanation i give above.


I agree. If I modify it to print " ", I get a fleeting "^" followed by "
D". The shell also echoes other control characters this way. Sorry if I
overlooked it, but I missed your post above in this thread:

<http://groups.google.com/group/comp....rowse_frm/thre
ad/dee2331e25a0c47a/e14f72c577449842?hl=en&lnk=st&q=#e14f72c577449842>

> > This sounds reasonable, but why don't I see the ^D when I talk to the
> > shell directly, as with the command "cat" (by itself taking input from
> > the command line). If that input is only ^D, then nothing is echoed.


If cat echoes anything, it swallows the first ^D and the shell backs
over a second one.

> > So Java's behavior still seems weird to me. Is this what I should
> > expect from Java? I could find no justification for it in the API
> > description.

>
> Got a C compiler? Try this:
>
> #include <stdio.h>
> int main(int argc, char **argv) {
> char buf[100] ;
> gets(buf) ;
> printf("%i\n", 0) ;
> return 0 ;
> }
>
> tom


FWIW, I get the same result in C on Mac OS, too.

--
John B. Matthews
trashgod at gmail dot com
home dot woh dot rr dot com slash jbmatthews
 
Reply With Quote
 
 
 
 
RedGrittyBrick
Guest
Posts: n/a
 
      09-07-2008

Spencer Rugaber wrote:
> In article <(E-Mail Removed)> ,
> Tom Anderson <(E-Mail Removed)> wrote:
>> I think what this is is the shell (or possibly the terminal driver, or
>> maybe even the java binary) echoing "^D" to the screen when you type that
>> escape sequence - that's standard behaviour. When the app then prints that
>> 0, it overwrites the ^, and you see 0D.

>
>> If you modify the program to print the empty string, then what you see on
>> screen is "^D". If you modify it to print 99, you just see the 99. If you
>> modify it not to call print at all, then you very briefly see ^D, but this
>> is then overwritten by the prompt that appears after the program
>> terminates (or at least, i do - your console may be faster than mine!). If
>> you run the unmodified program, but redirect the output to a file, it just
>> contains 0. All this fits with the explanation i give above.

>
> This sounds reasonable, but why don't I see the ^D when I talk to the
> shell directly, as with the command "cat" (by itself taking input from
> the command line). If that input is only ^D, then nothing is echoed.
>
> So Java's behavior still seems weird to me. Is this what I should
> expect from Java? I could find no justification for it in the API
> description.
>


From what Tom and others have said, it isn't Java , it is your shell
which is responsible for the "D" which you are seeing.

--
RGB
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: A Weird Appearance for a Weird Site Beauregard T. Shagnasty HTML 1 01-21-2011 04:17 PM
Re: A Weird Appearance for a Weird Site richard HTML 0 01-21-2011 07:10 AM
Re: A Weird Appearance for a Weird Site dorayme HTML 1 01-21-2011 06:51 AM
Re: A Weird Appearance for a Weird Site richard HTML 0 01-21-2011 06:46 AM
*bug* *bug* *bug* David Raleigh Arnold Firefox 12 04-02-2007 03:13 AM



Advertisments