Readline usage fixes

This commit is contained in:
whydoubt 2004-10-25 04:11:13 +00:00
parent 062259b408
commit fd04c906c8
6 changed files with 26 additions and 22 deletions

View File

@ -1,3 +1,10 @@
Sun Oct 24 23:07:16 CDT 2004 Jeff Smith <whydoubt@yahoo.com>
* configure.in:
* src/gmdb2/Makefile.am:
* src/libmdb/Makefile.am:
* src/util/Makefile.am:
* src/util/mdb-sql.c: Readline usage fixes
Wed Oct 20 21:49:04 CDT 2004 Jeff Smith <whydoubt@yahoo.com> Wed Oct 20 21:49:04 CDT 2004 Jeff Smith <whydoubt@yahoo.com>
* src/sql/mdbsql.c: Get rid of GLib 2.4+ call * src/sql/mdbsql.c: Get rid of GLib 2.4+ call

View File

@ -168,8 +168,6 @@ dnl Checks for library functions.
OLDLDFLAGS=$LDFLAGS OLDLDFLAGS=$LDFLAGS
VL_LIB_READLINE VL_LIB_READLINE
READLINE_LIBS=$vl_cv_lib_readline
AC_SUBST(READLINE_LIBS)
LDFLAGS=$OLDLDFLAGS LDFLAGS=$OLDLDFLAGS

View File

@ -2,7 +2,7 @@ SUBDIRS = help gladefiles pixmaps
bin_PROGRAMS = gmdb2 bin_PROGRAMS = gmdb2
include_HEADERS = gmdb.h include_HEADERS = gmdb.h
gmdb2_SOURCES = main2.c file.c util.c table.c query.c module.c macro.c report.c form.c info.c table_def.c table_data.c table_export.c debug.c sql.c schema.c prefs.c gmdb2_SOURCES = main2.c file.c util.c table.c query.c module.c macro.c report.c form.c info.c table_def.c table_data.c table_export.c debug.c sql.c schema.c prefs.c
LIBS = -rdynamic $(GNOME_LIBS) @LEXLIB@ LIBS = -rdynamic $(GNOME_LIBS) @LIBS@ @LEXLIB@
AM_CPPFLAGS = -I$(top_srcdir)/include \ AM_CPPFLAGS = -I$(top_srcdir)/include \
$(GNOME_CFLAGS) \ $(GNOME_CFLAGS) \
-DDATADIR=\""$(datadir)"\" \ -DDATADIR=\""$(datadir)"\" \

View File

@ -2,4 +2,4 @@ lib_LTLIBRARIES = libmdb.la
libmdb_la_SOURCES= catalog.c mem.c file.c kkd.c table.c data.c dump.c backend.c money.c sargs.c index.c like.c write.c stats.c map.c props.c worktable.c options.c iconv.c libmdb_la_SOURCES= catalog.c mem.c file.c kkd.c table.c data.c dump.c backend.c money.c sargs.c index.c like.c write.c stats.c map.c props.c worktable.c options.c iconv.c
libmdb_la_LDFLAGS = -version-info 1:0:0 libmdb_la_LDFLAGS = -version-info 1:0:0
AM_CPPFLAGS = -I$(top_srcdir)/include $(GLIB_CFLAGS) AM_CPPFLAGS = -I$(top_srcdir)/include $(GLIB_CFLAGS)
LIBS = $(GLIB_LIBS) -lm LIBS = $(GLIB_LIBS) @LIBS@ -lm

View File

@ -1,5 +1,5 @@
bin_PROGRAMS = mdb-export mdb-array mdb-schema mdb-tables mdb-parsecsv mdb-header mdb-sql mdb-ver mdb-prop mdb-import prtable prcat prdata prkkd prdump prole updrow prindex bin_PROGRAMS = mdb-export mdb-array mdb-schema mdb-tables mdb-parsecsv mdb-header mdb-sql mdb-ver mdb-prop mdb-import prtable prcat prdata prkkd prdump prole updrow prindex
LIBS = $(GLIB_LIBS) $(READLINE_LIBS) @LEXLIB@ LIBS = $(GLIB_LIBS) @LIBS@ @LEXLIB@
DEFS = @DEFS@ -DLOCALEDIR=\"$(localedir)\" DEFS = @DEFS@ -DLOCALEDIR=\"$(localedir)\"
AM_CPPFLAGS = -I$(top_srcdir)/include $(GLIB_CFLAGS) AM_CPPFLAGS = -I$(top_srcdir)/include $(GLIB_CFLAGS)
LDADD = ../libmdb/libmdb.la LDADD = ../libmdb/libmdb.la

View File

