Fossil SCM
Incorporate all recent trunk enhancements.
Commit
368f82a25536cea0eb180b8539be6d0e19881fc8
Parent
47162426494e60f…
14 files changed
+1
-1
+10
+4
-3
+4
-3
+1
+1
-1
+1
-1
+1
-1
+1
-1
+1
-1
+10
-3
+10
-3
+53
-32
+11
-2
+1
-1
| --- Makefile.in | ||
| +++ Makefile.in | ||
| @@ -37,11 +37,11 @@ | ||
| 37 | 37 | # care about testing the end result, this can be blank. |
| 38 | 38 | # |
| 39 | 39 | TCLSH = tclsh |
| 40 | 40 | |
| 41 | 41 | 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 | |
| 43 | 43 | INSTALLDIR = $(DESTDIR)@prefix@/bin |
| 44 | 44 | USE_SYSTEM_SQLITE = @USE_SYSTEM_SQLITE@ |
| 45 | 45 | FOSSIL_ENABLE_MINIZ = @FOSSIL_ENABLE_MINIZ@ |
| 46 | 46 | |
| 47 | 47 | include $(SRCDIR)/main.mk |
| 48 | 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 | 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 @@ | ||
| 24 | 24 | # include "miniz.c" |
| 25 | 25 | #else |
| 26 | 26 | # include <zlib.h> |
| 27 | 27 | #endif |
| 28 | 28 | #include "blob.h" |
| 29 | +#if defined(_WIN32) | |
| 30 | +#include <fcntl.h> | |
| 31 | +#include <io.h> | |
| 32 | +#endif | |
| 29 | 33 | |
| 30 | 34 | #if INTERFACE |
| 31 | 35 | /* |
| 32 | 36 | ** A Blob can hold a string or a binary object of arbitrary size. The |
| 33 | 37 | ** size changes as necessary. |
| @@ -823,12 +827,18 @@ | ||
| 823 | 827 | nWrote = blob_size(pBlob); |
| 824 | 828 | #if defined(_WIN32) |
| 825 | 829 | if( fossil_utf8_to_console(blob_buffer(pBlob), nWrote, 0) >= 0 ){ |
| 826 | 830 | return nWrote; |
| 827 | 831 | } |
| 832 | + fflush(stdout); | |
| 833 | + _setmode(_fileno(stdout), _O_BINARY); | |
| 828 | 834 | #endif |
| 829 | 835 | fwrite(blob_buffer(pBlob), 1, nWrote, stdout); |
| 836 | +#if defined(_WIN32) | |
| 837 | + fflush(stdout); | |
| 838 | + _setmode(_fileno(stdout), _O_TEXT); | |
| 839 | +#endif | |
| 830 | 840 | }else{ |
| 831 | 841 | file_mkfolder(zFilename, 1); |
| 832 | 842 | out = fossil_fopen(zFilename, "wb"); |
| 833 | 843 | if( out==0 ){ |
| 834 | 844 | fossil_fatal_recursive("unable to open file \"%s\" for writing", |
| 835 | 845 |
| --- 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 |
M
src/db.c
+4
-3
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -1005,20 +1005,21 @@ | ||
| 1005 | 1005 | ** is found, it is attached to the open database connection too. |
| 1006 | 1006 | */ |
| 1007 | 1007 | int db_open_local(const char *zDbName){ |
| 1008 | 1008 | int i, n; |
| 1009 | 1009 | char zPwd[2000]; |
| 1010 | - static const char aDbName[][10] = { "_FOSSIL_", ".fslckout", ".fos" }; | |
| 1010 | + static const char *(aDbName[]) = { "_FOSSIL_", ".fslckout", ".fos" }; | |
| 1011 | 1011 | |
| 1012 | 1012 | if( g.localOpen ) return 1; |
| 1013 | 1013 | file_getcwd(zPwd, sizeof(zPwd)-20); |
| 1014 | 1014 | n = strlen(zPwd); |
| 1015 | 1015 | while( n>0 ){ |
| 1016 | 1016 | for(i=0; i<count(aDbName); i++){ |
| 1017 | 1017 | sqlite3_snprintf(sizeof(zPwd)-n, &zPwd[n], "/%s", aDbName[i]); |
| 1018 | 1018 | if( isValidLocalDb(zPwd) ){ |
| 1019 | 1019 | /* Found a valid checkout database file */ |
| 1020 | + g.zLocalDbName = mprintf("%s", zPwd); | |
| 1020 | 1021 | zPwd[n] = 0; |
| 1021 | 1022 | while( n>0 && zPwd[n-1]=='/' ){ |
| 1022 | 1023 | n--; |
| 1023 | 1024 | zPwd[n] = 0; |
| 1024 | 1025 | } |
| @@ -1160,11 +1161,11 @@ | ||
| 1160 | 1161 | |
| 1161 | 1162 | /* |
| 1162 | 1163 | ** Return TRUE if the schema is out-of-date |
| 1163 | 1164 | */ |
| 1164 | 1165 | 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",""); | |
| 1166 | 1167 | return strcmp(g.zAuxSchema,AUX_SCHEMA_MIN)<0 |
| 1167 | 1168 | || strcmp(g.zAuxSchema,AUX_SCHEMA_MAX)>0; |
| 1168 | 1169 | } |
| 1169 | 1170 | |
| 1170 | 1171 | /* |
| @@ -1184,11 +1185,11 @@ | ||
| 1184 | 1185 | g.json.resultCode = FSL_JSON_E_DB_NEEDS_REBUILD; |
| 1185 | 1186 | #endif |
| 1186 | 1187 | fossil_warning("incorrect repository schema version: " |
| 1187 | 1188 | "current repository schema version is \"%s\" " |
| 1188 | 1189 | "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); | |
| 1190 | 1191 | fossil_fatal("run \"fossil rebuild\" to fix this problem"); |
| 1191 | 1192 | } |
| 1192 | 1193 | } |
| 1193 | 1194 | |
| 1194 | 1195 | |
| 1195 | 1196 |
| --- 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 |
M
src/db.c
+4
-3
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -1005,20 +1005,21 @@ | ||
| 1005 | 1005 | ** is found, it is attached to the open database connection too. |
| 1006 | 1006 | */ |
| 1007 | 1007 | int db_open_local(const char *zDbName){ |
| 1008 | 1008 | int i, n; |
| 1009 | 1009 | char zPwd[2000]; |
| 1010 | - static const char aDbName[][10] = { "_FOSSIL_", ".fslckout", ".fos" }; | |
| 1010 | + static const char *(aDbName[]) = { "_FOSSIL_", ".fslckout", ".fos" }; | |
| 1011 | 1011 | |
| 1012 | 1012 | if( g.localOpen ) return 1; |
| 1013 | 1013 | file_getcwd(zPwd, sizeof(zPwd)-20); |
| 1014 | 1014 | n = strlen(zPwd); |
| 1015 | 1015 | while( n>0 ){ |
| 1016 | 1016 | for(i=0; i<count(aDbName); i++){ |
| 1017 | 1017 | sqlite3_snprintf(sizeof(zPwd)-n, &zPwd[n], "/%s", aDbName[i]); |
| 1018 | 1018 | if( isValidLocalDb(zPwd) ){ |
| 1019 | 1019 | /* Found a valid checkout database file */ |
| 1020 | + g.zLocalDbName = mprintf("%s", zPwd); | |
| 1020 | 1021 | zPwd[n] = 0; |
| 1021 | 1022 | while( n>0 && zPwd[n-1]=='/' ){ |
| 1022 | 1023 | n--; |
| 1023 | 1024 | zPwd[n] = 0; |
| 1024 | 1025 | } |
| @@ -1160,11 +1161,11 @@ | ||
| 1160 | 1161 | |
| 1161 | 1162 | /* |
| 1162 | 1163 | ** Return TRUE if the schema is out-of-date |
| 1163 | 1164 | */ |
| 1164 | 1165 | 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",""); | |
| 1166 | 1167 | return strcmp(g.zAuxSchema,AUX_SCHEMA_MIN)<0 |
| 1167 | 1168 | || strcmp(g.zAuxSchema,AUX_SCHEMA_MAX)>0; |
| 1168 | 1169 | } |
| 1169 | 1170 | |
| 1170 | 1171 | /* |
| @@ -1184,11 +1185,11 @@ | ||
| 1184 | 1185 | g.json.resultCode = FSL_JSON_E_DB_NEEDS_REBUILD; |
| 1185 | 1186 | #endif |
| 1186 | 1187 | fossil_warning("incorrect repository schema version: " |
| 1187 | 1188 | "current repository schema version is \"%s\" " |
| 1188 | 1189 | "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); | |
| 1190 | 1191 | fossil_fatal("run \"fossil rebuild\" to fix this problem"); |
| 1191 | 1192 | } |
| 1192 | 1193 | } |
| 1193 | 1194 | |
| 1194 | 1195 | |
| 1195 | 1196 |
| --- 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 @@ | ||
| 132 | 132 | const char *zConfigDbName;/* Path of the config database. NULL if not open */ |
| 133 | 133 | sqlite3_int64 now; /* Seconds since 1970 */ |
| 134 | 134 | int repositoryOpen; /* True if the main repository database is open */ |
| 135 | 135 | char *zRepositoryOption; /* Most recent cached repository option value */ |
| 136 | 136 | char *zRepositoryName; /* Name of the repository database */ |
| 137 | + char *zLocalDbName; /* Name of the local database */ | |
| 137 | 138 | const char *zMainDbType;/* "configdb", "localdb", or "repository" */ |
| 138 | 139 | const char *zConfigDbType; /* "configdb", "localdb", or "repository" */ |
| 139 | 140 | int localOpen; /* True if the local database is open */ |
| 140 | 141 | char *zLocalRoot; /* The directory holding the local database */ |
| 141 | 142 | int minPrefix; /* Number of digits needed for a distinct UUID */ |
| 142 | 143 |
| --- 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 @@ | ||
| 8 | 8 | # to regenerate this file. |
| 9 | 9 | # |
| 10 | 10 | # This file is included by primary Makefile. |
| 11 | 11 | # |
| 12 | 12 | |
| 13 | -XTCC = $(TCC) $(CFLAGS) -I. -I$(SRCDIR) -I$(OBJDIR) | |
| 13 | +XTCC = $(TCC) -I. -I$(SRCDIR) -I$(OBJDIR) $(TCCFLAGS) $(CFLAGS) | |
| 14 | 14 | |
| 15 | 15 | |
| 16 | 16 | SRC = \ |
| 17 | 17 | $(SRCDIR)/add.c \ |
| 18 | 18 | $(SRCDIR)/allrepo.c \ |
| 19 | 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) $(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 @@ | ||
| 8 | 8 | # to regenerate this file. |
| 9 | 9 | # |
| 10 | 10 | # This file is included by primary Makefile. |
| 11 | 11 | # |
| 12 | 12 | |
| 13 | -XTCC = $(TCC) $(CFLAGS) -I. -I$(SRCDIR) -I$(OBJDIR) | |
| 13 | +XTCC = $(TCC) -I. -I$(SRCDIR) -I$(OBJDIR) $(TCCFLAGS) $(CFLAGS) | |
| 14 | 14 | |
| 15 | 15 | |
| 16 | 16 | SRC = \ |
| 17 | 17 | $(SRCDIR)/add.c \ |
| 18 | 18 | $(SRCDIR)/allrepo.c \ |
| 19 | 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) $(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/makemake.tcl | ||
| +++ src/makemake.tcl | ||
| @@ -223,11 +223,11 @@ | ||
| 223 | 223 | # to regenerate this file. |
| 224 | 224 | # |
| 225 | 225 | # This file is included by primary Makefile. |
| 226 | 226 | # |
| 227 | 227 | |
| 228 | -XTCC = $(TCC) $(CFLAGS) -I. -I$(SRCDIR) -I$(OBJDIR) | |
| 228 | +XTCC = $(TCC) -I. -I$(SRCDIR) -I$(OBJDIR) $(TCCFLAGS) $(CFLAGS) | |
| 229 | 229 | |
| 230 | 230 | } |
| 231 | 231 | writeln -nonewline "SRC =" |
| 232 | 232 | foreach s [lsort $src] { |
| 233 | 233 | writeln -nonewline " \\\n \$(SRCDIR)/$s.c" |
| 234 | 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) $(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/makemake.tcl | ||
| +++ src/makemake.tcl | ||
| @@ -223,11 +223,11 @@ | ||
| 223 | 223 | # to regenerate this file. |
| 224 | 224 | # |
| 225 | 225 | # This file is included by primary Makefile. |
| 226 | 226 | # |
| 227 | 227 | |
| 228 | -XTCC = $(TCC) $(CFLAGS) -I. -I$(SRCDIR) -I$(OBJDIR) | |
| 228 | +XTCC = $(TCC) -I. -I$(SRCDIR) -I$(OBJDIR) $(TCCFLAGS) $(CFLAGS) | |
| 229 | 229 | |
| 230 | 230 | } |
| 231 | 231 | writeln -nonewline "SRC =" |
| 232 | 232 | foreach s [lsort $src] { |
| 233 | 233 | writeln -nonewline " \\\n \$(SRCDIR)/$s.c" |
| 234 | 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) $(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 @@ | ||
| 1781 | 1781 | sqlite3_snprintf(sizeof(zBaseId), zBaseId, "%d", |
| 1782 | 1782 | uuid_to_rid(p->zBaseline,1)); |
| 1783 | 1783 | }else{ |
| 1784 | 1784 | sqlite3_snprintf(sizeof(zBaseId), zBaseId, "NULL"); |
| 1785 | 1785 | } |
| 1786 | - if( g.zAuxSchema==0 ) (void)db_schema_is_outofdate(); | |
| 1786 | + (void)db_schema_is_outofdate(); /* Make sure g.zAuxSchema is initialized */ | |
| 1787 | 1787 | for(i=0; i<p->nParent; i++){ |
| 1788 | 1788 | int pid = uuid_to_rid(p->azParent[i], 1); |
| 1789 | 1789 | if( strcmp(g.zAuxSchema,"2014-11-24 20:35")>=0 ){ |
| 1790 | 1790 | /* Support for PLINK.BASEID added on 2014-11-24 */ |
| 1791 | 1791 | db_multi_exec( |
| 1792 | 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 | 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 @@ | ||
| 199 | 199 | ** are about to be deleted or otherwise made inaccessible. This routine |
| 200 | 200 | ** is checking to ensure that purging the checkins in zTab will not delete |
| 201 | 201 | ** a baseline manifest out from under a delta. |
| 202 | 202 | */ |
| 203 | 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); | |
| 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 | + } | |
| 207 | 214 | } |
| 208 | 215 | |
| 209 | 216 | |
| 210 | 217 | /* |
| 211 | 218 | ** The TEMP table named zTab contains the RIDs for a set of checkin |
| 212 | 219 |
| --- 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 @@ | ||
| 199 | 199 | ** are about to be deleted or otherwise made inaccessible. This routine |
| 200 | 200 | ** is checking to ensure that purging the checkins in zTab will not delete |
| 201 | 201 | ** a baseline manifest out from under a delta. |
| 202 | 202 | */ |
| 203 | 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); | |
| 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 | + } | |
| 207 | 214 | } |
| 208 | 215 | |
| 209 | 216 | |
| 210 | 217 | /* |
| 211 | 218 | ** The TEMP table named zTab contains the RIDs for a set of checkin |
| 212 | 219 |
| --- 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 @@ | ||
| 4036 | 4036 | |
| 4037 | 4037 | int main(int argc, char **argv){ |
| 4038 | 4038 | char *zErrMsg = 0; |
| 4039 | 4039 | ShellState data; |
| 4040 | 4040 | const char *zInitFile = 0; |
| 4041 | - char *zFirstCmd = 0; | |
| 4042 | 4041 | int i; |
| 4043 | 4042 | int rc = 0; |
| 4044 | 4043 | int warnInmemoryDb = 0; |
| 4044 | + int readStdin = 1; | |
| 4045 | + int nCmd = 0; | |
| 4046 | + char **azCmd = 0; | |
| 4045 | 4047 | |
| 4046 | 4048 | #if USE_SYSTEM_SQLITE+0!=1 |
| 4047 | 4049 | if( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)!=0 ){ |
| 4048 | 4050 | fprintf(stderr, "SQLite header and source version mismatch\n%s\n%s\n", |
| 4049 | 4051 | sqlite3_sourceid(), SQLITE_SOURCE_ID); |
| @@ -4058,10 +4060,22 @@ | ||
| 4058 | 4060 | ** else is done. |
| 4059 | 4061 | */ |
| 4060 | 4062 | #ifdef SIGINT |
| 4061 | 4063 | signal(SIGINT, interrupt_handler); |
| 4062 | 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 | |
| 4063 | 4077 | |
| 4064 | 4078 | /* Do an initial pass through the command-line argument to locate |
| 4065 | 4079 | ** the name of the database file, the name of the initialization file, |
| 4066 | 4080 | ** the size of the alternative malloc heap, |
| 4067 | 4081 | ** and the first command to execute. |
| @@ -4070,19 +4084,22 @@ | ||
| 4070 | 4084 | char *z; |
| 4071 | 4085 | z = argv[i]; |
| 4072 | 4086 | if( z[0]!='-' ){ |
| 4073 | 4087 | if( data.zDbFilename==0 ){ |
| 4074 | 4088 | 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 | + } | |
| 4084 | 4101 | } |
| 4085 | 4102 | if( z[1]=='-' ) z++; |
| 4086 | 4103 | if( strcmp(z,"-separator")==0 |
| 4087 | 4104 | || strcmp(z,"-nullvalue")==0 |
| 4088 | 4105 | || strcmp(z,"-newline")==0 |
| @@ -4169,15 +4186,10 @@ | ||
| 4169 | 4186 | warnInmemoryDb = argc==1; |
| 4170 | 4187 | #else |
| 4171 | 4188 | fprintf(stderr,"%s: Error: no database filename specified\n", Argv0); |
| 4172 | 4189 | return 1; |
| 4173 | 4190 | #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 | 4191 | } |
| 4180 | 4192 | data.out = stdout; |
| 4181 | 4193 | |
| 4182 | 4194 | /* Go ahead and open the database file if it already exists. If the |
| 4183 | 4195 | ** file does not exist, delay opening it. This prevents empty database |
| @@ -4270,10 +4282,14 @@ | ||
| 4270 | 4282 | i++; |
| 4271 | 4283 | #endif |
| 4272 | 4284 | }else if( strcmp(z,"-help")==0 ){ |
| 4273 | 4285 | usage(1); |
| 4274 | 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. */ | |
| 4275 | 4291 | if( i==argc-1 ) break; |
| 4276 | 4292 | z = cmdline_option_value(argc,argv,++i); |
| 4277 | 4293 | if( z[0]=='.' ){ |
| 4278 | 4294 | rc = do_meta_command(z, &data); |
| 4279 | 4295 | if( rc && bail_on_error ) return rc==2 ? 0 : rc; |
| @@ -4293,27 +4309,32 @@ | ||
| 4293 | 4309 | fprintf(stderr,"Use -help for a list of options.\n"); |
| 4294 | 4310 | return 1; |
| 4295 | 4311 | } |
| 4296 | 4312 | } |
| 4297 | 4313 | |
| 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); | |
| 4315 | 4336 | }else{ |
| 4316 | 4337 | /* Run commands received from standard input |
| 4317 | 4338 | */ |
| 4318 | 4339 | if( stdin_is_interactive ){ |
| 4319 | 4340 | char *zHome; |
| 4320 | 4341 |
| --- 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 @@ | ||
| 309 | 309 | int fossil_utf8_to_console(const char *zUtf8, int nByte, int toStdErr){ |
| 310 | 310 | #ifdef _WIN32 |
| 311 | 311 | int nChar, written = 0; |
| 312 | 312 | wchar_t *zUnicode; /* Unicode version of zUtf8 */ |
| 313 | 313 | DWORD dummy; |
| 314 | + Blob blob; | |
| 314 | 315 | |
| 315 | 316 | static int istty[2] = { -1, -1 }; |
| 316 | 317 | if( istty[toStdErr] == -1 ){ |
| 317 | 318 | istty[toStdErr] = _isatty(toStdErr + 1) != 0; |
| 318 | 319 | } |
| @@ -319,16 +320,24 @@ | ||
| 319 | 320 | if( !istty[toStdErr] ){ |
| 320 | 321 | /* stdout/stderr is not a console. */ |
| 321 | 322 | return -1; |
| 322 | 323 | } |
| 323 | 324 | |
| 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); | |
| 325 | 332 | zUnicode = malloc( (nChar + 1) *sizeof(zUnicode[0]) ); |
| 326 | 333 | if( zUnicode==0 ){ |
| 327 | 334 | return 0; |
| 328 | 335 | } |
| 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); | |
| 330 | 339 | /* Split WriteConsoleW call into multiple chunks, if necessary. See: |
| 331 | 340 | * <https://connect.microsoft.com/VisualStudio/feedback/details/635230> */ |
| 332 | 341 | while( written < nChar ){ |
| 333 | 342 | int size = nChar-written; |
| 334 | 343 | if( size > 26000 ) size = 26000; |
| 335 | 344 |
| --- 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 |