-C Always\suse\sfputws()\sfor\soutput\sto\sa\sWindows\scommand-line\sprompt.
-D 2024-09-24T09:51:53.618
+C Use\s_wfopen()\sinstead\sof\sfopen()\son\sWindows\sin\sthe\sCLI.
+D 2024-09-24T10:30:07.376
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
F src/resolve.c b2cd748488012312824508639b6af908461e45403037d5c4e19d9b0e8195507f
F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97
F src/select.c 4b14337a2742f0c0beeba490e9a05507e9b4b12184b9cd12773501d08d48e3fe
-F src/shell.c.in 6054892954e926a30a5b3d2994805477d38154692b5bb571d81db86791d0e58b
+F src/shell.c.in 95f1bdfb9b1d513c7d82ab04fbca746a9668fb02d3eb984cd1cfb3b4ffc413e0
F src/sqlite.h.in 77f55bd1978a04a14db211732f0a609077cf60ba4ccf9baf39988f508945419c
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 5c54530d5a0a4125a1ba44f22537c4f63d5e5708f347c43cbac3e1832c4335da
-R 39e94947c12065fc6ead20518785128b
+P 33950a8c3f3e48e5107fe56647da05147aa84f9c3eccbe7c8671f5b502ebb70b
+R 563de058a2a6970ab738b542c7a8c099
U drh
-Z 9f7cd507ccaf6f6343bd8b5a2d5f1672
+Z 3b9fb03668dcca40431939db5346d2bc
# Remove this line to create a well-formed Fossil manifest.
# define cli_fprintf fprintf
#endif
+#ifdef _WIN32
+/* fopen() for windows */
+static FILE *cli_fopen(const char *zFilename, const char *zMode){
+ FILE *fp = 0;
+ wchar_t *b1, *b2;
+ int sz1, sz2;
+
+ sz1 = (int)strlen(zFilename);
+ sz2 = (int)strlen(zMode);
+ b1 = malloc( (sz1+1)*sizeof(b1[0]) );
+ b2 = malloc( (sz2+1)*sizeof(b1[0]) );
+ if( b1 && b2 ){
+ sz1 = MultiByteToWideChar(CP_UTF8, 0, zFilename, sz1, b1, sz1);
+ b1[sz1] = 0;
+ sz2 = MultiByteToWideChar(CP_UTF8, 0, zMode, sz2, b2, sz2);
+ b2[sz2] = 0;
+ fp = _wfopen(b1, b2);
+ }
+ free(b1);
+ free(b2);
+ return fp;
+}
+#else
+/* library version works for everybody else */
+# define cli_fopen fopen
+#endif
+
/* Use console I/O package as a direct INCLUDE. */
#define SQLITE_INTERNAL_LINKAGE static
/* On Windows, open first, then check the stream nature. This order
** is necessary because _stat() and sibs, when checking a named pipe,
** effectively break the pipe as its supplier sees it. */
- FILE *rv = fopen(zFile, "rb");
+ FILE *rv = cli_fopen(zFile, "rb");
if( rv==0 ) return 0;
if( _fstat64(_fileno(rv), &x) != 0
|| !STAT_CHR_SRC(x.st_mode)){
# define STAT_CHR_SRC(mode) (S_ISREG(mode)||S_ISFIFO(mode)||S_ISCHR(mode))
if( rc!=0 ) return 0;
if( STAT_CHR_SRC(x.st_mode) ){
- return fopen(zFile, "rb");
+ return cli_fopen(zFile, "rb");
}else{
return 0;
}
bBin = sqlite3_value_type(argv[0])==SQLITE_BLOB;
/* When writing the file to be edited, do \n to \r\n conversions on systems
** that want \r\n line endings */
- f = fopen(zTempFile, bBin ? "wb" : "w");
+ f = cli_fopen(zTempFile, bBin ? "wb" : "w");
if( f==0 ){
sqlite3_result_error(context, "edit() cannot open temp file", -1);
goto edit_func_end;
sqlite3_result_error(context, "EDITOR returned non-zero", -1);
goto edit_func_end;
}
- f = fopen(zTempFile, "rb");
+ f = cli_fopen(zTempFile, "rb");
if( f==0 ){
sqlite3_result_error(context,
"edit() cannot reopen temp file after edit", -1);
FILE *in;
char z[200];
sqlite3_snprintf(sizeof(z), z, "/proc/%d/io", getpid());
- in = fopen(z, "rb");
+ in = cli_fopen(z, "rb");
if( in==0 ) return;
while( cli_fgets(z, sizeof(z), in)!=0 ){
static const struct {
** is undefined in this case.
*/
static char *readFile(const char *zName, int *pnByte){
- FILE *in = fopen(zName, "rb");
+ FILE *in = cli_fopen(zName, "rb");
long nIn;
size_t nRead;
char *pBuf;
** the type cannot be determined from content.
*/
int deduceDatabaseType(const char *zName, int dfltZip){
- FILE *f = fopen(zName, "rb");
+ FILE *f = cli_fopen(zName, "rb");
size_t n;
int rc = SHELL_OPEN_UNSPEC;
char zBuf[100];
unsigned int x[16];
char zLine[1000];
if( zDbFilename ){
- in = fopen(zDbFilename, "r");
+ in = cli_fopen(zDbFilename, "r");
if( in==0 ){
eputf("cannot open \"%s\" for reading\n", zDbFilename);
return 0;
}else if( cli_strcmp(zFile, "off")==0 ){
f = 0;
}else{
- f = fopen(zFile, bTextMode ? "w" : "wb");
+ f = cli_fopen(zFile, bTextMode ? "w" : "wb");
if( f==0 ){
eputf("Error: cannot open \"%s\"\n", zFile);
}
sCtx.xCloser = pclose;
#endif
}else{
- sCtx.in = fopen(sCtx.zFile, "rb");
+ sCtx.in = cli_fopen(sCtx.zFile, "rb");
sCtx.xCloser = fclose;
}
if( sCtx.in==0 ){
sqlite3IoTrace = iotracePrintf;
iotrace = stdout;
}else{
- iotrace = fopen(azArg[1], "w");
+ iotrace = cli_fopen(azArg[1], "w");
if( iotrace==0 ){
eputf("Error: cannot open \"%s\"\n", azArg[1]);
sqlite3IoTrace = 0;
failIfSafeMode(p, "cannot run \".session %s\" in safe mode", azCmd[0]);
if( nCmd!=2 ) goto session_syntax_error;
if( pSession->p==0 ) goto session_not_open;
- out = fopen(azCmd[1], "wb");
+ out = cli_fopen(azCmd[1], "wb");
if( out==0 ){
eputf("ERROR: cannot open \"%s\" for writing\n",
azCmd[1]);
shell_check_oom(zBuf);
sqliterc = zBuf;
}
- p->in = fopen(sqliterc,"rb");
+ p->in = cli_fopen(sqliterc,"rb");
if( p->in ){
if( stdin_is_interactive ){
eputf("-- Loading resources from %s\n", sqliterc);