Re: Why does my program change the characters in my shell
From: Andrew Falanga (excalibur_at_icehouse.net)
Date: 06/28/03
- Next message: llewelly: "Re: newbie question"
- Previous message: Floyd Davidson: "Re: Why does my program change the characters in my shell"
- In reply to: Floyd Davidson: "Re: Why does my program change the characters in my shell"
- Next in thread: Anand Agrawal \(agrawala\): "Re: Why does my program change the characters in my shell"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Fri, 27 Jun 2003 18:17:34 -0600
Floyd Davidson wrote:
> noogie@cyberspace.org (Alex Sisson) wrote:
> >Lorinczy Zsigmond <nospam@for.me> wrote:
> >> Andrew Falanga wrote:
> >> > Hello,
> >> >
> >> > I'd like to know what the typical reason for this is. I'm debugging a
> >> > program I've written, and to make sure I'm using sscanf( ) and strcpy(
> >> > ). However, when it gets done puting the data on stdout, the program is
> >> > supposed to prompt me for action.
>
> That is probably the result of leaving a string unterminated,
> resulting in bytes beyond the end of the string being printed.
> One of those bytes happened to be ^N, which switches the
> terminal to a graphics character set. That is a common result
> of displaying binary data to a terminal. There are other weird
> attribute combinations that can occasionally happen, but that
> one is the most common.
>
> >> > What is displayed is really weird text. No English alphabetic
> >> > characters, just right angled shapes and stuff. What normally alters
> >> > the character set of stdout (don't know if I worded that correctly)?
> >>
> >> Your terminal is confused or switched into character-graphics mode...
> >> try "reset" command
> >> You can trace your program with "strace"
> >
> >alternatively, you can play a fun game instead; cat /bin/ls and try
> >and ^C it before its finished cat'ing. sometimes if you're lucky, the
> >characters will be ok again.
>
> That's even more hit or miss than the _reset_ command, which
> doesn't always clear some of the stranger states a terminal can
> be put into. But there are ways to handle it...
>
> alias sane='echo -e "\\033c";tput is2;stty $(stty -g)'
>
> That does a terminal reset, sends the TERMINFO init string for
> your terminal, and then resets all of the parameters to whatever
> they were at the time this alias was defined (presumably it is
> in an rc file run when the terminal session was invoked, so it
> will be correct).
>
> A demonstration of the difference is easy.
>
> echo -e "\016"
>
> will cause the line drawing characters to be used, and either
> the _reset_ command or the above _sane_ alias will restore the
> expected character font. But
>
> echo -e "\033[?25l"
>
> will cause the cursor to disappear, and _reset_ will not restore
> it. But _sane_ will.
>
> --
> Floyd L. Davidson <http://web.newsguy.com/floyd_davidson>
> Ukpeagvik (Barrow, Alaska) floyd@barrow.com
Thank you much, Floyd, for this explaination. I actually suspected it was
something like my program trying to print characters beyond the defined boundries
of my strings.
Also, thanks much for the alias listed above. I wonder, does it need to be
modified any to work on Sun Solaris? Also, I thank you because the reset command
didn't reset the terminal.
Thank you all, I really like this group.
Andy
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 80,000 Newsgroups - 16 Different Servers! =-----
- Next message: llewelly: "Re: newbie question"
- Previous message: Floyd Davidson: "Re: Why does my program change the characters in my shell"
- In reply to: Floyd Davidson: "Re: Why does my program change the characters in my shell"
- Next in thread: Anand Agrawal \(agrawala\): "Re: Why does my program change the characters in my shell"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|