mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-03 16:53:36 +03:00
Add support for linenoise to shell.c.
FossilOrigin-Name: f7f2598c376a27a86acc21578779c03d0016cd30
This commit is contained in:
17
manifest
17
manifest
@@ -1,5 +1,5 @@
|
|||||||
C When\scleaning\swith\sMSVC,\sprevent\ssuperfluous\soutput\sregarding\s'missing'\sfiles\sand\sdirectories.
|
C Add\ssupport\sfor\slinenoise\sto\sshell.c.
|
||||||
D 2015-02-25T01:06:08.853
|
D 2015-02-25T10:54:53.924
|
||||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||||
F Makefile.in 6b9e7677829aa94b9f30949656e27312aefb9a46
|
F Makefile.in 6b9e7677829aa94b9f30949656e27312aefb9a46
|
||||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||||
@@ -231,7 +231,7 @@ F src/random.c ba2679f80ec82c4190062d756f22d0c358180696
|
|||||||
F src/resolve.c f4d79e31ffa5820c2e3d1740baa5e9b190425f2b
|
F src/resolve.c f4d79e31ffa5820c2e3d1740baa5e9b190425f2b
|
||||||
F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e
|
F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e
|
||||||
F src/select.c e46cef4c224549b439384c88fc7f57ba064dad54
|
F src/select.c e46cef4c224549b439384c88fc7f57ba064dad54
|
||||||
F src/shell.c 6276582ee4e9114e0bb0795772414caaf21c0f8e
|
F src/shell.c f06cca68a3f07e03d35d2f879375967169db6a61
|
||||||
F src/sqlite.h.in 86cddbfdb3155967858c1469108813bcc08eda21
|
F src/sqlite.h.in 86cddbfdb3155967858c1469108813bcc08eda21
|
||||||
F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad
|
F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad
|
||||||
F src/sqlite3ext.h 17d487c3c91b0b8c584a32fbeb393f6f795eea7d
|
F src/sqlite3ext.h 17d487c3c91b0b8c584a32fbeb393f6f795eea7d
|
||||||
@@ -1239,7 +1239,10 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
|
|||||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
||||||
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
|
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
|
||||||
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
||||||
P 3af300bf6f5bee0b51a4c1ac1dc3879771378bff
|
P 034c16bd24ddca363946a4b8751418469d890d2a
|
||||||
R 8787792779793757c506c3a0c170c525
|
R 39a5a9d65bc63648e34cb80c3dc9dec4
|
||||||
U mistachkin
|
T *branch * linenoise
|
||||||
Z 74a7e954f31f0d389c5ddd5c11bb86cc
|
T *sym-linenoise *
|
||||||
|
T -sym-trunk *
|
||||||
|
U dan
|
||||||
|
Z 309f98e10b08754fd0af3602fd92a078
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
034c16bd24ddca363946a4b8751418469d890d2a
|
f7f2598c376a27a86acc21578779c03d0016cd30
|
||||||
52
src/shell.c
52
src/shell.c
@@ -59,18 +59,38 @@
|
|||||||
# include <readline/readline.h>
|
# include <readline/readline.h>
|
||||||
# include <readline/history.h>
|
# include <readline/history.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HAVE_EDITLINE
|
#if HAVE_EDITLINE
|
||||||
# undef HAVE_READLINE
|
|
||||||
# define HAVE_READLINE 1
|
|
||||||
# include <editline/readline.h>
|
# include <editline/readline.h>
|
||||||
#endif
|
#endif
|
||||||
#if !HAVE_READLINE
|
|
||||||
# define add_history(X)
|
#if HAVE_EDITLINE || HAVE_READLINE
|
||||||
# define read_history(X)
|
|
||||||
# define write_history(X)
|
# define shell_add_history(X) add_history(X)
|
||||||
# define stifle_history(X)
|
# define shell_read_history(X) read_history(X)
|
||||||
|
# define shell_write_history(X) write_history(X)
|
||||||
|
# define shell_stifle_history(X) stifle_history(X)
|
||||||
|
# define shell_readline(X) readline(X)
|
||||||
|
|
||||||
|
#elif HAVE_LINENOISE
|
||||||
|
|
||||||
|
# include "linenoise.h"
|
||||||
|
# define shell_add_history(X) linenoiseHistoryAdd(X)
|
||||||
|
# define shell_read_history(X) linenoiseHistoryLoad(X)
|
||||||
|
# define shell_write_history(X) linenoiseHistorySave(X)
|
||||||
|
# define shell_stifle_history(X) linenoiseHistorySetMaxLen(X)
|
||||||
|
# define shell_readline(X) linenoise(X)
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
# define shell_read_history(X)
|
||||||
|
# define shell_write_history(X)
|
||||||
|
# define shell_stifle_history(X)
|
||||||
|
|
||||||
|
# define SHELL_USE_LOCAL_GETLINE 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(WIN32)
|
#if defined(_WIN32) || defined(WIN32)
|
||||||
# include <io.h>
|
# include <io.h>
|
||||||
# include <fcntl.h>
|
# include <fcntl.h>
|
||||||
@@ -451,14 +471,14 @@ static char *one_input_line(FILE *in, char *zPrior, int isContinuation){
|
|||||||
zResult = local_getline(zPrior, in);
|
zResult = local_getline(zPrior, in);
|
||||||
}else{
|
}else{
|
||||||
zPrompt = isContinuation ? continuePrompt : mainPrompt;
|
zPrompt = isContinuation ? continuePrompt : mainPrompt;
|
||||||
#if HAVE_READLINE
|
#if SHELL_USE_LOCAL_GETLINE
|
||||||
free(zPrior);
|
|
||||||
zResult = readline(zPrompt);
|
|
||||||
if( zResult && *zResult ) add_history(zResult);
|
|
||||||
#else
|
|
||||||
printf("%s", zPrompt);
|
printf("%s", zPrompt);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
zResult = local_getline(zPrior, stdin);
|
zResult = local_getline(zPrior, stdin);
|
||||||
|
#else
|
||||||
|
free(zPrior);
|
||||||
|
zResult = shell_readline(zPrompt);
|
||||||
|
if( zResult && *zResult ) shell_add_history(zResult);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
return zResult;
|
return zResult;
|
||||||
@@ -4636,13 +4656,11 @@ int main(int argc, char **argv){
|
|||||||
sqlite3_snprintf(nHistory, zHistory,"%s/.sqlite_history", zHome);
|
sqlite3_snprintf(nHistory, zHistory,"%s/.sqlite_history", zHome);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if HAVE_READLINE
|
if( zHistory ) shell_read_history(zHistory);
|
||||||
if( zHistory ) read_history(zHistory);
|
|
||||||
#endif
|
|
||||||
rc = process_input(&data, 0);
|
rc = process_input(&data, 0);
|
||||||
if( zHistory ){
|
if( zHistory ){
|
||||||
stifle_history(100);
|
shell_stifle_history(100);
|
||||||
write_history(zHistory);
|
shell_write_history(zHistory);
|
||||||
free(zHistory);
|
free(zHistory);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
|||||||
Reference in New Issue
Block a user