diff options
author | drh <> | 2024-10-30 14:03:56 +0000 |
---|---|---|
committer | drh <> | 2024-10-30 14:03:56 +0000 |
commit | 9bcb0a510f993b48ba3264b55b7eceb2c993a8ac (patch) | |
tree | 14aa89f72cb06fc5f9e396b8e03e0fb272de26f1 /src | |
parent | 7d7e82c9b1ec7c9307734e063409000643ea42a7 (diff) | |
download | sqlite-9bcb0a510f993b48ba3264b55b7eceb2c993a8ac.tar.gz sqlite-9bcb0a510f993b48ba3264b55b7eceb2c993a8ac.zip |
Fix the CLI so that it can use either the canonical Antirez linenoise
(with HAVE_LINENOISE=1) or Steve Bennett's enhanced linenoise that works
on the Win32 console as well as on Unix (with HAVE_LINENOISE=2). The
./configure script detects which one to use and sets HAVE_LINENOISE accordingly.
FossilOrigin-Name: c0048e4482e9cb9662637899922af9609e7c8fb002a37b71e6181074df7a0dd1
Diffstat (limited to 'src')
-rw-r--r-- | src/shell.c.in | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/shell.c.in b/src/shell.c.in index 50f1c5bfe..cdd09becf 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -5795,15 +5795,22 @@ static char **readline_completion(const char *zText, int iStart, int iEnd){ ** Linenoise completion callback. Note that the 3rd argument is from ** the "msteveb" version of linenoise, not the "antirez" version. */ -static void linenoise_completion(const char *zLine, linenoiseCompletions *lc, - void *pUserData){ +static void linenoise_completion( + const char *zLine, + linenoiseCompletions *lc +#if HAVE_LINENOISE==2 + ,void *pUserData +#endif +){ i64 nLine = strlen(zLine); i64 i, iStart; sqlite3_stmt *pStmt = 0; char *zSql; char zBuf[1000]; +#if HAVE_LINENOISE==2 UNUSED_PARAMETER(pUserData); +#endif if( nLine>(i64)sizeof(zBuf)-30 ) return; if( zLine[0]=='.' || zLine[0]=='#') return; for(i=nLine-1; i>=0 && (isalnum(zLine[i]) || zLine[i]=='_'); i--){} @@ -13196,7 +13203,9 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){ if( zHistory ){ shell_read_history(zHistory); } #if (HAVE_READLINE || HAVE_EDITLINE) && !defined(SQLITE_OMIT_READLINE_COMPLETION) rl_attempted_completion_function = readline_completion; -#elif HAVE_LINENOISE +#elif HAVE_LINENOISE==1 + linenoiseSetCompletionCallback(linenoise_completion); +#elif HAVE_LINENOISE==2 linenoiseSetCompletionCallback(linenoise_completion, NULL); #endif data.in = 0; |