Fossil SCM

Incorporate all recent trunk enhancements.

drh 2014-11-28 15:46 UTC DBP-workflow merge
Commit 368f82a25536cea0eb180b8539be6d0e19881fc8
+1 -1
--- Makefile.in
+++ Makefile.in
@@ -37,11 +37,11 @@
3737
# care about testing the end result, this can be blank.
3838
#
3939
TCLSH = tclsh
4040
4141
LIB = @LDFLAGS@ @EXTRA_LDFLAGS@ @LIBS@
42
-TCC += @EXTRA_CFLAGS@ @CPPFLAGS@ @CFLAGS@ -DHAVE_AUTOCONFIG_H -D_HAVE_SQLITE_CONFIG_H
42
+TCCFLAGS = @EXTRA_CFLAGS@ @CPPFLAGS@ @CFLAGS@ -DHAVE_AUTOCONFIG_H -D_HAVE_SQLITE_CONFIG_H
4343
INSTALLDIR = $(DESTDIR)@prefix@/bin
4444
USE_SYSTEM_SQLITE = @USE_SYSTEM_SQLITE@
4545
FOSSIL_ENABLE_MINIZ = @FOSSIL_ENABLE_MINIZ@
4646
4747
include $(SRCDIR)/main.mk
4848
--- Makefile.in
+++ Makefile.in
@@ -37,11 +37,11 @@
37 # care about testing the end result, this can be blank.
38 #
39 TCLSH = tclsh
40
41 LIB = @LDFLAGS@ @EXTRA_LDFLAGS@ @LIBS@
42 TCC += @EXTRA_CFLAGS@ @CPPFLAGS@ @CFLAGS@ -DHAVE_AUTOCONFIG_H -D_HAVE_SQLITE_CONFIG_H
43 INSTALLDIR = $(DESTDIR)@prefix@/bin
44 USE_SYSTEM_SQLITE = @USE_SYSTEM_SQLITE@
45 FOSSIL_ENABLE_MINIZ = @FOSSIL_ENABLE_MINIZ@
46
47 include $(SRCDIR)/main.mk
48
--- Makefile.in
+++ Makefile.in
@@ -37,11 +37,11 @@
37 # care about testing the end result, this can be blank.
38 #
39 TCLSH = tclsh
40
41 LIB = @LDFLAGS@ @EXTRA_LDFLAGS@ @LIBS@
42 TCCFLAGS = @EXTRA_CFLAGS@ @CPPFLAGS@ @CFLAGS@ -DHAVE_AUTOCONFIG_H -D_HAVE_SQLITE_CONFIG_H
43 INSTALLDIR = $(DESTDIR)@prefix@/bin
44 USE_SYSTEM_SQLITE = @USE_SYSTEM_SQLITE@
45 FOSSIL_ENABLE_MINIZ = @FOSSIL_ENABLE_MINIZ@
46
47 include $(SRCDIR)/main.mk
48
+10
--- src/blob.c
+++ src/blob.c
@@ -24,10 +24,14 @@
2424
# include "miniz.c"
2525
#else
2626
# include <zlib.h>
2727
#endif
2828
#include "blob.h"
29
+#if defined(_WIN32)
30
+#include <fcntl.h>
31
+#include <io.h>
32
+#endif
2933
3034
#if INTERFACE
3135
/*
3236
** A Blob can hold a string or a binary object of arbitrary size. The
3337
** size changes as necessary.
@@ -823,12 +827,18 @@
823827
nWrote = blob_size(pBlob);
824828
#if defined(_WIN32)
825829
if( fossil_utf8_to_console(blob_buffer(pBlob), nWrote, 0) >= 0 ){
826830
return nWrote;
827831
}
832
+ fflush(stdout);
833
+ _setmode(_fileno(stdout), _O_BINARY);
828834
#endif
829835
fwrite(blob_buffer(pBlob), 1, nWrote, stdout);
836
+#if defined(_WIN32)
837
+ fflush(stdout);
838
+ _setmode(_fileno(stdout), _O_TEXT);
839
+#endif
830840
}else{
831841
file_mkfolder(zFilename, 1);
832842
out = fossil_fopen(zFilename, "wb");
833843
if( out==0 ){
834844
fossil_fatal_recursive("unable to open file \"%s\" for writing",
835845
--- src/blob.c
+++ src/blob.c
@@ -24,10 +24,14 @@
24 # include "miniz.c"
25 #else
26 # include <zlib.h>
27 #endif
28 #include "blob.h"
 
 
 
 
29
30 #if INTERFACE
31 /*
32 ** A Blob can hold a string or a binary object of arbitrary size. The
33 ** size changes as necessary.
@@ -823,12 +827,18 @@
823 nWrote = blob_size(pBlob);
824 #if defined(_WIN32)
825 if( fossil_utf8_to_console(blob_buffer(pBlob), nWrote, 0) >= 0 ){
826 return nWrote;
827 }
 
 
828 #endif
829 fwrite(blob_buffer(pBlob), 1, nWrote, stdout);
 
 
 
 
830 }else{
831 file_mkfolder(zFilename, 1);
832 out = fossil_fopen(zFilename, "wb");
833 if( out==0 ){
834 fossil_fatal_recursive("unable to open file \"%s\" for writing",
835
--- src/blob.c
+++ src/blob.c
@@ -24,10 +24,14 @@
24 # include "miniz.c"
25 #else
26 # include <zlib.h>
27 #endif
28 #include "blob.h"
29 #if defined(_WIN32)
30 #include <fcntl.h>
31 #include <io.h>
32 #endif
33
34 #if INTERFACE
35 /*
36 ** A Blob can hold a string or a binary object of arbitrary size. The
37 ** size changes as necessary.
@@ -823,12 +827,18 @@
827 nWrote = blob_size(pBlob);
828 #if defined(_WIN32)
829 if( fossil_utf8_to_console(blob_buffer(pBlob), nWrote, 0) >= 0 ){
830 return nWrote;
831 }
832 fflush(stdout);
833 _setmode(_fileno(stdout), _O_BINARY);
834 #endif
835 fwrite(blob_buffer(pBlob), 1, nWrote, stdout);
836 #if defined(_WIN32)
837 fflush(stdout);
838 _setmode(_fileno(stdout), _O_TEXT);
839 #endif
840 }else{
841 file_mkfolder(zFilename, 1);
842 out = fossil_fopen(zFilename, "wb");
843 if( out==0 ){
844 fossil_fatal_recursive("unable to open file \"%s\" for writing",
845
+4 -3
--- src/db.c
+++ src/db.c
@@ -1005,20 +1005,21 @@
10051005
** is found, it is attached to the open database connection too.
10061006
*/
10071007
int db_open_local(const char *zDbName){
10081008
int i, n;
10091009
char zPwd[2000];
1010
- static const char aDbName[][10] = { "_FOSSIL_", ".fslckout", ".fos" };
1010
+ static const char *(aDbName[]) = { "_FOSSIL_", ".fslckout", ".fos" };
10111011
10121012
if( g.localOpen ) return 1;
10131013
file_getcwd(zPwd, sizeof(zPwd)-20);
10141014
n = strlen(zPwd);
10151015
while( n>0 ){
10161016
for(i=0; i<count(aDbName); i++){
10171017
sqlite3_snprintf(sizeof(zPwd)-n, &zPwd[n], "/%s", aDbName[i]);
10181018
if( isValidLocalDb(zPwd) ){
10191019
/* Found a valid checkout database file */
1020
+ g.zLocalDbName = mprintf("%s", zPwd);
10201021
zPwd[n] = 0;
10211022
while( n>0 && zPwd[n-1]=='/' ){
10221023
n--;
10231024
zPwd[n] = 0;
10241025
}
@@ -1160,11 +1161,11 @@
11601161
11611162
/*
11621163
** Return TRUE if the schema is out-of-date
11631164
*/
11641165
int db_schema_is_outofdate(void){
1165
- g.zAuxSchema = db_text(0, "SELECT value FROM config WHERE name='aux-schema'");
1166
+ if( g.zAuxSchema==0 ) g.zAuxSchema = db_get("aux-schema","");
11661167
return strcmp(g.zAuxSchema,AUX_SCHEMA_MIN)<0
11671168
|| strcmp(g.zAuxSchema,AUX_SCHEMA_MAX)>0;
11681169
}
11691170
11701171
/*
@@ -1184,11 +1185,11 @@
11841185
g.json.resultCode = FSL_JSON_E_DB_NEEDS_REBUILD;
11851186
#endif
11861187
fossil_warning("incorrect repository schema version: "
11871188
"current repository schema version is \"%s\" "
11881189
"but need versions between \"%s\" and \"%s\".",
1189
- db_get("aux-schema",0), AUX_SCHEMA_MIN, AUX_SCHEMA_MAX);
1190
+ g.zAuxSchema, AUX_SCHEMA_MIN, AUX_SCHEMA_MAX);
11901191
fossil_fatal("run \"fossil rebuild\" to fix this problem");
11911192
}
11921193
}
11931194
11941195
11951196
--- src/db.c
+++ src/db.c
@@ -1005,20 +1005,21 @@
1005 ** is found, it is attached to the open database connection too.
1006 */
1007 int db_open_local(const char *zDbName){
1008 int i, n;
1009 char zPwd[2000];
1010 static const char aDbName[][10] = { "_FOSSIL_", ".fslckout", ".fos" };
1011
1012 if( g.localOpen ) return 1;
1013 file_getcwd(zPwd, sizeof(zPwd)-20);
1014 n = strlen(zPwd);
1015 while( n>0 ){
1016 for(i=0; i<count(aDbName); i++){
1017 sqlite3_snprintf(sizeof(zPwd)-n, &zPwd[n], "/%s", aDbName[i]);
1018 if( isValidLocalDb(zPwd) ){
1019 /* Found a valid checkout database file */
 
1020 zPwd[n] = 0;
1021 while( n>0 && zPwd[n-1]=='/' ){
1022 n--;
1023 zPwd[n] = 0;
1024 }
@@ -1160,11 +1161,11 @@
1160
1161 /*
1162 ** Return TRUE if the schema is out-of-date
1163 */
1164 int db_schema_is_outofdate(void){
1165 g.zAuxSchema = db_text(0, "SELECT value FROM config WHERE name='aux-schema'");
1166 return strcmp(g.zAuxSchema,AUX_SCHEMA_MIN)<0
1167 || strcmp(g.zAuxSchema,AUX_SCHEMA_MAX)>0;
1168 }
1169
1170 /*
@@ -1184,11 +1185,11 @@
1184 g.json.resultCode = FSL_JSON_E_DB_NEEDS_REBUILD;
1185 #endif
1186 fossil_warning("incorrect repository schema version: "
1187 "current repository schema version is \"%s\" "
1188 "but need versions between \"%s\" and \"%s\".",
1189 db_get("aux-schema",0), AUX_SCHEMA_MIN, AUX_SCHEMA_MAX);
1190 fossil_fatal("run \"fossil rebuild\" to fix this problem");
1191 }
1192 }
1193
1194
1195
--- src/db.c
+++ src/db.c
@@ -1005,20 +1005,21 @@
1005 ** is found, it is attached to the open database connection too.
1006 */
1007 int db_open_local(const char *zDbName){
1008 int i, n;
1009 char zPwd[2000];
1010 static const char *(aDbName[]) = { "_FOSSIL_", ".fslckout", ".fos" };
1011
1012 if( g.localOpen ) return 1;
1013 file_getcwd(zPwd, sizeof(zPwd)-20);
1014 n = strlen(zPwd);
1015 while( n>0 ){
1016 for(i=0; i<count(aDbName); i++){
1017 sqlite3_snprintf(sizeof(zPwd)-n, &zPwd[n], "/%s", aDbName[i]);
1018 if( isValidLocalDb(zPwd) ){
1019 /* Found a valid checkout database file */
1020 g.zLocalDbName = mprintf("%s", zPwd);
1021 zPwd[n] = 0;
1022 while( n>0 && zPwd[n-1]=='/' ){
1023 n--;
1024 zPwd[n] = 0;
1025 }
@@ -1160,11 +1161,11 @@
1161
1162 /*
1163 ** Return TRUE if the schema is out-of-date
1164 */
1165 int db_schema_is_outofdate(void){
1166 if( g.zAuxSchema==0 ) g.zAuxSchema = db_get("aux-schema","");
1167 return strcmp(g.zAuxSchema,AUX_SCHEMA_MIN)<0
1168 || strcmp(g.zAuxSchema,AUX_SCHEMA_MAX)>0;
1169 }
1170
1171 /*
@@ -1184,11 +1185,11 @@
1185 g.json.resultCode = FSL_JSON_E_DB_NEEDS_REBUILD;
1186 #endif
1187 fossil_warning("incorrect repository schema version: "
1188 "current repository schema version is \"%s\" "
1189 "but need versions between \"%s\" and \"%s\".",
1190 g.zAuxSchema, AUX_SCHEMA_MIN, AUX_SCHEMA_MAX);
1191 fossil_fatal("run \"fossil rebuild\" to fix this problem");
1192 }
1193 }
1194
1195
1196
+4 -3
--- src/db.c
+++ src/db.c
@@ -1005,20 +1005,21 @@
10051005
** is found, it is attached to the open database connection too.
10061006
*/
10071007
int db_open_local(const char *zDbName){
10081008
int i, n;
10091009
char zPwd[2000];
1010
- static const char aDbName[][10] = { "_FOSSIL_", ".fslckout", ".fos" };
1010
+ static const char *(aDbName[]) = { "_FOSSIL_", ".fslckout", ".fos" };
10111011
10121012
if( g.localOpen ) return 1;
10131013
file_getcwd(zPwd, sizeof(zPwd)-20);
10141014
n = strlen(zPwd);
10151015
while( n>0 ){
10161016
for(i=0; i<count(aDbName); i++){
10171017
sqlite3_snprintf(sizeof(zPwd)-n, &zPwd[n], "/%s", aDbName[i]);
10181018
if( isValidLocalDb(zPwd) ){
10191019
/* Found a valid checkout database file */
1020
+ g.zLocalDbName = mprintf("%s", zPwd);
10201021
zPwd[n] = 0;
10211022
while( n>0 && zPwd[n-1]=='/' ){
10221023
n--;
10231024
zPwd[n] = 0;
10241025
}
@@ -1160,11 +1161,11 @@
11601161
11611162
/*
11621163
** Return TRUE if the schema is out-of-date
11631164
*/
11641165
int db_schema_is_outofdate(void){
1165
- g.zAuxSchema = db_text(0, "SELECT value FROM config WHERE name='aux-schema'");
1166
+ if( g.zAuxSchema==0 ) g.zAuxSchema = db_get("aux-schema","");
11661167
return strcmp(g.zAuxSchema,AUX_SCHEMA_MIN)<0
11671168
|| strcmp(g.zAuxSchema,AUX_SCHEMA_MAX)>0;
11681169
}
11691170
11701171
/*
@@ -1184,11 +1185,11 @@
11841185
g.json.resultCode = FSL_JSON_E_DB_NEEDS_REBUILD;
11851186
#endif
11861187
fossil_warning("incorrect repository schema version: "
11871188
"current repository schema version is \"%s\" "
11881189
"but need versions between \"%s\" and \"%s\".",
1189
- db_get("aux-schema",0), AUX_SCHEMA_MIN, AUX_SCHEMA_MAX);
1190
+ g.zAuxSchema, AUX_SCHEMA_MIN, AUX_SCHEMA_MAX);
11901191
fossil_fatal("run \"fossil rebuild\" to fix this problem");
11911192
}
11921193
}
11931194
11941195
11951196
--- src/db.c
+++ src/db.c
@@ -1005,20 +1005,21 @@
1005 ** is found, it is attached to the open database connection too.
1006 */
1007 int db_open_local(const char *zDbName){
1008 int i, n;
1009 char zPwd[2000];
1010 static const char aDbName[][10] = { "_FOSSIL_", ".fslckout", ".fos" };
1011
1012 if( g.localOpen ) return 1;
1013 file_getcwd(zPwd, sizeof(zPwd)-20);
1014 n = strlen(zPwd);
1015 while( n>0 ){
1016 for(i=0; i<count(aDbName); i++){
1017 sqlite3_snprintf(sizeof(zPwd)-n, &zPwd[n], "/%s", aDbName[i]);
1018 if( isValidLocalDb(zPwd) ){
1019 /* Found a valid checkout database file */
 
1020 zPwd[n] = 0;
1021 while( n>0 && zPwd[n-1]=='/' ){
1022 n--;
1023 zPwd[n] = 0;
1024 }
@@ -1160,11 +1161,11 @@
1160
1161 /*
1162 ** Return TRUE if the schema is out-of-date
1163 */
1164 int db_schema_is_outofdate(void){
1165 g.zAuxSchema = db_text(0, "SELECT value FROM config WHERE name='aux-schema'");
1166 return strcmp(g.zAuxSchema,AUX_SCHEMA_MIN)<0
1167 || strcmp(g.zAuxSchema,AUX_SCHEMA_MAX)>0;
1168 }
1169
1170 /*
@@ -1184,11 +1185,11 @@
1184 g.json.resultCode = FSL_JSON_E_DB_NEEDS_REBUILD;
1185 #endif
1186 fossil_warning("incorrect repository schema version: "
1187 "current repository schema version is \"%s\" "
1188 "but need versions between \"%s\" and \"%s\".",
1189 db_get("aux-schema",0), AUX_SCHEMA_MIN, AUX_SCHEMA_MAX);
1190 fossil_fatal("run \"fossil rebuild\" to fix this problem");
1191 }
1192 }
1193
1194
1195
--- src/db.c
+++ src/db.c
@@ -1005,20 +1005,21 @@
1005 ** is found, it is attached to the open database connection too.
1006 */
1007 int db_open_local(const char *zDbName){
1008 int i, n;
1009 char zPwd[2000];
1010 static const char *(aDbName[]) = { "_FOSSIL_", ".fslckout", ".fos" };
1011
1012 if( g.localOpen ) return 1;
1013 file_getcwd(zPwd, sizeof(zPwd)-20);
1014 n = strlen(zPwd);
1015 while( n>0 ){
1016 for(i=0; i<count(aDbName); i++){
1017 sqlite3_snprintf(sizeof(zPwd)-n, &zPwd[n], "/%s", aDbName[i]);
1018 if( isValidLocalDb(zPwd) ){
1019 /* Found a valid checkout database file */
1020 g.zLocalDbName = mprintf("%s", zPwd);
1021 zPwd[n] = 0;
1022 while( n>0 && zPwd[n-1]=='/' ){
1023 n--;
1024 zPwd[n] = 0;
1025 }
@@ -1160,11 +1161,11 @@
1161
1162 /*
1163 ** Return TRUE if the schema is out-of-date
1164 */
1165 int db_schema_is_outofdate(void){
1166 if( g.zAuxSchema==0 ) g.zAuxSchema = db_get("aux-schema","");
1167 return strcmp(g.zAuxSchema,AUX_SCHEMA_MIN)<0
1168 || strcmp(g.zAuxSchema,AUX_SCHEMA_MAX)>0;
1169 }
1170
1171 /*
@@ -1184,11 +1185,11 @@
1185 g.json.resultCode = FSL_JSON_E_DB_NEEDS_REBUILD;
1186 #endif
1187 fossil_warning("incorrect repository schema version: "
1188 "current repository schema version is \"%s\" "
1189 "but need versions between \"%s\" and \"%s\".",
1190 g.zAuxSchema, AUX_SCHEMA_MIN, AUX_SCHEMA_MAX);
1191 fossil_fatal("run \"fossil rebuild\" to fix this problem");
1192 }
1193 }
1194
1195
1196
+1
--- src/main.c
+++ src/main.c
@@ -132,10 +132,11 @@
132132
const char *zConfigDbName;/* Path of the config database. NULL if not open */
133133
sqlite3_int64 now; /* Seconds since 1970 */
134134
int repositoryOpen; /* True if the main repository database is open */
135135
char *zRepositoryOption; /* Most recent cached repository option value */
136136
char *zRepositoryName; /* Name of the repository database */
137
+ char *zLocalDbName; /* Name of the local database */
137138
const char *zMainDbType;/* "configdb", "localdb", or "repository" */
138139
const char *zConfigDbType; /* "configdb", "localdb", or "repository" */
139140
int localOpen; /* True if the local database is open */
140141
char *zLocalRoot; /* The directory holding the local database */
141142
int minPrefix; /* Number of digits needed for a distinct UUID */
142143
--- src/main.c
+++ src/main.c
@@ -132,10 +132,11 @@
132 const char *zConfigDbName;/* Path of the config database. NULL if not open */
133 sqlite3_int64 now; /* Seconds since 1970 */
134 int repositoryOpen; /* True if the main repository database is open */
135 char *zRepositoryOption; /* Most recent cached repository option value */
136 char *zRepositoryName; /* Name of the repository database */
 
137 const char *zMainDbType;/* "configdb", "localdb", or "repository" */
138 const char *zConfigDbType; /* "configdb", "localdb", or "repository" */
139 int localOpen; /* True if the local database is open */
140 char *zLocalRoot; /* The directory holding the local database */
141 int minPrefix; /* Number of digits needed for a distinct UUID */
142
--- src/main.c
+++ src/main.c
@@ -132,10 +132,11 @@
132 const char *zConfigDbName;/* Path of the config database. NULL if not open */
133 sqlite3_int64 now; /* Seconds since 1970 */
134 int repositoryOpen; /* True if the main repository database is open */
135 char *zRepositoryOption; /* Most recent cached repository option value */
136 char *zRepositoryName; /* Name of the repository database */
137 char *zLocalDbName; /* Name of the local database */
138 const char *zMainDbType;/* "configdb", "localdb", or "repository" */
139 const char *zConfigDbType; /* "configdb", "localdb", or "repository" */
140 int localOpen; /* True if the local database is open */
141 char *zLocalRoot; /* The directory holding the local database */
142 int minPrefix; /* Number of digits needed for a distinct UUID */
143
+1 -1
--- src/main.mk
+++ src/main.mk
@@ -8,11 +8,11 @@
88
# to regenerate this file.
99
#
1010
# This file is included by primary Makefile.
1111
#
1212
13
-XTCC = $(TCC) $(CFLAGS) -I. -I$(SRCDIR) -I$(OBJDIR)
13
+XTCC = $(TCC) -I. -I$(SRCDIR) -I$(OBJDIR) $(TCCFLAGS) $(CFLAGS)
1414
1515
1616
SRC = \
1717
$(SRCDIR)/add.c \
1818
$(SRCDIR)/allrepo.c \
1919
--- src/main.mk
+++ src/main.mk
@@ -8,11 +8,11 @@
8 # to regenerate this file.
9 #
10 # This file is included by primary Makefile.
11 #
12
13 XTCC = $(TCC) $(CFLAGS) -I. -I$(SRCDIR) -I$(OBJDIR)
14
15
16 SRC = \
17 $(SRCDIR)/add.c \
18 $(SRCDIR)/allrepo.c \
19
--- src/main.mk
+++ src/main.mk
@@ -8,11 +8,11 @@
8 # to regenerate this file.
9 #
10 # This file is included by primary Makefile.
11 #
12
13 XTCC = $(TCC) -I. -I$(SRCDIR) -I$(OBJDIR) $(TCCFLAGS) $(CFLAGS)
14
15
16 SRC = \
17 $(SRCDIR)/add.c \
18 $(SRCDIR)/allrepo.c \
19
+1 -1
--- src/main.mk
+++ src/main.mk
@@ -8,11 +8,11 @@
88
# to regenerate this file.
99
#
1010
# This file is included by primary Makefile.
1111
#
1212
13
-XTCC = $(TCC) $(CFLAGS) -I. -I$(SRCDIR) -I$(OBJDIR)
13
+XTCC = $(TCC) -I. -I$(SRCDIR) -I$(OBJDIR) $(TCCFLAGS) $(CFLAGS)
1414
1515
1616
SRC = \
1717
$(SRCDIR)/add.c \
1818
$(SRCDIR)/allrepo.c \
1919
--- src/main.mk
+++ src/main.mk
@@ -8,11 +8,11 @@
8 # to regenerate this file.
9 #
10 # This file is included by primary Makefile.
11 #
12
13 XTCC = $(TCC) $(CFLAGS) -I. -I$(SRCDIR) -I$(OBJDIR)
14
15
16 SRC = \
17 $(SRCDIR)/add.c \
18 $(SRCDIR)/allrepo.c \
19
--- src/main.mk
+++ src/main.mk
@@ -8,11 +8,11 @@
8 # to regenerate this file.
9 #
10 # This file is included by primary Makefile.
11 #
12
13 XTCC = $(TCC) -I. -I$(SRCDIR) -I$(OBJDIR) $(TCCFLAGS) $(CFLAGS)
14
15
16 SRC = \
17 $(SRCDIR)/add.c \
18 $(SRCDIR)/allrepo.c \
19
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -223,11 +223,11 @@
223223
# to regenerate this file.
224224
#
225225
# This file is included by primary Makefile.
226226
#
227227
228
-XTCC = $(TCC) $(CFLAGS) -I. -I$(SRCDIR) -I$(OBJDIR)
228
+XTCC = $(TCC) -I. -I$(SRCDIR) -I$(OBJDIR) $(TCCFLAGS) $(CFLAGS)
229229
230230
}
231231
writeln -nonewline "SRC ="
232232
foreach s [lsort $src] {
233233
writeln -nonewline " \\\n \$(SRCDIR)/$s.c"
234234
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -223,11 +223,11 @@
223 # to regenerate this file.
224 #
225 # This file is included by primary Makefile.
226 #
227
228 XTCC = $(TCC) $(CFLAGS) -I. -I$(SRCDIR) -I$(OBJDIR)
229
230 }
231 writeln -nonewline "SRC ="
232 foreach s [lsort $src] {
233 writeln -nonewline " \\\n \$(SRCDIR)/$s.c"
234
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -223,11 +223,11 @@
223 # to regenerate this file.
224 #
225 # This file is included by primary Makefile.
226 #
227
228 XTCC = $(TCC) -I. -I$(SRCDIR) -I$(OBJDIR) $(TCCFLAGS) $(CFLAGS)
229
230 }
231 writeln -nonewline "SRC ="
232 foreach s [lsort $src] {
233 writeln -nonewline " \\\n \$(SRCDIR)/$s.c"
234
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -223,11 +223,11 @@
223223
# to regenerate this file.
224224
#
225225
# This file is included by primary Makefile.
226226
#
227227
228
-XTCC = $(TCC) $(CFLAGS) -I. -I$(SRCDIR) -I$(OBJDIR)
228
+XTCC = $(TCC) -I. -I$(SRCDIR) -I$(OBJDIR) $(TCCFLAGS) $(CFLAGS)
229229
230230
}
231231
writeln -nonewline "SRC ="
232232
foreach s [lsort $src] {
233233
writeln -nonewline " \\\n \$(SRCDIR)/$s.c"
234234
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -223,11 +223,11 @@
223 # to regenerate this file.
224 #
225 # This file is included by primary Makefile.
226 #
227
228 XTCC = $(TCC) $(CFLAGS) -I. -I$(SRCDIR) -I$(OBJDIR)
229
230 }
231 writeln -nonewline "SRC ="
232 foreach s [lsort $src] {
233 writeln -nonewline " \\\n \$(SRCDIR)/$s.c"
234
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -223,11 +223,11 @@
223 # to regenerate this file.
224 #
225 # This file is included by primary Makefile.
226 #
227
228 XTCC = $(TCC) -I. -I$(SRCDIR) -I$(OBJDIR) $(TCCFLAGS) $(CFLAGS)
229
230 }
231 writeln -nonewline "SRC ="
232 foreach s [lsort $src] {
233 writeln -nonewline " \\\n \$(SRCDIR)/$s.c"
234
+1 -1
--- src/manifest.c
+++ src/manifest.c
@@ -1781,11 +1781,11 @@
17811781
sqlite3_snprintf(sizeof(zBaseId), zBaseId, "%d",
17821782
uuid_to_rid(p->zBaseline,1));
17831783
}else{
17841784
sqlite3_snprintf(sizeof(zBaseId), zBaseId, "NULL");
17851785
}
1786
- if( g.zAuxSchema==0 ) (void)db_schema_is_outofdate();
1786
+ (void)db_schema_is_outofdate(); /* Make sure g.zAuxSchema is initialized */
17871787
for(i=0; i<p->nParent; i++){
17881788
int pid = uuid_to_rid(p->azParent[i], 1);
17891789
if( strcmp(g.zAuxSchema,"2014-11-24 20:35")>=0 ){
17901790
/* Support for PLINK.BASEID added on 2014-11-24 */
17911791
db_multi_exec(
17921792
--- src/manifest.c
+++ src/manifest.c
@@ -1781,11 +1781,11 @@
1781 sqlite3_snprintf(sizeof(zBaseId), zBaseId, "%d",
1782 uuid_to_rid(p->zBaseline,1));
1783 }else{
1784 sqlite3_snprintf(sizeof(zBaseId), zBaseId, "NULL");
1785 }
1786 if( g.zAuxSchema==0 ) (void)db_schema_is_outofdate();
1787 for(i=0; i<p->nParent; i++){
1788 int pid = uuid_to_rid(p->azParent[i], 1);
1789 if( strcmp(g.zAuxSchema,"2014-11-24 20:35")>=0 ){
1790 /* Support for PLINK.BASEID added on 2014-11-24 */
1791 db_multi_exec(
1792
--- src/manifest.c
+++ src/manifest.c
@@ -1781,11 +1781,11 @@
1781 sqlite3_snprintf(sizeof(zBaseId), zBaseId, "%d",
1782 uuid_to_rid(p->zBaseline,1));
1783 }else{
1784 sqlite3_snprintf(sizeof(zBaseId), zBaseId, "NULL");
1785 }
1786 (void)db_schema_is_outofdate(); /* Make sure g.zAuxSchema is initialized */
1787 for(i=0; i<p->nParent; i++){
1788 int pid = uuid_to_rid(p->azParent[i], 1);
1789 if( strcmp(g.zAuxSchema,"2014-11-24 20:35")>=0 ){
1790 /* Support for PLINK.BASEID added on 2014-11-24 */
1791 db_multi_exec(
1792
+10 -3
--- src/purge.c
+++ src/purge.c
@@ -199,13 +199,20 @@
199199
** are about to be deleted or otherwise made inaccessible. This routine
200200
** is checking to ensure that purging the checkins in zTab will not delete
201201
** a baseline manifest out from under a delta.
202202
*/
203203
int purge_baseline_out_from_under_delta(const char *zTab){
204
- return db_int(0,
205
- "SELECT 1 FROM plink WHERE baseid IN \"%w\" AND cid NOT IN \"%w\"",
206
- zTab, zTab);
204
+ if( !db_exists("SELECT 1 FROM %s.sqlite_master WHERE name='plink'"
205
+ " AND sql GLOB '* baseid *'", db_name("repository")) ){
206
+ /* Skip this check if the current database is an older schema that
207
+ ** does not contain the PLINK.BASEID field. */
208
+ return 0;
209
+ }else{
210
+ return db_int(0,
211
+ "SELECT 1 FROM plink WHERE baseid IN \"%w\" AND cid NOT IN \"%w\"",
212
+ zTab, zTab);
213
+ }
207214
}
208215
209216
210217
/*
211218
** The TEMP table named zTab contains the RIDs for a set of checkin
212219
--- src/purge.c
+++ src/purge.c
@@ -199,13 +199,20 @@
199 ** are about to be deleted or otherwise made inaccessible. This routine
200 ** is checking to ensure that purging the checkins in zTab will not delete
201 ** a baseline manifest out from under a delta.
202 */
203 int purge_baseline_out_from_under_delta(const char *zTab){
204 return db_int(0,
205 "SELECT 1 FROM plink WHERE baseid IN \"%w\" AND cid NOT IN \"%w\"",
206 zTab, zTab);
 
 
 
 
 
 
 
207 }
208
209
210 /*
211 ** The TEMP table named zTab contains the RIDs for a set of checkin
212
--- src/purge.c
+++ src/purge.c
@@ -199,13 +199,20 @@
199 ** are about to be deleted or otherwise made inaccessible. This routine
200 ** is checking to ensure that purging the checkins in zTab will not delete
201 ** a baseline manifest out from under a delta.
202 */
203 int purge_baseline_out_from_under_delta(const char *zTab){
204 if( !db_exists("SELECT 1 FROM %s.sqlite_master WHERE name='plink'"
205 " AND sql GLOB '* baseid *'", db_name("repository")) ){
206 /* Skip this check if the current database is an older schema that
207 ** does not contain the PLINK.BASEID field. */
208 return 0;
209 }else{
210 return db_int(0,
211 "SELECT 1 FROM plink WHERE baseid IN \"%w\" AND cid NOT IN \"%w\"",
212 zTab, zTab);
213 }
214 }
215
216
217 /*
218 ** The TEMP table named zTab contains the RIDs for a set of checkin
219
+10 -3
--- src/purge.c
+++ src/purge.c
@@ -199,13 +199,20 @@
199199
** are about to be deleted or otherwise made inaccessible. This routine
200200
** is checking to ensure that purging the checkins in zTab will not delete
201201
** a baseline manifest out from under a delta.
202202
*/
203203
int purge_baseline_out_from_under_delta(const char *zTab){
204
- return db_int(0,
205
- "SELECT 1 FROM plink WHERE baseid IN \"%w\" AND cid NOT IN \"%w\"",
206
- zTab, zTab);
204
+ if( !db_exists("SELECT 1 FROM %s.sqlite_master WHERE name='plink'"
205
+ " AND sql GLOB '* baseid *'", db_name("repository")) ){
206
+ /* Skip this check if the current database is an older schema that
207
+ ** does not contain the PLINK.BASEID field. */
208
+ return 0;
209
+ }else{
210
+ return db_int(0,
211
+ "SELECT 1 FROM plink WHERE baseid IN \"%w\" AND cid NOT IN \"%w\"",
212
+ zTab, zTab);
213
+ }
207214
}
208215
209216
210217
/*
211218
** The TEMP table named zTab contains the RIDs for a set of checkin
212219
--- src/purge.c
+++ src/purge.c
@@ -199,13 +199,20 @@
199 ** are about to be deleted or otherwise made inaccessible. This routine
200 ** is checking to ensure that purging the checkins in zTab will not delete
201 ** a baseline manifest out from under a delta.
202 */
203 int purge_baseline_out_from_under_delta(const char *zTab){
204 return db_int(0,
205 "SELECT 1 FROM plink WHERE baseid IN \"%w\" AND cid NOT IN \"%w\"",
206 zTab, zTab);
 
 
 
 
 
 
 
207 }
208
209
210 /*
211 ** The TEMP table named zTab contains the RIDs for a set of checkin
212
--- src/purge.c
+++ src/purge.c
@@ -199,13 +199,20 @@
199 ** are about to be deleted or otherwise made inaccessible. This routine
200 ** is checking to ensure that purging the checkins in zTab will not delete
201 ** a baseline manifest out from under a delta.
202 */
203 int purge_baseline_out_from_under_delta(const char *zTab){
204 if( !db_exists("SELECT 1 FROM %s.sqlite_master WHERE name='plink'"
205 " AND sql GLOB '* baseid *'", db_name("repository")) ){
206 /* Skip this check if the current database is an older schema that
207 ** does not contain the PLINK.BASEID field. */
208 return 0;
209 }else{
210 return db_int(0,
211 "SELECT 1 FROM plink WHERE baseid IN \"%w\" AND cid NOT IN \"%w\"",
212 zTab, zTab);
213 }
214 }
215
216
217 /*
218 ** The TEMP table named zTab contains the RIDs for a set of checkin
219
+53 -32
--- src/shell.c
+++ src/shell.c
@@ -4036,14 +4036,16 @@
40364036
40374037
int main(int argc, char **argv){
40384038
char *zErrMsg = 0;
40394039
ShellState data;
40404040
const char *zInitFile = 0;
4041
- char *zFirstCmd = 0;
40424041
int i;
40434042
int rc = 0;
40444043
int warnInmemoryDb = 0;
4044
+ int readStdin = 1;
4045
+ int nCmd = 0;
4046
+ char **azCmd = 0;
40454047
40464048
#if USE_SYSTEM_SQLITE+0!=1
40474049
if( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)!=0 ){
40484050
fprintf(stderr, "SQLite header and source version mismatch\n%s\n%s\n",
40494051
sqlite3_sourceid(), SQLITE_SOURCE_ID);
@@ -4058,10 +4060,22 @@
40584060
** else is done.
40594061
*/
40604062
#ifdef SIGINT
40614063
signal(SIGINT, interrupt_handler);
40624064
#endif
4065
+
4066
+#ifdef SQLITE_SHELL_DBNAME_PROC
4067
+ {
4068
+ /* If the SQLITE_SHELL_DBNAME_PROC macro is defined, then it is the name
4069
+ ** of a C-function that will provide the name of the database file. Use
4070
+ ** this compile-time option to embed this shell program in larger
4071
+ ** applications. */
4072
+ extern void SQLITE_SHELL_DBNAME_PROC(const char**);
4073
+ SQLITE_SHELL_DBNAME_PROC(&data.zDbFilename);
4074
+ warnInmemoryDb = 0;
4075
+ }
4076
+#endif
40634077
40644078
/* Do an initial pass through the command-line argument to locate
40654079
** the name of the database file, the name of the initialization file,
40664080
** the size of the alternative malloc heap,
40674081
** and the first command to execute.
@@ -4070,19 +4084,22 @@
40704084
char *z;
40714085
z = argv[i];
40724086
if( z[0]!='-' ){
40734087
if( data.zDbFilename==0 ){
40744088
data.zDbFilename = z;
4075
- continue;
4076
- }
4077
- if( zFirstCmd==0 ){
4078
- zFirstCmd = z;
4079
- continue;
4080
- }
4081
- fprintf(stderr,"%s: Error: too many options: \"%s\"\n", Argv0, argv[i]);
4082
- fprintf(stderr,"Use -help for a list of options.\n");
4083
- return 1;
4089
+ }else{
4090
+ /* Excesss arguments are interpreted as SQL (or dot-commands) and
4091
+ ** mean that nothing is read from stdin */
4092
+ readStdin = 0;
4093
+ nCmd++;
4094
+ azCmd = realloc(azCmd, sizeof(azCmd[0])*nCmd);
4095
+ if( azCmd==0 ){
4096
+ fprintf(stderr, "out of memory\n");
4097
+ exit(1);
4098
+ }
4099
+ azCmd[nCmd-1] = z;
4100
+ }
40844101
}
40854102
if( z[1]=='-' ) z++;
40864103
if( strcmp(z,"-separator")==0
40874104
|| strcmp(z,"-nullvalue")==0
40884105
|| strcmp(z,"-newline")==0
@@ -4169,15 +4186,10 @@
41694186
warnInmemoryDb = argc==1;
41704187
#else
41714188
fprintf(stderr,"%s: Error: no database filename specified\n", Argv0);
41724189
return 1;
41734190
#endif
4174
-#ifdef SQLITE_SHELL_DBNAME_PROC
4175
- { extern void SQLITE_SHELL_DBNAME_PROC(const char**);
4176
- SQLITE_SHELL_DBNAME_PROC(&data.zDbFilename);
4177
- warnInmemoryDb = 0; }
4178
-#endif
41794191
}
41804192
data.out = stdout;
41814193
41824194
/* Go ahead and open the database file if it already exists. If the
41834195
** file does not exist, delay opening it. This prevents empty database
@@ -4270,10 +4282,14 @@
42704282
i++;
42714283
#endif
42724284
}else if( strcmp(z,"-help")==0 ){
42734285
usage(1);
42744286
}else if( strcmp(z,"-cmd")==0 ){
4287
+ /* Run commands that follow -cmd first and separately from commands
4288
+ ** that simply appear on the command-line. This seems goofy. It would
4289
+ ** be better if all commands ran in the order that they appear. But
4290
+ ** we retain the goofy behavior for historical compatibility. */
42754291
if( i==argc-1 ) break;
42764292
z = cmdline_option_value(argc,argv,++i);
42774293
if( z[0]=='.' ){
42784294
rc = do_meta_command(z, &data);
42794295
if( rc && bail_on_error ) return rc==2 ? 0 : rc;
@@ -4293,27 +4309,32 @@
42934309
fprintf(stderr,"Use -help for a list of options.\n");
42944310
return 1;
42954311
}
42964312
}
42974313
4298
- if( zFirstCmd ){
4299
- /* Run just the command that follows the database name
4300
- */
4301
- if( zFirstCmd[0]=='.' ){
4302
- rc = do_meta_command(zFirstCmd, &data);
4303
- if( rc==2 ) rc = 0;
4304
- }else{
4305
- open_db(&data, 0);
4306
- rc = shell_exec(data.db, zFirstCmd, shell_callback, &data, &zErrMsg);
4307
- if( zErrMsg!=0 ){
4308
- fprintf(stderr,"Error: %s\n", zErrMsg);
4309
- return rc!=0 ? rc : 1;
4310
- }else if( rc!=0 ){
4311
- fprintf(stderr,"Error: unable to process SQL \"%s\"\n", zFirstCmd);
4312
- return rc;
4313
- }
4314
- }
4314
+ if( !readStdin ){
4315
+ /* Run all arguments that do not begin with '-' as if they were separate
4316
+ ** command-line inputs, except for the argToSkip argument which contains
4317
+ ** the database filename.
4318
+ */
4319
+ for(i=0; i<nCmd; i++){
4320
+ if( azCmd[i][0]=='.' ){
4321
+ rc = do_meta_command(azCmd[i], &data);
4322
+ if( rc ) return rc==2 ? 0 : rc;
4323
+ }else{
4324
+ open_db(&data, 0);
4325
+ rc = shell_exec(data.db, azCmd[i], shell_callback, &data, &zErrMsg);
4326
+ if( zErrMsg!=0 ){
4327
+ fprintf(stderr,"Error: %s\n", zErrMsg);
4328
+ return rc!=0 ? rc : 1;
4329
+ }else if( rc!=0 ){
4330
+ fprintf(stderr,"Error: unable to process SQL: %s\n", azCmd[i]);
4331
+ return rc;
4332
+ }
4333
+ }
4334
+ }
4335
+ free(azCmd);
43154336
}else{
43164337
/* Run commands received from standard input
43174338
*/
43184339
if( stdin_is_interactive ){
43194340
char *zHome;
43204341
--- src/shell.c
+++ src/shell.c
@@ -4036,14 +4036,16 @@
4036
4037 int main(int argc, char **argv){
4038 char *zErrMsg = 0;
4039 ShellState data;
4040 const char *zInitFile = 0;
4041 char *zFirstCmd = 0;
4042 int i;
4043 int rc = 0;
4044 int warnInmemoryDb = 0;
 
 
 
4045
4046 #if USE_SYSTEM_SQLITE+0!=1
4047 if( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)!=0 ){
4048 fprintf(stderr, "SQLite header and source version mismatch\n%s\n%s\n",
4049 sqlite3_sourceid(), SQLITE_SOURCE_ID);
@@ -4058,10 +4060,22 @@
4058 ** else is done.
4059 */
4060 #ifdef SIGINT
4061 signal(SIGINT, interrupt_handler);
4062 #endif
 
 
 
 
 
 
 
 
 
 
 
 
4063
4064 /* Do an initial pass through the command-line argument to locate
4065 ** the name of the database file, the name of the initialization file,
4066 ** the size of the alternative malloc heap,
4067 ** and the first command to execute.
@@ -4070,19 +4084,22 @@
4070 char *z;
4071 z = argv[i];
4072 if( z[0]!='-' ){
4073 if( data.zDbFilename==0 ){
4074 data.zDbFilename = z;
4075 continue;
4076 }
4077 if( zFirstCmd==0 ){
4078 zFirstCmd = z;
4079 continue;
4080 }
4081 fprintf(stderr,"%s: Error: too many options: \"%s\"\n", Argv0, argv[i]);
4082 fprintf(stderr,"Use -help for a list of options.\n");
4083 return 1;
 
 
 
4084 }
4085 if( z[1]=='-' ) z++;
4086 if( strcmp(z,"-separator")==0
4087 || strcmp(z,"-nullvalue")==0
4088 || strcmp(z,"-newline")==0
@@ -4169,15 +4186,10 @@
4169 warnInmemoryDb = argc==1;
4170 #else
4171 fprintf(stderr,"%s: Error: no database filename specified\n", Argv0);
4172 return 1;
4173 #endif
4174 #ifdef SQLITE_SHELL_DBNAME_PROC
4175 { extern void SQLITE_SHELL_DBNAME_PROC(const char**);
4176 SQLITE_SHELL_DBNAME_PROC(&data.zDbFilename);
4177 warnInmemoryDb = 0; }
4178 #endif
4179 }
4180 data.out = stdout;
4181
4182 /* Go ahead and open the database file if it already exists. If the
4183 ** file does not exist, delay opening it. This prevents empty database
@@ -4270,10 +4282,14 @@
4270 i++;
4271 #endif
4272 }else if( strcmp(z,"-help")==0 ){
4273 usage(1);
4274 }else if( strcmp(z,"-cmd")==0 ){
 
 
 
 
4275 if( i==argc-1 ) break;
4276 z = cmdline_option_value(argc,argv,++i);
4277 if( z[0]=='.' ){
4278 rc = do_meta_command(z, &data);
4279 if( rc && bail_on_error ) return rc==2 ? 0 : rc;
@@ -4293,27 +4309,32 @@
4293 fprintf(stderr,"Use -help for a list of options.\n");
4294 return 1;
4295 }
4296 }
4297
4298 if( zFirstCmd ){
4299 /* Run just the command that follows the database name
4300 */
4301 if( zFirstCmd[0]=='.' ){
4302 rc = do_meta_command(zFirstCmd, &data);
4303 if( rc==2 ) rc = 0;
4304 }else{
4305 open_db(&data, 0);
4306 rc = shell_exec(data.db, zFirstCmd, shell_callback, &data, &zErrMsg);
4307 if( zErrMsg!=0 ){
4308 fprintf(stderr,"Error: %s\n", zErrMsg);
4309 return rc!=0 ? rc : 1;
4310 }else if( rc!=0 ){
4311 fprintf(stderr,"Error: unable to process SQL \"%s\"\n", zFirstCmd);
4312 return rc;
4313 }
4314 }
 
 
 
 
 
4315 }else{
4316 /* Run commands received from standard input
4317 */
4318 if( stdin_is_interactive ){
4319 char *zHome;
4320
--- src/shell.c
+++ src/shell.c
@@ -4036,14 +4036,16 @@
4036
4037 int main(int argc, char **argv){
4038 char *zErrMsg = 0;
4039 ShellState data;
4040 const char *zInitFile = 0;
 
4041 int i;
4042 int rc = 0;
4043 int warnInmemoryDb = 0;
4044 int readStdin = 1;
4045 int nCmd = 0;
4046 char **azCmd = 0;
4047
4048 #if USE_SYSTEM_SQLITE+0!=1
4049 if( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)!=0 ){
4050 fprintf(stderr, "SQLite header and source version mismatch\n%s\n%s\n",
4051 sqlite3_sourceid(), SQLITE_SOURCE_ID);
@@ -4058,10 +4060,22 @@
4060 ** else is done.
4061 */
4062 #ifdef SIGINT
4063 signal(SIGINT, interrupt_handler);
4064 #endif
4065
4066 #ifdef SQLITE_SHELL_DBNAME_PROC
4067 {
4068 /* If the SQLITE_SHELL_DBNAME_PROC macro is defined, then it is the name
4069 ** of a C-function that will provide the name of the database file. Use
4070 ** this compile-time option to embed this shell program in larger
4071 ** applications. */
4072 extern void SQLITE_SHELL_DBNAME_PROC(const char**);
4073 SQLITE_SHELL_DBNAME_PROC(&data.zDbFilename);
4074 warnInmemoryDb = 0;
4075 }
4076 #endif
4077
4078 /* Do an initial pass through the command-line argument to locate
4079 ** the name of the database file, the name of the initialization file,
4080 ** the size of the alternative malloc heap,
4081 ** and the first command to execute.
@@ -4070,19 +4084,22 @@
4084 char *z;
4085 z = argv[i];
4086 if( z[0]!='-' ){
4087 if( data.zDbFilename==0 ){
4088 data.zDbFilename = z;
4089 }else{
4090 /* Excesss arguments are interpreted as SQL (or dot-commands) and
4091 ** mean that nothing is read from stdin */
4092 readStdin = 0;
4093 nCmd++;
4094 azCmd = realloc(azCmd, sizeof(azCmd[0])*nCmd);
4095 if( azCmd==0 ){
4096 fprintf(stderr, "out of memory\n");
4097 exit(1);
4098 }
4099 azCmd[nCmd-1] = z;
4100 }
4101 }
4102 if( z[1]=='-' ) z++;
4103 if( strcmp(z,"-separator")==0
4104 || strcmp(z,"-nullvalue")==0
4105 || strcmp(z,"-newline")==0
@@ -4169,15 +4186,10 @@
4186 warnInmemoryDb = argc==1;
4187 #else
4188 fprintf(stderr,"%s: Error: no database filename specified\n", Argv0);
4189 return 1;
4190 #endif
 
 
 
 
 
4191 }
4192 data.out = stdout;
4193
4194 /* Go ahead and open the database file if it already exists. If the
4195 ** file does not exist, delay opening it. This prevents empty database
@@ -4270,10 +4282,14 @@
4282 i++;
4283 #endif
4284 }else if( strcmp(z,"-help")==0 ){
4285 usage(1);
4286 }else if( strcmp(z,"-cmd")==0 ){
4287 /* Run commands that follow -cmd first and separately from commands
4288 ** that simply appear on the command-line. This seems goofy. It would
4289 ** be better if all commands ran in the order that they appear. But
4290 ** we retain the goofy behavior for historical compatibility. */
4291 if( i==argc-1 ) break;
4292 z = cmdline_option_value(argc,argv,++i);
4293 if( z[0]=='.' ){
4294 rc = do_meta_command(z, &data);
4295 if( rc && bail_on_error ) return rc==2 ? 0 : rc;
@@ -4293,27 +4309,32 @@
4309 fprintf(stderr,"Use -help for a list of options.\n");
4310 return 1;
4311 }
4312 }
4313
4314 if( !readStdin ){
4315 /* Run all arguments that do not begin with '-' as if they were separate
4316 ** command-line inputs, except for the argToSkip argument which contains
4317 ** the database filename.
4318 */
4319 for(i=0; i<nCmd; i++){
4320 if( azCmd[i][0]=='.' ){
4321 rc = do_meta_command(azCmd[i], &data);
4322 if( rc ) return rc==2 ? 0 : rc;
4323 }else{
4324 open_db(&data, 0);
4325 rc = shell_exec(data.db, azCmd[i], shell_callback, &data, &zErrMsg);
4326 if( zErrMsg!=0 ){
4327 fprintf(stderr,"Error: %s\n", zErrMsg);
4328 return rc!=0 ? rc : 1;
4329 }else if( rc!=0 ){
4330 fprintf(stderr,"Error: unable to process SQL: %s\n", azCmd[i]);
4331 return rc;
4332 }
4333 }
4334 }
4335 free(azCmd);
4336 }else{
4337 /* Run commands received from standard input
4338 */
4339 if( stdin_is_interactive ){
4340 char *zHome;
4341
+11 -2
--- src/utf8.c
+++ src/utf8.c
@@ -309,10 +309,11 @@
309309
int fossil_utf8_to_console(const char *zUtf8, int nByte, int toStdErr){
310310
#ifdef _WIN32
311311
int nChar, written = 0;
312312
wchar_t *zUnicode; /* Unicode version of zUtf8 */
313313
DWORD dummy;
314
+ Blob blob;
314315
315316
static int istty[2] = { -1, -1 };
316317
if( istty[toStdErr] == -1 ){
317318
istty[toStdErr] = _isatty(toStdErr + 1) != 0;
318319
}
@@ -319,16 +320,24 @@
319320
if( !istty[toStdErr] ){
320321
/* stdout/stderr is not a console. */
321322
return -1;
322323
}
323324
324
- nChar = MultiByteToWideChar(CP_UTF8, 0, zUtf8, nByte, NULL, 0);
325
+ /* If blob to be written to the Windows console is not
326
+ * UTF-8, convert it to UTF-8 first.
327
+ */
328
+ blob_init(&blob, zUtf8, nByte);
329
+ blob_to_utf8_no_bom(&blob, 1);
330
+ nChar = MultiByteToWideChar(CP_UTF8, 0, blob_buffer(&blob),
331
+ blob_size(&blob), NULL, 0);
325332
zUnicode = malloc( (nChar + 1) *sizeof(zUnicode[0]) );
326333
if( zUnicode==0 ){
327334
return 0;
328335
}
329
- nChar = MultiByteToWideChar(CP_UTF8, 0, zUtf8, nByte, zUnicode, nChar);
336
+ nChar = MultiByteToWideChar(CP_UTF8, 0, blob_buffer(&blob),
337
+ blob_size(&blob), zUnicode, nChar);
338
+ blob_reset(&blob);
330339
/* Split WriteConsoleW call into multiple chunks, if necessary. See:
331340
* <https://connect.microsoft.com/VisualStudio/feedback/details/635230> */
332341
while( written < nChar ){
333342
int size = nChar-written;
334343
if( size > 26000 ) size = 26000;
335344
--- src/utf8.c
+++ src/utf8.c
@@ -309,10 +309,11 @@
309 int fossil_utf8_to_console(const char *zUtf8, int nByte, int toStdErr){
310 #ifdef _WIN32
311 int nChar, written = 0;
312 wchar_t *zUnicode; /* Unicode version of zUtf8 */
313 DWORD dummy;
 
314
315 static int istty[2] = { -1, -1 };
316 if( istty[toStdErr] == -1 ){
317 istty[toStdErr] = _isatty(toStdErr + 1) != 0;
318 }
@@ -319,16 +320,24 @@
319 if( !istty[toStdErr] ){
320 /* stdout/stderr is not a console. */
321 return -1;
322 }
323
324 nChar = MultiByteToWideChar(CP_UTF8, 0, zUtf8, nByte, NULL, 0);
 
 
 
 
 
 
325 zUnicode = malloc( (nChar + 1) *sizeof(zUnicode[0]) );
326 if( zUnicode==0 ){
327 return 0;
328 }
329 nChar = MultiByteToWideChar(CP_UTF8, 0, zUtf8, nByte, zUnicode, nChar);
 
 
330 /* Split WriteConsoleW call into multiple chunks, if necessary. See:
331 * <https://connect.microsoft.com/VisualStudio/feedback/details/635230> */
332 while( written < nChar ){
333 int size = nChar-written;
334 if( size > 26000 ) size = 26000;
335
--- src/utf8.c
+++ src/utf8.c
@@ -309,10 +309,11 @@
309 int fossil_utf8_to_console(const char *zUtf8, int nByte, int toStdErr){
310 #ifdef _WIN32
311 int nChar, written = 0;
312 wchar_t *zUnicode; /* Unicode version of zUtf8 */
313 DWORD dummy;
314 Blob blob;
315
316 static int istty[2] = { -1, -1 };
317 if( istty[toStdErr] == -1 ){
318 istty[toStdErr] = _isatty(toStdErr + 1) != 0;
319 }
@@ -319,16 +320,24 @@
320 if( !istty[toStdErr] ){
321 /* stdout/stderr is not a console. */
322 return -1;
323 }
324
325 /* If blob to be written to the Windows console is not
326 * UTF-8, convert it to UTF-8 first.
327 */
328 blob_init(&blob, zUtf8, nByte);
329 blob_to_utf8_no_bom(&blob, 1);
330 nChar = MultiByteToWideChar(CP_UTF8, 0, blob_buffer(&blob),
331 blob_size(&blob), NULL, 0);
332 zUnicode = malloc( (nChar + 1) *sizeof(zUnicode[0]) );
333 if( zUnicode==0 ){
334 return 0;
335 }
336 nChar = MultiByteToWideChar(CP_UTF8, 0, blob_buffer(&blob),
337 blob_size(&blob), zUnicode, nChar);
338 blob_reset(&blob);
339 /* Split WriteConsoleW call into multiple chunks, if necessary. See:
340 * <https://connect.microsoft.com/VisualStudio/feedback/details/635230> */
341 while( written < nChar ){
342 int size = nChar-written;
343 if( size > 26000 ) size = 26000;
344

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button