mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-03 16:53:36 +03:00
Merge the latest trunk fixes into the sessions branch.
FossilOrigin-Name: 131a2d3116436ca6304777c9c5d46b7c4051d949
This commit is contained in:
52
src/shell.c
52
src/shell.c
@@ -59,18 +59,38 @@
|
||||
# include <readline/readline.h>
|
||||
# include <readline/history.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_EDITLINE
|
||||
# undef HAVE_READLINE
|
||||
# define HAVE_READLINE 1
|
||||
# include <editline/readline.h>
|
||||
#endif
|
||||
#if !HAVE_READLINE
|
||||
# define add_history(X)
|
||||
# define read_history(X)
|
||||
# define write_history(X)
|
||||
# define stifle_history(X)
|
||||
|
||||
#if HAVE_EDITLINE || HAVE_READLINE
|
||||
|
||||
# define shell_add_history(X) add_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
|
||||
|
||||
|
||||
#if defined(_WIN32) || defined(WIN32)
|
||||
# include <io.h>
|
||||
# include <fcntl.h>
|
||||
@@ -451,14 +471,14 @@ static char *one_input_line(FILE *in, char *zPrior, int isContinuation){
|
||||
zResult = local_getline(zPrior, in);
|
||||
}else{
|
||||
zPrompt = isContinuation ? continuePrompt : mainPrompt;
|
||||
#if HAVE_READLINE
|
||||
free(zPrior);
|
||||
zResult = readline(zPrompt);
|
||||
if( zResult && *zResult ) add_history(zResult);
|
||||
#else
|
||||
#if SHELL_USE_LOCAL_GETLINE
|
||||
printf("%s", zPrompt);
|
||||
fflush(stdout);
|
||||
zResult = local_getline(zPrior, stdin);
|
||||
#else
|
||||
free(zPrior);
|
||||
zResult = shell_readline(zPrompt);
|
||||
if( zResult && *zResult ) shell_add_history(zResult);
|
||||
#endif
|
||||
}
|
||||
return zResult;
|
||||
@@ -4917,13 +4937,11 @@ int main(int argc, char **argv){
|
||||
sqlite3_snprintf(nHistory, zHistory,"%s/.sqlite_history", zHome);
|
||||
}
|
||||
}
|
||||
#if HAVE_READLINE
|
||||
if( zHistory ) read_history(zHistory);
|
||||
#endif
|
||||
if( zHistory ) shell_read_history(zHistory);
|
||||
rc = process_input(&data, 0);
|
||||
if( zHistory ){
|
||||
stifle_history(100);
|
||||
write_history(zHistory);
|
||||
shell_stifle_history(100);
|
||||
shell_write_history(zHistory);
|
||||
free(zHistory);
|
||||
}
|
||||
}else{
|
||||
|
||||
Reference in New Issue
Block a user