-C Avoid\ssigned\sinteger\soverflow\swhen\san\sfts5\s'merge'\scommand\sis\spassed\s-2147483648\sas\sa\sparameter.
-D 2025-12-30T11:36:23.388
+C Improved\shandling\sof\sthe\sprocess\sentry\spoint\sin\sWindows,\sto\stranslate\narguments\sinto\sUTF8.
+D 2025-12-30T12:38:43.349
F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F src/resolve.c 47aa7fdc9ec4c19b103ac5e79d7887d30119b5675309facf5eed1118391c868b
F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97
F src/select.c 85852256d860f3ba5be4a9edc1238e68dbea082a0167f31b7345c821ae45775d
-F src/shell.c.in a1bbd7dd24c10c18190c66b4f6258dcd04a77fba5c60c4d92fe04b4f20a316b9
+F src/shell.c.in eda201c925ef603dcbd602aa9175d33c6239c3504cacd09bcf06978ba270fa15
F src/sqlite.h.in b6599377f02ef9d545a8da48959213928b63291ad83ff65e5f3a72bf4fec595d
F src/sqlite3.rc 015537e6ac1eec6c7050e17b616c2ffe6f70fca241835a84a4f0d5937383c479
F src/sqlite3ext.h 5d5330f5f8461f5ce74960436ddcfa53ecd09c2b8b23901e22ae38aec3243998
F tool/warnings.sh d924598cf2f55a4ecbc2aeb055c10bd5f48114793e7ba25f9585435da29e7e98
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
F tool/winmain.c f40bccf0236f8bcc34b299781b7d34cb269ace23afe5c1b8a9d966e2fa1ce9e5
-P d58846e74b6971a5fd80e5f030985273b7dfa0087c2f3c9d0c088c248e183f8a 7f0b9e7a8bba1b73ef16257e72a055ea84fb10eb5cf0e6431fca81b2f040c5ee
-R 4b14869b8ea6686a23e18d14ecb69d10
-T +closed 7f0b9e7a8bba1b73ef16257e72a055ea84fb10eb5cf0e6431fca81b2f040c5ee
-U dan
-Z f65be022e8b9c70a31eec0ffafb9ac65
+P 52738908b04848b93d54431def37ffaa9723043270ff8ba1e2fa59ab0040afc5
+R cb09b246c37bfff2eb717b355f39c425
+U drh
+Z d5389fca5c5b11091c96d873f13e083b
# Remove this line to create a well-formed Fossil manifest.
/* Continuation prompt. default: " ...> " */
static char continuePrompt[PROMPT_LEN_MAX];
+/*
+** Write I/O traces to the following stream.
+*/
+#ifdef SQLITE_ENABLE_IOTRACE
+static FILE *iotrace = 0;
+#endif
+
+
/* This is variant of the standard-library strncpy() routine with the
** one change that the destination string is always zero-terminated, even
** if there is no zero-terminator in the first n-1 characters of the source
if( p==0 ) shell_out_of_memory();
}
-/*
-** Write I/O traces to the following stream.
-*/
-#ifdef SQLITE_ENABLE_IOTRACE
-static FILE *iotrace = 0;
-#endif
-
/*
** This routine works like printf in that its first argument is a
** format string and subsequent arguments are values to be substituted
return 1;
}
-#ifndef SQLITE_SHELL_IS_UTF8
-# if (defined(_WIN32) || defined(WIN32)) \
- && (defined(_MSC_VER) || (defined(UNICODE) && defined(__GNUC__)))
-# define SQLITE_SHELL_IS_UTF8 (0)
-# else
-# define SQLITE_SHELL_IS_UTF8 (1)
-# endif
-#endif
-
+/* Alternative name to the entry point for Fiddle */
#ifdef SQLITE_SHELL_FIDDLE
# define main fiddle_main
#endif
-#if SQLITE_SHELL_IS_UTF8
-int SQLITE_CDECL main(int argc, char **argv){
-#else
+/* Use the wmain() entry point on Windows. Translate arguments to
+** UTF8, then invoke the traditional main() entry point which is
+** renamed using a #define to utf8_main() .
+*/
+#if defined(_WIN32) && !defined(main)
+# define main utf8_main /* Rename entry point to utf_main() */
+int SQLITE_CDECL utf8_main(int,char**); /* Forward declaration */
int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
- char **argv;
-#endif
+ int rc, i;
+ char **argv = malloc( sizeof(char*) * (argc+1) );
+ char **orig = argv;
+ if( argv==0 ){
+ fprintf(stderr, "malloc failed\n");
+ exit(1);
+ }
+ for(i=0; i<argc; i++){
+ int nByte = WideCharToMultiByte(CP_UTF8, 0, wargv[i], -1, 0, 0, 0, 0);
+ if( nByte==0 ){
+ argv[i] = 0;
+ }else{
+ argv[i] = malloc( nByte );
+ if( argv[i]==0 ){
+ fprintf(stderr, "malloc failed\n");
+ exit(1);
+ }
+ nByte = WideCharToMultiByte(CP_UTF8, 0, wargv[i], -1, argv[i],nByte,0,0);
+ if( nByte==0 ){
+ free(argv[i]);
+ argv[i] = 0;
+ }
+ }
+ }
+ argv[argc] = 0;
+ rc = utf8_main(argc, argv);
+ for(i=0; i<argc; i++) free(orig[i]);
+ return rc;
+}
+#endif /* WIN32 */
+
+/*
+** This is the main entry point for the process. Everything starts here.
+**
+** The "main" identifier may have been #defined to something else:
+**
+** utf8_main On Windows
+** fiddle_main In Fiddle
+** sqlite3_shell Other projects that use shell.c as a subroutine
+*/
+int SQLITE_CDECL main(int argc, char **argv){
#ifdef SQLITE_DEBUG
sqlite3_int64 mem_main_enter = 0;
#endif
char **azCmd = 0;
int *aiCmd = 0;
const char *zVfs = 0; /* Value of -vfs command-line option */
-#if !SQLITE_SHELL_IS_UTF8
- char **argvToFree = 0;
- int argcToFree = 0;
-#endif
setvbuf(stderr, 0, _IONBF, 0); /* Make sure stderr is unbuffered */
#ifdef SQLITE_SHELL_FIDDLE
#endif
main_init(&data);
- /* On Windows, we must translate command-line arguments into UTF-8.
- ** The SQLite memory allocator subsystem has to be enabled in order to
- ** do this. But we want to run an sqlite3_shutdown() afterwards so that
- ** subsequent sqlite3_config() calls will work. So copy all results into
- ** memory that does not come from the SQLite memory allocator.
- */
-#if !SQLITE_SHELL_IS_UTF8
- sqlite3_initialize();
- argvToFree = malloc(sizeof(argv[0])*argc*2);
- shell_check_oom(argvToFree);
- argcToFree = argc;
- argv = argvToFree + argc;
- for(i=0; i<argc; i++){
- char *z = sqlite3_win32_unicode_to_utf8(wargv[i]);
- i64 n;
- shell_check_oom(z);
- n = strlen(z);
- argv[i] = malloc( n+1 );
- shell_check_oom(argv[i]);
- memcpy(argv[i], z, n+1);
- argvToFree[i] = argv[i];
- sqlite3_free(z);
- }
- sqlite3_shutdown();
-#endif
-
assert( argc>=1 && argv && argv[0] );
Argv0 = argv[0];
}else if( cli_strcmp(z,"-escape")==0 && i+1<argc ){
/* skip over the argument */
i++;
+ }else if( cli_strcmp(z,"-test-argv")==0 ){
+ /* Undocumented test option. Print the values in argv[] and exit.
+ ** Use this to verify that any translation of the argv[], for example
+ ** on Windows that receives wargv[] from the OS and must convert
+ ** to UTF8 prior to calling this routine. */
+ int kk;
+ for(kk=0; kk<argc; kk++){
+ fprintf(stdout,"argv[%d] = \"%s\"\n", kk, argv[kk]);
+ }
+ return 0;
}
}
#ifndef SQLITE_SHELL_FIDDLE
output_reset(&data);
data.doXdgOpen = 0;
clearTempFile(&data);
-#if !SQLITE_SHELL_IS_UTF8
- for(i=0; i<argcToFree; i++) free(argvToFree[i]);
- free(argvToFree);
-#endif
modeFree(&data.mode);
if( data.nSavedModes ){
int ii;