]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
Add editline support in for cases where readline is unavailable.
authorNathan Scott <nathans@sgi.com>
Wed, 16 Apr 2003 23:38:03 +0000 (23:38 +0000)
committerNathan Scott <nathans@sgi.com>
Wed, 16 Apr 2003 23:38:03 +0000 (23:38 +0000)
configure.in
db/Makefile
db/input.c
doc/CHANGES
include/builddefs.in
io/Makefile
io/input.c
libxfs/xfs_inode.c

index b618aca673632468f119f4f459898f41578d3094..646af3f1955a0f49643df53b2eb33bb3e27b7751 100644 (file)
@@ -166,13 +166,21 @@ AC_ARG_ENABLE(readline,
 [ --enable-readline=[yes/no] Enable readline command editing [default=no]],,
        enable_readline=no)
 if test $enable_readline = yes; then
-       libreadline="-lreadline -lncurses"
-else
-       libreadline=""
+       libreadline="-lreadline -ltermcap"
 fi
 AC_SUBST(libreadline)
 AC_SUBST(enable_readline)
 
+dnl will we be making use of editline?
+AC_ARG_ENABLE(editline,
+[ --enable-editline=[yes/no] Enable editline command editing [default=no]],,
+       enable_editline=no)
+if test $enable_editline = yes; then
+       libeditline="-ledit -ltermcap"
+fi
+AC_SUBST(libeditline)
+AC_SUBST(enable_editline)
+
 dnl will we be making use of gettext?
 AC_ARG_ENABLE(gettext,
 [ --enable-gettext=[yes/no] Enable alternate language support [default=yes]],,
index b98459d071029a1dac3b9610366ae69933782ef8..1e5b815e4e8f8808f2f8bbf2b18e64f20ce3af09 100644 (file)
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2000-2001 Silicon Graphics, Inc.  All Rights Reserved.
+# Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
 #
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of version 2 of the GNU General Public License as
@@ -52,6 +52,11 @@ LLDLIBS += $(LIBREADLINE)
 CFLAGS += -DENABLE_READLINE
 endif
 
+ifeq ($(ENABLE_EDITLINE),yes)
+LLDLIBS += $(LIBEDITLINE)
+CFLAGS += -DENABLE_EDITLINE
+endif
+
 default: $(LTCOMMAND)
 
 include $(BUILDRULES)
index f92b2f0952f47f8b198b80c6acab5bed392e933a..3d828d9249adcaff62797b4035ae49e66183ba57 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2001 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of version 2 of the GNU General Public License as
 #include "malloc.h"
 #include "init.h"
 
-#ifdef ENABLE_READLINE
+#if defined(ENABLE_READLINE)
 # include <readline/history.h>
 # include <readline/readline.h>
+#elif defined(ENABLE_EDITLINE)
+# include <histedit.h>
 #endif
 
 int    inputstacksize;
@@ -147,6 +149,16 @@ doneline(
        xfree(vec);
 }
 
+static char *
+get_prompt(void)
+{
+       static char     prompt[FILENAME_MAX + 1];
+
+       if (!prompt[0])
+               snprintf(prompt, sizeof(prompt), "%s> ", progname);
+       return prompt;
+}
+
 static char *
 fetchline_internal(void)
 {
@@ -162,7 +174,7 @@ fetchline_internal(void)
                        if (iscont)
                                dbprintf("... ");
                        else
-                               dbprintf("%s> ", progname);
+                               dbprintf(get_prompt(), progname);
                        fflush(stdin);
                }
                if (seenint() ||
@@ -223,29 +235,57 @@ fetchline_internal(void)
 char *
 fetchline(void)
 {
-       static char     prompt[FILENAME_MAX + 1];
-       char            *line;
-
-       if (!prompt[0])
-               snprintf(prompt, sizeof(prompt), "%s> ", progname);
+       char    *line;
 
        if (inputstacksize == 1) {
-               line = readline(prompt);
-               if (line && *line)
+               line = readline(get_prompt());
+               if (line && *line) {
                        add_history(line);
-               else
                        logprintf("%s", line);
+               }
        } else {
                line = fetchline_internal();
        }
        return line;
 }
-#else
+#elif defined(ENABLE_EDITLINE)
+static char *el_get_prompt(EditLine *e) { return get_prompt(); }
 char *
 fetchline(void)
-{
-       return fetchline_internal();
+{     
+       static EditLine *el;
+       static History  *hist;
+       HistEvent       hevent;
+       char            *line;    
+       int             count;
+
+       if (!el) {
+               hist = history_init();
+               history(hist, &hevent, H_SETSIZE, 100);
+               el = el_init(progname, stdin, stdout, stderr);
+               el_source(el, NULL);
+               el_set(el, EL_SIGNAL, 1);
+               el_set(el, EL_PROMPT, el_get_prompt);
+               el_set(el, EL_HIST, history, (const char *)hist);
+       }
+
+       if (inputstacksize == 1) {
+               line = xstrdup(el_gets(el, &count));
+               if (line) {
+                       if (count > 0)
+                               line[count-1] = '\0';
+                       if (*line) {
+                               history(hist, &hevent, H_ENTER, line);
+                               logprintf("%s", line);
+                       }
+               }
+       } else {
+               line = fetchline_internal();
+       }
+       return line;
 }
+#else
+char * fetchline(void) { return fetchline_internal(); }
 #endif
 
 static void
index 5e110964c058258a2241660a67c6f09cfa3f4060..08a1e6835b307902e94b2d37394791fec8d23000 100644 (file)
@@ -2,6 +2,9 @@ xfsprogs-2.4.6 (11 April 2003)
        - Fix a bug in detection of "clean" and "error" states with
          MD devices.
        - Fix configure tests that used AC_PATH_PROG incorrectly.
+       - Add support for libedit, if libreadline is unavailable.
+       - Fix the libxfs build on big endian platforms.
+       - Sync up user/kernel source in libxfs and headers.
 
 xfsprogs-2.4.5 (03 April 2003)
        - Sync up xfs_inode.c in libxfs.
index f0c8e95cba65fedc020aa2602744c23f60d4e71c..886e07306725420761ebaf46c3ebfc92367dbf89 100644 (file)
@@ -40,6 +40,7 @@ OPTIMIZER = @opt_build@
 MALLOCLIB = @malloc_lib@
 
 LIBUUID = @libuuid@
+LIBEDITLINE = @libeditline@
 LIBREADLINE = @libreadline@
 LIBXFS = $(TOPDIR)/libxfs/libxfs.la
 LIBXLOG = $(TOPDIR)/libxlog/libxlog.la
@@ -89,6 +90,7 @@ RPM_VERSION   = @rpm_version@
 
 ENABLE_SHARED = @enable_shared@
 ENABLE_GETTEXT = @enable_gettext@
+ENABLE_EDITLINE = @enable_editline@
 ENABLE_READLINE = @enable_readline@
 HAVE_ZIPPED_MANPAGES = @have_zipped_manpages@
 
index a069d67d0bfe798153965721300e06bd579edccf..e24caeff6902f364b70b9a58989fba3c60b8ae67 100644 (file)
@@ -45,6 +45,11 @@ LLDLIBS += $(LIBREADLINE)
 CFLAGS += -DENABLE_READLINE
 endif
 
+ifeq ($(ENABLE_EDITLINE),yes)
+LLDLIBS += $(LIBEDITLINE)
+CFLAGS += -DENABLE_EDITLINE
+endif
+
 default: $(LTCOMMAND)
 
 include $(BUILDRULES)
index c3d0c01d7252303009ccbbecb14888c5f41e2b26..c6263285bff02487e1a36783ddc61cc6b5e66f69 100644 (file)
 #include "input.h"
 #include "init.h"
 
-#ifdef ENABLE_READLINE
+#if defined(ENABLE_READLINE)
 # include <readline/history.h>
 # include <readline/readline.h>
+#elif defined(ENABLE_EDITLINE)
+# include <histedit.h>
+#endif
+
+static char *
+get_prompt(void)
+{
+       static char     prompt[FILENAME_MAX + 1];
+
+       if (!prompt[0])
+               snprintf(prompt, sizeof(prompt), "%s> ", progname);
+       return prompt;
+}
+
+#if defined(ENABLE_READLINE)
+char *
+fetchline(void)
+{
+       char    *line;
+
+       line = readline(get_prompt());
+       if (line && *line)
+               add_history(line);
+       return line;
+}
+#elif defined(ENABLE_EDITLINE)
+static char *el_get_prompt(EditLine *e) { return get_prompt(); }
+char *
+fetchline(void)
+{
+       static EditLine *el;
+       static History  *hist;
+       HistEvent       hevent;
+       char            *line;
+       int             count;
+
+       if (!el) {
+               hist = history_init();
+               history(hist, &hevent, H_SETSIZE, 100);
+               el = el_init(progname, stdin, stdout, stderr);
+               el_source(el, NULL);
+               el_set(el, EL_SIGNAL, 1);
+               el_set(el, EL_PROMPT, el_get_prompt);
+               el_set(el, EL_HIST, history, (const char *)hist);
+       }
+       line = strdup(el_gets(el, &count));
+       if (line) {
+               if (count > 0)
+                       line[count-1] = '\0';
+               if (*line)
+                       history(hist, &hevent, H_ENTER, line);
+       }
+       return line;
+}
 #else
 # define MAXREADLINESZ 1024
-static char *
-readline(char *prompt)
+char *
+fetchline(void)
 {
        char    *p, *line = malloc(MAXREADLINESZ);
 
        if (!line)
                return NULL;
-       printf(prompt);
+       printf(get_prompt());
        fflush(stdout);
        if (!fgets(line, MAXREADLINESZ, stdin)) {
                free(line);
@@ -57,24 +111,8 @@ readline(char *prompt)
                p[-1] = '\0';
        return line;
 }
-static void add_history(char *line) { }
-# undef MAXREADLINESZ
 #endif
 
-char *
-fetchline(void)
-{
-       static char     prompt[FILENAME_MAX + 1];
-       char            *line;
-
-       if (!prompt[0])
-               snprintf(prompt, sizeof(prompt), "%s> ", progname);
-       line = readline(prompt);
-       if (line && *line)
-               add_history(line);
-       return line;
-}
-
 char **
 breakline(
        char    *input,
index 5c9e5ad295e3194abcbb6920f3bc5db4c435d9c0..538ab6cc3da68b27f2df889b8edf281a85767b92 100644 (file)
@@ -430,14 +430,12 @@ xfs_iformat_extents(
        xfs_dinode_t    *dip,
        int             whichfork)
 {
+       xfs_bmbt_rec_t  *ep, *dp;
        xfs_ifork_t     *ifp;
        int             nex;
        int             real_size;
        int             size;
-#if ARCH_CONVERT != ARCH_NOCONVERT
        int             i;
-#endif
-       xfs_bmbt_rec_t  *ep, *dp;
 
        ifp = XFS_IFORK_PTR(ip, whichfork);
        nex = XFS_DFORK_NEXTENTS_ARCH(dip, whichfork, ARCH_CONVERT);
@@ -565,66 +563,69 @@ xfs_iformat_btree(
  *                    -ve -> native to disk
  * arch = on-disk architecture
  */
-
 void
-xfs_xlate_dinode_core(xfs_caddr_t buf, xfs_dinode_core_t *dip,
-    int dir, xfs_arch_t arch)
+xfs_xlate_dinode_core(
+       xfs_caddr_t             buf,
+       xfs_dinode_core_t       *dip,
+       int                     dir,
+       xfs_arch_t              arch)
 {
-    xfs_dinode_core_t   *buf_core;
-    xfs_dinode_core_t   *mem_core;
-
-    ASSERT(dir);
-
-    buf_core=(xfs_dinode_core_t*)buf;
-    mem_core=(xfs_dinode_core_t*)dip;
+       xfs_dinode_core_t       *buf_core = (xfs_dinode_core_t *)buf;
+       xfs_dinode_core_t       *mem_core = (xfs_dinode_core_t *)dip;
+
+       ASSERT(dir);
+       if (arch == ARCH_NOCONVERT) {
+               if (dir > 0) {
+                       memcpy((xfs_caddr_t)mem_core, (xfs_caddr_t)buf_core,
+                               sizeof(xfs_dinode_core_t));
+               } else {
+                       memcpy((xfs_caddr_t)buf_core, (xfs_caddr_t)mem_core,
+                               sizeof(xfs_dinode_core_t));
+               }
+               return;
+       }
 
-    if (arch == ARCH_NOCONVERT) {
-       if (dir>0) {
-           memcpy((xfs_caddr_t)mem_core, (xfs_caddr_t)buf_core, sizeof(xfs_dinode_core_t));
+       INT_XLATE(buf_core->di_magic, mem_core->di_magic, dir, arch);
+       INT_XLATE(buf_core->di_mode, mem_core->di_mode, dir, arch);
+       INT_XLATE(buf_core->di_version, mem_core->di_version, dir, arch);
+       INT_XLATE(buf_core->di_format, mem_core->di_format, dir, arch);
+       INT_XLATE(buf_core->di_onlink, mem_core->di_onlink, dir, arch);
+       INT_XLATE(buf_core->di_uid, mem_core->di_uid, dir, arch);
+       INT_XLATE(buf_core->di_gid, mem_core->di_gid, dir, arch);
+       INT_XLATE(buf_core->di_nlink, mem_core->di_nlink, dir, arch);
+       INT_XLATE(buf_core->di_projid, mem_core->di_projid, dir, arch);
+
+       if (dir > 0) {
+               memcpy(mem_core->di_pad, buf_core->di_pad,
+                       sizeof(buf_core->di_pad));
        } else {
-           memcpy((xfs_caddr_t)buf_core, (xfs_caddr_t)mem_core, sizeof(xfs_dinode_core_t));
+               memcpy(buf_core->di_pad, mem_core->di_pad,
+                       sizeof(buf_core->di_pad));
        }
-       return;
-    }
-
-    INT_XLATE(buf_core->di_magic,       mem_core->di_magic,        dir, arch);
-    INT_XLATE(buf_core->di_mode,        mem_core->di_mode,         dir, arch);
-    INT_XLATE(buf_core->di_version,     mem_core->di_version,      dir, arch);
-    INT_XLATE(buf_core->di_format,      mem_core->di_format,       dir, arch);
-    INT_XLATE(buf_core->di_onlink,      mem_core->di_onlink,       dir, arch);
-    INT_XLATE(buf_core->di_uid,         mem_core->di_uid,          dir, arch);
-    INT_XLATE(buf_core->di_gid,         mem_core->di_gid,          dir, arch);
-    INT_XLATE(buf_core->di_nlink,       mem_core->di_nlink,        dir, arch);
-    INT_XLATE(buf_core->di_projid,      mem_core->di_projid,       dir, arch);
-
-    if (dir>0) {
-       memcpy(mem_core->di_pad, buf_core->di_pad, sizeof(buf_core->di_pad));
-    } else {
-       memcpy(buf_core->di_pad, mem_core->di_pad, sizeof(buf_core->di_pad));
-    }
-
-    INT_XLATE(buf_core->di_atime.t_sec, mem_core->di_atime.t_sec,  dir, arch);
-    INT_XLATE(buf_core->di_atime.t_nsec,mem_core->di_atime.t_nsec, dir, arch);
-
-    INT_XLATE(buf_core->di_mtime.t_sec, mem_core->di_mtime.t_sec,  dir, arch);
-    INT_XLATE(buf_core->di_mtime.t_nsec,mem_core->di_mtime.t_nsec, dir, arch);
-
-    INT_XLATE(buf_core->di_ctime.t_sec, mem_core->di_ctime.t_sec,  dir, arch);
-    INT_XLATE(buf_core->di_ctime.t_nsec,mem_core->di_ctime.t_nsec, dir, arch);
-
-    INT_XLATE(buf_core->di_size,        mem_core->di_size,         dir, arch);
-    INT_XLATE(buf_core->di_nblocks,     mem_core->di_nblocks,      dir, arch);
-    INT_XLATE(buf_core->di_extsize,     mem_core->di_extsize,      dir, arch);
-
-    INT_XLATE(buf_core->di_nextents,    mem_core->di_nextents,     dir, arch);
-    INT_XLATE(buf_core->di_anextents,   mem_core->di_anextents,    dir, arch);
-    INT_XLATE(buf_core->di_forkoff,     mem_core->di_forkoff,      dir, arch);
-    INT_XLATE(buf_core->di_aformat,     mem_core->di_aformat,      dir, arch);
-    INT_XLATE(buf_core->di_dmevmask,    mem_core->di_dmevmask,     dir, arch);
-    INT_XLATE(buf_core->di_dmstate,     mem_core->di_dmstate,      dir, arch);
-    INT_XLATE(buf_core->di_flags,       mem_core->di_flags,        dir, arch);
-    INT_XLATE(buf_core->di_gen,         mem_core->di_gen,          dir, arch);
 
+       INT_XLATE(buf_core->di_atime.t_sec, mem_core->di_atime.t_sec,
+                       dir, arch);
+       INT_XLATE(buf_core->di_atime.t_nsec, mem_core->di_atime.t_nsec,
+                       dir, arch);
+       INT_XLATE(buf_core->di_mtime.t_sec, mem_core->di_mtime.t_sec,
+                       dir, arch);
+       INT_XLATE(buf_core->di_mtime.t_nsec, mem_core->di_mtime.t_nsec,
+                       dir, arch);
+       INT_XLATE(buf_core->di_ctime.t_sec, mem_core->di_ctime.t_sec,
+                       dir, arch);
+       INT_XLATE(buf_core->di_ctime.t_nsec, mem_core->di_ctime.t_nsec,
+                       dir, arch);
+       INT_XLATE(buf_core->di_size, mem_core->di_size, dir, arch);
+       INT_XLATE(buf_core->di_nblocks, mem_core->di_nblocks, dir, arch);
+       INT_XLATE(buf_core->di_extsize, mem_core->di_extsize, dir, arch);
+       INT_XLATE(buf_core->di_nextents, mem_core->di_nextents, dir, arch);
+       INT_XLATE(buf_core->di_anextents, mem_core->di_anextents, dir, arch);
+       INT_XLATE(buf_core->di_forkoff, mem_core->di_forkoff, dir, arch);
+       INT_XLATE(buf_core->di_aformat, mem_core->di_aformat, dir, arch);
+       INT_XLATE(buf_core->di_dmevmask, mem_core->di_dmevmask, dir, arch);
+       INT_XLATE(buf_core->di_dmstate, mem_core->di_dmstate, dir, arch);
+       INT_XLATE(buf_core->di_flags, mem_core->di_flags, dir, arch);
+       INT_XLATE(buf_core->di_gen, mem_core->di_gen, dir, arch);
 }
 
 /*