Author: yamakenz
Date: Sat Aug 11 14:49:40 2007
New Revision: 4834
Removed:
trunk/uim/editline.h
Modified:
trunk/NEWS
trunk/configure.ac
trunk/scm/uim-sh.scm
trunk/uim/Makefile.am
trunk/uim/editline.c
trunk/uim/uim-sh.c
Log:
* This commit turn editline feature into plugin
* uim/editline.h
- Removed
* uim/editline.c
- Turn into plugin
- Exclude editline.h
- (UIM_EDITLINE_SEPARATED_BUILD): Removed
- (editline_init): Renamed to uim_plugin_instance_init()
- (uim_plugin_instance_init):
* Renamed from editline_init()
* Provide "editline"
- (editline_quit): Renamed to uim_plugin_instance_quit()
- (uim_plugin_instance_quit): Renamed from editline_quit()
* uim/uim-sh.c
- Exclude editline.h
- (uim_sh): Remove editline handlings
* uim/Makefile.am
- Add libuim-editline plugin
- (uim_sh_SOURCES): Remove editline.c and editline.h
* scm/uim-sh.scm
- Require SRFI 1, 2, 23
- (uim-sh-opt-batch, uim-sh-opt-strict-batch, uim-sh-opt-help):
Removed. These variables are automatically defined according to
the option table definition
- (uim-editline-enabled): Removed
- (uim-sh-option-table): New variable
- (uim-sh-usage): Describe all options
- (uim-sh-define-opt-vars): New procedure
- (uim-sh-parse-args): Replace with table-based option handler
- (uim-sh-loop): Change editline feature detection method
- (uim-sh):
* Ditto
* Add optional Scheme files loading (by require)
* configure.ac
- Fix a typo for libedit library path option
* NEWS
- Update
Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS (original)
+++ trunk/NEWS Sat Aug 11 14:49:40 2007
@@ -1,5 +1,10 @@
Overview of changes from 1.4.x to 1.5.0-alpha
==
+* New features
+ - uim-sh
+ - Accept script files after options
+ - Add --require-module option (-r for short)
+
* Fixed
- uim Scheme library
- Fix fullwidth middle dot in halfwidth katakana table for
@@ -12,6 +17,7 @@
- Fix EOF (^d) ignorance on editline feature is enabled
- Fix ignorance of multiple expressions on a line on editline
feature is enabled
+ - Fix pseudo -r (require module) option with real require-module
Overview of changes from 1.4.0-beta to 1.4.0
==
Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Sat Aug 11 14:49:40 2007
@@ -901,7 +901,7 @@
LDFLAGS="${LDFLAGS} -L$libedit_path/lib"
AC_CHECK_LIB(edit, el_init,
[
- LIBEDIT_LIBS="-ledit -lcurses -l$libedit_path/lib"
+ LIBEDIT_LIBS="-ledit -lcurses -L$libedit_path/lib"
AC_SUBST(LIBEDIT_LIBS)
], [
AC_MSG_WARN("libedit not found. Disabled...")
Modified: trunk/scm/uim-sh.scm
==============================================================================
--- trunk/scm/uim-sh.scm (original)
+++ trunk/scm/uim-sh.scm Sat Aug 11 14:49:40 2007
@@ -30,19 +30,68 @@
;;; SUCH DAMAGE.
;;;;
-(require-extension (srfi 6 34))
+(require-extension (srfi 1 2 6 23 34))
(define uim-sh-prompt "uim> ")
-(define uim-sh-opt-batch #f)
-(define uim-sh-opt-strict-batch #f)
-(define uim-sh-opt-help #f)
-(define uim-editline-enabled #f)
+(define uim-sh-option-table
+ `((("-b" "--batch") . batch)
+ (("-B" "--strict-batch") . strict-batch)
+ (("-h" "--help") . help)
+ (("-r" "--require-module") . ,(lambda (args)
+ (and-let* ((name (safe-car args))
+ ((require-module name)))
+ (safe-cdr args))))
+ (("--editline") . ,(lambda (args)
+ (require-module "editline")
+ args))))
+
+(define uim-sh-usage
+ (lambda ()
+ (display "Usage: uim-sh [options] [file ...]
+ -b
+ --batch batch mode. suppress shell prompts
+ -B
+ --strict-batch strict batch mode, implies -b. suppress shell prompts
+ and evaluated results
+ -r <name>
+ --require-module <name> require module
+ --editline require editline module for Emacs-like line editing
+ -h
+ --help show this help
+ file absolute path or relative to system scm
directory\n")))
+
+(define uim-sh-define-opt-vars
+ (lambda ()
+ (for-each (lambda (name)
+ (eval `(define ,(symbol-append 'uim-sh-opt- name) #f)
+ (interaction-environment)))
+ (filter symbol? (map cdr uim-sh-option-table)))))
+
+(define uim-sh-parse-args
+ (lambda (args)
+ (uim-sh-define-opt-vars)
+ (let rec ((args args))
+ (or (and-let* (((pair? args))
+ (opt (car args))
+ (rest (cdr args))
+ (ent (assoc opt uim-sh-option-table member))
+ (action (cdr ent)))
+ (cond
+ ((symbol? action)
+ (set-symbol-value! (symbol-append 'uim-sh-opt- action) #t))
+ ((procedure? action)
+ (set! rest (action rest)))
+ (else
+ (error "invalid action on option table")))
+ (rec rest))
+ (or args
+ '())))))
(define uim-sh-loop
(lambda (my-read)
(if (and (not uim-sh-opt-batch)
- (not uim-editline-enabled))
+ (not (provided? "editline")))
(display uim-sh-prompt))
;; Non-recoverable read error is turned into fatal errorr such as
;; non-ASCII char in token on a non-Unicode port.
@@ -55,40 +104,15 @@
(writeln res))
(uim-sh-loop my-read))))))
-(define uim-sh-parse-args
- (lambda (args)
- (let ((batch? (or (member "-b" args)
- (member "--batch" args)))
- (strict-batch? (or (member "-B" args)
- (member "--strict-batch" args))))
- (set! uim-sh-opt-batch (or batch?
- strict-batch?))
- (set! uim-sh-opt-strict-batch strict-batch?)
- (set! uim-sh-opt-help (or (member "-h" args)
- (member "--help" args)))
- (if (symbol-bound? 'uim-editline-readline)
- (set! uim-editline-enabled (or (and (member "-r" args)
- (member "editline" args))
- (member "--editline" args)))))))
-
-(define uim-sh-usage
- (lambda ()
- (display "Usage: uim-sh [options]
- -b batch mode. suppress shell prompts
- -B strict batch mode, implies -b. suppress shell prompts and
- evaluated results\n")
- (if (symbol-bound? 'uim-editline-readline)
- (display " -r [module] Load and import module.\n"))
- (display " -h show this help\n")))
-
;; Loop even if error has been occurred. This is required to run
;; GaUnit-based unit test for uim.
(define uim-sh
(lambda (args)
- (uim-sh-parse-args args)
- (let ((my-read (if uim-editline-enabled
+ (let ((files (uim-sh-parse-args (cdr args))) ;; drop the command name
+ (my-read (if (provided? "editline")
uim-editline-read
read)))
+ (for-each require files)
(if uim-sh-opt-help
(uim-sh-usage)
(let reloop ()
Modified: trunk/uim/Makefile.am
==============================================================================
--- trunk/uim/Makefile.am (original)
+++ trunk/uim/Makefile.am Sat Aug 11 14:49:40 2007
@@ -181,10 +181,13 @@
uim_sh_CFLAGS =
uim_sh_LDADD = libuim.la
uim_sh_SOURCES = uim-sh.c
+
if LIBEDIT
- uim_sh_CFLAGS += -DLIBEDIT
- uim_sh_SOURCES += editline.c editline.h
- uim_sh_LDADD += -ledit -lcurses
+ uim_plugin_LTLIBRARIES += libuim-editline.la
+ libuim_editline_la_SOURCES = editline.c
+ libuim_editline_la_LIBADD = @LIBEDIT_LIBS@ libuim.la
+ libuim_editline_la_LDFLAGS = -rpath $(uim_plugindir) -avoid-version -module
+ libuim_editline_la_CPPFLAGS = -I$(top_srcdir)
endif
uim_module_manager_LIBS =
Modified: trunk/uim/editline.c
==============================================================================
--- trunk/uim/editline.c (original)
+++ trunk/uim/editline.c Sat Aug 11 14:49:40 2007
@@ -30,25 +30,12 @@
SUCH DAMAGE.
*/
-/*
- * Currently defined as 1 to be compatible with previous code. If no
- * distro packagers need this, please remove
- */
-#define UIM_EDITLINE_SEPARATED_BUILD 1
#include <histedit.h>
-#if UIM_EDITLINE_SEPARATED_BUILD
-#include <uim/uim.h>
-#include <uim/uim-scm.h>
-#include <uim/plugin.h>
-#else
#include "uim.h"
#include "uim-scm.h"
#include "plugin.h"
-#endif
-
-#include "editline.h"
#define UIM_SH_FALLBACK_PROMPT "uim-sh> "
@@ -60,7 +47,7 @@
static char *prompt(EditLine *e);
void
-editline_init(void)
+uim_plugin_instance_init(void)
{
el = el_init("uim", stdin, stdout, stderr);
el_set(el, EL_PROMPT, &prompt);
@@ -72,10 +59,12 @@
el_source(el, NULL);
uim_scm_init_subr_0("uim-editline-readline", uim_editline_readline);
+
+ uim_scm_callf("provide", "s", "editline");
}
void
-editline_quit(void)
+uim_plugin_instance_quit(void)
{
history_end(hist);
el_end(el);
Modified: trunk/uim/uim-sh.c
==============================================================================
--- trunk/uim/uim-sh.c (original)
+++ trunk/uim/uim-sh.c Sat Aug 11 14:49:40 2007
@@ -38,10 +38,6 @@
#include "uim.h"
#include "uim-scm.h"
-#ifdef LIBEDIT
-#include "editline.h"
-#endif
-
struct uim_sh_args {
int argc;
@@ -71,19 +67,11 @@
{
uim_lisp args;
-#ifdef LIBEDIT
- editline_init();
-#endif
-
uim_scm_require_file("uim-sh.scm");
args = uim_scm_array2list((void **)c_args->argv, c_args->argc,
(uim_lisp (*)(void *))uim_scm_make_str);
uim_scm_callf("uim-sh", "o", args);
-
-#ifdef LIBEDIT
- editline_quit();
-#endif
return NULL;
}