This is the mail archive of the cygwin mailing list for the Cygwin 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: Non-canonical mode input via tcsetattr(), under mintty console


Sorry for forgetting 3 things.
1. I was testing on cygwin 1.7.
2. I was running the latest version of mintty (0.5.8-1).
3. I have included an output from cygcheck here.

Thanks.

--- On Sun, 2/28/10, Dave Lee <mailtolky@yahoo.com.hk> wrote:

> Hi all,
> 
> I was testing a program that uses non-canonical mode input
> via
> tcsetattr().
> 
> The intent of the program is:
> (1) have read() to wait if nothing has been entered;
> (2) read() should not return until 1 character is read
> Â Â and put into the buffer.
> 
> The essence is this:
> 
> >Â Â ÂÂÂstruct termios newtty;
> >Â Â Â Â ÂÂÂ.
> >Â Â Â Â ÂÂÂ.
> >Â Â Â Â ÂÂÂ.
> >Â Â ÂÂÂtcgetattr (0,
> &newtty);
> >Â Â ÂÂÂnewtty.c_lflags &=
> (~ICANON);
> >
> >Â Â ÂÂÂnewtty.c_cc[VMIN] = 1;
> >Â Â ÂÂÂnewtty.c_cc[VTIME] =
> 0;
> >
> >Â Â ÂÂÂtcsetattr (0, TCSANOW,
> &newtty);
> >
> >Â Â ÂÂÂunsigned char
> buf[100];
> >Â Â ÂÂÂsize_t n = read (0,
> buf, sizeof(buf));
> >Â Â Â Â ÂÂÂ.
> >Â Â Â Â ÂÂÂ.
> >Â Â Â Â ÂÂÂ.
> 
> I had no problem while entering an ASCII character. I also
> had success
> if I entered a non-ASCII character under standard console,
> but not under
> mintty.
> 
> Specifically, I entered the chinese character "ä" (which
> means "rule"
> or "example"). It occupies 3 bytes in UTF-8 representation:
> E4, BE, 8B.
> 
> On standard console, the read() call returned THREE bytes
> (n == 3), and
> (not surprisingly) E4, BE and 8B were returned to buf[].
> 
> On mintty console, the read() call returned ONE byte (n ==
> 1), and only
> E4 were returned to buf[]. I could grab the other two bytes
> if I did
> additional calls to read().
> 
> I have attached a sample program for testing purpose.
> Basically it waits
> for input, and when something is entered, prints it.
> Instruction is
> included in the source.
> 
> I suspected this is a bug shown under mintty (but not
> standard
> console). Is it the case?
> 
> Thanks,
> 
> Dave Lee.
> 
> 
> Â Â Â --
> Problem reports:Â Â ÂÂÂhttp://cygwin.com/problems.html
> FAQ:Â Â Â Â Â Â Â Â
> ÂÂÂhttp://cygwin.com/faq/
> Documentation:Â Â Â ÂÂÂhttp://cygwin.com/docs.html
> Unsubscribe info:Â Â Â http://cygwin.com/ml/#unsubscribe-simple


      

Attachment: cygcheck.out
Description: Binary data

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

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