stas            Thu Jan 18 03:42:09 2001 EDT

  Added files:                 
    /php4/ext/readline  README.libedit 

  Modified files:              
    /php4/ext/readline  config.m4 php_readline.h readline.c 
  Log:
  Libedit readline replacement support
  # Comments are very welcome!
  
  
Index: php4/ext/readline/config.m4
diff -u php4/ext/readline/config.m4:1.8 php4/ext/readline/config.m4:1.9
--- php4/ext/readline/config.m4:1.8     Mon May  1 21:26:48 2000
+++ php4/ext/readline/config.m4 Thu Jan 18 03:42:09 2001
@@ -1,7 +1,9 @@
-dnl $Id: config.m4,v 1.8 2000/05/02 04:26:48 sas Exp $
+dnl $Id: config.m4,v 1.9 2001/01/18 11:42:09 stas Exp $
 dnl config.m4 for extension readline
 dnl don't forget to call PHP_EXTENSION(readline)
 
+PHP_ARG_WITH(libedit,for libedit readline replacement, 
+[  --with-libedit[=DIR]    Include libedit readline replacement.])
 
 PHP_ARG_WITH(readline,for readline support,
 [  --with-readline[=DIR]   Include readline support.  DIR is the readline
@@ -32,3 +34,28 @@
   AC_DEFINE(HAVE_LIBREADLINE, 1, [ ])
   PHP_EXTENSION(readline, $ext_shared)
 fi
+
+if test "$PHP_LIBEDIT" != "no"; then
+  for i in /usr/local /usr $PHP_LIBEDIT; do
+    if test -f $i/include/readline/readline.h; then
+      LIBEDIT_DIR=$i
+    fi
+  done
+
+  if test -z "$LIBEDIT_DIR"; then
+    AC_MSG_ERROR(Please reinstall libedit - I cannot find readline.h)
+  fi
+  AC_ADD_INCLUDE($LIBEDIT_DIR/include)
+
+  AC_CHECK_LIB(ncurses, tgetent, [
+    AC_ADD_LIBRARY_WITH_PATH(ncurses,,READLINE__SHARED_LIBADD)],[
+    AC_CHECK_LIB(termcap, tgetent, [
+      AC_ADD_LIBRARY_WITH_PATH(termcap,,READLINE_SHARED_LIBADD)])
+  ])
+
+  AC_ADD_LIBRARY_WITH_PATH(edit, $LIBEDIT_DIR/lib, READLINE_SHARED_LIBADD)  
+  PHP_SUBST(READLINE_SHARED_LIBADD)
+
+  AC_DEFINE(HAVE_LIBEDIT, 1, [ ])
+  PHP_EXTENSION(readline, $ext_shared)
+fi
\ No newline at end of file
Index: php4/ext/readline/php_readline.h
diff -u php4/ext/readline/php_readline.h:1.8 php4/ext/readline/php_readline.h:1.9
--- php4/ext/readline/php_readline.h:1.8        Sun Oct 29 01:14:53 2000
+++ php4/ext/readline/php_readline.h    Thu Jan 18 03:42:09 2001
@@ -16,12 +16,12 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_readline.h,v 1.8 2000/10/29 09:14:53 thies Exp $ */
+/* $Id: php_readline.h,v 1.9 2001/01/18 11:42:09 stas Exp $ */
 
 #ifndef PHP_READLINE_H
 #define PHP_READLINE_H
 
-#if HAVE_LIBREADLINE
+#if HAVE_LIBREADLINE || HAVE_LIBEDIT
 #ifdef ZTS 
 #warning Readline module will *NEVER* be thread-safe
 #endif
Index: php4/ext/readline/readline.c
diff -u php4/ext/readline/readline.c:1.16 php4/ext/readline/readline.c:1.17
--- php4/ext/readline/readline.c:1.16   Sun Oct 29 01:14:53 2000
+++ php4/ext/readline/readline.c        Thu Jan 18 03:42:09 2001
@@ -16,17 +16,19 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: readline.c,v 1.16 2000/10/29 09:14:53 thies Exp $ */
+/* $Id: readline.c,v 1.17 2001/01/18 11:42:09 stas Exp $ */
 
 /* {{{ includes & prototypes */
 
 #include "php.h"
 #include "php_readline.h"
 
-#if HAVE_LIBREADLINE
+#if HAVE_LIBREADLINE || HAVE_LIBEDIT
 
 #include <readline/readline.h>
+#ifndef HAVE_LIBEDIT
 #include <readline/history.h>
+#endif
 
 PHP_FUNCTION(readline);
 PHP_FUNCTION(readline_add_history);
@@ -51,7 +53,11 @@
        PHP_FE(readline_info,               NULL)
        PHP_FE(readline_add_history,            NULL)
        PHP_FE(readline_clear_history,          NULL)
+#ifdef HAVE_READLINE
        PHP_FE(readline_list_history,           NULL)
+#else
+       PHP_FALIAS(readline_list_history, warn_not_available,                   NULL)
+#endif
        PHP_FE(readline_read_history,           NULL)
        PHP_FE(readline_write_history,          NULL)
        PHP_FE(readline_completion_function,NULL)
@@ -137,15 +143,17 @@
                
add_assoc_string(return_value,"line_buffer",SAFE_STRING(rl_line_buffer),1);
                add_assoc_long(return_value,"point",rl_point);
                add_assoc_long(return_value,"end",rl_end);
+#ifdef HAVE_READLINE
                add_assoc_long(return_value,"mark",rl_mark);
                add_assoc_long(return_value,"done",rl_done);
                add_assoc_long(return_value,"pending_input",rl_pending_input);
+               add_assoc_string(return_value,"prompt",SAFE_STRING(rl_prompt),1);
+               
+add_assoc_string(return_value,"terminal_name",SAFE_STRING(rl_terminal_name),1);
+#endif
 #if HAVE_ERASE_EMPTY_LINE
                add_assoc_long(return_value,"erase_empty_line",rl_erase_empty_line);
 #endif
-               add_assoc_string(return_value,"prompt",SAFE_STRING(rl_prompt),1);
                
add_assoc_string(return_value,"library_version",SAFE_STRING(rl_library_version),1);
-               
add_assoc_string(return_value,"terminal_name",SAFE_STRING(rl_terminal_name),1);
                
add_assoc_string(return_value,"readline_name",SAFE_STRING(rl_readline_name),1);
        } else {
                convert_to_string_ex(what);
@@ -162,6 +170,7 @@
                        RETVAL_LONG(rl_point);
                } else if (! strcasecmp((*what)->value.str.val,"end")) {
                        RETVAL_LONG(rl_end);
+#ifdef HAVE_READLINE
                } else if (! strcasecmp((*what)->value.str.val,"mark")) {
                        RETVAL_LONG(rl_mark);
                } else if (! strcasecmp((*what)->value.str.val,"done")) {
@@ -178,6 +187,11 @@
                                rl_pending_input = (*value)->value.str.val[0];
                        }
                        RETVAL_LONG(oldval);
+               } else if (! strcasecmp((*what)->value.str.val,"prompt")) {
+                       RETVAL_STRING(SAFE_STRING(rl_prompt),1);
+               } else if (! strcasecmp((*what)->value.str.val,"terminal_name")) {
+                       RETVAL_STRING(SAFE_STRING(rl_terminal_name),1);
+#endif
 #if HAVE_ERASE_EMPTY_LINE
                } else if (! strcasecmp((*what)->value.str.val,"erase_empty_line")) {
                        oldval = rl_erase_empty_line;
@@ -187,12 +201,8 @@
                        }
                        RETVAL_LONG(oldval);
 #endif
