RE: [PHP-DEV] Unbuffered fgetc needed for stdin

2001-12-15 Thread August Zajonc

Doh... That's right. Stream input is usually buffered. Futzing with tty is
pretty ugly I think (stty/ioctl)...

On further reflection it seems that the getting a wrapper for ncurses or cdk
would be a real nice win for PHP. Perl's got a cdk module, think Python has
a ncurses wrapper. If they have reasonable license terms might be easy to
use those as a starting point for a php wrapper.

Wrapping these ncurses / cdk would be a nice add for PHP on the commandline.

Unfortunatly don't have the time to attempt something like this.

-AZ

 -Original Message-
 From: Andi Gutmans [mailto:[EMAIL PROTECTED]]
 Sent: Saturday, December 15, 2001 1:34 PM
 To: August Zajonc; [EMAIL PROTECTED]
 Subject: Re: [PHP-DEV] Unbuffered fgetc needed for stdin


 This usually depends on how you configured your tty. I think by
 default it
 is buffered by the OS until a newline so it's probably not PHP
 which needs
 changing but your settings.

 Andi

 At 12:30 PM 12/15/2001 -0800, August Zajonc wrote:
 I've really run into a wall trying to get single charachters from stdin.
 
 Something similar to the getchar macro or a real fgetc would be nice.
 
 The current behavior is that more than a signle charachter can
 be typed and
 fgetc only returns when it sees a \n.
 
 I'd like it to return immediatly after the first charachter.
 
 fscanf with a format string something like %c requires a \n before
 returning as well, though I suppose that is more understandable.
 
 various things like fread with length of 1 also don't work.
 
 This is missing functionality for which there is no workaround that would
 certainly make shell scripting easier. It should be relativly trivial to
 implement, either an unbuffered fgetc option or a new function
 or something.
 
 -AZ
 
 
 --
 PHP Development Mailing List http://www.php.net/
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] Unbuffered fgetc needed for stdin

2001-12-15 Thread Andi Gutmans

This usually depends on how you configured your tty. I think by default it 
is buffered by the OS until a newline so it's probably not PHP which needs 
changing but your settings.

Andi

At 12:30 PM 12/15/2001 -0800, August Zajonc wrote:
I've really run into a wall trying to get single charachters from stdin.

Something similar to the getchar macro or a real fgetc would be nice.

The current behavior is that more than a signle charachter can be typed and
fgetc only returns when it sees a \n.

I'd like it to return immediatly after the first charachter.

fscanf with a format string something like %c requires a \n before
returning as well, though I suppose that is more understandable.

various things like fread with length of 1 also don't work.

This is missing functionality for which there is no workaround that would
certainly make shell scripting easier. It should be relativly trivial to
implement, either an unbuffered fgetc option or a new function or something.

-AZ


--
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]