Feature complete: 'libedit'

This commit is contained in:
Greyson Fischer 2013-05-20 16:26:06 -04:00
commit cca453cc06
2 changed files with 50 additions and 15 deletions

View File

@ -297,31 +297,44 @@ class ConsoleLoop extends Thread{
public $stop; public $stop;
public $base; public $base;
public $ev; public $ev;
public $fp;
public function __construct(){ public function __construct(){
$this->line = false; $this->line = false;
$this->stop = false; $this->stop = false;
$this->start(); $this->start();
} }
public function stop(){ public function stop(){
$this->stop = true; $this->stop = true;
} }
public function readLine($fp, $events = null){ private function readLine(){
$line = trim(fgets($fp)); if( $this->fp ){
if($line != ""){ $line = trim( fgets( $this->fp ) );
$this->line = $line; } else {
} $line = trim( readline( "" ) );
} if( $line != "" ){
readline_add_history( $line );
}
}
return $line;
}
public function run(){ public function run(){
$fp = fopen("php://stdin", "r"); if( ! extension_loaded( 'readline' ) ){
while($this->stop === false and ($line = fgets($fp)) !== false){ $this->fp = fopen( "php://stdin", "r" );
$this->line = $line; }
$this->wait();
$this->line = false; while( $this->stop === false ) {
$this->line = $this->readLine();
$this->wait();
$this->line = false;
} }
@fclose($fp);
if( ! $this->haveReadline ) {
@fclose($fp);
}
exit(0); exit(0);
} }
} }

View File

@ -4,6 +4,7 @@ COMPILER_VERSION="0.12"
PHP_VERSION="5.4.15" PHP_VERSION="5.4.15"
ZEND_VM="GOTO" ZEND_VM="GOTO"
LIBEDIT_VERSION="0.3"
ZLIB_VERSION="1.2.8" ZLIB_VERSION="1.2.8"
PTHREADS_VERSION="e5d95dfb847c8963c100bd4fb601dde41e0b75d1" PTHREADS_VERSION="e5d95dfb847c8963c100bd4fb601dde41e0b75d1"
CURL_VERSION="curl-7_30_0" CURL_VERSION="curl-7_30_0"
@ -36,6 +37,26 @@ wget http://php.net/get/php-$PHP_VERSION.tar.gz/from/this/mirror -q -O - | tar -
mv php-$PHP_VERSION php mv php-$PHP_VERSION php
echo " done!" echo " done!"
#libedit
echo -n "[libedit] downloading $LIBEDIT_VERSION..."
wget http://download.sourceforge.net/project/libedit/libedit/libedit-$LIBEDIT_VERSION/libedit-$LIBEDIT_VERSION.tar.gz -q -O - | tar -zx >> "$DIR/install.log" 2>&1
echo -n " checking..."
cd libedit
CFLAGS=-fPIC ./configure --prefix="$DIR/install_data/php/ext/libedit" --enable-static >> "$DIR/install.log" 2>&1
echo -n " compiling..."
if make >> "$DIR/install.log" 2>&1; then
echo -n " installing..."
make install >> "$DIR/install.log" 2>&1
HAVE_LIBEDIT="--with-libedit=$DIR/install_data/php/ext/libedit"
else
echo -n " disabling..."
HAVE_LIBEDIT="--without-libedit"
fi
echo -n " cleaning..."
cd ..
rm -r -f ./libedit
echo " done!"
#zlib #zlib
echo -n "[zlib] downloading $ZLIB_VERSION..." echo -n "[zlib] downloading $ZLIB_VERSION..."
wget http://zlib.net/zlib-$ZLIB_VERSION.tar.gz -q -O - | tar -zx >> "$DIR/install.log" 2>&1 wget http://zlib.net/zlib-$ZLIB_VERSION.tar.gz -q -O - | tar -zx >> "$DIR/install.log" 2>&1
@ -103,6 +124,7 @@ rm -f ./configure >> "$DIR/install.log" 2>&1
--exec-prefix="$DIR/php5" \ --exec-prefix="$DIR/php5" \
--with-curl="$DIR/install_data/php/ext/curl" \ --with-curl="$DIR/install_data/php/ext/curl" \
--with-zlib="$DIR/install_data/php/ext/zlib" \ --with-zlib="$DIR/install_data/php/ext/zlib" \
"$HAVE_LIBEDIT" \
--disable-libxml \ --disable-libxml \
--disable-xml \ --disable-xml \
--disable-dom \ --disable-dom \