-               } else if (! strcasecmp((*what)->value.str.val,"prompt")) {
-                       RETVAL_STRING(SAFE_STRING(rl_prompt),1);
                } else if (! strcasecmp((*what)->value.str.val,"library_version")) {
                        RETVAL_STRING(SAFE_STRING(rl_library_version),1);
-               } else if (! strcasecmp((*what)->value.str.val,"terminal_name")) {
-                       RETVAL_STRING(SAFE_STRING(rl_terminal_name),1);
                } else if (! strcasecmp((*what)->value.str.val,"readline_name")) {
                        oldstr = rl_readline_name;
                        if (ac == 2) {
@@ -242,6 +252,7 @@
 /* }}} */
 /* {{{ proto array readline_list_history(void) 
    Lists the history */
+#ifdef HAVE_READLINE
 PHP_FUNCTION(readline_list_history)
 {
        HIST_ENTRY **history;
@@ -262,7 +273,7 @@
                }
        }
 }
-
+#endif
 /* }}} */
 /* {{{ proto int readline_read_history([string filename] [, int from] [,int to]) 
    Reads the history */

Index: php4/ext/readline/README.libedit
+++ php4/ext/readline/README.libedit
This library can be built with libedit - non-GPL drop-in readline replacement.
Libedit can be obtained from http://sourceforge.net/projects/libedit/
It is taken from NetBSD (http://www.netbsd.org/) CVS repository and modified
to work as stand-alone library.



-- 
PHP CVS 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]

Reply via email to