@ -25,12 +25,11 @@
# include <readline/readline.h> # include <readline/readline.h>
# elif defined(HAVE_READLINE_H) # elif defined(HAVE_READLINE_H)
# include <readline.h> # include <readline.h>
# else /* !defined(HAVE_READLINE_H) */ # else
/* no readline.h */
extern char *readline (); extern char *readline ();
# endif /* !defined(HAVE_READLINE_H) */ # endif
char *cmdline = NULL; char *cmdline = NULL;
#else /* !defined(HAVE_READLINE_READLINE_H) */
/* no readline */
#endif /* HAVE_LIBREADLINE */ #endif /* HAVE_LIBREADLINE */
#ifdef HAVE_READLINE_HISTORY #ifdef HAVE_READLINE_HISTORY
@ -38,12 +37,12 @@ char *cmdline = NULL;
# include <readline/history.h> # include <readline/history.h>
# elif defined(HAVE_HISTORY_H) # elif defined(HAVE_HISTORY_H)
# include <history.h> # include <history.h>
# else /* !defined(HAVE_HISTORY_H) */ # else
/* no history.h */
extern void add_history (); extern void add_history ();
extern int write_history (); extern int write_history ();
extern int read_history (); extern int read_history ();
# endif /* defined(HAVE_READLINE_HISTORY_H) */ # endif
/* no history */
#endif /* HAVE_READLINE_HISTORY */ #endif /* HAVE_READLINE_HISTORY */
#include <string.h> #include <string.h>
@ -66,7 +65,9 @@ char *delimiter;
int showplan = 0; int showplan = 0;
int noexec = 0; int noexec = 0;
#ifdef HAVE_READLINE_HISTORY
#define HISTFILE ".mdbhistory" #define HISTFILE ".mdbhistory"
#endif
#ifndef HAVE_LIBREADLINE #ifndef HAVE_LIBREADLINE
char *readline(char *prompt) char *readline(char *prompt)
@ -89,16 +90,6 @@ int i = 0;
return buf; return buf;
} }
void add_history(char *s)
{
}
void read_history(char *s)
{
}
void write_history(char *s)
{
}
#endif #endif
int parse(MdbSQL *sql, char *buf) int parse(MdbSQL *sql, char *buf)
@ -190,8 +181,10 @@ read_file(char *s, int line, unsigned int *bufsz, char *mybuf)
mybuf = (char *) realloc(mybuf, *bufsz); mybuf = (char *) realloc(mybuf, *bufsz);
} }
strcat(mybuf, buf); strcat(mybuf, buf);
#ifdef HAVE_READLINE_HISTORY
/* don't record blank lines */ /* don't record blank lines */
if (strlen(buf)) add_history(buf); if (strlen(buf)) add_history(buf);
#endif
strcat(mybuf, "\n"); strcat(mybuf, "\n");
lines++; lines++;
printf("%d => %s",line+lines, buf); printf("%d => %s",line+lines, buf);
@ -375,11 +368,13 @@ char *home = getenv("HOME");
char *histpath; char *histpath;
#ifdef HAVE_READLINE_HISTORY
if (home) { if (home) {
histpath = (char *) g_strconcat(home, "/", HISTFILE, NULL); histpath = (char *) g_strconcat(home, "/", HISTFILE, NULL);
read_history(histpath); read_history(histpath);
g_free(histpath); g_free(histpath);
} }
#endif
if (!isatty(fileno(stdin))) { if (!isatty(fileno(stdin))) {
in = stdin; in = stdin;
} }
@ -462,8 +457,10 @@ char *histpath;
bufsz *= 2; bufsz *= 2;
mybuf = (char *) g_realloc(mybuf, bufsz); mybuf = (char *) g_realloc(mybuf, bufsz);
} }
#ifdef HAVE_READLINE_HISTORY
/* don't record blank lines */ /* don't record blank lines */
if (strlen(s)) add_history(s); if (strlen(s)) add_history(s);
#endif
strcat(mybuf,s); strcat(mybuf,s);
/* preserve line numbering for the parser */ /* preserve line numbering for the parser */
strcat(mybuf,"\n"); strcat(mybuf,"\n");
@ -494,11 +491,13 @@ char *histpath;
g_free(mybuf); g_free(mybuf);
if (s) free(s); if (s) free(s);
#ifdef HAVE_READLINE_HISTORY
if (home) { if (home) {
histpath = (char *) g_strconcat(home, "/", HISTFILE, NULL); histpath = (char *) g_strconcat(home, "/", HISTFILE, NULL);
write_history(histpath); write_history(histpath);
g_free(histpath); g_free(histpath);
} }
#endif
myexit(0); myexit(0);