Fossil SCM

Merge the windows-i18n branch into the trunk.

drh 2011-05-20 11:32 trunk merge
Commit d8ec765face2759d204a96f7a1f2b1f4350d1a67
+6 -6
--- src/add.c
+++ src/add.c
@@ -116,11 +116,11 @@
116116
"INSERT INTO vfile(vid,deleted,rid,mrid,pathname,isexe)"
117117
"VALUES(%d,0,0,0,%Q,%d)",
118118
vid, zPath, file_isexe(zFullname));
119119
fossil_free(zFullname);
120120
}
121
- printf("ADDED %s\n", zPath);
121
+ fossil_print("ADDED %s\n", zPath);
122122
return 1;
123123
}
124124
125125
/*
126126
** Add all files in the sfile temp table.
@@ -215,11 +215,11 @@
215215
isDir = file_isdir(zName);
216216
if( isDir==1 ){
217217
vfile_scan(&fullName, nRoot-1, includeDotFiles, pIgnore);
218218
}else if( isDir==0 ){
219219
fossil_fatal("not found: %s", zName);
220
- }else if( access(zName, R_OK) ){
220
+ }else if( file_access(zName, R_OK) ){
221221
fossil_fatal("cannot open %s", zName);
222222
}else{
223223
char *zTreeName = &zName[nRoot];
224224
db_multi_exec(
225225
"INSERT OR IGNORE INTO sfile(x)"
@@ -280,11 +280,11 @@
280280
blob_reset(&treeName);
281281
}
282282
283283
db_prepare(&loop, "SELECT x FROM sfile");
284284
while( db_step(&loop)==SQLITE_ROW ){
285
- printf("DELETED %s\n", db_column_text(&loop, 0));
285
+ fossil_print("DELETED %s\n", db_column_text(&loop, 0));
286286
}
287287
db_finalize(&loop);
288288
db_multi_exec(
289289
"UPDATE vfile SET deleted=1 WHERE pathname IN sfile;"
290290
"DELETE FROM vfile WHERE rid=0 AND deleted;"
@@ -377,17 +377,17 @@
377377
zPath = db_column_text(&q, 1);
378378
if( !file_isfile(zPath) ){
379379
if( !isTest ){
380380
db_multi_exec("UPDATE vfile SET deleted=1 WHERE pathname=%Q", zFile);
381381
}
382
- printf("DELETED %s\n", zFile);
382
+ fossil_print("DELETED %s\n", zFile);
383383
nDelete++;
384384
}
385385
}
386386
db_finalize(&q);
387387
/* show cmmand summary */
388
- printf("added %d files, deleted %d files\n", nAdd, nDelete);
388
+ fossil_print("added %d files, deleted %d files\n", nAdd, nDelete);
389389
390390
db_end_transaction(isTest);
391391
}
392392
393393
@@ -395,11 +395,11 @@
395395
** Rename a single file.
396396
**
397397
** The original name of the file is zOrig. The new filename is zNew.
398398
*/
399399
static void mv_one_file(int vid, const char *zOrig, const char *zNew){
400
- printf("RENAME %s %s\n", zOrig, zNew);
400
+ fossil_print("RENAME %s %s\n", zOrig, zNew);
401401
db_multi_exec(
402402
"UPDATE vfile SET pathname='%s' WHERE pathname='%s' AND vid=%d",
403403
zNew, zOrig, vid
404404
);
405405
}
406406
--- src/add.c
+++ src/add.c
@@ -116,11 +116,11 @@
116 "INSERT INTO vfile(vid,deleted,rid,mrid,pathname,isexe)"
117 "VALUES(%d,0,0,0,%Q,%d)",
118 vid, zPath, file_isexe(zFullname));
119 fossil_free(zFullname);
120 }
121 printf("ADDED %s\n", zPath);
122 return 1;
123 }
124
125 /*
126 ** Add all files in the sfile temp table.
@@ -215,11 +215,11 @@
215 isDir = file_isdir(zName);
216 if( isDir==1 ){
217 vfile_scan(&fullName, nRoot-1, includeDotFiles, pIgnore);
218 }else if( isDir==0 ){
219 fossil_fatal("not found: %s", zName);
220 }else if( access(zName, R_OK) ){
221 fossil_fatal("cannot open %s", zName);
222 }else{
223 char *zTreeName = &zName[nRoot];
224 db_multi_exec(
225 "INSERT OR IGNORE INTO sfile(x)"
@@ -280,11 +280,11 @@
280 blob_reset(&treeName);
281 }
282
283 db_prepare(&loop, "SELECT x FROM sfile");
284 while( db_step(&loop)==SQLITE_ROW ){
285 printf("DELETED %s\n", db_column_text(&loop, 0));
286 }
287 db_finalize(&loop);
288 db_multi_exec(
289 "UPDATE vfile SET deleted=1 WHERE pathname IN sfile;"
290 "DELETE FROM vfile WHERE rid=0 AND deleted;"
@@ -377,17 +377,17 @@
377 zPath = db_column_text(&q, 1);
378 if( !file_isfile(zPath) ){
379 if( !isTest ){
380 db_multi_exec("UPDATE vfile SET deleted=1 WHERE pathname=%Q", zFile);
381 }
382 printf("DELETED %s\n", zFile);
383 nDelete++;
384 }
385 }
386 db_finalize(&q);
387 /* show cmmand summary */
388 printf("added %d files, deleted %d files\n", nAdd, nDelete);
389
390 db_end_transaction(isTest);
391 }
392
393
@@ -395,11 +395,11 @@
395 ** Rename a single file.
396 **
397 ** The original name of the file is zOrig. The new filename is zNew.
398 */
399 static void mv_one_file(int vid, const char *zOrig, const char *zNew){
400 printf("RENAME %s %s\n", zOrig, zNew);
401 db_multi_exec(
402 "UPDATE vfile SET pathname='%s' WHERE pathname='%s' AND vid=%d",
403 zNew, zOrig, vid
404 );
405 }
406
--- src/add.c
+++ src/add.c
@@ -116,11 +116,11 @@
116 "INSERT INTO vfile(vid,deleted,rid,mrid,pathname,isexe)"
117 "VALUES(%d,0,0,0,%Q,%d)",
118 vid, zPath, file_isexe(zFullname));
119 fossil_free(zFullname);
120 }
121 fossil_print("ADDED %s\n", zPath);
122 return 1;
123 }
124
125 /*
126 ** Add all files in the sfile temp table.
@@ -215,11 +215,11 @@
215 isDir = file_isdir(zName);
216 if( isDir==1 ){
217 vfile_scan(&fullName, nRoot-1, includeDotFiles, pIgnore);
218 }else if( isDir==0 ){
219 fossil_fatal("not found: %s", zName);
220 }else if( file_access(zName, R_OK) ){
221 fossil_fatal("cannot open %s", zName);
222 }else{
223 char *zTreeName = &zName[nRoot];
224 db_multi_exec(
225 "INSERT OR IGNORE INTO sfile(x)"
@@ -280,11 +280,11 @@
280 blob_reset(&treeName);
281 }
282
283 db_prepare(&loop, "SELECT x FROM sfile");
284 while( db_step(&loop)==SQLITE_ROW ){
285 fossil_print("DELETED %s\n", db_column_text(&loop, 0));
286 }
287 db_finalize(&loop);
288 db_multi_exec(
289 "UPDATE vfile SET deleted=1 WHERE pathname IN sfile;"
290 "DELETE FROM vfile WHERE rid=0 AND deleted;"
@@ -377,17 +377,17 @@
377 zPath = db_column_text(&q, 1);
378 if( !file_isfile(zPath) ){
379 if( !isTest ){
380 db_multi_exec("UPDATE vfile SET deleted=1 WHERE pathname=%Q", zFile);
381 }
382 fossil_print("DELETED %s\n", zFile);
383 nDelete++;
384 }
385 }
386 db_finalize(&q);
387 /* show cmmand summary */
388 fossil_print("added %d files, deleted %d files\n", nAdd, nDelete);
389
390 db_end_transaction(isTest);
391 }
392
393
@@ -395,11 +395,11 @@
395 ** Rename a single file.
396 **
397 ** The original name of the file is zOrig. The new filename is zNew.
398 */
399 static void mv_one_file(int vid, const char *zOrig, const char *zNew){
400 fossil_print("RENAME %s %s\n", zOrig, zNew);
401 db_multi_exec(
402 "UPDATE vfile SET pathname='%s' WHERE pathname='%s' AND vid=%d",
403 zNew, zOrig, vid
404 );
405 }
406
+4 -4
--- src/allrepo.c
+++ src/allrepo.c
@@ -129,22 +129,22 @@
129129
" FROM global_config"
130130
" WHERE substr(name, 1, 5)=='repo:' ORDER BY 1"
131131
);
132132
while( db_step(&q)==SQLITE_ROW ){
133133
const char *zFilename = db_column_text(&q, 0);
134
- if( access(zFilename, 0) ){
134
+ if( file_access(zFilename, 0) ){
135135
nMissing++;
136136
continue;
137137
}
138138
if( !file_is_canonical(zFilename) ) nMissing++;
139139
if( zCmd[0]=='l' ){
140
- printf("%s\n", zFilename);
140
+ fossil_print("%s\n", zFilename);
141141
continue;
142142
}
143143
zQFilename = quoteFilename(zFilename);
144144
zSyscmd = mprintf("%s %s %s", zFossil, zCmd, zQFilename);
145
- printf("%s\n", zSyscmd);
145
+ fossil_print("%s\n", zSyscmd);
146146
fflush(stdout);
147147
rc = fossil_system(zSyscmd);
148148
free(zSyscmd);
149149
free(zQFilename);
150150
if( stopOnError && rc ){
@@ -159,11 +159,11 @@
159159
if( nMissing ){
160160
db_begin_transaction();
161161
db_reset(&q);
162162
while( db_step(&q)==SQLITE_ROW ){
163163
const char *zFilename = db_column_text(&q, 0);
164
- if( access(zFilename, 0) ){
164
+ if( file_access(zFilename, 0) ){
165165
char *zRepo = mprintf("repo:%s", zFilename);
166166
db_unset(zRepo, 1);
167167
free(zRepo);
168168
}else if( !file_is_canonical(zFilename) ){
169169
Blob cname;
170170
--- src/allrepo.c
+++ src/allrepo.c
@@ -129,22 +129,22 @@
129 " FROM global_config"
130 " WHERE substr(name, 1, 5)=='repo:' ORDER BY 1"
131 );
132 while( db_step(&q)==SQLITE_ROW ){
133 const char *zFilename = db_column_text(&q, 0);
134 if( access(zFilename, 0) ){
135 nMissing++;
136 continue;
137 }
138 if( !file_is_canonical(zFilename) ) nMissing++;
139 if( zCmd[0]=='l' ){
140 printf("%s\n", zFilename);
141 continue;
142 }
143 zQFilename = quoteFilename(zFilename);
144 zSyscmd = mprintf("%s %s %s", zFossil, zCmd, zQFilename);
145 printf("%s\n", zSyscmd);
146 fflush(stdout);
147 rc = fossil_system(zSyscmd);
148 free(zSyscmd);
149 free(zQFilename);
150 if( stopOnError && rc ){
@@ -159,11 +159,11 @@
159 if( nMissing ){
160 db_begin_transaction();
161 db_reset(&q);
162 while( db_step(&q)==SQLITE_ROW ){
163 const char *zFilename = db_column_text(&q, 0);
164 if( access(zFilename, 0) ){
165 char *zRepo = mprintf("repo:%s", zFilename);
166 db_unset(zRepo, 1);
167 free(zRepo);
168 }else if( !file_is_canonical(zFilename) ){
169 Blob cname;
170
--- src/allrepo.c
+++ src/allrepo.c
@@ -129,22 +129,22 @@
129 " FROM global_config"
130 " WHERE substr(name, 1, 5)=='repo:' ORDER BY 1"
131 );
132 while( db_step(&q)==SQLITE_ROW ){
133 const char *zFilename = db_column_text(&q, 0);
134 if( file_access(zFilename, 0) ){
135 nMissing++;
136 continue;
137 }
138 if( !file_is_canonical(zFilename) ) nMissing++;
139 if( zCmd[0]=='l' ){
140 fossil_print("%s\n", zFilename);
141 continue;
142 }
143 zQFilename = quoteFilename(zFilename);
144 zSyscmd = mprintf("%s %s %s", zFossil, zCmd, zQFilename);
145 fossil_print("%s\n", zSyscmd);
146 fflush(stdout);
147 rc = fossil_system(zSyscmd);
148 free(zSyscmd);
149 free(zQFilename);
150 if( stopOnError && rc ){
@@ -159,11 +159,11 @@
159 if( nMissing ){
160 db_begin_transaction();
161 db_reset(&q);
162 while( db_step(&q)==SQLITE_ROW ){
163 const char *zFilename = db_column_text(&q, 0);
164 if( file_access(zFilename, 0) ){
165 char *zRepo = mprintf("repo:%s", zFilename);
166 db_unset(zRepo, 1);
167 free(zRepo);
168 }else if( !file_is_canonical(zFilename) ){
169 Blob cname;
170
+8 -8
--- src/bisect.c
+++ src/bisect.c
@@ -184,11 +184,11 @@
184184
}else if( memcmp(zCmd, "options", n)==0 ){
185185
if( g.argc==3 ){
186186
unsigned int i;
187187
for(i=0; i<sizeof(aBisectOption)/sizeof(aBisectOption[0]); i++){
188188
char *z = mprintf("bisect-%s", aBisectOption[i].zName);
189
- printf(" %-15s %-6s ", aBisectOption[i].zName,
189
+ fossil_print(" %-15s %-6s ", aBisectOption[i].zName,
190190
db_lget(z, (char*)aBisectOption[i].zDefault));
191191
fossil_free(z);
192192
comment_print(aBisectOption[i].zDesc, 27, 79);
193193
}
194194
}else if( g.argc==4 || g.argc==5 ){
@@ -198,11 +198,11 @@
198198
if( memcmp(g.argv[3], aBisectOption[i].zName, n)==0 ){
199199
char *z = mprintf("bisect-%s", aBisectOption[i].zName);
200200
if( g.argc==5 ){
201201
db_lset(z, g.argv[4]);
202202
}
203
- printf("%s\n", db_lget(z, (char*)aBisectOption[i].zDefault));
203
+ fossil_print("%s\n", db_lget(z, (char*)aBisectOption[i].zDefault));
204204
fossil_free(z);
205205
break;
206206
}
207207
}
208208
if( i>=sizeof(aBisectOption)/sizeof(aBisectOption[0]) ){
@@ -230,19 +230,19 @@
230230
for(p=path_last(), n=0; p; p=p->pFrom, n++){
231231
const char *z;
232232
db_bind_int(&s, ":rid", p->rid);
233233
if( db_step(&s)==SQLITE_ROW ){
234234
z = db_column_text(&s, 0);
235
- printf("%s", z);
236
- if( p->rid==bisect.good ) printf(" GOOD");
237
- if( p->rid==bisect.bad ) printf(" BAD");
238
- if( p->rid==vid ) printf(" CURRENT");
239
- if( nStep>1 && n==nStep/2 ) printf(" NEXT");
240
- printf("\n");
235
+ fossil_print("%s", z);
236
+ if( p->rid==bisect.good ) fossil_print(" GOOD");
237
+ if( p->rid==bisect.bad ) fossil_print(" BAD");
238
+ if( p->rid==vid ) fossil_print(" CURRENT");
239
+ if( nStep>1 && n==nStep/2 ) fossil_print(" NEXT");
240
+ fossil_print("\n");
241241
}
242242
db_reset(&s);
243243
}
244244
db_finalize(&s);
245245
}else{
246246
usage("bad|good|next|reset|vlist ...");
247247
}
248248
}
249249
--- src/bisect.c
+++ src/bisect.c
@@ -184,11 +184,11 @@
184 }else if( memcmp(zCmd, "options", n)==0 ){
185 if( g.argc==3 ){
186 unsigned int i;
187 for(i=0; i<sizeof(aBisectOption)/sizeof(aBisectOption[0]); i++){
188 char *z = mprintf("bisect-%s", aBisectOption[i].zName);
189 printf(" %-15s %-6s ", aBisectOption[i].zName,
190 db_lget(z, (char*)aBisectOption[i].zDefault));
191 fossil_free(z);
192 comment_print(aBisectOption[i].zDesc, 27, 79);
193 }
194 }else if( g.argc==4 || g.argc==5 ){
@@ -198,11 +198,11 @@
198 if( memcmp(g.argv[3], aBisectOption[i].zName, n)==0 ){
199 char *z = mprintf("bisect-%s", aBisectOption[i].zName);
200 if( g.argc==5 ){
201 db_lset(z, g.argv[4]);
202 }
203 printf("%s\n", db_lget(z, (char*)aBisectOption[i].zDefault));
204 fossil_free(z);
205 break;
206 }
207 }
208 if( i>=sizeof(aBisectOption)/sizeof(aBisectOption[0]) ){
@@ -230,19 +230,19 @@
230 for(p=path_last(), n=0; p; p=p->pFrom, n++){
231 const char *z;
232 db_bind_int(&s, ":rid", p->rid);
233 if( db_step(&s)==SQLITE_ROW ){
234 z = db_column_text(&s, 0);
235 printf("%s", z);
236 if( p->rid==bisect.good ) printf(" GOOD");
237 if( p->rid==bisect.bad ) printf(" BAD");
238 if( p->rid==vid ) printf(" CURRENT");
239 if( nStep>1 && n==nStep/2 ) printf(" NEXT");
240 printf("\n");
241 }
242 db_reset(&s);
243 }
244 db_finalize(&s);
245 }else{
246 usage("bad|good|next|reset|vlist ...");
247 }
248 }
249
--- src/bisect.c
+++ src/bisect.c
@@ -184,11 +184,11 @@
184 }else if( memcmp(zCmd, "options", n)==0 ){
185 if( g.argc==3 ){
186 unsigned int i;
187 for(i=0; i<sizeof(aBisectOption)/sizeof(aBisectOption[0]); i++){
188 char *z = mprintf("bisect-%s", aBisectOption[i].zName);
189 fossil_print(" %-15s %-6s ", aBisectOption[i].zName,
190 db_lget(z, (char*)aBisectOption[i].zDefault));
191 fossil_free(z);
192 comment_print(aBisectOption[i].zDesc, 27, 79);
193 }
194 }else if( g.argc==4 || g.argc==5 ){
@@ -198,11 +198,11 @@
198 if( memcmp(g.argv[3], aBisectOption[i].zName, n)==0 ){
199 char *z = mprintf("bisect-%s", aBisectOption[i].zName);
200 if( g.argc==5 ){
201 db_lset(z, g.argv[4]);
202 }
203 fossil_print("%s\n", db_lget(z, (char*)aBisectOption[i].zDefault));
204 fossil_free(z);
205 break;
206 }
207 }
208 if( i>=sizeof(aBisectOption)/sizeof(aBisectOption[0]) ){
@@ -230,19 +230,19 @@
230 for(p=path_last(), n=0; p; p=p->pFrom, n++){
231 const char *z;
232 db_bind_int(&s, ":rid", p->rid);
233 if( db_step(&s)==SQLITE_ROW ){
234 z = db_column_text(&s, 0);
235 fossil_print("%s", z);
236 if( p->rid==bisect.good ) fossil_print(" GOOD");
237 if( p->rid==bisect.bad ) fossil_print(" BAD");
238 if( p->rid==vid ) fossil_print(" CURRENT");
239 if( nStep>1 && n==nStep/2 ) fossil_print(" NEXT");
240 fossil_print("\n");
241 }
242 db_reset(&s);
243 }
244 db_finalize(&s);
245 }else{
246 usage("bad|good|next|reset|vlist ...");
247 }
248 }
249
+5 -5
--- src/blob.c
+++ src/blob.c
@@ -111,11 +111,11 @@
111111
assert( fossil_isspace((char)i) );
112112
}else{
113113
assert( !fossil_isspace((char)i) );
114114
}
115115
}
116
- printf("All 256 characters OK\n");
116
+ fossil_print("All 256 characters OK\n");
117117
}
118118
119119
/*
120120
** This routine is called if a blob operation fails because we
121121
** have run out of memory.
@@ -690,11 +690,11 @@
690690
}
691691
if( size==0 ){
692692
return 0;
693693
}
694694
blob_resize(pBlob, size);
695
- in = fopen(zFilename, "rb");
695
+ in = fossil_fopen(zFilename, "rb");
696696
if( in==0 ){
697697
fossil_panic("cannot open %s for reading", zFilename);
698698
}
699699
got = fread(blob_buffer(pBlob), 1, size, in);
700700
fclose(in);
@@ -750,11 +750,11 @@
750750
}
751751
#endif
752752
zName[i] = '/';
753753
}
754754
}
755
- out = fopen(zName, "wb");
755
+ out = fossil_fopen(zName, "wb");
756756
if( out==0 ){
757757
fossil_fatal_recursive("unable to open file \"%s\" for writing", zName);
758758
return 0;
759759
}
760760
needToClose = 1;
@@ -761,11 +761,11 @@
761761
if( zName!=zBuf ) free(zName);
762762
}
763763
blob_is_init(pBlob);
764764
wrote = fwrite(blob_buffer(pBlob), 1, blob_size(pBlob), out);
765765
if( needToClose ) fclose(out);
766
- if( wrote!=blob_size(pBlob) ){
766
+ if( wrote!=blob_size(pBlob) && out!=stdout ){
767767
fossil_fatal_recursive("short write: %d of %d bytes to %s", wrote,
768768
blob_size(pBlob), zFilename);
769769
}
770770
return wrote;
771771
}
@@ -925,11 +925,11 @@
925925
}
926926
blob_reset(&b1);
927927
blob_reset(&b2);
928928
blob_reset(&b3);
929929
}
930
- printf("ok\n");
930
+ fossil_print("ok\n");
931931
}
932932
933933
#if defined(_WIN32)
934934
/*
935935
** Convert every \n character in the given blob into \r\n.
936936
--- src/blob.c
+++ src/blob.c
@@ -111,11 +111,11 @@
111 assert( fossil_isspace((char)i) );
112 }else{
113 assert( !fossil_isspace((char)i) );
114 }
115 }
116 printf("All 256 characters OK\n");
117 }
118
119 /*
120 ** This routine is called if a blob operation fails because we
121 ** have run out of memory.
@@ -690,11 +690,11 @@
690 }
691 if( size==0 ){
692 return 0;
693 }
694 blob_resize(pBlob, size);
695 in = fopen(zFilename, "rb");
696 if( in==0 ){
697 fossil_panic("cannot open %s for reading", zFilename);
698 }
699 got = fread(blob_buffer(pBlob), 1, size, in);
700 fclose(in);
@@ -750,11 +750,11 @@
750 }
751 #endif
752 zName[i] = '/';
753 }
754 }
755 out = fopen(zName, "wb");
756 if( out==0 ){
757 fossil_fatal_recursive("unable to open file \"%s\" for writing", zName);
758 return 0;
759 }
760 needToClose = 1;
@@ -761,11 +761,11 @@
761 if( zName!=zBuf ) free(zName);
762 }
763 blob_is_init(pBlob);
764 wrote = fwrite(blob_buffer(pBlob), 1, blob_size(pBlob), out);
765 if( needToClose ) fclose(out);
766 if( wrote!=blob_size(pBlob) ){
767 fossil_fatal_recursive("short write: %d of %d bytes to %s", wrote,
768 blob_size(pBlob), zFilename);
769 }
770 return wrote;
771 }
@@ -925,11 +925,11 @@
925 }
926 blob_reset(&b1);
927 blob_reset(&b2);
928 blob_reset(&b3);
929 }
930 printf("ok\n");
931 }
932
933 #if defined(_WIN32)
934 /*
935 ** Convert every \n character in the given blob into \r\n.
936
--- src/blob.c
+++ src/blob.c
@@ -111,11 +111,11 @@
111 assert( fossil_isspace((char)i) );
112 }else{
113 assert( !fossil_isspace((char)i) );
114 }
115 }
116 fossil_print("All 256 characters OK\n");
117 }
118
119 /*
120 ** This routine is called if a blob operation fails because we
121 ** have run out of memory.
@@ -690,11 +690,11 @@
690 }
691 if( size==0 ){
692 return 0;
693 }
694 blob_resize(pBlob, size);
695 in = fossil_fopen(zFilename, "rb");
696 if( in==0 ){
697 fossil_panic("cannot open %s for reading", zFilename);
698 }
699 got = fread(blob_buffer(pBlob), 1, size, in);
700 fclose(in);
@@ -750,11 +750,11 @@
750 }
751 #endif
752 zName[i] = '/';
753 }
754 }
755 out = fossil_fopen(zName, "wb");
756 if( out==0 ){
757 fossil_fatal_recursive("unable to open file \"%s\" for writing", zName);
758 return 0;
759 }
760 needToClose = 1;
@@ -761,11 +761,11 @@
761 if( zName!=zBuf ) free(zName);
762 }
763 blob_is_init(pBlob);
764 wrote = fwrite(blob_buffer(pBlob), 1, blob_size(pBlob), out);
765 if( needToClose ) fclose(out);
766 if( wrote!=blob_size(pBlob) && out!=stdout ){
767 fossil_fatal_recursive("short write: %d of %d bytes to %s", wrote,
768 blob_size(pBlob), zFilename);
769 }
770 return wrote;
771 }
@@ -925,11 +925,11 @@
925 }
926 blob_reset(&b1);
927 blob_reset(&b2);
928 blob_reset(&b3);
929 }
930 fossil_print("ok\n");
931 }
932
933 #if defined(_WIN32)
934 /*
935 ** Convert every \n character in the given blob into \r\n.
936
+3 -3
--- src/branch.c
+++ src/branch.c
@@ -157,13 +157,13 @@
157157
fossil_panic("unable to install new manifest");
158158
}
159159
assert( blob_is_reset(&branch) );
160160
content_deltify(rootid, brid, 0);
161161
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", brid);
162
- printf("New branch: %s\n", zUuid);
162
+ fossil_print("New branch: %s\n", zUuid);
163163
if( g.argc==3 ){
164
- printf(
164
+ fossil_print(
165165
"\n"
166166
"Note: the local check-out has not been updated to the new\n"
167167
" branch. To begin working on the new branch, do this:\n"
168168
"\n"
169169
" %s update %s\n",
@@ -229,11 +229,11 @@
229229
TAG_BRANCH, leaf_is_closed_sql("tagxref.rid")
230230
);
231231
while( db_step(&q)==SQLITE_ROW ){
232232
const char *zBr = db_column_text(&q, 0);
233233
int isCur = zCurrent!=0 && fossil_strcmp(zCurrent,zBr)==0;
234
- printf("%s%s\n", (isCur ? "* " : " "), zBr);
234
+ fossil_print("%s%s\n", (isCur ? "* " : " "), zBr);
235235
}
236236
db_finalize(&q);
237237
}else{
238238
fossil_panic("branch subcommand should be one of: "
239239
"new list ls");
240240
--- src/branch.c
+++ src/branch.c
@@ -157,13 +157,13 @@
157 fossil_panic("unable to install new manifest");
158 }
159 assert( blob_is_reset(&branch) );
160 content_deltify(rootid, brid, 0);
161 zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", brid);
162 printf("New branch: %s\n", zUuid);
163 if( g.argc==3 ){
164 printf(
165 "\n"
166 "Note: the local check-out has not been updated to the new\n"
167 " branch. To begin working on the new branch, do this:\n"
168 "\n"
169 " %s update %s\n",
@@ -229,11 +229,11 @@
229 TAG_BRANCH, leaf_is_closed_sql("tagxref.rid")
230 );
231 while( db_step(&q)==SQLITE_ROW ){
232 const char *zBr = db_column_text(&q, 0);
233 int isCur = zCurrent!=0 && fossil_strcmp(zCurrent,zBr)==0;
234 printf("%s%s\n", (isCur ? "* " : " "), zBr);
235 }
236 db_finalize(&q);
237 }else{
238 fossil_panic("branch subcommand should be one of: "
239 "new list ls");
240
--- src/branch.c
+++ src/branch.c
@@ -157,13 +157,13 @@
157 fossil_panic("unable to install new manifest");
158 }
159 assert( blob_is_reset(&branch) );
160 content_deltify(rootid, brid, 0);
161 zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", brid);
162 fossil_print("New branch: %s\n", zUuid);
163 if( g.argc==3 ){
164 fossil_print(
165 "\n"
166 "Note: the local check-out has not been updated to the new\n"
167 " branch. To begin working on the new branch, do this:\n"
168 "\n"
169 " %s update %s\n",
@@ -229,11 +229,11 @@
229 TAG_BRANCH, leaf_is_closed_sql("tagxref.rid")
230 );
231 while( db_step(&q)==SQLITE_ROW ){
232 const char *zBr = db_column_text(&q, 0);
233 int isCur = zCurrent!=0 && fossil_strcmp(zCurrent,zBr)==0;
234 fossil_print("%s%s\n", (isCur ? "* " : " "), zBr);
235 }
236 db_finalize(&q);
237 }else{
238 fossil_panic("branch subcommand should be one of: "
239 "new list ls");
240
+1 -1
--- src/captcha.c
+++ src/captcha.c
@@ -392,11 +392,11 @@
392392
for(i=2; i<g.argc; i++){
393393
char zHex[30];
394394
v = (unsigned int)atoi(g.argv[i]);
395395
sqlite3_snprintf(sizeof(zHex), zHex, "%x", v);
396396
z = captcha_render(zHex);
397
- printf("%s:\n%s", zHex, z);
397
+ fossil_print("%s:\n%s", zHex, z);
398398
free(z);
399399
}
400400
}
401401
402402
/*
403403
--- src/captcha.c
+++ src/captcha.c
@@ -392,11 +392,11 @@
392 for(i=2; i<g.argc; i++){
393 char zHex[30];
394 v = (unsigned int)atoi(g.argv[i]);
395 sqlite3_snprintf(sizeof(zHex), zHex, "%x", v);
396 z = captcha_render(zHex);
397 printf("%s:\n%s", zHex, z);
398 free(z);
399 }
400 }
401
402 /*
403
--- src/captcha.c
+++ src/captcha.c
@@ -392,11 +392,11 @@
392 for(i=2; i<g.argc; i++){
393 char zHex[30];
394 v = (unsigned int)atoi(g.argv[i]);
395 sqlite3_snprintf(sizeof(zHex), zHex, "%x", v);
396 z = captcha_render(zHex);
397 fossil_print("%s:\n%s", zHex, z);
398 free(z);
399 }
400 }
401
402 /*
403
+2 -2
--- src/cgi.c
+++ src/cgi.c
@@ -2,11 +2,11 @@
22
** Copyright (c) 2006 D. Richard Hipp
33
**
44
** This program is free software; you can redistribute it and/or
55
** modify it under the terms of the Simplified BSD License (also
66
** known as the "2-Clause License" or "FreeBSD License".)
7
-
7
+**
88
** This program is distributed in the hope that it will be useful,
99
** but without any warranty; without even the implied warranty of
1010
** merchantability or fitness for a particular purpose.
1111
**
1212
** Author contact information:
@@ -1116,11 +1116,11 @@
11161116
}
11171117
}
11181118
if( iPort>mxPort ) return 1;
11191119
listen(listener,10);
11201120
if( iPort>mnPort ){
1121
- printf("Listening for HTTP requests on TCP port %d\n", iPort);
1121
+ fossil_print("Listening for HTTP requests on TCP port %d\n", iPort);
11221122
fflush(stdout);
11231123
}
11241124
if( zBrowser ){
11251125
zBrowser = mprintf(zBrowser, iPort);
11261126
system(zBrowser);
11271127
--- src/cgi.c
+++ src/cgi.c
@@ -2,11 +2,11 @@
2 ** Copyright (c) 2006 D. Richard Hipp
3 **
4 ** This program is free software; you can redistribute it and/or
5 ** modify it under the terms of the Simplified BSD License (also
6 ** known as the "2-Clause License" or "FreeBSD License".)
7
8 ** This program is distributed in the hope that it will be useful,
9 ** but without any warranty; without even the implied warranty of
10 ** merchantability or fitness for a particular purpose.
11 **
12 ** Author contact information:
@@ -1116,11 +1116,11 @@
1116 }
1117 }
1118 if( iPort>mxPort ) return 1;
1119 listen(listener,10);
1120 if( iPort>mnPort ){
1121 printf("Listening for HTTP requests on TCP port %d\n", iPort);
1122 fflush(stdout);
1123 }
1124 if( zBrowser ){
1125 zBrowser = mprintf(zBrowser, iPort);
1126 system(zBrowser);
1127
--- src/cgi.c
+++ src/cgi.c
@@ -2,11 +2,11 @@
2 ** Copyright (c) 2006 D. Richard Hipp
3 **
4 ** This program is free software; you can redistribute it and/or
5 ** modify it under the terms of the Simplified BSD License (also
6 ** known as the "2-Clause License" or "FreeBSD License".)
7 **
8 ** This program is distributed in the hope that it will be useful,
9 ** but without any warranty; without even the implied warranty of
10 ** merchantability or fitness for a particular purpose.
11 **
12 ** Author contact information:
@@ -1116,11 +1116,11 @@
1116 }
1117 }
1118 if( iPort>mxPort ) return 1;
1119 listen(listener,10);
1120 if( iPort>mnPort ){
1121 fossil_print("Listening for HTTP requests on TCP port %d\n", iPort);
1122 fflush(stdout);
1123 }
1124 if( zBrowser ){
1125 zBrowser = mprintf(zBrowser, iPort);
1126 system(zBrowser);
1127
+26 -21
--- src/checkin.c
+++ src/checkin.c
@@ -54,11 +54,11 @@
5454
char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname);
5555
blob_append(report, zPrefix, nPrefix);
5656
if( isDeleted ){
5757
blob_appendf(report, "DELETED %s\n", zPathname);
5858
}else if( !file_isfile(zFullName) ){
59
- if( access(zFullName, 0)==0 ){
59
+ if( file_access(zFullName, 0)==0 ){
6060
blob_appendf(report, "NOT_A_FILE %s\n", zPathname);
6161
if( missingIsFatal ){
6262
fossil_warning("not a file: %s", zPathname);
6363
nErr++;
6464
}
@@ -136,13 +136,13 @@
136136
*/
137137
void status_cmd(void){
138138
int vid;
139139
db_must_be_within_tree();
140140
/* 012345678901234 */
141
- printf("repository: %s\n", db_lget("repository",""));
142
- printf("local-root: %s\n", g.zLocalRoot);
143
- printf("server-code: %s\n", db_get("server-code", ""));
141
+ fossil_print("repository: %s\n", db_lget("repository",""));
142
+ fossil_print("local-root: %s\n", g.zLocalRoot);
143
+ fossil_print("server-code: %s\n", db_get("server-code", ""));
144144
vid = db_lget_int("checkout", 0);
145145
if( vid ){
146146
show_common_info(vid, "checkout:", 1, 1);
147147
}
148148
changes_cmd();
@@ -176,27 +176,27 @@
176176
int isNew = db_column_int(&q,2)==0;
177177
int chnged = db_column_int(&q,3);
178178
int renamed = db_column_int(&q,4);
179179
char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname);
180180
if( isBrief ){
181
- printf("%s\n", zPathname);
181
+ fossil_print("%s\n", zPathname);
182182
}else if( isNew ){
183
- printf("ADDED %s\n", zPathname);
183
+ fossil_print("ADDED %s\n", zPathname);
184184
}else if( isDeleted ){
185
- printf("DELETED %s\n", zPathname);
185
+ fossil_print("DELETED %s\n", zPathname);
186186
}else if( !file_isfile(zFullName) ){
187
- if( access(zFullName, 0)==0 ){
188
- printf("NOT_A_FILE %s\n", zPathname);
187
+ if( file_access(zFullName, 0)==0 ){
188
+ fossil_print("NOT_A_FILE %s\n", zPathname);
189189
}else{
190
- printf("MISSING %s\n", zPathname);
190
+ fossil_print("MISSING %s\n", zPathname);
191191
}
192192
}else if( chnged ){
193
- printf("EDITED %s\n", zPathname);
193
+ fossil_print("EDITED %s\n", zPathname);
194194
}else if( renamed ){
195
- printf("RENAMED %s\n", zPathname);
195
+ fossil_print("RENAMED %s\n", zPathname);
196196
}else{
197
- printf("UNCHANGED %s\n", zPathname);
197
+ fossil_print("UNCHANGED %s\n", zPathname);
198198
}
199199
free(zFullName);
200200
}
201201
db_finalize(&q);
202202
}
@@ -244,11 +244,11 @@
244244
);
245245
if( file_tree_name(g.zRepositoryName, &repo, 0) ){
246246
db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo);
247247
}
248248
while( db_step(&q)==SQLITE_ROW ){
249
- printf("%s\n", db_column_text(&q, 0));
249
+ fossil_print("%s\n", db_column_text(&q, 0));
250250
}
251251
db_finalize(&q);
252252
}
253253
254254
/*
@@ -302,19 +302,19 @@
302302
if( file_tree_name(g.zRepositoryName, &repo, 0) ){
303303
db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo);
304304
}
305305
while( db_step(&q)==SQLITE_ROW ){
306306
if( allFlag ){
307
- unlink(db_column_text(&q, 0));
307
+ file_delete(db_column_text(&q, 0));
308308
}else{
309309
Blob ans;
310310
char *prompt = mprintf("remove unmanaged file \"%s\" (y/N)? ",
311311
db_column_text(&q, 0));
312312
blob_zero(&ans);
313313
prompt_user(prompt, &ans);
314314
if( blob_str(&ans)[0]=='y' ){
315
- unlink(db_column_text(&q, 0));
315
+ file_delete(db_column_text(&q, 0));
316316
}
317317
}
318318
}
319319
db_finalize(&q);
320320
}
@@ -395,26 +395,31 @@
395395
blob_add_cr(&text);
396396
#endif
397397
blob_write_to_file(&text, zFile);
398398
if( zEditor ){
399399
zCmd = mprintf("%s \"%s\"", zEditor, zFile);
400
- printf("%s\n", zCmd);
400
+ fossil_print("%s\n", zCmd);
401401
if( fossil_system(zCmd) ){
402402
fossil_panic("editor aborted");
403403
}
404404
blob_reset(&text);
405405
blob_read_from_file(&text, zFile);
406406
}else{
407407
char zIn[300];
408408
blob_reset(&text);
409409
while( fgets(zIn, sizeof(zIn), stdin)!=0 ){
410
- if( zIn[0]=='.' && (zIn[1]==0 || zIn[1]=='\r' || zIn[1]=='\n') ) break;
410
+ char *zUtf8 = fossil_mbcs_to_utf8(zIn);
411
+ if( zUtf8[0]=='.' && (zUtf8[1]==0 || zUtf8[1]=='\r' || zUtf8[1]=='\n') ){
412
+ fossil_mbcs_free(zUtf8);
413
+ break;
414
+ }
411415
blob_append(&text, zIn, -1);
416
+ fossil_mbcs_free(zUtf8);
412417
}
413418
}
414419
blob_remove_cr(&text);
415
- unlink(zFile);
420
+ file_delete(zFile);
416421
free(zFile);
417422
blob_zero(pComment);
418423
while( blob_line(&text, &line) ){
419424
int i, n;
420425
char *z;
@@ -1084,11 +1089,11 @@
10841089
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nvid);
10851090
manifest_crosslink(nvid, &manifest);
10861091
assert( blob_is_reset(&manifest) );
10871092
content_deltify(vid, nvid, 0);
10881093
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", nvid);
1089
- printf("New_Version: %s\n", zUuid);
1094
+ fossil_print("New_Version: %s\n", zUuid);
10901095
if( outputManifest ){
10911096
zManifestFile = mprintf("%smanifest.uuid", g.zLocalRoot);
10921097
blob_zero(&muuid);
10931098
blob_appendf(&muuid, "%s\n", zUuid);
10941099
blob_write_to_file(&muuid, zManifestFile);
@@ -1153,8 +1158,8 @@
11531158
11541159
if( !g.markPrivate ){
11551160
autosync(AUTOSYNC_PUSH);
11561161
}
11571162
if( count_nonbranch_children(vid)>1 ){
1158
- printf("**** warning: a fork has occurred *****\n");
1163
+ fossil_print("**** warning: a fork has occurred *****\n");
11591164
}
11601165
}
11611166
--- src/checkin.c
+++ src/checkin.c
@@ -54,11 +54,11 @@
54 char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname);
55 blob_append(report, zPrefix, nPrefix);
56 if( isDeleted ){
57 blob_appendf(report, "DELETED %s\n", zPathname);
58 }else if( !file_isfile(zFullName) ){
59 if( access(zFullName, 0)==0 ){
60 blob_appendf(report, "NOT_A_FILE %s\n", zPathname);
61 if( missingIsFatal ){
62 fossil_warning("not a file: %s", zPathname);
63 nErr++;
64 }
@@ -136,13 +136,13 @@
136 */
137 void status_cmd(void){
138 int vid;
139 db_must_be_within_tree();
140 /* 012345678901234 */
141 printf("repository: %s\n", db_lget("repository",""));
142 printf("local-root: %s\n", g.zLocalRoot);
143 printf("server-code: %s\n", db_get("server-code", ""));
144 vid = db_lget_int("checkout", 0);
145 if( vid ){
146 show_common_info(vid, "checkout:", 1, 1);
147 }
148 changes_cmd();
@@ -176,27 +176,27 @@
176 int isNew = db_column_int(&q,2)==0;
177 int chnged = db_column_int(&q,3);
178 int renamed = db_column_int(&q,4);
179 char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname);
180 if( isBrief ){
181 printf("%s\n", zPathname);
182 }else if( isNew ){
183 printf("ADDED %s\n", zPathname);
184 }else if( isDeleted ){
185 printf("DELETED %s\n", zPathname);
186 }else if( !file_isfile(zFullName) ){
187 if( access(zFullName, 0)==0 ){
188 printf("NOT_A_FILE %s\n", zPathname);
189 }else{
190 printf("MISSING %s\n", zPathname);
191 }
192 }else if( chnged ){
193 printf("EDITED %s\n", zPathname);
194 }else if( renamed ){
195 printf("RENAMED %s\n", zPathname);
196 }else{
197 printf("UNCHANGED %s\n", zPathname);
198 }
199 free(zFullName);
200 }
201 db_finalize(&q);
202 }
@@ -244,11 +244,11 @@
244 );
245 if( file_tree_name(g.zRepositoryName, &repo, 0) ){
246 db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo);
247 }
248 while( db_step(&q)==SQLITE_ROW ){
249 printf("%s\n", db_column_text(&q, 0));
250 }
251 db_finalize(&q);
252 }
253
254 /*
@@ -302,19 +302,19 @@
302 if( file_tree_name(g.zRepositoryName, &repo, 0) ){
303 db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo);
304 }
305 while( db_step(&q)==SQLITE_ROW ){
306 if( allFlag ){
307 unlink(db_column_text(&q, 0));
308 }else{
309 Blob ans;
310 char *prompt = mprintf("remove unmanaged file \"%s\" (y/N)? ",
311 db_column_text(&q, 0));
312 blob_zero(&ans);
313 prompt_user(prompt, &ans);
314 if( blob_str(&ans)[0]=='y' ){
315 unlink(db_column_text(&q, 0));
316 }
317 }
318 }
319 db_finalize(&q);
320 }
@@ -395,26 +395,31 @@
395 blob_add_cr(&text);
396 #endif
397 blob_write_to_file(&text, zFile);
398 if( zEditor ){
399 zCmd = mprintf("%s \"%s\"", zEditor, zFile);
400 printf("%s\n", zCmd);
401 if( fossil_system(zCmd) ){
402 fossil_panic("editor aborted");
403 }
404 blob_reset(&text);
405 blob_read_from_file(&text, zFile);
406 }else{
407 char zIn[300];
408 blob_reset(&text);
409 while( fgets(zIn, sizeof(zIn), stdin)!=0 ){
410 if( zIn[0]=='.' && (zIn[1]==0 || zIn[1]=='\r' || zIn[1]=='\n') ) break;
 
 
 
 
411 blob_append(&text, zIn, -1);
 
412 }
413 }
414 blob_remove_cr(&text);
415 unlink(zFile);
416 free(zFile);
417 blob_zero(pComment);
418 while( blob_line(&text, &line) ){
419 int i, n;
420 char *z;
@@ -1084,11 +1089,11 @@
1084 db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nvid);
1085 manifest_crosslink(nvid, &manifest);
1086 assert( blob_is_reset(&manifest) );
1087 content_deltify(vid, nvid, 0);
1088 zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", nvid);
1089 printf("New_Version: %s\n", zUuid);
1090 if( outputManifest ){
1091 zManifestFile = mprintf("%smanifest.uuid", g.zLocalRoot);
1092 blob_zero(&muuid);
1093 blob_appendf(&muuid, "%s\n", zUuid);
1094 blob_write_to_file(&muuid, zManifestFile);
@@ -1153,8 +1158,8 @@
1153
1154 if( !g.markPrivate ){
1155 autosync(AUTOSYNC_PUSH);
1156 }
1157 if( count_nonbranch_children(vid)>1 ){
1158 printf("**** warning: a fork has occurred *****\n");
1159 }
1160 }
1161
--- src/checkin.c
+++ src/checkin.c
@@ -54,11 +54,11 @@
54 char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname);
55 blob_append(report, zPrefix, nPrefix);
56 if( isDeleted ){
57 blob_appendf(report, "DELETED %s\n", zPathname);
58 }else if( !file_isfile(zFullName) ){
59 if( file_access(zFullName, 0)==0 ){
60 blob_appendf(report, "NOT_A_FILE %s\n", zPathname);
61 if( missingIsFatal ){
62 fossil_warning("not a file: %s", zPathname);
63 nErr++;
64 }
@@ -136,13 +136,13 @@
136 */
137 void status_cmd(void){
138 int vid;
139 db_must_be_within_tree();
140 /* 012345678901234 */
141 fossil_print("repository: %s\n", db_lget("repository",""));
142 fossil_print("local-root: %s\n", g.zLocalRoot);
143 fossil_print("server-code: %s\n", db_get("server-code", ""));
144 vid = db_lget_int("checkout", 0);
145 if( vid ){
146 show_common_info(vid, "checkout:", 1, 1);
147 }
148 changes_cmd();
@@ -176,27 +176,27 @@
176 int isNew = db_column_int(&q,2)==0;
177 int chnged = db_column_int(&q,3);
178 int renamed = db_column_int(&q,4);
179 char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname);
180 if( isBrief ){
181 fossil_print("%s\n", zPathname);
182 }else if( isNew ){
183 fossil_print("ADDED %s\n", zPathname);
184 }else if( isDeleted ){
185 fossil_print("DELETED %s\n", zPathname);
186 }else if( !file_isfile(zFullName) ){
187 if( file_access(zFullName, 0)==0 ){
188 fossil_print("NOT_A_FILE %s\n", zPathname);
189 }else{
190 fossil_print("MISSING %s\n", zPathname);
191 }
192 }else if( chnged ){
193 fossil_print("EDITED %s\n", zPathname);
194 }else if( renamed ){
195 fossil_print("RENAMED %s\n", zPathname);
196 }else{
197 fossil_print("UNCHANGED %s\n", zPathname);
198 }
199 free(zFullName);
200 }
201 db_finalize(&q);
202 }
@@ -244,11 +244,11 @@
244 );
245 if( file_tree_name(g.zRepositoryName, &repo, 0) ){
246 db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo);
247 }
248 while( db_step(&q)==SQLITE_ROW ){
249 fossil_print("%s\n", db_column_text(&q, 0));
250 }
251 db_finalize(&q);
252 }
253
254 /*
@@ -302,19 +302,19 @@
302 if( file_tree_name(g.zRepositoryName, &repo, 0) ){
303 db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo);
304 }
305 while( db_step(&q)==SQLITE_ROW ){
306 if( allFlag ){
307 file_delete(db_column_text(&q, 0));
308 }else{
309 Blob ans;
310 char *prompt = mprintf("remove unmanaged file \"%s\" (y/N)? ",
311 db_column_text(&q, 0));
312 blob_zero(&ans);
313 prompt_user(prompt, &ans);
314 if( blob_str(&ans)[0]=='y' ){
315 file_delete(db_column_text(&q, 0));
316 }
317 }
318 }
319 db_finalize(&q);
320 }
@@ -395,26 +395,31 @@
395 blob_add_cr(&text);
396 #endif
397 blob_write_to_file(&text, zFile);
398 if( zEditor ){
399 zCmd = mprintf("%s \"%s\"", zEditor, zFile);
400 fossil_print("%s\n", zCmd);
401 if( fossil_system(zCmd) ){
402 fossil_panic("editor aborted");
403 }
404 blob_reset(&text);
405 blob_read_from_file(&text, zFile);
406 }else{
407 char zIn[300];
408 blob_reset(&text);
409 while( fgets(zIn, sizeof(zIn), stdin)!=0 ){
410 char *zUtf8 = fossil_mbcs_to_utf8(zIn);
411 if( zUtf8[0]=='.' && (zUtf8[1]==0 || zUtf8[1]=='\r' || zUtf8[1]=='\n') ){
412 fossil_mbcs_free(zUtf8);
413 break;
414 }
415 blob_append(&text, zIn, -1);
416 fossil_mbcs_free(zUtf8);
417 }
418 }
419 blob_remove_cr(&text);
420 file_delete(zFile);
421 free(zFile);
422 blob_zero(pComment);
423 while( blob_line(&text, &line) ){
424 int i, n;
425 char *z;
@@ -1084,11 +1089,11 @@
1089 db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nvid);
1090 manifest_crosslink(nvid, &manifest);
1091 assert( blob_is_reset(&manifest) );
1092 content_deltify(vid, nvid, 0);
1093 zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", nvid);
1094 fossil_print("New_Version: %s\n", zUuid);
1095 if( outputManifest ){
1096 zManifestFile = mprintf("%smanifest.uuid", g.zLocalRoot);
1097 blob_zero(&muuid);
1098 blob_appendf(&muuid, "%s\n", zUuid);
1099 blob_write_to_file(&muuid, zManifestFile);
@@ -1153,8 +1158,8 @@
1158
1159 if( !g.markPrivate ){
1160 autosync(AUTOSYNC_PUSH);
1161 }
1162 if( count_nonbranch_children(vid)>1 ){
1163 fossil_print("**** warning: a fork has occurred *****\n");
1164 }
1165 }
1166
+5 -5
--- src/checkout.c
+++ src/checkout.c
@@ -157,16 +157,16 @@
157157
free(zManFile);
158158
blob_reset(&hash);
159159
}else{
160160
if( !db_exists("SELECT 1 FROM vfile WHERE pathname='manifest'") ){
161161
zManFile = mprintf("%smanifest", g.zLocalRoot);
162
- unlink(zManFile);
162
+ file_delete(zManFile);
163163
free(zManFile);
164164
}
165165
if( !db_exists("SELECT 1 FROM vfile WHERE pathname='manifest.uuid'") ){
166166
zManFile = mprintf("%smanifest.uuid", g.zLocalRoot);
167
- unlink(zManFile);
167
+ file_delete(zManFile);
168168
free(zManFile);
169169
}
170170
}
171171
172172
}
@@ -249,14 +249,14 @@
249249
db_multi_exec("DELETE FROM vmerge");
250250
if( !keepFlag && db_get_boolean("repo-cksum",1) ){
251251
vfile_aggregate_checksum_manifest(vid, &cksum1, &cksum1b);
252252
vfile_aggregate_checksum_disk(vid, &cksum2);
253253
if( blob_compare(&cksum1, &cksum2) ){
254
- printf("WARNING: manifest checksum does not agree with disk\n");
254
+ fossil_print("WARNING: manifest checksum does not agree with disk\n");
255255
}
256256
if( blob_size(&cksum1b) && blob_compare(&cksum1, &cksum1b) ){
257
- printf("WARNING: manifest checksum does not agree with manifest\n");
257
+ fossil_print("WARNING: manifest checksum does not agree with manifest\n");
258258
}
259259
}
260260
db_end_transaction(0);
261261
}
262262
@@ -268,11 +268,11 @@
268268
int i;
269269
for(i=0; (zReserved = fossil_reserved_name(i))!=0; i++){
270270
if( manifestOnly==0 || zReserved[0]=='m' ){
271271
char *z;
272272
z = mprintf("%s%s", g.zLocalRoot, zReserved);
273
- unlink(z);
273
+ file_delete(z);
274274
free(z);
275275
}
276276
}
277277
}
278278
279279
--- src/checkout.c
+++ src/checkout.c
@@ -157,16 +157,16 @@
157 free(zManFile);
158 blob_reset(&hash);
159 }else{
160 if( !db_exists("SELECT 1 FROM vfile WHERE pathname='manifest'") ){
161 zManFile = mprintf("%smanifest", g.zLocalRoot);
162 unlink(zManFile);
163 free(zManFile);
164 }
165 if( !db_exists("SELECT 1 FROM vfile WHERE pathname='manifest.uuid'") ){
166 zManFile = mprintf("%smanifest.uuid", g.zLocalRoot);
167 unlink(zManFile);
168 free(zManFile);
169 }
170 }
171
172 }
@@ -249,14 +249,14 @@
249 db_multi_exec("DELETE FROM vmerge");
250 if( !keepFlag && db_get_boolean("repo-cksum",1) ){
251 vfile_aggregate_checksum_manifest(vid, &cksum1, &cksum1b);
252 vfile_aggregate_checksum_disk(vid, &cksum2);
253 if( blob_compare(&cksum1, &cksum2) ){
254 printf("WARNING: manifest checksum does not agree with disk\n");
255 }
256 if( blob_size(&cksum1b) && blob_compare(&cksum1, &cksum1b) ){
257 printf("WARNING: manifest checksum does not agree with manifest\n");
258 }
259 }
260 db_end_transaction(0);
261 }
262
@@ -268,11 +268,11 @@
268 int i;
269 for(i=0; (zReserved = fossil_reserved_name(i))!=0; i++){
270 if( manifestOnly==0 || zReserved[0]=='m' ){
271 char *z;
272 z = mprintf("%s%s", g.zLocalRoot, zReserved);
273 unlink(z);
274 free(z);
275 }
276 }
277 }
278
279
--- src/checkout.c
+++ src/checkout.c
@@ -157,16 +157,16 @@
157 free(zManFile);
158 blob_reset(&hash);
159 }else{
160 if( !db_exists("SELECT 1 FROM vfile WHERE pathname='manifest'") ){
161 zManFile = mprintf("%smanifest", g.zLocalRoot);
162 file_delete(zManFile);
163 free(zManFile);
164 }
165 if( !db_exists("SELECT 1 FROM vfile WHERE pathname='manifest.uuid'") ){
166 zManFile = mprintf("%smanifest.uuid", g.zLocalRoot);
167 file_delete(zManFile);
168 free(zManFile);
169 }
170 }
171
172 }
@@ -249,14 +249,14 @@
249 db_multi_exec("DELETE FROM vmerge");
250 if( !keepFlag && db_get_boolean("repo-cksum",1) ){
251 vfile_aggregate_checksum_manifest(vid, &cksum1, &cksum1b);
252 vfile_aggregate_checksum_disk(vid, &cksum2);
253 if( blob_compare(&cksum1, &cksum2) ){
254 fossil_print("WARNING: manifest checksum does not agree with disk\n");
255 }
256 if( blob_size(&cksum1b) && blob_compare(&cksum1, &cksum1b) ){
257 fossil_print("WARNING: manifest checksum does not agree with manifest\n");
258 }
259 }
260 db_end_transaction(0);
261 }
262
@@ -268,11 +268,11 @@
268 int i;
269 for(i=0; (zReserved = fossil_reserved_name(i))!=0; i++){
270 if( manifestOnly==0 || zReserved[0]=='m' ){
271 char *z;
272 z = mprintf("%s%s", g.zLocalRoot, zReserved);
273 file_delete(z);
274 free(z);
275 }
276 }
277 }
278
279
+2 -2
--- src/clearsign.c
+++ src/clearsign.c
@@ -52,11 +52,11 @@
5252
}else{
5353
if( pOut!=pIn ){
5454
blob_copy(pOut, pIn);
5555
}
5656
}
57
- unlink(zOut);
58
- unlink(zIn);
57
+ file_delete(zOut);
58
+ file_delete(zIn);
5959
free(zOut);
6060
free(zIn);
6161
return rc;
6262
}
6363
--- src/clearsign.c
+++ src/clearsign.c
@@ -52,11 +52,11 @@
52 }else{
53 if( pOut!=pIn ){
54 blob_copy(pOut, pIn);
55 }
56 }
57 unlink(zOut);
58 unlink(zIn);
59 free(zOut);
60 free(zIn);
61 return rc;
62 }
63
--- src/clearsign.c
+++ src/clearsign.c
@@ -52,11 +52,11 @@
52 }else{
53 if( pOut!=pIn ){
54 blob_copy(pOut, pIn);
55 }
56 }
57 file_delete(zOut);
58 file_delete(zIn);
59 free(zOut);
60 free(zIn);
61 return rc;
62 }
63
+6 -6
--- src/clone.c
+++ src/clone.c
@@ -80,11 +80,11 @@
8080
shun_artifacts();
8181
g.zLogin = db_text(0, "SELECT login FROM user WHERE cap LIKE '%%s%%'");
8282
if( g.zLogin==0 ){
8383
db_create_default_users(1,zDefaultUser);
8484
}
85
- printf("Repository cloned into %s\n", g.argv[3]);
85
+ fossil_print("Repository cloned into %s\n", g.argv[3]);
8686
}else{
8787
db_create_repository(g.argv[3]);
8888
db_open_repository(g.argv[3]);
8989
db_begin_transaction();
9090
db_record_repository_filename(g.argv[3]);
@@ -104,19 +104,19 @@
104104
g.xlinkClusterOnly = 0;
105105
verify_cancel();
106106
db_end_transaction(0);
107107
db_close(1);
108108
if( nErr ){
109
- unlink(g.argv[3]);
109
+ file_delete(g.argv[3]);
110110
fossil_fatal("server returned an error - clone aborted");
111111
}
112112
db_open_repository(g.argv[3]);
113113
}
114114
db_begin_transaction();
115
- printf("Rebuilding repository meta-data...\n");
115
+ fossil_print("Rebuilding repository meta-data...\n");
116116
rebuild_db(0, 1, 0);
117
- printf("project-id: %s\n", db_get("project-code", 0));
118
- printf("server-id: %s\n", db_get("server-code", 0));
117
+ fossil_print("project-id: %s\n", db_get("project-code", 0));
118
+ fossil_print("server-id: %s\n", db_get("server-code", 0));
119119
zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin);
120
- printf("admin-user: %s (password is \"%s\")\n", g.zLogin, zPassword);
120
+ fossil_print("admin-user: %s (password is \"%s\")\n", g.zLogin, zPassword);
121121
db_end_transaction(0);
122122
}
123123
--- src/clone.c
+++ src/clone.c
@@ -80,11 +80,11 @@
80 shun_artifacts();
81 g.zLogin = db_text(0, "SELECT login FROM user WHERE cap LIKE '%%s%%'");
82 if( g.zLogin==0 ){
83 db_create_default_users(1,zDefaultUser);
84 }
85 printf("Repository cloned into %s\n", g.argv[3]);
86 }else{
87 db_create_repository(g.argv[3]);
88 db_open_repository(g.argv[3]);
89 db_begin_transaction();
90 db_record_repository_filename(g.argv[3]);
@@ -104,19 +104,19 @@
104 g.xlinkClusterOnly = 0;
105 verify_cancel();
106 db_end_transaction(0);
107 db_close(1);
108 if( nErr ){
109 unlink(g.argv[3]);
110 fossil_fatal("server returned an error - clone aborted");
111 }
112 db_open_repository(g.argv[3]);
113 }
114 db_begin_transaction();
115 printf("Rebuilding repository meta-data...\n");
116 rebuild_db(0, 1, 0);
117 printf("project-id: %s\n", db_get("project-code", 0));
118 printf("server-id: %s\n", db_get("server-code", 0));
119 zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin);
120 printf("admin-user: %s (password is \"%s\")\n", g.zLogin, zPassword);
121 db_end_transaction(0);
122 }
123
--- src/clone.c
+++ src/clone.c
@@ -80,11 +80,11 @@
80 shun_artifacts();
81 g.zLogin = db_text(0, "SELECT login FROM user WHERE cap LIKE '%%s%%'");
82 if( g.zLogin==0 ){
83 db_create_default_users(1,zDefaultUser);
84 }
85 fossil_print("Repository cloned into %s\n", g.argv[3]);
86 }else{
87 db_create_repository(g.argv[3]);
88 db_open_repository(g.argv[3]);
89 db_begin_transaction();
90 db_record_repository_filename(g.argv[3]);
@@ -104,19 +104,19 @@
104 g.xlinkClusterOnly = 0;
105 verify_cancel();
106 db_end_transaction(0);
107 db_close(1);
108 if( nErr ){
109 file_delete(g.argv[3]);
110 fossil_fatal("server returned an error - clone aborted");
111 }
112 db_open_repository(g.argv[3]);
113 }
114 db_begin_transaction();
115 fossil_print("Rebuilding repository meta-data...\n");
116 rebuild_db(0, 1, 0);
117 fossil_print("project-id: %s\n", db_get("project-code", 0));
118 fossil_print("server-id: %s\n", db_get("server-code", 0));
119 zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin);
120 fossil_print("admin-user: %s (password is \"%s\")\n", g.zLogin, zPassword);
121 db_end_transaction(0);
122 }
123
+6 -6
--- src/comformat.c
+++ src/comformat.c
@@ -41,11 +41,11 @@
4141
4242
for(;;){
4343
while( fossil_isspace(zText[0]) ){ zText++; }
4444
if( zText[0]==0 ){
4545
if( doIndent==0 ){
46
- printf("\n");
46
+ fossil_print("\n");
4747
lineCnt = 1;
4848
}
4949
return lineCnt;
5050
}
5151
for(sk=si=i=k=0; zText[i] && k<tlen; i++){
@@ -64,23 +64,23 @@
6464
}
6565
k++;
6666
}
6767
}
6868
if( doIndent ){
69
- printf("%*s", indent, "");
69
+ fossil_print("%*s", indent, "");
7070
}
7171
doIndent = 1;
7272
if( sk>0 && zText[i] ){
7373
zText += si;
7474
zBuf[sk++] = '\n';
7575
zBuf[sk] = 0;
76
- printf("%s", zBuf);
76
+ fossil_print("%s", zBuf);
7777
}else{
7878
zText += i;
7979
zBuf[k++] = '\n';
8080
zBuf[k] = 0;
81
- printf("%s", zBuf);
81
+ fossil_print("%s", zBuf);
8282
}
8383
lineCnt++;
8484
}
8585
}
8686
@@ -93,8 +93,8 @@
9393
int indent;
9494
if( g.argc!=4 ){
9595
usage("PREFIX TEXT");
9696
}
9797
indent = strlen(g.argv[2]) + 1;
98
- printf("%s ", g.argv[2]);
99
- printf("(%d lines output)\n", comment_print(g.argv[3], indent, 79));
98
+ fossil_print("%s ", g.argv[2]);
99
+ fossil_print("(%d lines output)\n", comment_print(g.argv[3], indent, 79));
100100
}
101101
--- src/comformat.c
+++ src/comformat.c
@@ -41,11 +41,11 @@
41
42 for(;;){
43 while( fossil_isspace(zText[0]) ){ zText++; }
44 if( zText[0]==0 ){
45 if( doIndent==0 ){
46 printf("\n");
47 lineCnt = 1;
48 }
49 return lineCnt;
50 }
51 for(sk=si=i=k=0; zText[i] && k<tlen; i++){
@@ -64,23 +64,23 @@
64 }
65 k++;
66 }
67 }
68 if( doIndent ){
69 printf("%*s", indent, "");
70 }
71 doIndent = 1;
72 if( sk>0 && zText[i] ){
73 zText += si;
74 zBuf[sk++] = '\n';
75 zBuf[sk] = 0;
76 printf("%s", zBuf);
77 }else{
78 zText += i;
79 zBuf[k++] = '\n';
80 zBuf[k] = 0;
81 printf("%s", zBuf);
82 }
83 lineCnt++;
84 }
85 }
86
@@ -93,8 +93,8 @@
93 int indent;
94 if( g.argc!=4 ){
95 usage("PREFIX TEXT");
96 }
97 indent = strlen(g.argv[2]) + 1;
98 printf("%s ", g.argv[2]);
99 printf("(%d lines output)\n", comment_print(g.argv[3], indent, 79));
100 }
101
--- src/comformat.c
+++ src/comformat.c
@@ -41,11 +41,11 @@
41
42 for(;;){
43 while( fossil_isspace(zText[0]) ){ zText++; }
44 if( zText[0]==0 ){
45 if( doIndent==0 ){
46 fossil_print("\n");
47 lineCnt = 1;
48 }
49 return lineCnt;
50 }
51 for(sk=si=i=k=0; zText[i] && k<tlen; i++){
@@ -64,23 +64,23 @@
64 }
65 k++;
66 }
67 }
68 if( doIndent ){
69 fossil_print("%*s", indent, "");
70 }
71 doIndent = 1;
72 if( sk>0 && zText[i] ){
73 zText += si;
74 zBuf[sk++] = '\n';
75 zBuf[sk] = 0;
76 fossil_print("%s", zBuf);
77 }else{
78 zText += i;
79 zBuf[k++] = '\n';
80 zBuf[k] = 0;
81 fossil_print("%s", zBuf);
82 }
83 lineCnt++;
84 }
85 }
86
@@ -93,8 +93,8 @@
93 int indent;
94 if( g.argc!=4 ){
95 usage("PREFIX TEXT");
96 }
97 indent = strlen(g.argv[2]) + 1;
98 fossil_print("%s ", g.argv[2]);
99 fossil_print("(%d lines output)\n", comment_print(g.argv[3], indent, 79));
100 }
101
+4 -4
--- src/configure.c
+++ src/configure.c
@@ -688,13 +688,13 @@
688688
if( strncmp(z, &aGroupName[i].zName[1], n)==0 ){
689689
return aGroupName[i].groupMask;
690690
}
691691
}
692692
if( notFoundIsFatal ){
693
- printf("Available configuration areas:\n");
693
+ fossil_print("Available configuration areas:\n");
694694
for(i=0; i<count(aGroupName); i++){
695
- printf(" %-10s %s\n", &aGroupName[i].zName[1], aGroupName[i].zHelp);
695
+ fossil_print(" %-10s %s\n", &aGroupName[i].zName[1], aGroupName[i].zHelp);
696696
}
697697
fossil_fatal("no such configuration area: \"%s\"", z);
698698
}
699699
return 0;
700700
}
@@ -883,14 +883,14 @@
883883
}else if( fossil_strcmp(zName,"@reportfmt")==0 ){
884884
db_multi_exec("DELETE FROM reportfmt");
885885
}
886886
}
887887
db_end_transaction(0);
888
- printf("Configuration reset to factory defaults.\n");
889
- printf("To recover, use: %s %s import %s\n",
888
+ fossil_print("Configuration reset to factory defaults.\n");
889
+ fossil_print("To recover, use: %s %s import %s\n",
890890
fossil_nameofexe(), g.argv[1], zBackup);
891891
}else
892892
{
893893
fossil_fatal("METHOD should be one of:"
894894
" export import merge pull push reset");
895895
}
896896
}
897897
--- src/configure.c
+++ src/configure.c
@@ -688,13 +688,13 @@
688 if( strncmp(z, &aGroupName[i].zName[1], n)==0 ){
689 return aGroupName[i].groupMask;
690 }
691 }
692 if( notFoundIsFatal ){
693 printf("Available configuration areas:\n");
694 for(i=0; i<count(aGroupName); i++){
695 printf(" %-10s %s\n", &aGroupName[i].zName[1], aGroupName[i].zHelp);
696 }
697 fossil_fatal("no such configuration area: \"%s\"", z);
698 }
699 return 0;
700 }
@@ -883,14 +883,14 @@
883 }else if( fossil_strcmp(zName,"@reportfmt")==0 ){
884 db_multi_exec("DELETE FROM reportfmt");
885 }
886 }
887 db_end_transaction(0);
888 printf("Configuration reset to factory defaults.\n");
889 printf("To recover, use: %s %s import %s\n",
890 fossil_nameofexe(), g.argv[1], zBackup);
891 }else
892 {
893 fossil_fatal("METHOD should be one of:"
894 " export import merge pull push reset");
895 }
896 }
897
--- src/configure.c
+++ src/configure.c
@@ -688,13 +688,13 @@
688 if( strncmp(z, &aGroupName[i].zName[1], n)==0 ){
689 return aGroupName[i].groupMask;
690 }
691 }
692 if( notFoundIsFatal ){
693 fossil_print("Available configuration areas:\n");
694 for(i=0; i<count(aGroupName); i++){
695 fossil_print(" %-10s %s\n", &aGroupName[i].zName[1], aGroupName[i].zHelp);
696 }
697 fossil_fatal("no such configuration area: \"%s\"", z);
698 }
699 return 0;
700 }
@@ -883,14 +883,14 @@
883 }else if( fossil_strcmp(zName,"@reportfmt")==0 ){
884 db_multi_exec("DELETE FROM reportfmt");
885 }
886 }
887 db_end_transaction(0);
888 fossil_print("Configuration reset to factory defaults.\n");
889 fossil_print("To recover, use: %s %s import %s\n",
890 fossil_nameofexe(), g.argv[1], zBackup);
891 }else
892 {
893 fossil_fatal("METHOD should be one of:"
894 " export import merge pull push reset");
895 }
896 }
897
+4 -4
--- src/content.c
+++ src/content.c
@@ -670,11 +670,11 @@
670670
if( g.argc!=3 ) usage("FILENAME");
671671
db_must_be_within_tree();
672672
user_select();
673673
blob_read_from_file(&content, g.argv[2]);
674674
rid = content_put(&content);
675
- printf("inserted as record %d\n", rid);
675
+ fossil_print("inserted as record %d\n", rid);
676676
}
677677
678678
/*
679679
** Make sure the content at rid is the original content and is not a
680680
** delta.
@@ -838,14 +838,14 @@
838838
while( db_step(&q)==SQLITE_ROW ){
839839
int rid = db_column_int(&q, 0);
840840
const char *zUuid = db_column_text(&q, 1);
841841
int size = db_column_int(&q, 2);
842842
n1++;
843
- printf(" %d/%d\r", n1, total);
843
+ fossil_print(" %d/%d\r", n1, total);
844844
fflush(stdout);
845845
if( size<0 ){
846
- printf("skip phantom %d %s\n", rid, zUuid);
846
+ fossil_print("skip phantom %d %s\n", rid, zUuid);
847847
continue; /* Ignore phantoms */
848848
}
849849
content_get(rid, &content);
850850
if( blob_size(&content)!=size ){
851851
fossil_warning("size mismatch on blob rid=%d: %d vs %d",
@@ -859,7 +859,7 @@
859859
blob_reset(&cksum);
860860
blob_reset(&content);
861861
n2++;
862862
}
863863
db_finalize(&q);
864
- printf("%d non-phantom blobs (out of %d total) verified\n", n2, n1);
864
+ fossil_print("%d non-phantom blobs (out of %d total) verified\n", n2, n1);
865865
}
866866
--- src/content.c
+++ src/content.c
@@ -670,11 +670,11 @@
670 if( g.argc!=3 ) usage("FILENAME");
671 db_must_be_within_tree();
672 user_select();
673 blob_read_from_file(&content, g.argv[2]);
674 rid = content_put(&content);
675 printf("inserted as record %d\n", rid);
676 }
677
678 /*
679 ** Make sure the content at rid is the original content and is not a
680 ** delta.
@@ -838,14 +838,14 @@
838 while( db_step(&q)==SQLITE_ROW ){
839 int rid = db_column_int(&q, 0);
840 const char *zUuid = db_column_text(&q, 1);
841 int size = db_column_int(&q, 2);
842 n1++;
843 printf(" %d/%d\r", n1, total);
844 fflush(stdout);
845 if( size<0 ){
846 printf("skip phantom %d %s\n", rid, zUuid);
847 continue; /* Ignore phantoms */
848 }
849 content_get(rid, &content);
850 if( blob_size(&content)!=size ){
851 fossil_warning("size mismatch on blob rid=%d: %d vs %d",
@@ -859,7 +859,7 @@
859 blob_reset(&cksum);
860 blob_reset(&content);
861 n2++;
862 }
863 db_finalize(&q);
864 printf("%d non-phantom blobs (out of %d total) verified\n", n2, n1);
865 }
866
--- src/content.c
+++ src/content.c
@@ -670,11 +670,11 @@
670 if( g.argc!=3 ) usage("FILENAME");
671 db_must_be_within_tree();
672 user_select();
673 blob_read_from_file(&content, g.argv[2]);
674 rid = content_put(&content);
675 fossil_print("inserted as record %d\n", rid);
676 }
677
678 /*
679 ** Make sure the content at rid is the original content and is not a
680 ** delta.
@@ -838,14 +838,14 @@
838 while( db_step(&q)==SQLITE_ROW ){
839 int rid = db_column_int(&q, 0);
840 const char *zUuid = db_column_text(&q, 1);
841 int size = db_column_int(&q, 2);
842 n1++;
843 fossil_print(" %d/%d\r", n1, total);
844 fflush(stdout);
845 if( size<0 ){
846 fossil_print("skip phantom %d %s\n", rid, zUuid);
847 continue; /* Ignore phantoms */
848 }
849 content_get(rid, &content);
850 if( blob_size(&content)!=size ){
851 fossil_warning("size mismatch on blob rid=%d: %d vs %d",
@@ -859,7 +859,7 @@
859 blob_reset(&cksum);
860 blob_reset(&content);
861 n2++;
862 }
863 db_finalize(&q);
864 fossil_print("%d non-phantom blobs (out of %d total) verified\n", n2, n1);
865 }
866
+8 -7
--- src/db.c
+++ src/db.c
@@ -166,11 +166,11 @@
166166
nBegin = 0;
167167
}
168168
busy = 0;
169169
db_close(0);
170170
for(i=0; i<nDeleteOnFail; i++){
171
- unlink(azDeleteOnFail[i]);
171
+ file_delete(azDeleteOnFail[i]);
172172
}
173173
}
174174
175175
/*
176176
** Install a commit hook. Hooks are installed in sequence order.
@@ -695,10 +695,11 @@
695695
if( zHome==0 ){
696696
fossil_fatal("cannot locate home directory - "
697697
"please set the LOCALAPPDATA or APPDATA or HOMEPATH "
698698
"environment variables");
699699
}
700
+ zHome = fossil_mbcs_to_utf8(zHome);
700701
#else
701702
zHome = getenv("HOME");
702703
if( zHome==0 ){
703704
fossil_fatal("cannot locate home directory - "
704705
"please set the HOME environment variable");
@@ -740,11 +741,11 @@
740741
static int isValidLocalDb(const char *zDbName){
741742
i64 lsize;
742743
int rc;
743744
sqlite3_stmt *pStmt;
744745
745
- if( access(zDbName, F_OK) ) return 0;
746
+ if( file_access(zDbName, F_OK) ) return 0;
746747
lsize = file_size(zDbName);
747748
if( lsize%1024!=0 || lsize<4096 ) return 0;
748749
db_open_or_attach(zDbName, "localdb");
749750
g.localOpen = 1;
750751
db_open_config(0);
@@ -815,11 +816,11 @@
815816
n = strlen(zPwd);
816817
zPwdConv = mprintf("%/", zPwd);
817818
strncpy(zPwd, zPwdConv, 2000-20);
818819
free(zPwdConv);
819820
while( n>0 ){
820
- if( access(zPwd, W_OK) ) break;
821
+ if( file_access(zPwd, W_OK) ) break;
821822
for(i=0; i<sizeof(aDbName)/sizeof(aDbName[0]); i++){
822823
sqlite3_snprintf(sizeof(zPwd)-n, &zPwd[n], "%s", aDbName[i]);
823824
if( isValidLocalDb(zPwd) ){
824825
/* Found a valid checkout database file */
825826
zPwd[n] = 0;
@@ -853,15 +854,15 @@
853854
}
854855
if( zDbName==0 ){
855856
db_err("unable to find the name of a repository database");
856857
}
857858
}
858
- if( access(zDbName, R_OK) || file_size(zDbName)<1024 ){
859
- if( access(zDbName, 0) ){
859
+ if( file_access(zDbName, R_OK) || file_size(zDbName)<1024 ){
860
+ if( file_access(zDbName, 0) ){
860861
fossil_panic("repository does not exist or"
861862
" is in an unreadable directory: %s", zDbName);
862
- }else if( access(zDbName, R_OK) ){
863
+ }else if( file_access(zDbName, R_OK) ){
863864
fossil_panic("read permission denied for repository %s", zDbName);
864865
}else{
865866
fossil_panic("not a valid repository: %s", zDbName);
866867
}
867868
}
@@ -964,11 +965,11 @@
964965
fossil_fatal("not in a local checkout");
965966
return;
966967
}
967968
file_canonical_name(g.argv[2], &repo);
968969
zRepo = blob_str(&repo);
969
- if( access(zRepo, 0) ){
970
+ if( file_access(zRepo, 0) ){
970971
fossil_fatal("no such file: %s", zRepo);
971972
}
972973
db_open_or_attach(zRepo, "test_repo");
973974
db_lset("repository", blob_str(&repo));
974975
db_close(1);
975976
--- src/db.c
+++ src/db.c
@@ -166,11 +166,11 @@
166 nBegin = 0;
167 }
168 busy = 0;
169 db_close(0);
170 for(i=0; i<nDeleteOnFail; i++){
171 unlink(azDeleteOnFail[i]);
172 }
173 }
174
175 /*
176 ** Install a commit hook. Hooks are installed in sequence order.
@@ -695,10 +695,11 @@
695 if( zHome==0 ){
696 fossil_fatal("cannot locate home directory - "
697 "please set the LOCALAPPDATA or APPDATA or HOMEPATH "
698 "environment variables");
699 }
 
700 #else
701 zHome = getenv("HOME");
702 if( zHome==0 ){
703 fossil_fatal("cannot locate home directory - "
704 "please set the HOME environment variable");
@@ -740,11 +741,11 @@
740 static int isValidLocalDb(const char *zDbName){
741 i64 lsize;
742 int rc;
743 sqlite3_stmt *pStmt;
744
745 if( access(zDbName, F_OK) ) return 0;
746 lsize = file_size(zDbName);
747 if( lsize%1024!=0 || lsize<4096 ) return 0;
748 db_open_or_attach(zDbName, "localdb");
749 g.localOpen = 1;
750 db_open_config(0);
@@ -815,11 +816,11 @@
815 n = strlen(zPwd);
816 zPwdConv = mprintf("%/", zPwd);
817 strncpy(zPwd, zPwdConv, 2000-20);
818 free(zPwdConv);
819 while( n>0 ){
820 if( access(zPwd, W_OK) ) break;
821 for(i=0; i<sizeof(aDbName)/sizeof(aDbName[0]); i++){
822 sqlite3_snprintf(sizeof(zPwd)-n, &zPwd[n], "%s", aDbName[i]);
823 if( isValidLocalDb(zPwd) ){
824 /* Found a valid checkout database file */
825 zPwd[n] = 0;
@@ -853,15 +854,15 @@
853 }
854 if( zDbName==0 ){
855 db_err("unable to find the name of a repository database");
856 }
857 }
858 if( access(zDbName, R_OK) || file_size(zDbName)<1024 ){
859 if( access(zDbName, 0) ){
860 fossil_panic("repository does not exist or"
861 " is in an unreadable directory: %s", zDbName);
862 }else if( access(zDbName, R_OK) ){
863 fossil_panic("read permission denied for repository %s", zDbName);
864 }else{
865 fossil_panic("not a valid repository: %s", zDbName);
866 }
867 }
@@ -964,11 +965,11 @@
964 fossil_fatal("not in a local checkout");
965 return;
966 }
967 file_canonical_name(g.argv[2], &repo);
968 zRepo = blob_str(&repo);
969 if( access(zRepo, 0) ){
970 fossil_fatal("no such file: %s", zRepo);
971 }
972 db_open_or_attach(zRepo, "test_repo");
973 db_lset("repository", blob_str(&repo));
974 db_close(1);
975
--- src/db.c
+++ src/db.c
@@ -166,11 +166,11 @@
166 nBegin = 0;
167 }
168 busy = 0;
169 db_close(0);
170 for(i=0; i<nDeleteOnFail; i++){
171 file_delete(azDeleteOnFail[i]);
172 }
173 }
174
175 /*
176 ** Install a commit hook. Hooks are installed in sequence order.
@@ -695,10 +695,11 @@
695 if( zHome==0 ){
696 fossil_fatal("cannot locate home directory - "
697 "please set the LOCALAPPDATA or APPDATA or HOMEPATH "
698 "environment variables");
699 }
700 zHome = fossil_mbcs_to_utf8(zHome);
701 #else
702 zHome = getenv("HOME");
703 if( zHome==0 ){
704 fossil_fatal("cannot locate home directory - "
705 "please set the HOME environment variable");
@@ -740,11 +741,11 @@
741 static int isValidLocalDb(const char *zDbName){
742 i64 lsize;
743 int rc;
744 sqlite3_stmt *pStmt;
745
746 if( file_access(zDbName, F_OK) ) return 0;
747 lsize = file_size(zDbName);
748 if( lsize%1024!=0 || lsize<4096 ) return 0;
749 db_open_or_attach(zDbName, "localdb");
750 g.localOpen = 1;
751 db_open_config(0);
@@ -815,11 +816,11 @@
816 n = strlen(zPwd);
817 zPwdConv = mprintf("%/", zPwd);
818 strncpy(zPwd, zPwdConv, 2000-20);
819 free(zPwdConv);
820 while( n>0 ){
821 if( file_access(zPwd, W_OK) ) break;
822 for(i=0; i<sizeof(aDbName)/sizeof(aDbName[0]); i++){
823 sqlite3_snprintf(sizeof(zPwd)-n, &zPwd[n], "%s", aDbName[i]);
824 if( isValidLocalDb(zPwd) ){
825 /* Found a valid checkout database file */
826 zPwd[n] = 0;
@@ -853,15 +854,15 @@
854 }
855 if( zDbName==0 ){
856 db_err("unable to find the name of a repository database");
857 }
858 }
859 if( file_access(zDbName, R_OK) || file_size(zDbName)<1024 ){
860 if( file_access(zDbName, 0) ){
861 fossil_panic("repository does not exist or"
862 " is in an unreadable directory: %s", zDbName);
863 }else if( file_access(zDbName, R_OK) ){
864 fossil_panic("read permission denied for repository %s", zDbName);
865 }else{
866 fossil_panic("not a valid repository: %s", zDbName);
867 }
868 }
@@ -964,11 +965,11 @@
965 fossil_fatal("not in a local checkout");
966 return;
967 }
968 file_canonical_name(g.argv[2], &repo);
969 zRepo = blob_str(&repo);
970 if( file_access(zRepo, 0) ){
971 fossil_fatal("no such file: %s", zRepo);
972 }
973 db_open_or_attach(zRepo, "test_repo");
974 db_lset("repository", blob_str(&repo));
975 db_close(1);
976
+7 -13
--- src/deltacmd.c
+++ src/deltacmd.c
@@ -52,21 +52,18 @@
5252
Blob orig, target, delta;
5353
if( g.argc!=5 ){
5454
usage("ORIGIN TARGET DELTA");
5555
}
5656
if( blob_read_from_file(&orig, g.argv[2])<0 ){
57
- fprintf(stderr,"cannot read %s\n", g.argv[2]);
58
- fossil_exit(1);
57
+ fossil_fatal("cannot read %s\n", g.argv[2]);
5958
}
6059
if( blob_read_from_file(&target, g.argv[3])<0 ){
61
- fprintf(stderr,"cannot read %s\n", g.argv[3]);
62
- fossil_exit(1);
60
+ fossil_fatal("cannot read %s\n", g.argv[3]);
6361
}
6462
blob_delta_create(&orig, &target, &delta);
6563
if( blob_write_to_file(&delta, g.argv[4])<blob_size(&delta) ){
66
- fprintf(stderr,"cannot write %s\n", g.argv[4]);
67
- fossil_exit(1);
64
+ fossil_fatal("cannot write %s\n", g.argv[4]);
6865
}
6966
blob_reset(&orig);
7067
blob_reset(&target);
7168
blob_reset(&delta);
7269
}
@@ -114,21 +111,18 @@
114111
Blob orig, target, delta;
115112
if( g.argc!=5 ){
116113
usage("ORIGIN DELTA TARGET");
117114
}
118115
if( blob_read_from_file(&orig, g.argv[2])<0 ){
119
- fprintf(stderr,"cannot read %s\n", g.argv[2]);
120
- fossil_exit(1);
116
+ fossil_fatal("cannot read %s\n", g.argv[2]);
121117
}
122118
if( blob_read_from_file(&delta, g.argv[3])<0 ){
123
- fprintf(stderr,"cannot read %s\n", g.argv[3]);
124
- fossil_exit(1);
119
+ fossil_fatal("cannot read %s\n", g.argv[3]);
125120
}
126121
blob_delta_apply(&orig, &delta, &target);
127122
if( blob_write_to_file(&target, g.argv[4])<blob_size(&target) ){
128
- fprintf(stderr,"cannot write %s\n", g.argv[4]);
129
- fossil_exit(1);
123
+ fossil_fatal("cannot write %s\n", g.argv[4]);
130124
}
131125
blob_reset(&orig);
132126
blob_reset(&target);
133127
blob_reset(&delta);
134128
}
@@ -152,7 +146,7 @@
152146
blob_delta_apply(&f1, &d12, &a2);
153147
blob_delta_apply(&f2, &d21, &a1);
154148
if( blob_compare(&f1,&a1) || blob_compare(&f2, &a2) ){
155149
fossil_panic("delta test failed");
156150
}
157
- printf("ok\n");
151
+ fossil_print("ok\n");
158152
}
159153
--- src/deltacmd.c
+++ src/deltacmd.c
@@ -52,21 +52,18 @@
52 Blob orig, target, delta;
53 if( g.argc!=5 ){
54 usage("ORIGIN TARGET DELTA");
55 }
56 if( blob_read_from_file(&orig, g.argv[2])<0 ){
57 fprintf(stderr,"cannot read %s\n", g.argv[2]);
58 fossil_exit(1);
59 }
60 if( blob_read_from_file(&target, g.argv[3])<0 ){
61 fprintf(stderr,"cannot read %s\n", g.argv[3]);
62 fossil_exit(1);
63 }
64 blob_delta_create(&orig, &target, &delta);
65 if( blob_write_to_file(&delta, g.argv[4])<blob_size(&delta) ){
66 fprintf(stderr,"cannot write %s\n", g.argv[4]);
67 fossil_exit(1);
68 }
69 blob_reset(&orig);
70 blob_reset(&target);
71 blob_reset(&delta);
72 }
@@ -114,21 +111,18 @@
114 Blob orig, target, delta;
115 if( g.argc!=5 ){
116 usage("ORIGIN DELTA TARGET");
117 }
118 if( blob_read_from_file(&orig, g.argv[2])<0 ){
119 fprintf(stderr,"cannot read %s\n", g.argv[2]);
120 fossil_exit(1);
121 }
122 if( blob_read_from_file(&delta, g.argv[3])<0 ){
123 fprintf(stderr,"cannot read %s\n", g.argv[3]);
124 fossil_exit(1);
125 }
126 blob_delta_apply(&orig, &delta, &target);
127 if( blob_write_to_file(&target, g.argv[4])<blob_size(&target) ){
128 fprintf(stderr,"cannot write %s\n", g.argv[4]);
129 fossil_exit(1);
130 }
131 blob_reset(&orig);
132 blob_reset(&target);
133 blob_reset(&delta);
134 }
@@ -152,7 +146,7 @@
152 blob_delta_apply(&f1, &d12, &a2);
153 blob_delta_apply(&f2, &d21, &a1);
154 if( blob_compare(&f1,&a1) || blob_compare(&f2, &a2) ){
155 fossil_panic("delta test failed");
156 }
157 printf("ok\n");
158 }
159
--- src/deltacmd.c
+++ src/deltacmd.c
@@ -52,21 +52,18 @@
52 Blob orig, target, delta;
53 if( g.argc!=5 ){
54 usage("ORIGIN TARGET DELTA");
55 }
56 if( blob_read_from_file(&orig, g.argv[2])<0 ){
57 fossil_fatal("cannot read %s\n", g.argv[2]);
 
58 }
59 if( blob_read_from_file(&target, g.argv[3])<0 ){
60 fossil_fatal("cannot read %s\n", g.argv[3]);
 
61 }
62 blob_delta_create(&orig, &target, &delta);
63 if( blob_write_to_file(&delta, g.argv[4])<blob_size(&delta) ){
64 fossil_fatal("cannot write %s\n", g.argv[4]);
 
65 }
66 blob_reset(&orig);
67 blob_reset(&target);
68 blob_reset(&delta);
69 }
@@ -114,21 +111,18 @@
111 Blob orig, target, delta;
112 if( g.argc!=5 ){
113 usage("ORIGIN DELTA TARGET");
114 }
115 if( blob_read_from_file(&orig, g.argv[2])<0 ){
116 fossil_fatal("cannot read %s\n", g.argv[2]);
 
117 }
118 if( blob_read_from_file(&delta, g.argv[3])<0 ){
119 fossil_fatal("cannot read %s\n", g.argv[3]);
 
120 }
121 blob_delta_apply(&orig, &delta, &target);
122 if( blob_write_to_file(&target, g.argv[4])<blob_size(&target) ){
123 fossil_fatal("cannot write %s\n", g.argv[4]);
 
124 }
125 blob_reset(&orig);
126 blob_reset(&target);
127 blob_reset(&delta);
128 }
@@ -152,7 +146,7 @@
146 blob_delta_apply(&f1, &d12, &a2);
147 blob_delta_apply(&f2, &d21, &a1);
148 if( blob_compare(&f1,&a1) || blob_compare(&f2, &a2) ){
149 fossil_panic("delta test failed");
150 }
151 fossil_print("ok\n");
152 }
153
+5 -4
--- src/diff.c
+++ src/diff.c
@@ -590,15 +590,15 @@
590590
int i;
591591
int *R;
592592
if( g.argc<4 ) usage("FILE1 FILE2 ...");
593593
blob_read_from_file(&a, g.argv[2]);
594594
for(i=3; i<g.argc; i++){
595
- if( i>3 ) printf("-------------------------------\n");
595
+ if( i>3 ) fossil_print("-------------------------------\n");
596596
blob_read_from_file(&b, g.argv[i]);
597597
R = text_diff(&a, &b, 0, 0, 0);
598598
for(r=0; R[r] || R[r+1] || R[r+2]; r += 3){
599
- printf(" copy %4d delete %4d insert %4d\n", R[r], R[r+1], R[r+2]);
599
+ fossil_print(" copy %4d delete %4d insert %4d\n", R[r], R[r+1], R[r+2]);
600600
}
601601
/* free(R); */
602602
blob_reset(&b);
603603
}
604604
}
@@ -743,11 +743,11 @@
743743
}
744744
}
745745
for(i=0; i<x.nOrig; i++){
746746
const char *zSrc = x.aOrig[i].zSrc;
747747
if( zSrc==0 ) zSrc = g.argv[g.argc-1];
748
- printf("%10s: %.*s\n", zSrc, x.aOrig[i].n, x.aOrig[i].z);
748
+ fossil_print("%10s: %.*s\n", zSrc, x.aOrig[i].n, x.aOrig[i].z);
749749
}
750750
}
751751
752752
/* Annotation flags */
753753
#define ANN_FILE_VERS 0x001 /* Show file version rather than commit version */
@@ -926,8 +926,9 @@
926926
printf("version %3d: %s\n", i+1, ann.azVers[i]);
927927
}
928928
printf("---------------------------------------------------\n");
929929
}
930930
for(i=0; i<ann.nOrig; i++){
931
- printf("%s: %.*s\n", ann.aOrig[i].zSrc, ann.aOrig[i].n, ann.aOrig[i].z);
931
+ fossil_print("%s: %.*s\n",
932
+ ann.aOrig[i].zSrc, ann.aOrig[i].n, ann.aOrig[i].z);
932933
}
933934
}
934935
--- src/diff.c
+++ src/diff.c
@@ -590,15 +590,15 @@
590 int i;
591 int *R;
592 if( g.argc<4 ) usage("FILE1 FILE2 ...");
593 blob_read_from_file(&a, g.argv[2]);
594 for(i=3; i<g.argc; i++){
595 if( i>3 ) printf("-------------------------------\n");
596 blob_read_from_file(&b, g.argv[i]);
597 R = text_diff(&a, &b, 0, 0, 0);
598 for(r=0; R[r] || R[r+1] || R[r+2]; r += 3){
599 printf(" copy %4d delete %4d insert %4d\n", R[r], R[r+1], R[r+2]);
600 }
601 /* free(R); */
602 blob_reset(&b);
603 }
604 }
@@ -743,11 +743,11 @@
743 }
744 }
745 for(i=0; i<x.nOrig; i++){
746 const char *zSrc = x.aOrig[i].zSrc;
747 if( zSrc==0 ) zSrc = g.argv[g.argc-1];
748 printf("%10s: %.*s\n", zSrc, x.aOrig[i].n, x.aOrig[i].z);
749 }
750 }
751
752 /* Annotation flags */
753 #define ANN_FILE_VERS 0x001 /* Show file version rather than commit version */
@@ -926,8 +926,9 @@
926 printf("version %3d: %s\n", i+1, ann.azVers[i]);
927 }
928 printf("---------------------------------------------------\n");
929 }
930 for(i=0; i<ann.nOrig; i++){
931 printf("%s: %.*s\n", ann.aOrig[i].zSrc, ann.aOrig[i].n, ann.aOrig[i].z);
 
932 }
933 }
934
--- src/diff.c
+++ src/diff.c
@@ -590,15 +590,15 @@
590 int i;
591 int *R;
592 if( g.argc<4 ) usage("FILE1 FILE2 ...");
593 blob_read_from_file(&a, g.argv[2]);
594 for(i=3; i<g.argc; i++){
595 if( i>3 ) fossil_print("-------------------------------\n");
596 blob_read_from_file(&b, g.argv[i]);
597 R = text_diff(&a, &b, 0, 0, 0);
598 for(r=0; R[r] || R[r+1] || R[r+2]; r += 3){
599 fossil_print(" copy %4d delete %4d insert %4d\n", R[r], R[r+1], R[r+2]);
600 }
601 /* free(R); */
602 blob_reset(&b);
603 }
604 }
@@ -743,11 +743,11 @@
743 }
744 }
745 for(i=0; i<x.nOrig; i++){
746 const char *zSrc = x.aOrig[i].zSrc;
747 if( zSrc==0 ) zSrc = g.argv[g.argc-1];
748 fossil_print("%10s: %.*s\n", zSrc, x.aOrig[i].n, x.aOrig[i].z);
749 }
750 }
751
752 /* Annotation flags */
753 #define ANN_FILE_VERS 0x001 /* Show file version rather than commit version */
@@ -926,8 +926,9 @@
926 printf("version %3d: %s\n", i+1, ann.azVers[i]);
927 }
928 printf("---------------------------------------------------\n");
929 }
930 for(i=0; i<ann.nOrig; i++){
931 fossil_print("%s: %.*s\n",
932 ann.aOrig[i].zSrc, ann.aOrig[i].n, ann.aOrig[i].z);
933 }
934 }
935
+5 -5
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -100,11 +100,11 @@
100100
** zFile2 */
101101
blob_zero(&nameFile1);
102102
do{
103103
blob_reset(&nameFile1);
104104
blob_appendf(&nameFile1, "%s~%d", zFile2, cnt++);
105
- }while( access(blob_str(&nameFile1),0)==0 );
105
+ }while( file_access(blob_str(&nameFile1),0)==0 );
106106
blob_write_to_file(pFile1, blob_str(&nameFile1));
107107
108108
/* Construct the external diff command */
109109
blob_zero(&cmd);
110110
blob_appendf(&cmd, "%s ", zDiffCmd);
@@ -114,11 +114,11 @@
114114
115115
/* Run the external diff command */
116116
fossil_system(blob_str(&cmd));
117117
118118
/* Delete the temporary file and clean up memory used */
119
- unlink(blob_str(&nameFile1));
119
+ file_delete(blob_str(&nameFile1));
120120
blob_reset(&nameFile1);
121121
blob_reset(&cmd);
122122
}
123123
}
124124
@@ -168,12 +168,12 @@
168168
169169
/* Run the external diff command */
170170
fossil_system(blob_str(&cmd));
171171
172172
/* Delete the temporary file and clean up memory used */
173
- unlink(zTemp1);
174
- unlink(zTemp2);
173
+ file_delete(zTemp1);
174
+ file_delete(zTemp2);
175175
blob_reset(&cmd);
176176
}
177177
}
178178
179179
/*
@@ -263,11 +263,11 @@
263263
char *zToFree = zFullName;
264264
int showDiff = 1;
265265
if( isDeleted ){
266266
diff_printf("DELETED %s\n", zPathname);
267267
if( !asNewFile ){ showDiff = 0; zFullName = "/dev/null"; }
268
- }else if( access(zFullName, 0) ){
268
+ }else if( file_access(zFullName, 0) ){
269269
diff_printf("MISSING %s\n", zPathname);
270270
if( !asNewFile ){ showDiff = 0; }
271271
}else if( isNew ){
272272
diff_printf("ADDED %s\n", zPathname);
273273
srcid = 0;
274274
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -100,11 +100,11 @@
100 ** zFile2 */
101 blob_zero(&nameFile1);
102 do{
103 blob_reset(&nameFile1);
104 blob_appendf(&nameFile1, "%s~%d", zFile2, cnt++);
105 }while( access(blob_str(&nameFile1),0)==0 );
106 blob_write_to_file(pFile1, blob_str(&nameFile1));
107
108 /* Construct the external diff command */
109 blob_zero(&cmd);
110 blob_appendf(&cmd, "%s ", zDiffCmd);
@@ -114,11 +114,11 @@
114
115 /* Run the external diff command */
116 fossil_system(blob_str(&cmd));
117
118 /* Delete the temporary file and clean up memory used */
119 unlink(blob_str(&nameFile1));
120 blob_reset(&nameFile1);
121 blob_reset(&cmd);
122 }
123 }
124
@@ -168,12 +168,12 @@
168
169 /* Run the external diff command */
170 fossil_system(blob_str(&cmd));
171
172 /* Delete the temporary file and clean up memory used */
173 unlink(zTemp1);
174 unlink(zTemp2);
175 blob_reset(&cmd);
176 }
177 }
178
179 /*
@@ -263,11 +263,11 @@
263 char *zToFree = zFullName;
264 int showDiff = 1;
265 if( isDeleted ){
266 diff_printf("DELETED %s\n", zPathname);
267 if( !asNewFile ){ showDiff = 0; zFullName = "/dev/null"; }
268 }else if( access(zFullName, 0) ){
269 diff_printf("MISSING %s\n", zPathname);
270 if( !asNewFile ){ showDiff = 0; }
271 }else if( isNew ){
272 diff_printf("ADDED %s\n", zPathname);
273 srcid = 0;
274
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -100,11 +100,11 @@
100 ** zFile2 */
101 blob_zero(&nameFile1);
102 do{
103 blob_reset(&nameFile1);
104 blob_appendf(&nameFile1, "%s~%d", zFile2, cnt++);
105 }while( file_access(blob_str(&nameFile1),0)==0 );
106 blob_write_to_file(pFile1, blob_str(&nameFile1));
107
108 /* Construct the external diff command */
109 blob_zero(&cmd);
110 blob_appendf(&cmd, "%s ", zDiffCmd);
@@ -114,11 +114,11 @@
114
115 /* Run the external diff command */
116 fossil_system(blob_str(&cmd));
117
118 /* Delete the temporary file and clean up memory used */
119 file_delete(blob_str(&nameFile1));
120 blob_reset(&nameFile1);
121 blob_reset(&cmd);
122 }
123 }
124
@@ -168,12 +168,12 @@
168
169 /* Run the external diff command */
170 fossil_system(blob_str(&cmd));
171
172 /* Delete the temporary file and clean up memory used */
173 file_delete(zTemp1);
174 file_delete(zTemp2);
175 blob_reset(&cmd);
176 }
177 }
178
179 /*
@@ -263,11 +263,11 @@
263 char *zToFree = zFullName;
264 int showDiff = 1;
265 if( isDeleted ){
266 diff_printf("DELETED %s\n", zPathname);
267 if( !asNewFile ){ showDiff = 0; zFullName = "/dev/null"; }
268 }else if( file_access(zFullName, 0) ){
269 diff_printf("MISSING %s\n", zPathname);
270 if( !asNewFile ){ showDiff = 0; }
271 }else if( isNew ){
272 diff_printf("ADDED %s\n", zPathname);
273 srcid = 0;
274
+4 -4
--- src/encode.c
+++ src/encode.c
@@ -340,11 +340,11 @@
340340
void test_encode64_cmd(void){
341341
char *z;
342342
int i;
343343
for(i=2; i<g.argc; i++){
344344
z = encode64(g.argv[i], -1);
345
- printf("%s\n", z);
345
+ fossil_print("%s\n", z);
346346
free(z);
347347
}
348348
}
349349
350350
@@ -405,11 +405,11 @@
405405
void test_decode64_cmd(void){
406406
char *z;
407407
int i, n;
408408
for(i=2; i<g.argc; i++){
409409
z = decode64(g.argv[i], &n);
410
- printf("%d: %s\n", n, z);
410
+ fossil_print("%d: %s\n", n, z);
411411
free(z);
412412
}
413413
}
414414
415415
/*
@@ -579,13 +579,13 @@
579579
int i;
580580
char *z, *z2;
581581
for(i=2; i<g.argc; i++){
582582
z = obscure(g.argv[i]);
583583
z2 = unobscure(z);
584
- printf("OBSCURE: %s -> %s (%s)\n", g.argv[i], z, z2);
584
+ fossil_print("OBSCURE: %s -> %s (%s)\n", g.argv[i], z, z2);
585585
free(z);
586586
free(z2);
587587
z = unobscure(g.argv[i]);
588
- printf("UNOBSCURE: %s -> %s\n", g.argv[i], z);
588
+ fossil_print("UNOBSCURE: %s -> %s\n", g.argv[i], z);
589589
free(z);
590590
}
591591
}
592592
--- src/encode.c
+++ src/encode.c
@@ -340,11 +340,11 @@
340 void test_encode64_cmd(void){
341 char *z;
342 int i;
343 for(i=2; i<g.argc; i++){
344 z = encode64(g.argv[i], -1);
345 printf("%s\n", z);
346 free(z);
347 }
348 }
349
350
@@ -405,11 +405,11 @@
405 void test_decode64_cmd(void){
406 char *z;
407 int i, n;
408 for(i=2; i<g.argc; i++){
409 z = decode64(g.argv[i], &n);
410 printf("%d: %s\n", n, z);
411 free(z);
412 }
413 }
414
415 /*
@@ -579,13 +579,13 @@
579 int i;
580 char *z, *z2;
581 for(i=2; i<g.argc; i++){
582 z = obscure(g.argv[i]);
583 z2 = unobscure(z);
584 printf("OBSCURE: %s -> %s (%s)\n", g.argv[i], z, z2);
585 free(z);
586 free(z2);
587 z = unobscure(g.argv[i]);
588 printf("UNOBSCURE: %s -> %s\n", g.argv[i], z);
589 free(z);
590 }
591 }
592
--- src/encode.c
+++ src/encode.c
@@ -340,11 +340,11 @@
340 void test_encode64_cmd(void){
341 char *z;
342 int i;
343 for(i=2; i<g.argc; i++){
344 z = encode64(g.argv[i], -1);
345 fossil_print("%s\n", z);
346 free(z);
347 }
348 }
349
350
@@ -405,11 +405,11 @@
405 void test_decode64_cmd(void){
406 char *z;
407 int i, n;
408 for(i=2; i<g.argc; i++){
409 z = decode64(g.argv[i], &n);
410 fossil_print("%d: %s\n", n, z);
411 free(z);
412 }
413 }
414
415 /*
@@ -579,13 +579,13 @@
579 int i;
580 char *z, *z2;
581 for(i=2; i<g.argc; i++){
582 z = obscure(g.argv[i]);
583 z2 = unobscure(z);
584 fossil_print("OBSCURE: %s -> %s (%s)\n", g.argv[i], z, z2);
585 free(z);
586 free(z2);
587 z = unobscure(g.argv[i]);
588 fossil_print("UNOBSCURE: %s -> %s\n", g.argv[i], z);
589 free(z);
590 }
591 }
592
+145 -24
--- src/file.c
+++ src/file.c
@@ -47,17 +47,19 @@
4747
static int getStat(const char *zFilename){
4848
int rc = 0;
4949
if( zFilename==0 ){
5050
if( fileStatValid==0 ) rc = 1;
5151
}else{
52
- if( stat(zFilename, &fileStat)!=0 ){
52
+ char *zMbcs = fossil_utf8_to_mbcs(zFilename);
53
+ if( stat(zMbcs, &fileStat)!=0 ){
5354
fileStatValid = 0;
5455
rc = 1;
5556
}else{
5657
fileStatValid = 1;
5758
rc = 0;
5859
}
60
+ fossil_mbcs_free(zMbcs);
5961
}
6062
return rc;
6163
}
6264
6365
@@ -120,10 +122,20 @@
120122
}else{
121123
rc = getStat(0);
122124
}
123125
return rc ? 0 : (S_ISDIR(fileStat.st_mode) ? 1 : 2);
124126
}
127
+
128
+/*
129
+** Wrapper around the access() system call.
130
+*/
131
+int file_access(const char *zFilename, int flags){
132
+ char *zMbcs = fossil_utf8_to_mbcs(zFilename);
133
+ int rc = access(zMbcs, flags);
134
+ fossil_mbcs_free(zMbcs);
135
+ return rc;
136
+}
125137
126138
/*
127139
** Find an unused filename similar to zBase with zSuffix appended.
128140
**
129141
** Make the name relative to the working directory if relFlag is true.
@@ -166,13 +178,13 @@
166178
*/
167179
void file_copy(const char *zFrom, const char *zTo){
168180
FILE *in, *out;
169181
int got;
170182
char zBuf[8192];
171
- in = fopen(zFrom, "rb");
183
+ in = fossil_fopen(zFrom, "rb");
172184
if( in==0 ) fossil_fatal("cannot open \"%s\" for reading", zFrom);
173
- out = fopen(zTo, "wb");
185
+ out = fossil_fopen(zTo, "wb");
174186
if( out==0 ) fossil_fatal("cannot open \"%s\" for writing", zTo);
175187
while( (got=fread(zBuf, 1, sizeof(zBuf), in))>0 ){
176188
fwrite(zBuf, 1, got, out);
177189
}
178190
fclose(in);
@@ -200,10 +212,19 @@
200212
}
201213
}
202214
#endif /* _WIN32 */
203215
return rc;
204216
}
217
+
218
+/*
219
+** Delete a file.
220
+*/
221
+void file_delete(const char *zFilename){
222
+ char *z = fossil_utf8_to_mbcs(zFilename);
223
+ unlink(z);
224
+ fossil_mbcs_free(z);
225
+}
205226
206227
/*
207228
** Create the directory named in the argument, if it does not already
208229
** exist. If forceFlag is 1, delete any prior non-directory object
209230
** with the same name.
@@ -212,15 +233,19 @@
212233
*/
213234
int file_mkdir(const char *zName, int forceFlag){
214235
int rc = file_isdir(zName);
215236
if( rc==2 ){
216237
if( !forceFlag ) return 1;
217
- unlink(zName);
238
+ file_delete(zName);
218239
}
219240
if( rc!=1 ){
220241
#if defined(_WIN32)
221
- return mkdir(zName);
242
+ int rc;
243
+ char *zMbcs = fossil_utf8_to_mbcs(zName);
244
+ rc = mkdir(zMbcs);
245
+ fossil_mbcs_free(zMbcs);
246
+ return rc;
222247
#else
223248
return mkdir(zName, 0755);
224249
#endif
225250
}
226251
return 0;
@@ -350,13 +375,13 @@
350375
void cmd_test_simplify_name(void){
351376
int i;
352377
char *z;
353378
for(i=2; i<g.argc; i++){
354379
z = mprintf("%s", g.argv[i]);
355
- printf("[%s] -> ", z);
380
+ fossil_print("[%s] -> ", z);
356381
file_simplify_name(z, -1);
357
- printf("[%s]\n", z);
382
+ fossil_print("[%s]\n", z);
358383
fossil_free(z);
359384
}
360385
}
361386
362387
/*
@@ -377,12 +402,11 @@
377402
blob_set(pOut, zOrigName);
378403
blob_materialize(pOut);
379404
}else{
380405
char zPwd[2000];
381406
if( getcwd(zPwd, sizeof(zPwd)-20)==0 ){
382
- fprintf(stderr, "pwd too big: max %d\n", (int)sizeof(zPwd)-20);
383
- fossil_exit(1);
407
+ fossil_fatal("pwd too big: max %d\n", (int)sizeof(zPwd)-20);
384408
}
385409
blob_zero(pOut);
386410
blob_appendf(pOut, "%//%/", zPwd, zOrigName);
387411
}
388412
blob_resize(pOut, file_simplify_name(blob_buffer(pOut), blob_size(pOut)));
@@ -401,19 +425,19 @@
401425
blob_zero(&x);
402426
for(i=2; i<g.argc; i++){
403427
char zBuf[100];
404428
const char *zName = g.argv[i];
405429
file_canonical_name(zName, &x);
406
- printf("[%s] -> [%s]\n", zName, blob_buffer(&x));
430
+ fossil_print("[%s] -> [%s]\n", zName, blob_buffer(&x));
407431
blob_reset(&x);
408432
sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_size(zName));
409
- printf(" file_size = %s\n", zBuf);
433
+ fossil_print(" file_size = %s\n", zBuf);
410434
sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_mtime(zName));
411
- printf(" file_mtime = %s\n", zBuf);
412
- printf(" file_isfile = %d\n", file_isfile(zName));
413
- printf(" file_isexe = %d\n", file_isexe(zName));
414
- printf(" file_isdir = %d\n", file_isdir(zName));
435
+ fossil_print(" file_mtime = %s\n", zBuf);
436
+ fossil_print(" file_isfile = %d\n", file_isfile(zName));
437
+ fossil_print(" file_isexe = %d\n", file_isexe(zName));
438
+ fossil_print(" file_isdir = %d\n", file_isdir(zName));
415439
}
416440
}
417441
418442
/*
419443
** Return TRUE if the given filename is canonical.
@@ -453,12 +477,11 @@
453477
if( zPath[0]=='/' ){
454478
int i, j;
455479
Blob tmp;
456480
char zPwd[2000];
457481
if( getcwd(zPwd, sizeof(zPwd)-20)==0 ){
458
- fprintf(stderr, "pwd too big: max %d\n", (int)sizeof(zPwd)-20);
459
- fossil_exit(1);
482
+ fossil_fatal("pwd too big: max %d\n", (int)sizeof(zPwd)-20);
460483
}
461484
for(i=1; zPath[i] && zPwd[i]==zPath[i]; i++){}
462485
if( zPath[i]==0 ){
463486
blob_reset(pOut);
464487
if( zPwd[i]==0 ){
@@ -502,11 +525,11 @@
502525
int i;
503526
Blob x;
504527
blob_zero(&x);
505528
for(i=2; i<g.argc; i++){
506529
file_relative_name(g.argv[i], &x);
507
- printf("%s\n", blob_buffer(&x));
530
+ fossil_print("%s\n", blob_buffer(&x));
508531
blob_reset(&x);
509532
}
510533
}
511534
512535
/*
@@ -557,11 +580,11 @@
557580
int i;
558581
Blob x;
559582
blob_zero(&x);
560583
for(i=2; i<g.argc; i++){
561584
if( file_tree_name(g.argv[i], &x, 1) ){
562
- printf("%s\n", blob_buffer(&x));
585
+ fossil_print("%s\n", blob_buffer(&x));
563586
blob_reset(&x);
564587
}
565588
}
566589
}
567590
@@ -620,17 +643,14 @@
620643
static const unsigned char zChars[] =
621644
"abcdefghijklmnopqrstuvwxyz"
622645
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
623646
"0123456789";
624647
unsigned int i, j;
625
- struct stat buf;
626648
const char *zDir = ".";
627649
628650
for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); i++){
629
- if( stat(azDirs[i], &buf) ) continue;
630
- if( !S_ISDIR(buf.st_mode) ) continue;
631
- if( access(azDirs[i], 07) ) continue;
651
+ if( !file_isdir(azDirs[i]) ) continue;
632652
zDir = azDirs[i];
633653
break;
634654
}
635655
636656
/* Check that the output buffer is large enough for the temporary file
@@ -646,11 +666,11 @@
646666
sqlite3_randomness(15, &zBuf[j]);
647667
for(i=0; i<15; i++, j++){
648668
zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ];
649669
}
650670
zBuf[j] = 0;
651
- }while( access(zBuf,0)==0 );
671
+ }while( file_size(zBuf)<0 );
652672
}
653673
654674
655675
/*
656676
** Return true if a file named zName exists and has identical content
@@ -668,5 +688,106 @@
668688
blob_read_from_file(&onDisk, zName);
669689
rc = blob_compare(&onDisk, pContent);
670690
blob_reset(&onDisk);
671691
return rc==0;
672692
}
693
+
694
+
695
+/**************************************************************************
696
+** The following routines translate between MBCS and UTF8 on windows.
697
+** Since everything is always UTF8 on unix, these routines are no-ops
698
+** there.
699
+*/
700
+#ifdef _WIN32
701
+# include <windows.h>
702
+#endif
703
+
704
+/*
705
+** Translate MBCS to UTF8. Return a pointer to the translated text.
706
+** Call fossil_mbcs_free() to deallocate any memory used to store the
707
+** returned pointer when done.
708
+*/
709
+char *fossil_mbcs_to_utf8(const char *zMbcs){
710
+#ifdef _WIN32
711
+ extern char *sqlite3_win32_mbcs_to_utf8(const char*);
712
+ return sqlite3_win32_mbcs_to_utf8(zMbcs);
713
+#else
714
+ return (char*)zMbcs; /* No-op on unix */
715
+#endif
716
+}
717
+
718
+/*
719
+** Translate UTF8 to MBCS for use in system calls. Return a pointer to the
720
+** translated text.. Call fossil_mbcs_free() to deallocate any memory
721
+** used to store the returned pointer when done.
722
+*/
723
+char *fossil_utf8_to_mbcs(const char *zUtf8){
724
+#ifdef _WIN32
725
+ extern char *sqlite3_win32_utf8_to_mbcs(const char*);
726
+ return sqlite3_win32_utf8_to_mbcs(zUtf8);
727
+#else
728
+ return (char*)zUtf8; /* No-op on unix */
729
+#endif
730
+}
731
+
732
+/*
733
+** Translate UTF8 to MBCS for display on the console. Return a pointer to the
734
+** translated text.. Call fossil_mbcs_free() to deallocate any memory
735
+** used to store the returned pointer when done.
736
+*/
737
+char *fossil_utf8_to_console(const char *zUtf8){
738
+#ifdef _WIN32
739
+ int nChar, nByte;
740
+ WCHAR *zUnicode; /* Unicode version of zUtf8 */
741
+ char *zConsole; /* Console version of zUtf8 */
742
+ int codepage; /* Console code page */
743
+
744
+ nChar = MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, NULL, 0);
745
+ zUnicode = malloc( nChar*sizeof(zUnicode[0]) );
746
+ if( zUnicode==0 ){
747
+ return 0;
748
+ }
749
+ nChar = MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, zUnicode, nChar);
750
+ if( nChar==0 ){
751
+ free(zUnicode);
752
+ return 0;
753
+ }
754
+ codepage = GetConsoleCP();
755
+ nByte = WideCharToMultiByte(codepage, 0, zUnicode, -1, 0, 0, 0, 0);
756
+ zConsole = malloc( nByte );
757
+ if( zConsole==0 ){
758
+ free(zUnicode);
759
+ return 0;
760
+ }
761
+ nByte = WideCharToMultiByte(codepage, 0, zUnicode, -1, zConsole, nByte, 0, 0);
762
+ free(zUnicode);
763
+ if( nByte == 0 ){
764
+ free(zConsole);
765
+ zConsole = 0;
766
+ }
767
+ return zConsole;
768
+#else
769
+ return (char*)zUtf8; /* No-op on unix */
770
+#endif
771
+}
772
+
773
+/*
774
+** Translate MBCS to UTF8. Return a pointer. Call fossil_mbcs_free()
775
+** to deallocate any memory used to store the returned pointer when done.
776
+*/
777
+void fossil_mbcs_free(char *zOld){
778
+#ifdef _WIN32
779
+ free(zOld);
780
+#else
781
+ /* No-op on unix */
782
+#endif
783
+}
784
+
785
+/*
786
+** Like fopen() but always takes a UTF8 argument.
787
+*/
788
+FILE *fossil_fopen(const char *zName, const char *zMode){
789
+ char *zMbcs = fossil_utf8_to_mbcs(zName);
790
+ FILE *f = fopen(zMbcs, zMode);
791
+ fossil_mbcs_free(zMbcs);
792
+ return f;
793
+}
673794
--- src/file.c
+++ src/file.c
@@ -47,17 +47,19 @@
47 static int getStat(const char *zFilename){
48 int rc = 0;
49 if( zFilename==0 ){
50 if( fileStatValid==0 ) rc = 1;
51 }else{
52 if( stat(zFilename, &fileStat)!=0 ){
 
53 fileStatValid = 0;
54 rc = 1;
55 }else{
56 fileStatValid = 1;
57 rc = 0;
58 }
 
59 }
60 return rc;
61 }
62
63
@@ -120,10 +122,20 @@
120 }else{
121 rc = getStat(0);
122 }
123 return rc ? 0 : (S_ISDIR(fileStat.st_mode) ? 1 : 2);
124 }
 
 
 
 
 
 
 
 
 
 
125
126 /*
127 ** Find an unused filename similar to zBase with zSuffix appended.
128 **
129 ** Make the name relative to the working directory if relFlag is true.
@@ -166,13 +178,13 @@
166 */
167 void file_copy(const char *zFrom, const char *zTo){
168 FILE *in, *out;
169 int got;
170 char zBuf[8192];
171 in = fopen(zFrom, "rb");
172 if( in==0 ) fossil_fatal("cannot open \"%s\" for reading", zFrom);
173 out = fopen(zTo, "wb");
174 if( out==0 ) fossil_fatal("cannot open \"%s\" for writing", zTo);
175 while( (got=fread(zBuf, 1, sizeof(zBuf), in))>0 ){
176 fwrite(zBuf, 1, got, out);
177 }
178 fclose(in);
@@ -200,10 +212,19 @@
200 }
201 }
202 #endif /* _WIN32 */
203 return rc;
204 }
 
 
 
 
 
 
 
 
 
205
206 /*
207 ** Create the directory named in the argument, if it does not already
208 ** exist. If forceFlag is 1, delete any prior non-directory object
209 ** with the same name.
@@ -212,15 +233,19 @@
212 */
213 int file_mkdir(const char *zName, int forceFlag){
214 int rc = file_isdir(zName);
215 if( rc==2 ){
216 if( !forceFlag ) return 1;
217 unlink(zName);
218 }
219 if( rc!=1 ){
220 #if defined(_WIN32)
221 return mkdir(zName);
 
 
 
 
222 #else
223 return mkdir(zName, 0755);
224 #endif
225 }
226 return 0;
@@ -350,13 +375,13 @@
350 void cmd_test_simplify_name(void){
351 int i;
352 char *z;
353 for(i=2; i<g.argc; i++){
354 z = mprintf("%s", g.argv[i]);
355 printf("[%s] -> ", z);
356 file_simplify_name(z, -1);
357 printf("[%s]\n", z);
358 fossil_free(z);
359 }
360 }
361
362 /*
@@ -377,12 +402,11 @@
377 blob_set(pOut, zOrigName);
378 blob_materialize(pOut);
379 }else{
380 char zPwd[2000];
381 if( getcwd(zPwd, sizeof(zPwd)-20)==0 ){
382 fprintf(stderr, "pwd too big: max %d\n", (int)sizeof(zPwd)-20);
383 fossil_exit(1);
384 }
385 blob_zero(pOut);
386 blob_appendf(pOut, "%//%/", zPwd, zOrigName);
387 }
388 blob_resize(pOut, file_simplify_name(blob_buffer(pOut), blob_size(pOut)));
@@ -401,19 +425,19 @@
401 blob_zero(&x);
402 for(i=2; i<g.argc; i++){
403 char zBuf[100];
404 const char *zName = g.argv[i];
405 file_canonical_name(zName, &x);
406 printf("[%s] -> [%s]\n", zName, blob_buffer(&x));
407 blob_reset(&x);
408 sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_size(zName));
409 printf(" file_size = %s\n", zBuf);
410 sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_mtime(zName));
411 printf(" file_mtime = %s\n", zBuf);
412 printf(" file_isfile = %d\n", file_isfile(zName));
413 printf(" file_isexe = %d\n", file_isexe(zName));
414 printf(" file_isdir = %d\n", file_isdir(zName));
415 }
416 }
417
418 /*
419 ** Return TRUE if the given filename is canonical.
@@ -453,12 +477,11 @@
453 if( zPath[0]=='/' ){
454 int i, j;
455 Blob tmp;
456 char zPwd[2000];
457 if( getcwd(zPwd, sizeof(zPwd)-20)==0 ){
458 fprintf(stderr, "pwd too big: max %d\n", (int)sizeof(zPwd)-20);
459 fossil_exit(1);
460 }
461 for(i=1; zPath[i] && zPwd[i]==zPath[i]; i++){}
462 if( zPath[i]==0 ){
463 blob_reset(pOut);
464 if( zPwd[i]==0 ){
@@ -502,11 +525,11 @@
502 int i;
503 Blob x;
504 blob_zero(&x);
505 for(i=2; i<g.argc; i++){
506 file_relative_name(g.argv[i], &x);
507 printf("%s\n", blob_buffer(&x));
508 blob_reset(&x);
509 }
510 }
511
512 /*
@@ -557,11 +580,11 @@
557 int i;
558 Blob x;
559 blob_zero(&x);
560 for(i=2; i<g.argc; i++){
561 if( file_tree_name(g.argv[i], &x, 1) ){
562 printf("%s\n", blob_buffer(&x));
563 blob_reset(&x);
564 }
565 }
566 }
567
@@ -620,17 +643,14 @@
620 static const unsigned char zChars[] =
621 "abcdefghijklmnopqrstuvwxyz"
622 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
623 "0123456789";
624 unsigned int i, j;
625 struct stat buf;
626 const char *zDir = ".";
627
628 for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); i++){
629 if( stat(azDirs[i], &buf) ) continue;
630 if( !S_ISDIR(buf.st_mode) ) continue;
631 if( access(azDirs[i], 07) ) continue;
632 zDir = azDirs[i];
633 break;
634 }
635
636 /* Check that the output buffer is large enough for the temporary file
@@ -646,11 +666,11 @@
646 sqlite3_randomness(15, &zBuf[j]);
647 for(i=0; i<15; i++, j++){
648 zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ];
649 }
650 zBuf[j] = 0;
651 }while( access(zBuf,0)==0 );
652 }
653
654
655 /*
656 ** Return true if a file named zName exists and has identical content
@@ -668,5 +688,106 @@
668 blob_read_from_file(&onDisk, zName);
669 rc = blob_compare(&onDisk, pContent);
670 blob_reset(&onDisk);
671 return rc==0;
672 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
673
--- src/file.c
+++ src/file.c
@@ -47,17 +47,19 @@
47 static int getStat(const char *zFilename){
48 int rc = 0;
49 if( zFilename==0 ){
50 if( fileStatValid==0 ) rc = 1;
51 }else{
52 char *zMbcs = fossil_utf8_to_mbcs(zFilename);
53 if( stat(zMbcs, &fileStat)!=0 ){
54 fileStatValid = 0;
55 rc = 1;
56 }else{
57 fileStatValid = 1;
58 rc = 0;
59 }
60 fossil_mbcs_free(zMbcs);
61 }
62 return rc;
63 }
64
65
@@ -120,10 +122,20 @@
122 }else{
123 rc = getStat(0);
124 }
125 return rc ? 0 : (S_ISDIR(fileStat.st_mode) ? 1 : 2);
126 }
127
128 /*
129 ** Wrapper around the access() system call.
130 */
131 int file_access(const char *zFilename, int flags){
132 char *zMbcs = fossil_utf8_to_mbcs(zFilename);
133 int rc = access(zMbcs, flags);
134 fossil_mbcs_free(zMbcs);
135 return rc;
136 }
137
138 /*
139 ** Find an unused filename similar to zBase with zSuffix appended.
140 **
141 ** Make the name relative to the working directory if relFlag is true.
@@ -166,13 +178,13 @@
178 */
179 void file_copy(const char *zFrom, const char *zTo){
180 FILE *in, *out;
181 int got;
182 char zBuf[8192];
183 in = fossil_fopen(zFrom, "rb");
184 if( in==0 ) fossil_fatal("cannot open \"%s\" for reading", zFrom);
185 out = fossil_fopen(zTo, "wb");
186 if( out==0 ) fossil_fatal("cannot open \"%s\" for writing", zTo);
187 while( (got=fread(zBuf, 1, sizeof(zBuf), in))>0 ){
188 fwrite(zBuf, 1, got, out);
189 }
190 fclose(in);
@@ -200,10 +212,19 @@
212 }
213 }
214 #endif /* _WIN32 */
215 return rc;
216 }
217
218 /*
219 ** Delete a file.
220 */
221 void file_delete(const char *zFilename){
222 char *z = fossil_utf8_to_mbcs(zFilename);
223 unlink(z);
224 fossil_mbcs_free(z);
225 }
226
227 /*
228 ** Create the directory named in the argument, if it does not already
229 ** exist. If forceFlag is 1, delete any prior non-directory object
230 ** with the same name.
@@ -212,15 +233,19 @@
233 */
234 int file_mkdir(const char *zName, int forceFlag){
235 int rc = file_isdir(zName);
236 if( rc==2 ){
237 if( !forceFlag ) return 1;
238 file_delete(zName);
239 }
240 if( rc!=1 ){
241 #if defined(_WIN32)
242 int rc;
243 char *zMbcs = fossil_utf8_to_mbcs(zName);
244 rc = mkdir(zMbcs);
245 fossil_mbcs_free(zMbcs);
246 return rc;
247 #else
248 return mkdir(zName, 0755);
249 #endif
250 }
251 return 0;
@@ -350,13 +375,13 @@
375 void cmd_test_simplify_name(void){
376 int i;
377 char *z;
378 for(i=2; i<g.argc; i++){
379 z = mprintf("%s", g.argv[i]);
380 fossil_print("[%s] -> ", z);
381 file_simplify_name(z, -1);
382 fossil_print("[%s]\n", z);
383 fossil_free(z);
384 }
385 }
386
387 /*
@@ -377,12 +402,11 @@
402 blob_set(pOut, zOrigName);
403 blob_materialize(pOut);
404 }else{
405 char zPwd[2000];
406 if( getcwd(zPwd, sizeof(zPwd)-20)==0 ){
407 fossil_fatal("pwd too big: max %d\n", (int)sizeof(zPwd)-20);
 
408 }
409 blob_zero(pOut);
410 blob_appendf(pOut, "%//%/", zPwd, zOrigName);
411 }
412 blob_resize(pOut, file_simplify_name(blob_buffer(pOut), blob_size(pOut)));
@@ -401,19 +425,19 @@
425 blob_zero(&x);
426 for(i=2; i<g.argc; i++){
427 char zBuf[100];
428 const char *zName = g.argv[i];
429 file_canonical_name(zName, &x);
430 fossil_print("[%s] -> [%s]\n", zName, blob_buffer(&x));
431 blob_reset(&x);
432 sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_size(zName));
433 fossil_print(" file_size = %s\n", zBuf);
434 sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_mtime(zName));
435 fossil_print(" file_mtime = %s\n", zBuf);
436 fossil_print(" file_isfile = %d\n", file_isfile(zName));
437 fossil_print(" file_isexe = %d\n", file_isexe(zName));
438 fossil_print(" file_isdir = %d\n", file_isdir(zName));
439 }
440 }
441
442 /*
443 ** Return TRUE if the given filename is canonical.
@@ -453,12 +477,11 @@
477 if( zPath[0]=='/' ){
478 int i, j;
479 Blob tmp;
480 char zPwd[2000];
481 if( getcwd(zPwd, sizeof(zPwd)-20)==0 ){
482 fossil_fatal("pwd too big: max %d\n", (int)sizeof(zPwd)-20);
 
483 }
484 for(i=1; zPath[i] && zPwd[i]==zPath[i]; i++){}
485 if( zPath[i]==0 ){
486 blob_reset(pOut);
487 if( zPwd[i]==0 ){
@@ -502,11 +525,11 @@
525 int i;
526 Blob x;
527 blob_zero(&x);
528 for(i=2; i<g.argc; i++){
529 file_relative_name(g.argv[i], &x);
530 fossil_print("%s\n", blob_buffer(&x));
531 blob_reset(&x);
532 }
533 }
534
535 /*
@@ -557,11 +580,11 @@
580 int i;
581 Blob x;
582 blob_zero(&x);
583 for(i=2; i<g.argc; i++){
584 if( file_tree_name(g.argv[i], &x, 1) ){
585 fossil_print("%s\n", blob_buffer(&x));
586 blob_reset(&x);
587 }
588 }
589 }
590
@@ -620,17 +643,14 @@
643 static const unsigned char zChars[] =
644 "abcdefghijklmnopqrstuvwxyz"
645 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
646 "0123456789";
647 unsigned int i, j;
 
648 const char *zDir = ".";
649
650 for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); i++){
651 if( !file_isdir(azDirs[i]) ) continue;
 
 
652 zDir = azDirs[i];
653 break;
654 }
655
656 /* Check that the output buffer is large enough for the temporary file
@@ -646,11 +666,11 @@
666 sqlite3_randomness(15, &zBuf[j]);
667 for(i=0; i<15; i++, j++){
668 zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ];
669 }
670 zBuf[j] = 0;
671 }while( file_size(zBuf)<0 );
672 }
673
674
675 /*
676 ** Return true if a file named zName exists and has identical content
@@ -668,5 +688,106 @@
688 blob_read_from_file(&onDisk, zName);
689 rc = blob_compare(&onDisk, pContent);
690 blob_reset(&onDisk);
691 return rc==0;
692 }
693
694
695 /**************************************************************************
696 ** The following routines translate between MBCS and UTF8 on windows.
697 ** Since everything is always UTF8 on unix, these routines are no-ops
698 ** there.
699 */
700 #ifdef _WIN32
701 # include <windows.h>
702 #endif
703
704 /*
705 ** Translate MBCS to UTF8. Return a pointer to the translated text.
706 ** Call fossil_mbcs_free() to deallocate any memory used to store the
707 ** returned pointer when done.
708 */
709 char *fossil_mbcs_to_utf8(const char *zMbcs){
710 #ifdef _WIN32
711 extern char *sqlite3_win32_mbcs_to_utf8(const char*);
712 return sqlite3_win32_mbcs_to_utf8(zMbcs);
713 #else
714 return (char*)zMbcs; /* No-op on unix */
715 #endif
716 }
717
718 /*
719 ** Translate UTF8 to MBCS for use in system calls. Return a pointer to the
720 ** translated text.. Call fossil_mbcs_free() to deallocate any memory
721 ** used to store the returned pointer when done.
722 */
723 char *fossil_utf8_to_mbcs(const char *zUtf8){
724 #ifdef _WIN32
725 extern char *sqlite3_win32_utf8_to_mbcs(const char*);
726 return sqlite3_win32_utf8_to_mbcs(zUtf8);
727 #else
728 return (char*)zUtf8; /* No-op on unix */
729 #endif
730 }
731
732 /*
733 ** Translate UTF8 to MBCS for display on the console. Return a pointer to the
734 ** translated text.. Call fossil_mbcs_free() to deallocate any memory
735 ** used to store the returned pointer when done.
736 */
737 char *fossil_utf8_to_console(const char *zUtf8){
738 #ifdef _WIN32
739 int nChar, nByte;
740 WCHAR *zUnicode; /* Unicode version of zUtf8 */
741 char *zConsole; /* Console version of zUtf8 */
742 int codepage; /* Console code page */
743
744 nChar = MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, NULL, 0);
745 zUnicode = malloc( nChar*sizeof(zUnicode[0]) );
746 if( zUnicode==0 ){
747 return 0;
748 }
749 nChar = MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, zUnicode, nChar);
750 if( nChar==0 ){
751 free(zUnicode);
752 return 0;
753 }
754 codepage = GetConsoleCP();
755 nByte = WideCharToMultiByte(codepage, 0, zUnicode, -1, 0, 0, 0, 0);
756 zConsole = malloc( nByte );
757 if( zConsole==0 ){
758 free(zUnicode);
759 return 0;
760 }
761 nByte = WideCharToMultiByte(codepage, 0, zUnicode, -1, zConsole, nByte, 0, 0);
762 free(zUnicode);
763 if( nByte == 0 ){
764 free(zConsole);
765 zConsole = 0;
766 }
767 return zConsole;
768 #else
769 return (char*)zUtf8; /* No-op on unix */
770 #endif
771 }
772
773 /*
774 ** Translate MBCS to UTF8. Return a pointer. Call fossil_mbcs_free()
775 ** to deallocate any memory used to store the returned pointer when done.
776 */
777 void fossil_mbcs_free(char *zOld){
778 #ifdef _WIN32
779 free(zOld);
780 #else
781 /* No-op on unix */
782 #endif
783 }
784
785 /*
786 ** Like fopen() but always takes a UTF8 argument.
787 */
788 FILE *fossil_fopen(const char *zName, const char *zMode){
789 char *zMbcs = fossil_utf8_to_mbcs(zName);
790 FILE *f = fopen(zMbcs, zMode);
791 fossil_mbcs_free(zMbcs);
792 return f;
793 }
794
+3 -3
--- src/finfo.c
+++ src/finfo.c
@@ -89,11 +89,11 @@
8989
blob_reset(&uuid);
9090
}else{
9191
blob_appendf(&line, "unknown 0000000000");
9292
}
9393
db_finalize(&q);
94
- printf("%s\n", blob_str(&line));
94
+ fossil_print("%s\n", blob_str(&line));
9595
blob_reset(&fname);
9696
blob_reset(&line);
9797
}else if( find_option("print","p",0) ){
9898
Blob record;
9999
Blob fname;
@@ -152,21 +152,21 @@
152152
" ORDER BY event.mtime DESC LIMIT %d OFFSET %d",
153153
zFilename, iLimit, iOffset
154154
);
155155
blob_zero(&line);
156156
if( iBrief ){
157
- printf("History of %s\n", blob_str(&fname));
157
+ fossil_print("History of %s\n", blob_str(&fname));
158158
}
159159
while( db_step(&q)==SQLITE_ROW ){
160160
const char *zFileUuid = db_column_text(&q, 0);
161161
const char *zCiUuid = db_column_text(&q,1);
162162
const char *zDate = db_column_text(&q, 2);
163163
const char *zCom = db_column_text(&q, 3);
164164
const char *zUser = db_column_text(&q, 4);
165165
char *zOut;
166166
if( iBrief ){
167
- printf("%s ", zDate);
167
+ fossil_print("%s ", zDate);
168168
zOut = sqlite3_mprintf("[%.10s] %s (user: %s, artifact: [%.10s])",
169169
zCiUuid, zCom, zUser, zFileUuid);
170170
comment_print(zOut, 11, 79);
171171
sqlite3_free(zOut);
172172
}else{
173173
--- src/finfo.c
+++ src/finfo.c
@@ -89,11 +89,11 @@
89 blob_reset(&uuid);
90 }else{
91 blob_appendf(&line, "unknown 0000000000");
92 }
93 db_finalize(&q);
94 printf("%s\n", blob_str(&line));
95 blob_reset(&fname);
96 blob_reset(&line);
97 }else if( find_option("print","p",0) ){
98 Blob record;
99 Blob fname;
@@ -152,21 +152,21 @@
152 " ORDER BY event.mtime DESC LIMIT %d OFFSET %d",
153 zFilename, iLimit, iOffset
154 );
155 blob_zero(&line);
156 if( iBrief ){
157 printf("History of %s\n", blob_str(&fname));
158 }
159 while( db_step(&q)==SQLITE_ROW ){
160 const char *zFileUuid = db_column_text(&q, 0);
161 const char *zCiUuid = db_column_text(&q,1);
162 const char *zDate = db_column_text(&q, 2);
163 const char *zCom = db_column_text(&q, 3);
164 const char *zUser = db_column_text(&q, 4);
165 char *zOut;
166 if( iBrief ){
167 printf("%s ", zDate);
168 zOut = sqlite3_mprintf("[%.10s] %s (user: %s, artifact: [%.10s])",
169 zCiUuid, zCom, zUser, zFileUuid);
170 comment_print(zOut, 11, 79);
171 sqlite3_free(zOut);
172 }else{
173
--- src/finfo.c
+++ src/finfo.c
@@ -89,11 +89,11 @@
89 blob_reset(&uuid);
90 }else{
91 blob_appendf(&line, "unknown 0000000000");
92 }
93 db_finalize(&q);
94 fossil_print("%s\n", blob_str(&line));
95 blob_reset(&fname);
96 blob_reset(&line);
97 }else if( find_option("print","p",0) ){
98 Blob record;
99 Blob fname;
@@ -152,21 +152,21 @@
152 " ORDER BY event.mtime DESC LIMIT %d OFFSET %d",
153 zFilename, iLimit, iOffset
154 );
155 blob_zero(&line);
156 if( iBrief ){
157 fossil_print("History of %s\n", blob_str(&fname));
158 }
159 while( db_step(&q)==SQLITE_ROW ){
160 const char *zFileUuid = db_column_text(&q, 0);
161 const char *zCiUuid = db_column_text(&q,1);
162 const char *zDate = db_column_text(&q, 2);
163 const char *zCom = db_column_text(&q, 3);
164 const char *zUser = db_column_text(&q, 4);
165 char *zOut;
166 if( iBrief ){
167 fossil_print("%s ", zDate);
168 zOut = sqlite3_mprintf("[%.10s] %s (user: %s, artifact: [%.10s])",
169 zCiUuid, zCom, zUser, zFileUuid);
170 comment_print(zOut, 11, 79);
171 sqlite3_free(zOut);
172 }else{
173
+3 -3
--- src/glob.c
+++ src/glob.c
@@ -250,15 +250,15 @@
250250
*/
251251
void glob_test_cmd(void){
252252
Glob *pGlob;
253253
int i;
254254
if( g.argc<4 ) usage("PATTERN STRING ...");
255
- printf("SQL expression: %s\n", glob_expr("x", g.argv[2]));
255
+ fossil_print("SQL expression: %s\n", glob_expr("x", g.argv[2]));
256256
pGlob = glob_create(g.argv[2]);
257257
for(i=0; i<pGlob->nPattern; i++){
258
- printf("pattern[%d] = [%s]\n", i, pGlob->azPattern[i]);
258
+ fossil_print("pattern[%d] = [%s]\n", i, pGlob->azPattern[i]);
259259
}
260260
for(i=3; i<g.argc; i++){
261
- printf("%d %s\n", glob_match(pGlob, g.argv[i]), g.argv[i]);
261
+ fossil_print("%d %s\n", glob_match(pGlob, g.argv[i]), g.argv[i]);
262262
}
263263
glob_free(pGlob);
264264
}
265265
--- src/glob.c
+++ src/glob.c
@@ -250,15 +250,15 @@
250 */
251 void glob_test_cmd(void){
252 Glob *pGlob;
253 int i;
254 if( g.argc<4 ) usage("PATTERN STRING ...");
255 printf("SQL expression: %s\n", glob_expr("x", g.argv[2]));
256 pGlob = glob_create(g.argv[2]);
257 for(i=0; i<pGlob->nPattern; i++){
258 printf("pattern[%d] = [%s]\n", i, pGlob->azPattern[i]);
259 }
260 for(i=3; i<g.argc; i++){
261 printf("%d %s\n", glob_match(pGlob, g.argv[i]), g.argv[i]);
262 }
263 glob_free(pGlob);
264 }
265
--- src/glob.c
+++ src/glob.c
@@ -250,15 +250,15 @@
250 */
251 void glob_test_cmd(void){
252 Glob *pGlob;
253 int i;
254 if( g.argc<4 ) usage("PATTERN STRING ...");
255 fossil_print("SQL expression: %s\n", glob_expr("x", g.argv[2]));
256 pGlob = glob_create(g.argv[2]);
257 for(i=0; i<pGlob->nPattern; i++){
258 fossil_print("pattern[%d] = [%s]\n", i, pGlob->azPattern[i]);
259 }
260 for(i=3; i<g.argc; i++){
261 fossil_print("%d %s\n", glob_match(pGlob, g.argv[i]), g.argv[i]);
262 }
263 glob_free(pGlob);
264 }
265
--- src/http_transport.c
+++ src/http_transport.c
@@ -120,11 +120,11 @@
120120
blob_appendf(&zCmd, " -P %d", g.urlPort);
121121
#else
122122
blob_appendf(&zCmd, " -p %d", g.urlPort);
123123
#endif
124124
}
125
- printf("%s", blob_str(&zCmd)); /* Show the base of the SSH command */
125
+ fossil_print("%s", blob_str(&zCmd)); /* Show the base of the SSH command */
126126
if( g.urlUser && g.urlUser[0] ){
127127
zHost = mprintf("%s@%s", g.urlUser, g.urlName);
128128
#ifdef __MINGW32__
129129
/* Only win32 (and specifically PLINK.EXE) support the -pw option */
130130
if( g.urlPasswd && g.urlPasswd[0] ){
@@ -139,19 +139,19 @@
139139
blob_init(&pw, g.urlPasswd, -1);
140140
}
141141
blob_append(&zCmd, " -pw ", -1);
142142
shell_escape(&zCmd, blob_str(&pw));
143143
blob_reset(&pw);
144
- printf(" -pw ********"); /* Do not show the password text */
144
+ fossil_print(" -pw ********"); /* Do not show the password text */
145145
}
146146
#endif
147147
}else{
148148
zHost = mprintf("%s", g.urlName);
149149
}
150150
blob_append(&zCmd, " ", 1);
151151
shell_escape(&zCmd, zHost);
152
- printf(" %s\n", zHost); /* Show the conclusion of the SSH command */
152
+ fossil_print(" %s\n", zHost); /* Show the conclusion of the SSH command */
153153
free(zHost);
154154
popen2(blob_str(&zCmd), &sshIn, &sshOut, &sshPid);
155155
if( sshPid==0 ){
156156
fossil_fatal("cannot start ssh tunnel using [%b]", &zCmd);
157157
}
@@ -246,12 +246,12 @@
246246
}else if( g.urlIsFile ){
247247
if( transport.pFile ){
248248
fclose(transport.pFile);
249249
transport.pFile = 0;
250250
}
251
- unlink(transport.zInFile);
252
- unlink(transport.zOutFile);
251
+ file_delete(transport.zInFile);
252
+ file_delete(transport.zOutFile);
253253
free(transport.zInFile);
254254
free(transport.zOutFile);
255255
}else{
256256
socket_close();
257257
}
258258
--- src/http_transport.c
+++ src/http_transport.c
@@ -120,11 +120,11 @@
120 blob_appendf(&zCmd, " -P %d", g.urlPort);
121 #else
122 blob_appendf(&zCmd, " -p %d", g.urlPort);
123 #endif
124 }
125 printf("%s", blob_str(&zCmd)); /* Show the base of the SSH command */
126 if( g.urlUser && g.urlUser[0] ){
127 zHost = mprintf("%s@%s", g.urlUser, g.urlName);
128 #ifdef __MINGW32__
129 /* Only win32 (and specifically PLINK.EXE) support the -pw option */
130 if( g.urlPasswd && g.urlPasswd[0] ){
@@ -139,19 +139,19 @@
139 blob_init(&pw, g.urlPasswd, -1);
140 }
141 blob_append(&zCmd, " -pw ", -1);
142 shell_escape(&zCmd, blob_str(&pw));
143 blob_reset(&pw);
144 printf(" -pw ********"); /* Do not show the password text */
145 }
146 #endif
147 }else{
148 zHost = mprintf("%s", g.urlName);
149 }
150 blob_append(&zCmd, " ", 1);
151 shell_escape(&zCmd, zHost);
152 printf(" %s\n", zHost); /* Show the conclusion of the SSH command */
153 free(zHost);
154 popen2(blob_str(&zCmd), &sshIn, &sshOut, &sshPid);
155 if( sshPid==0 ){
156 fossil_fatal("cannot start ssh tunnel using [%b]", &zCmd);
157 }
@@ -246,12 +246,12 @@
246 }else if( g.urlIsFile ){
247 if( transport.pFile ){
248 fclose(transport.pFile);
249 transport.pFile = 0;
250 }
251 unlink(transport.zInFile);
252 unlink(transport.zOutFile);
253 free(transport.zInFile);
254 free(transport.zOutFile);
255 }else{
256 socket_close();
257 }
258
--- src/http_transport.c
+++ src/http_transport.c
@@ -120,11 +120,11 @@
120 blob_appendf(&zCmd, " -P %d", g.urlPort);
121 #else
122 blob_appendf(&zCmd, " -p %d", g.urlPort);
123 #endif
124 }
125 fossil_print("%s", blob_str(&zCmd)); /* Show the base of the SSH command */
126 if( g.urlUser && g.urlUser[0] ){
127 zHost = mprintf("%s@%s", g.urlUser, g.urlName);
128 #ifdef __MINGW32__
129 /* Only win32 (and specifically PLINK.EXE) support the -pw option */
130 if( g.urlPasswd && g.urlPasswd[0] ){
@@ -139,19 +139,19 @@
139 blob_init(&pw, g.urlPasswd, -1);
140 }
141 blob_append(&zCmd, " -pw ", -1);
142 shell_escape(&zCmd, blob_str(&pw));
143 blob_reset(&pw);
144 fossil_print(" -pw ********"); /* Do not show the password text */
145 }
146 #endif
147 }else{
148 zHost = mprintf("%s", g.urlName);
149 }
150 blob_append(&zCmd, " ", 1);
151 shell_escape(&zCmd, zHost);
152 fossil_print(" %s\n", zHost); /* Show the conclusion of the SSH command */
153 free(zHost);
154 popen2(blob_str(&zCmd), &sshIn, &sshOut, &sshPid);
155 if( sshPid==0 ){
156 fossil_fatal("cannot start ssh tunnel using [%b]", &zCmd);
157 }
@@ -246,12 +246,12 @@
246 }else if( g.urlIsFile ){
247 if( transport.pFile ){
248 fclose(transport.pFile);
249 transport.pFile = 0;
250 }
251 file_delete(transport.zInFile);
252 file_delete(transport.zOutFile);
253 free(transport.zInFile);
254 free(transport.zOutFile);
255 }else{
256 socket_close();
257 }
258
+8 -8
--- src/import.c
+++ src/import.c
@@ -497,11 +497,11 @@
497497
gg.xFinish();
498498
}else
499499
if( memcmp(zLine, "progress ", 9)==0 ){
500500
gg.xFinish();
501501
trim_newline(&zLine[9]);
502
- printf("%s\n", &zLine[9]);
502
+ fossil_print("%s\n", &zLine[9]);
503503
fflush(stdout);
504504
}else
505505
if( memcmp(zLine, "data ", 5)==0 ){
506506
fossil_free(gg.aData); gg.aData = 0;
507507
gg.nData = atoi(&zLine[5]);
@@ -697,11 +697,11 @@
697697
}else{
698698
pIn = stdin;
699699
fossil_binary_mode(pIn);
700700
}
701701
if( !incrFlag ){
702
- if( forceFlag ) unlink(g.argv[2]);
702
+ if( forceFlag ) file_delete(g.argv[2]);
703703
db_create_repository(g.argv[2]);
704704
}
705705
db_open_repository(g.argv[2]);
706706
db_open_config(0);
707707
@@ -742,19 +742,19 @@
742742
import_reset(0);
743743
}
744744
db_finalize(&q);
745745
db_end_transaction(0);
746746
db_begin_transaction();
747
- printf("Rebuilding repository meta-data...\n");
747
+ fossil_print("Rebuilding repository meta-data...\n");
748748
rebuild_db(0, 1, !incrFlag);
749749
verify_cancel();
750750
db_end_transaction(0);
751
- printf("Vacuuming..."); fflush(stdout);
751
+ fossil_print("Vacuuming..."); fflush(stdout);
752752
db_multi_exec("VACUUM");
753
- printf(" ok\n");
753
+ fossil_print(" ok\n");
754754
if( !incrFlag ){
755
- printf("project-id: %s\n", db_get("project-code", 0));
756
- printf("server-id: %s\n", db_get("server-code", 0));
755
+ fossil_print("project-id: %s\n", db_get("project-code", 0));
756
+ fossil_print("server-id: %s\n", db_get("server-code", 0));
757757
zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin);
758
- printf("admin-user: %s (password is \"%s\")\n", g.zLogin, zPassword);
758
+ fossil_print("admin-user: %s (password is \"%s\")\n", g.zLogin, zPassword);
759759
}
760760
}
761761
--- src/import.c
+++ src/import.c
@@ -497,11 +497,11 @@
497 gg.xFinish();
498 }else
499 if( memcmp(zLine, "progress ", 9)==0 ){
500 gg.xFinish();
501 trim_newline(&zLine[9]);
502 printf("%s\n", &zLine[9]);
503 fflush(stdout);
504 }else
505 if( memcmp(zLine, "data ", 5)==0 ){
506 fossil_free(gg.aData); gg.aData = 0;
507 gg.nData = atoi(&zLine[5]);
@@ -697,11 +697,11 @@
697 }else{
698 pIn = stdin;
699 fossil_binary_mode(pIn);
700 }
701 if( !incrFlag ){
702 if( forceFlag ) unlink(g.argv[2]);
703 db_create_repository(g.argv[2]);
704 }
705 db_open_repository(g.argv[2]);
706 db_open_config(0);
707
@@ -742,19 +742,19 @@
742 import_reset(0);
743 }
744 db_finalize(&q);
745 db_end_transaction(0);
746 db_begin_transaction();
747 printf("Rebuilding repository meta-data...\n");
748 rebuild_db(0, 1, !incrFlag);
749 verify_cancel();
750 db_end_transaction(0);
751 printf("Vacuuming..."); fflush(stdout);
752 db_multi_exec("VACUUM");
753 printf(" ok\n");
754 if( !incrFlag ){
755 printf("project-id: %s\n", db_get("project-code", 0));
756 printf("server-id: %s\n", db_get("server-code", 0));
757 zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin);
758 printf("admin-user: %s (password is \"%s\")\n", g.zLogin, zPassword);
759 }
760 }
761
--- src/import.c
+++ src/import.c
@@ -497,11 +497,11 @@
497 gg.xFinish();
498 }else
499 if( memcmp(zLine, "progress ", 9)==0 ){
500 gg.xFinish();
501 trim_newline(&zLine[9]);
502 fossil_print("%s\n", &zLine[9]);
503 fflush(stdout);
504 }else
505 if( memcmp(zLine, "data ", 5)==0 ){
506 fossil_free(gg.aData); gg.aData = 0;
507 gg.nData = atoi(&zLine[5]);
@@ -697,11 +697,11 @@
697 }else{
698 pIn = stdin;
699 fossil_binary_mode(pIn);
700 }
701 if( !incrFlag ){
702 if( forceFlag ) file_delete(g.argv[2]);
703 db_create_repository(g.argv[2]);
704 }
705 db_open_repository(g.argv[2]);
706 db_open_config(0);
707
@@ -742,19 +742,19 @@
742 import_reset(0);
743 }
744 db_finalize(&q);
745 db_end_transaction(0);
746 db_begin_transaction();
747 fossil_print("Rebuilding repository meta-data...\n");
748 rebuild_db(0, 1, !incrFlag);
749 verify_cancel();
750 db_end_transaction(0);
751 fossil_print("Vacuuming..."); fflush(stdout);
752 db_multi_exec("VACUUM");
753 fossil_print(" ok\n");
754 if( !incrFlag ){
755 fossil_print("project-id: %s\n", db_get("project-code", 0));
756 fossil_print("server-id: %s\n", db_get("server-code", 0));
757 zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin);
758 fossil_print("admin-user: %s (password is \"%s\")\n", g.zLogin, zPassword);
759 }
760 }
761
+15 -15
--- src/info.c
+++ src/info.c
@@ -67,11 +67,11 @@
6767
zDate = db_text(0,
6868
"SELECT datetime(mtime) || ' UTC' FROM event WHERE objid=%d",
6969
rid
7070
);
7171
/* 01234567890123 */
72
- printf("%-13s %s %s\n", zUuidName, zUuid, zDate ? zDate : "");
72
+ fossil_print("%-13s %s %s\n", zUuidName, zUuid, zDate ? zDate : "");
7373
free(zUuid);
7474
free(zDate);
7575
}
7676
if( zUuid && showComment ){
7777
zComment = db_text(0,
@@ -88,11 +88,11 @@
8888
const char *zUuid = db_column_text(&q, 0);
8989
zDate = db_text("",
9090
"SELECT datetime(mtime) || ' UTC' FROM event WHERE objid=%d",
9191
db_column_int(&q, 1)
9292
);
93
- printf("parent: %s %s\n", zUuid, zDate);
93
+ fossil_print("parent: %s %s\n", zUuid, zDate);
9494
free(zDate);
9595
}
9696
db_finalize(&q);
9797
db_prepare(&q, "SELECT uuid, cid FROM plink JOIN blob ON cid=rid "
9898
" WHERE pid=%d", rid);
@@ -100,22 +100,22 @@
100100
const char *zUuid = db_column_text(&q, 0);
101101
zDate = db_text("",
102102
"SELECT datetime(mtime) || ' UTC' FROM event WHERE objid=%d",
103103
db_column_int(&q, 1)
104104
);
105
- printf("child: %s %s\n", zUuid, zDate);
105
+ fossil_print("child: %s %s\n", zUuid, zDate);
106106
free(zDate);
107107
}
108108
db_finalize(&q);
109109
}
110110
zTags = info_tags_of_checkin(rid, 0);
111111
if( zTags && zTags[0] ){
112
- printf("tags: %s\n", zTags);
112
+ fossil_print("tags: %s\n", zTags);
113113
}
114114
free(zTags);
115115
if( zComment ){
116
- printf("comment: ");
116
+ fossil_print("comment: ");
117117
comment_print(zComment, 14, 79);
118118
free(zComment);
119119
}
120120
}
121121
@@ -141,33 +141,33 @@
141141
}
142142
if( g.argc==3 && (fsize = file_size(g.argv[2]))>0 && (fsize&0x1ff)==0 ){
143143
db_open_config(0);
144144
db_record_repository_filename(g.argv[2]);
145145
db_open_repository(g.argv[2]);
146
- printf("project-name: %s\n", db_get("project-name", "<unnamed>"));
147
- printf("project-code: %s\n", db_get("project-code", "<none>"));
148
- printf("server-code: %s\n", db_get("server-code", "<none>"));
146
+ fossil_print("project-name: %s\n", db_get("project-name", "<unnamed>"));
147
+ fossil_print("project-code: %s\n", db_get("project-code", "<none>"));
148
+ fossil_print("server-code: %s\n", db_get("server-code", "<none>"));
149149
return;
150150
}
151151
db_must_be_within_tree();
152152
if( g.argc==2 ){
153153
int vid;
154154
/* 012345678901234 */
155155
db_record_repository_filename(0);
156
- printf("project-name: %s\n", db_get("project-name", "<unnamed>"));
157
- printf("repository: %s\n", db_lget("repository", ""));
158
- printf("local-root: %s\n", g.zLocalRoot);
156
+ fossil_print("project-name: %s\n", db_get("project-name", "<unnamed>"));
157
+ fossil_print("repository: %s\n", db_lget("repository", ""));
158
+ fossil_print("local-root: %s\n", g.zLocalRoot);
159159
#if defined(_WIN32)
160160
if( g.zHome ){
161
- printf("user-home: %s\n", g.zHome);
161
+ fossil_print("user-home: %s\n", g.zHome);
162162
}
163163
#endif
164
- printf("project-code: %s\n", db_get("project-code", ""));
165
- printf("server-code: %s\n", db_get("server-code", ""));
164
+ fossil_print("project-code: %s\n", db_get("project-code", ""));
165
+ fossil_print("server-code: %s\n", db_get("server-code", ""));
166166
vid = db_lget_int("checkout", 0);
167167
if( vid==0 ){
168
- printf("checkout: nil\n");
168
+ fossil_print("checkout: nil\n");
169169
}else{
170170
show_common_info(vid, "checkout:", 1, 1);
171171
}
172172
}else{
173173
int rid;
174174
--- src/info.c
+++ src/info.c
@@ -67,11 +67,11 @@
67 zDate = db_text(0,
68 "SELECT datetime(mtime) || ' UTC' FROM event WHERE objid=%d",
69 rid
70 );
71 /* 01234567890123 */
72 printf("%-13s %s %s\n", zUuidName, zUuid, zDate ? zDate : "");
73 free(zUuid);
74 free(zDate);
75 }
76 if( zUuid && showComment ){
77 zComment = db_text(0,
@@ -88,11 +88,11 @@
88 const char *zUuid = db_column_text(&q, 0);
89 zDate = db_text("",
90 "SELECT datetime(mtime) || ' UTC' FROM event WHERE objid=%d",
91 db_column_int(&q, 1)
92 );
93 printf("parent: %s %s\n", zUuid, zDate);
94 free(zDate);
95 }
96 db_finalize(&q);
97 db_prepare(&q, "SELECT uuid, cid FROM plink JOIN blob ON cid=rid "
98 " WHERE pid=%d", rid);
@@ -100,22 +100,22 @@
100 const char *zUuid = db_column_text(&q, 0);
101 zDate = db_text("",
102 "SELECT datetime(mtime) || ' UTC' FROM event WHERE objid=%d",
103 db_column_int(&q, 1)
104 );
105 printf("child: %s %s\n", zUuid, zDate);
106 free(zDate);
107 }
108 db_finalize(&q);
109 }
110 zTags = info_tags_of_checkin(rid, 0);
111 if( zTags && zTags[0] ){
112 printf("tags: %s\n", zTags);
113 }
114 free(zTags);
115 if( zComment ){
116 printf("comment: ");
117 comment_print(zComment, 14, 79);
118 free(zComment);
119 }
120 }
121
@@ -141,33 +141,33 @@
141 }
142 if( g.argc==3 && (fsize = file_size(g.argv[2]))>0 && (fsize&0x1ff)==0 ){
143 db_open_config(0);
144 db_record_repository_filename(g.argv[2]);
145 db_open_repository(g.argv[2]);
146 printf("project-name: %s\n", db_get("project-name", "<unnamed>"));
147 printf("project-code: %s\n", db_get("project-code", "<none>"));
148 printf("server-code: %s\n", db_get("server-code", "<none>"));
149 return;
150 }
151 db_must_be_within_tree();
152 if( g.argc==2 ){
153 int vid;
154 /* 012345678901234 */
155 db_record_repository_filename(0);
156 printf("project-name: %s\n", db_get("project-name", "<unnamed>"));
157 printf("repository: %s\n", db_lget("repository", ""));
158 printf("local-root: %s\n", g.zLocalRoot);
159 #if defined(_WIN32)
160 if( g.zHome ){
161 printf("user-home: %s\n", g.zHome);
162 }
163 #endif
164 printf("project-code: %s\n", db_get("project-code", ""));
165 printf("server-code: %s\n", db_get("server-code", ""));
166 vid = db_lget_int("checkout", 0);
167 if( vid==0 ){
168 printf("checkout: nil\n");
169 }else{
170 show_common_info(vid, "checkout:", 1, 1);
171 }
172 }else{
173 int rid;
174
--- src/info.c
+++ src/info.c
@@ -67,11 +67,11 @@
67 zDate = db_text(0,
68 "SELECT datetime(mtime) || ' UTC' FROM event WHERE objid=%d",
69 rid
70 );
71 /* 01234567890123 */
72 fossil_print("%-13s %s %s\n", zUuidName, zUuid, zDate ? zDate : "");
73 free(zUuid);
74 free(zDate);
75 }
76 if( zUuid && showComment ){
77 zComment = db_text(0,
@@ -88,11 +88,11 @@
88 const char *zUuid = db_column_text(&q, 0);
89 zDate = db_text("",
90 "SELECT datetime(mtime) || ' UTC' FROM event WHERE objid=%d",
91 db_column_int(&q, 1)
92 );
93 fossil_print("parent: %s %s\n", zUuid, zDate);
94 free(zDate);
95 }
96 db_finalize(&q);
97 db_prepare(&q, "SELECT uuid, cid FROM plink JOIN blob ON cid=rid "
98 " WHERE pid=%d", rid);
@@ -100,22 +100,22 @@
100 const char *zUuid = db_column_text(&q, 0);
101 zDate = db_text("",
102 "SELECT datetime(mtime) || ' UTC' FROM event WHERE objid=%d",
103 db_column_int(&q, 1)
104 );
105 fossil_print("child: %s %s\n", zUuid, zDate);
106 free(zDate);
107 }
108 db_finalize(&q);
109 }
110 zTags = info_tags_of_checkin(rid, 0);
111 if( zTags && zTags[0] ){
112 fossil_print("tags: %s\n", zTags);
113 }
114 free(zTags);
115 if( zComment ){
116 fossil_print("comment: ");
117 comment_print(zComment, 14, 79);
118 free(zComment);
119 }
120 }
121
@@ -141,33 +141,33 @@
141 }
142 if( g.argc==3 && (fsize = file_size(g.argv[2]))>0 && (fsize&0x1ff)==0 ){
143 db_open_config(0);
144 db_record_repository_filename(g.argv[2]);
145 db_open_repository(g.argv[2]);
146 fossil_print("project-name: %s\n", db_get("project-name", "<unnamed>"));
147 fossil_print("project-code: %s\n", db_get("project-code", "<none>"));
148 fossil_print("server-code: %s\n", db_get("server-code", "<none>"));
149 return;
150 }
151 db_must_be_within_tree();
152 if( g.argc==2 ){
153 int vid;
154 /* 012345678901234 */
155 db_record_repository_filename(0);
156 fossil_print("project-name: %s\n", db_get("project-name", "<unnamed>"));
157 fossil_print("repository: %s\n", db_lget("repository", ""));
158 fossil_print("local-root: %s\n", g.zLocalRoot);
159 #if defined(_WIN32)
160 if( g.zHome ){
161 fossil_print("user-home: %s\n", g.zHome);
162 }
163 #endif
164 fossil_print("project-code: %s\n", db_get("project-code", ""));
165 fossil_print("server-code: %s\n", db_get("server-code", ""));
166 vid = db_lget_int("checkout", 0);
167 if( vid==0 ){
168 fossil_print("checkout: nil\n");
169 }else{
170 show_common_info(vid, "checkout:", 1, 1);
171 }
172 }else{
173 int rid;
174
+36 -30
--- src/main.c
+++ src/main.c
@@ -227,23 +227,24 @@
227227
*/
228228
int main(int argc, char **argv){
229229
const char *zCmdName = "unknown";
230230
int idx;
231231
int rc;
232
+ int i;
232233
233234
sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
234235
g.now = time(0);
235236
g.argc = argc;
236237
g.argv = argv;
238
+ for(i=0; i<argc; i++) g.argv[i] = fossil_mbcs_to_utf8(argv[i]);
237239
if( getenv("GATEWAY_INTERFACE")!=0 && !find_option("nocgi", 0, 0)){
238240
zCmdName = "cgi";
239241
}else if( argc<2 ){
240
- fprintf(stderr, "Usage: %s COMMAND ...\n"
241
- "\"%s help\" for a list of available commands\n"
242
- "\"%s help COMMAND\" for specific details\n",
243
- argv[0], argv[0], argv[0]);
244
- fossil_exit(1);
242
+ fossil_fatal("Usage: %s COMMAND ...\n"
243
+ "\"%s help\" for a list of available commands\n"
244
+ "\"%s help COMMAND\" for specific details\n",
245
+ argv[0], argv[0], argv[0]);
245246
}else{
246247
g.fQuiet = find_option("quiet", 0, 0)!=0;
247248
g.fSqlTrace = find_option("sqltrace", 0, 0)!=0;
248249
g.fSqlStats = find_option("sqlstats", 0, 0)!=0;
249250
if( g.fSqlTrace ) g.fSqlStats = 1;
@@ -264,14 +265,13 @@
264265
}
265266
zCmdName = g.argv[1];
266267
}
267268
rc = name_search(zCmdName, aCommand, count(aCommand), &idx);
268269
if( rc==1 ){
269
- fprintf(stderr,"%s: unknown command: %s\n"
270
- "%s: use \"help\" for more information\n",
270
+ fossil_fatal("%s: unknown command: %s\n"
271
+ "%s: use \"help\" for more information\n",
271272
argv[0], zCmdName, argv[0]);
272
- fossil_exit(1);
273273
}else if( rc==2 ){
274274
int i, n;
275275
Blob couldbe;
276276
blob_zero(&couldbe);
277277
n = strlen(zCmdName);
@@ -278,15 +278,14 @@
278278
for(i=0; i<count(aCommand); i++){
279279
if( memcmp(zCmdName, aCommand[i].zName, n)==0 ){
280280
blob_appendf(&couldbe, " %s", aCommand[i].zName);
281281
}
282282
}
283
- fprintf(stderr,"%s: ambiguous command prefix: %s\n"
284
- "%s: could be any of:%s\n"
285
- "%s: use \"help\" for more information\n",
286
- argv[0], zCmdName, argv[0], blob_str(&couldbe), argv[0]);
287
- fossil_exit(1);
283
+ fossil_fatal("%s: ambiguous command prefix: %s\n"
284
+ "%s: could be any of:%s\n"
285
+ "%s: use \"help\" for more information\n",
286
+ argv[0], zCmdName, argv[0], blob_str(&couldbe), argv[0]);
288287
}
289288
aCommand[idx].xFunc();
290289
fossil_exit(0);
291290
/*NOT_REACHED*/
292291
return 0;
@@ -333,11 +332,12 @@
333332
if( g.cgiOutput && once ){
334333
once = 0;
335334
cgi_printf("<p class=\"generalError\">%h</p>", z);
336335
cgi_reply();
337336
}else{
338
- fprintf(stderr, "%s: %s\n", fossil_nameofexe(), z);
337
+ char *zOut = mprintf("%s: %s\n", fossil_nameofexe(), z);
338
+ fossil_puts(zOut, 1);
339339
}
340340
db_force_rollback();
341341
fossil_exit(1);
342342
}
343343
void fossil_fatal(const char *zFormat, ...){
@@ -350,11 +350,12 @@
350350
if( g.cgiOutput ){
351351
g.cgiOutput = 0;
352352
cgi_printf("<p class=\"generalError\">%h</p>", z);
353353
cgi_reply();
354354
}else{
355
- fprintf(stderr, "\r%s: %s\n", fossil_nameofexe(), z);
355
+ char *zOut = mprintf("\r%s: %s\n", fossil_nameofexe(), z);
356
+ fossil_puts(zOut, 1);
356357
}
357358
db_force_rollback();
358359
fossil_exit(1);
359360
}
360361
@@ -378,11 +379,12 @@
378379
if( g.cgiOutput ){
379380
g.cgiOutput = 0;
380381
cgi_printf("<p class=\"generalError\">%h</p>", z);
381382
cgi_reply();
382383
}else{
383
- fprintf(stderr, "\r%s: %s\n", fossil_nameofexe(), z);
384
+ char *zOut = mprintf("\r%s: %s\n", fossil_nameofexe(), z);
385
+ fossil_puts(zOut, 1);
384386
}
385387
db_force_rollback();
386388
fossil_exit(1);
387389
}
388390
@@ -395,11 +397,13 @@
395397
z = vmprintf(zFormat, ap);
396398
va_end(ap);
397399
if( g.cgiOutput ){
398400
cgi_printf("<p class=\"generalError\">%h</p>", z);
399401
}else{
400
- fprintf(stderr, "\r%s: %s\n", fossil_nameofexe(), z);
402
+ char *zOut = mprintf("\r%s: %s\n", fossil_nameofexe(), z);
403
+ fossil_puts(zOut, 1);
404
+ free(zOut);
401405
}
402406
}
403407
404408
/*
405409
** Malloc and free routines that cannot fail
@@ -426,11 +430,13 @@
426430
#if defined(_WIN32)
427431
/* On windows, we have to put double-quotes around the entire command.
428432
** Who knows why - this is just the way windows works.
429433
*/
430434
char *zNewCmd = mprintf("\"%s\"", zOrigCmd);
431
- rc = system(zNewCmd);
435
+ char *zMbcs = fossil_utf8_to_mbcs(zNewCmd);
436
+ rc = system(zMbcs);
437
+ fossil_mbcs_free(zMbcs);
432438
free(zNewCmd);
433439
#else
434440
/* On unix, evaluate the command directly.
435441
*/
436442
rc = system(zOrigCmd);
@@ -507,12 +513,11 @@
507513
508514
/*
509515
** Print a usage comment and quit
510516
*/
511517
void usage(const char *zFormat){
512
- fprintf(stderr, "Usage: %s %s %s\n", fossil_nameofexe(), g.argv[1], zFormat);
513
- fossil_exit(1);
518
+ fossil_fatal("Usage: %s %s %s\n", fossil_nameofexe(), g.argv[1], zFormat);
514519
}
515520
516521
/*
517522
** Remove n elements from g.argv beginning with the i-th element.
518523
*/
@@ -601,14 +606,14 @@
601606
if( nCol==0 ) nCol = 1;
602607
nRow = (nWord + nCol - 1)/nCol;
603608
for(i=0; i<nRow; i++){
604609
const char *zSpacer = "";
605610
for(j=i; j<nWord; j+=nRow){
606
- printf("%s%-*s", zSpacer, mxLen, azWord[j]);
611
+ fossil_print("%s%-*s", zSpacer, mxLen, azWord[j]);
607612
zSpacer = " ";
608613
}
609
- printf("\n");
614
+ fossil_print("\n");
610615
}
611616
}
612617
613618
/*
614619
** List of commands starting with zPrefix, or all commands if zPrefix is NULL.
@@ -650,11 +655,12 @@
650655
** Usage: %fossil version
651656
**
652657
** Print the source code version number for the fossil executable.
653658
*/
654659
void version_cmd(void){
655
- printf("This is fossil version " MANIFEST_VERSION " " MANIFEST_DATE " UTC\n");
660
+ fossil_print("This is fossil version "
661
+ MANIFEST_VERSION " " MANIFEST_DATE " UTC\n");
656662
}
657663
658664
659665
/*
660666
** COMMAND: help
@@ -665,12 +671,12 @@
665671
*/
666672
void help_cmd(void){
667673
int rc, idx;
668674
const char *z;
669675
if( g.argc<3 ){
670
- printf("Usage: %s help COMMAND.\nAvailable COMMANDs:\n",
671
- fossil_nameofexe());
676
+ fossil_print("Usage: %s help COMMAND.\nAvailable COMMANDs:\n",
677
+ fossil_nameofexe());
672678
cmd_cmd_list(0);
673679
version_cmd();
674680
return;
675681
}
676682
rc = name_search(g.argv[2], aCommand, count(aCommand), &idx);
@@ -689,11 +695,11 @@
689695
fossil_fatal("no help available for the %s command",
690696
aCommand[idx].zName);
691697
}
692698
while( *z ){
693699
if( *z=='%' && strncmp(z, "%fossil", 7)==0 ){
694
- printf("%s", fossil_nameofexe());
700
+ fossil_print("%s", fossil_nameofexe());
695701
z += 7;
696702
}else{
697703
putchar(*z);
698704
z++;
699705
}
@@ -1281,12 +1287,12 @@
12811287
if( g.argc!=2 && g.argc!=3 && g.argc!=6 ){
12821288
fossil_fatal("no repository specified");
12831289
}
12841290
g.fullHttpReply = 1;
12851291
if( g.argc==6 ){
1286
- g.httpIn = fopen(g.argv[3], "rb");
1287
- g.httpOut = fopen(g.argv[4], "wb");
1292
+ g.httpIn = fossil_fopen(g.argv[3], "rb");
1293
+ g.httpOut = fossil_fopen(g.argv[4], "wb");
12881294
zIpAddr = g.argv[5];
12891295
}else{
12901296
g.httpIn = stdin;
12911297
g.httpOut = stdout;
12921298
zIpAddr = 0;
@@ -1327,11 +1333,11 @@
13271333
int bExists;
13281334
while( zPath && zPath[0] ){
13291335
while( zPath[0]==':' ) zPath++;
13301336
for(i=0; zPath[i] && zPath[i]!=':'; i++){}
13311337
zFull = mprintf("%.*s/%s", i, zPath, zBinary);
1332
- bExists = access(zFull, X_OK);
1338
+ bExists = file_access(zFull, X_OK);
13331339
free(zFull);
13341340
if( bExists==0 ) return 1;
13351341
zPath += i;
13361342
}
13371343
return 0;
@@ -1455,8 +1461,8 @@
14551461
** wildcard expansion behavior of the host shell can be investigated.
14561462
*/
14571463
void test_echo_cmd(void){
14581464
int i;
14591465
for(i=0; i<g.argc; i++){
1460
- printf("argv[%d] = [%s]\n", i, g.argv[i]);
1466
+ fossil_print("argv[%d] = [%s]\n", i, g.argv[i]);
14611467
}
14621468
}
14631469
--- src/main.c
+++ src/main.c
@@ -227,23 +227,24 @@
227 */
228 int main(int argc, char **argv){
229 const char *zCmdName = "unknown";
230 int idx;
231 int rc;
 
232
233 sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
234 g.now = time(0);
235 g.argc = argc;
236 g.argv = argv;
 
237 if( getenv("GATEWAY_INTERFACE")!=0 && !find_option("nocgi", 0, 0)){
238 zCmdName = "cgi";
239 }else if( argc<2 ){
240 fprintf(stderr, "Usage: %s COMMAND ...\n"
241 "\"%s help\" for a list of available commands\n"
242 "\"%s help COMMAND\" for specific details\n",
243 argv[0], argv[0], argv[0]);
244 fossil_exit(1);
245 }else{
246 g.fQuiet = find_option("quiet", 0, 0)!=0;
247 g.fSqlTrace = find_option("sqltrace", 0, 0)!=0;
248 g.fSqlStats = find_option("sqlstats", 0, 0)!=0;
249 if( g.fSqlTrace ) g.fSqlStats = 1;
@@ -264,14 +265,13 @@
264 }
265 zCmdName = g.argv[1];
266 }
267 rc = name_search(zCmdName, aCommand, count(aCommand), &idx);
268 if( rc==1 ){
269 fprintf(stderr,"%s: unknown command: %s\n"
270 "%s: use \"help\" for more information\n",
271 argv[0], zCmdName, argv[0]);
272 fossil_exit(1);
273 }else if( rc==2 ){
274 int i, n;
275 Blob couldbe;
276 blob_zero(&couldbe);
277 n = strlen(zCmdName);
@@ -278,15 +278,14 @@
278 for(i=0; i<count(aCommand); i++){
279 if( memcmp(zCmdName, aCommand[i].zName, n)==0 ){
280 blob_appendf(&couldbe, " %s", aCommand[i].zName);
281 }
282 }
283 fprintf(stderr,"%s: ambiguous command prefix: %s\n"
284 "%s: could be any of:%s\n"
285 "%s: use \"help\" for more information\n",
286 argv[0], zCmdName, argv[0], blob_str(&couldbe), argv[0]);
287 fossil_exit(1);
288 }
289 aCommand[idx].xFunc();
290 fossil_exit(0);
291 /*NOT_REACHED*/
292 return 0;
@@ -333,11 +332,12 @@
333 if( g.cgiOutput && once ){
334 once = 0;
335 cgi_printf("<p class=\"generalError\">%h</p>", z);
336 cgi_reply();
337 }else{
338 fprintf(stderr, "%s: %s\n", fossil_nameofexe(), z);
 
339 }
340 db_force_rollback();
341 fossil_exit(1);
342 }
343 void fossil_fatal(const char *zFormat, ...){
@@ -350,11 +350,12 @@
350 if( g.cgiOutput ){
351 g.cgiOutput = 0;
352 cgi_printf("<p class=\"generalError\">%h</p>", z);
353 cgi_reply();
354 }else{
355 fprintf(stderr, "\r%s: %s\n", fossil_nameofexe(), z);
 
356 }
357 db_force_rollback();
358 fossil_exit(1);
359 }
360
@@ -378,11 +379,12 @@
378 if( g.cgiOutput ){
379 g.cgiOutput = 0;
380 cgi_printf("<p class=\"generalError\">%h</p>", z);
381 cgi_reply();
382 }else{
383 fprintf(stderr, "\r%s: %s\n", fossil_nameofexe(), z);
 
384 }
385 db_force_rollback();
386 fossil_exit(1);
387 }
388
@@ -395,11 +397,13 @@
395 z = vmprintf(zFormat, ap);
396 va_end(ap);
397 if( g.cgiOutput ){
398 cgi_printf("<p class=\"generalError\">%h</p>", z);
399 }else{
400 fprintf(stderr, "\r%s: %s\n", fossil_nameofexe(), z);
 
 
401 }
402 }
403
404 /*
405 ** Malloc and free routines that cannot fail
@@ -426,11 +430,13 @@
426 #if defined(_WIN32)
427 /* On windows, we have to put double-quotes around the entire command.
428 ** Who knows why - this is just the way windows works.
429 */
430 char *zNewCmd = mprintf("\"%s\"", zOrigCmd);
431 rc = system(zNewCmd);
 
 
432 free(zNewCmd);
433 #else
434 /* On unix, evaluate the command directly.
435 */
436 rc = system(zOrigCmd);
@@ -507,12 +513,11 @@
507
508 /*
509 ** Print a usage comment and quit
510 */
511 void usage(const char *zFormat){
512 fprintf(stderr, "Usage: %s %s %s\n", fossil_nameofexe(), g.argv[1], zFormat);
513 fossil_exit(1);
514 }
515
516 /*
517 ** Remove n elements from g.argv beginning with the i-th element.
518 */
@@ -601,14 +606,14 @@
601 if( nCol==0 ) nCol = 1;
602 nRow = (nWord + nCol - 1)/nCol;
603 for(i=0; i<nRow; i++){
604 const char *zSpacer = "";
605 for(j=i; j<nWord; j+=nRow){
606 printf("%s%-*s", zSpacer, mxLen, azWord[j]);
607 zSpacer = " ";
608 }
609 printf("\n");
610 }
611 }
612
613 /*
614 ** List of commands starting with zPrefix, or all commands if zPrefix is NULL.
@@ -650,11 +655,12 @@
650 ** Usage: %fossil version
651 **
652 ** Print the source code version number for the fossil executable.
653 */
654 void version_cmd(void){
655 printf("This is fossil version " MANIFEST_VERSION " " MANIFEST_DATE " UTC\n");
 
656 }
657
658
659 /*
660 ** COMMAND: help
@@ -665,12 +671,12 @@
665 */
666 void help_cmd(void){
667 int rc, idx;
668 const char *z;
669 if( g.argc<3 ){
670 printf("Usage: %s help COMMAND.\nAvailable COMMANDs:\n",
671 fossil_nameofexe());
672 cmd_cmd_list(0);
673 version_cmd();
674 return;
675 }
676 rc = name_search(g.argv[2], aCommand, count(aCommand), &idx);
@@ -689,11 +695,11 @@
689 fossil_fatal("no help available for the %s command",
690 aCommand[idx].zName);
691 }
692 while( *z ){
693 if( *z=='%' && strncmp(z, "%fossil", 7)==0 ){
694 printf("%s", fossil_nameofexe());
695 z += 7;
696 }else{
697 putchar(*z);
698 z++;
699 }
@@ -1281,12 +1287,12 @@
1281 if( g.argc!=2 && g.argc!=3 && g.argc!=6 ){
1282 fossil_fatal("no repository specified");
1283 }
1284 g.fullHttpReply = 1;
1285 if( g.argc==6 ){
1286 g.httpIn = fopen(g.argv[3], "rb");
1287 g.httpOut = fopen(g.argv[4], "wb");
1288 zIpAddr = g.argv[5];
1289 }else{
1290 g.httpIn = stdin;
1291 g.httpOut = stdout;
1292 zIpAddr = 0;
@@ -1327,11 +1333,11 @@
1327 int bExists;
1328 while( zPath && zPath[0] ){
1329 while( zPath[0]==':' ) zPath++;
1330 for(i=0; zPath[i] && zPath[i]!=':'; i++){}
1331 zFull = mprintf("%.*s/%s", i, zPath, zBinary);
1332 bExists = access(zFull, X_OK);
1333 free(zFull);
1334 if( bExists==0 ) return 1;
1335 zPath += i;
1336 }
1337 return 0;
@@ -1455,8 +1461,8 @@
1455 ** wildcard expansion behavior of the host shell can be investigated.
1456 */
1457 void test_echo_cmd(void){
1458 int i;
1459 for(i=0; i<g.argc; i++){
1460 printf("argv[%d] = [%s]\n", i, g.argv[i]);
1461 }
1462 }
1463
--- src/main.c
+++ src/main.c
@@ -227,23 +227,24 @@
227 */
228 int main(int argc, char **argv){
229 const char *zCmdName = "unknown";
230 int idx;
231 int rc;
232 int i;
233
234 sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
235 g.now = time(0);
236 g.argc = argc;
237 g.argv = argv;
238 for(i=0; i<argc; i++) g.argv[i] = fossil_mbcs_to_utf8(argv[i]);
239 if( getenv("GATEWAY_INTERFACE")!=0 && !find_option("nocgi", 0, 0)){
240 zCmdName = "cgi";
241 }else if( argc<2 ){
242 fossil_fatal("Usage: %s COMMAND ...\n"
243 "\"%s help\" for a list of available commands\n"
244 "\"%s help COMMAND\" for specific details\n",
245 argv[0], argv[0], argv[0]);
 
246 }else{
247 g.fQuiet = find_option("quiet", 0, 0)!=0;
248 g.fSqlTrace = find_option("sqltrace", 0, 0)!=0;
249 g.fSqlStats = find_option("sqlstats", 0, 0)!=0;
250 if( g.fSqlTrace ) g.fSqlStats = 1;
@@ -264,14 +265,13 @@
265 }
266 zCmdName = g.argv[1];
267 }
268 rc = name_search(zCmdName, aCommand, count(aCommand), &idx);
269 if( rc==1 ){
270 fossil_fatal("%s: unknown command: %s\n"
271 "%s: use \"help\" for more information\n",
272 argv[0], zCmdName, argv[0]);
 
273 }else if( rc==2 ){
274 int i, n;
275 Blob couldbe;
276 blob_zero(&couldbe);
277 n = strlen(zCmdName);
@@ -278,15 +278,14 @@
278 for(i=0; i<count(aCommand); i++){
279 if( memcmp(zCmdName, aCommand[i].zName, n)==0 ){
280 blob_appendf(&couldbe, " %s", aCommand[i].zName);
281 }
282 }
283 fossil_fatal("%s: ambiguous command prefix: %s\n"
284 "%s: could be any of:%s\n"
285 "%s: use \"help\" for more information\n",
286 argv[0], zCmdName, argv[0], blob_str(&couldbe), argv[0]);
 
287 }
288 aCommand[idx].xFunc();
289 fossil_exit(0);
290 /*NOT_REACHED*/
291 return 0;
@@ -333,11 +332,12 @@
332 if( g.cgiOutput && once ){
333 once = 0;
334 cgi_printf("<p class=\"generalError\">%h</p>", z);
335 cgi_reply();
336 }else{
337 char *zOut = mprintf("%s: %s\n", fossil_nameofexe(), z);
338 fossil_puts(zOut, 1);
339 }
340 db_force_rollback();
341 fossil_exit(1);
342 }
343 void fossil_fatal(const char *zFormat, ...){
@@ -350,11 +350,12 @@
350 if( g.cgiOutput ){
351 g.cgiOutput = 0;
352 cgi_printf("<p class=\"generalError\">%h</p>", z);
353 cgi_reply();
354 }else{
355 char *zOut = mprintf("\r%s: %s\n", fossil_nameofexe(), z);
356 fossil_puts(zOut, 1);
357 }
358 db_force_rollback();
359 fossil_exit(1);
360 }
361
@@ -378,11 +379,12 @@
379 if( g.cgiOutput ){
380 g.cgiOutput = 0;
381 cgi_printf("<p class=\"generalError\">%h</p>", z);
382 cgi_reply();
383 }else{
384 char *zOut = mprintf("\r%s: %s\n", fossil_nameofexe(), z);
385 fossil_puts(zOut, 1);
386 }
387 db_force_rollback();
388 fossil_exit(1);
389 }
390
@@ -395,11 +397,13 @@
397 z = vmprintf(zFormat, ap);
398 va_end(ap);
399 if( g.cgiOutput ){
400 cgi_printf("<p class=\"generalError\">%h</p>", z);
401 }else{
402 char *zOut = mprintf("\r%s: %s\n", fossil_nameofexe(), z);
403 fossil_puts(zOut, 1);
404 free(zOut);
405 }
406 }
407
408 /*
409 ** Malloc and free routines that cannot fail
@@ -426,11 +430,13 @@
430 #if defined(_WIN32)
431 /* On windows, we have to put double-quotes around the entire command.
432 ** Who knows why - this is just the way windows works.
433 */
434 char *zNewCmd = mprintf("\"%s\"", zOrigCmd);
435 char *zMbcs = fossil_utf8_to_mbcs(zNewCmd);
436 rc = system(zMbcs);
437 fossil_mbcs_free(zMbcs);
438 free(zNewCmd);
439 #else
440 /* On unix, evaluate the command directly.
441 */
442 rc = system(zOrigCmd);
@@ -507,12 +513,11 @@
513
514 /*
515 ** Print a usage comment and quit
516 */
517 void usage(const char *zFormat){
518 fossil_fatal("Usage: %s %s %s\n", fossil_nameofexe(), g.argv[1], zFormat);
 
519 }
520
521 /*
522 ** Remove n elements from g.argv beginning with the i-th element.
523 */
@@ -601,14 +606,14 @@
606 if( nCol==0 ) nCol = 1;
607 nRow = (nWord + nCol - 1)/nCol;
608 for(i=0; i<nRow; i++){
609 const char *zSpacer = "";
610 for(j=i; j<nWord; j+=nRow){
611 fossil_print("%s%-*s", zSpacer, mxLen, azWord[j]);
612 zSpacer = " ";
613 }
614 fossil_print("\n");
615 }
616 }
617
618 /*
619 ** List of commands starting with zPrefix, or all commands if zPrefix is NULL.
@@ -650,11 +655,12 @@
655 ** Usage: %fossil version
656 **
657 ** Print the source code version number for the fossil executable.
658 */
659 void version_cmd(void){
660 fossil_print("This is fossil version "
661 MANIFEST_VERSION " " MANIFEST_DATE " UTC\n");
662 }
663
664
665 /*
666 ** COMMAND: help
@@ -665,12 +671,12 @@
671 */
672 void help_cmd(void){
673 int rc, idx;
674 const char *z;
675 if( g.argc<3 ){
676 fossil_print("Usage: %s help COMMAND.\nAvailable COMMANDs:\n",
677 fossil_nameofexe());
678 cmd_cmd_list(0);
679 version_cmd();
680 return;
681 }
682 rc = name_search(g.argv[2], aCommand, count(aCommand), &idx);
@@ -689,11 +695,11 @@
695 fossil_fatal("no help available for the %s command",
696 aCommand[idx].zName);
697 }
698 while( *z ){
699 if( *z=='%' && strncmp(z, "%fossil", 7)==0 ){
700 fossil_print("%s", fossil_nameofexe());
701 z += 7;
702 }else{
703 putchar(*z);
704 z++;
705 }
@@ -1281,12 +1287,12 @@
1287 if( g.argc!=2 && g.argc!=3 && g.argc!=6 ){
1288 fossil_fatal("no repository specified");
1289 }
1290 g.fullHttpReply = 1;
1291 if( g.argc==6 ){
1292 g.httpIn = fossil_fopen(g.argv[3], "rb");
1293 g.httpOut = fossil_fopen(g.argv[4], "wb");
1294 zIpAddr = g.argv[5];
1295 }else{
1296 g.httpIn = stdin;
1297 g.httpOut = stdout;
1298 zIpAddr = 0;
@@ -1327,11 +1333,11 @@
1333 int bExists;
1334 while( zPath && zPath[0] ){
1335 while( zPath[0]==':' ) zPath++;
1336 for(i=0; zPath[i] && zPath[i]!=':'; i++){}
1337 zFull = mprintf("%.*s/%s", i, zPath, zBinary);
1338 bExists = file_access(zFull, X_OK);
1339 free(zFull);
1340 if( bExists==0 ) return 1;
1341 zPath += i;
1342 }
1343 return 0;
@@ -1455,8 +1461,8 @@
1461 ** wildcard expansion behavior of the host shell can be investigated.
1462 */
1463 void test_echo_cmd(void){
1464 int i;
1465 for(i=0; i<g.argc; i++){
1466 fossil_print("argv[%d] = [%s]\n", i, g.argv[i]);
1467 }
1468 }
1469
+1 -1
--- src/main.mk
+++ src/main.mk
@@ -892,11 +892,11 @@
892892
$(OBJDIR)/zip.h: $(OBJDIR)/headers
893893
$(OBJDIR)/sqlite3.o: $(SRCDIR)/sqlite3.c
894894
$(XTCC) -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_STAT2 -Dlocaltime=fossil_localtime -DSQLITE_ENABLE_LOCKING_STYLE=0 -c $(SRCDIR)/sqlite3.c -o $(OBJDIR)/sqlite3.o
895895
896896
$(OBJDIR)/shell.o: $(SRCDIR)/shell.c
897
- $(XTCC) -Dmain=sqlite3_shell -DSQLITE_OMIT_LOAD_EXTENSION=1 -c $(SRCDIR)/shell.c -o $(OBJDIR)/shell.o
897
+ $(XTCC) -Dmain=sqlite3_shell -DSQLITE_OMIT_LOAD_EXTENSION=1 -Dfopen=fossil_fopen -c $(SRCDIR)/shell.c -o $(OBJDIR)/shell.o
898898
899899
$(OBJDIR)/th.o: $(SRCDIR)/th.c
900900
$(XTCC) -I$(SRCDIR) -c $(SRCDIR)/th.c -o $(OBJDIR)/th.o
901901
902902
$(OBJDIR)/th_lang.o: $(SRCDIR)/th_lang.c
903903
--- src/main.mk
+++ src/main.mk
@@ -892,11 +892,11 @@
892 $(OBJDIR)/zip.h: $(OBJDIR)/headers
893 $(OBJDIR)/sqlite3.o: $(SRCDIR)/sqlite3.c
894 $(XTCC) -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_STAT2 -Dlocaltime=fossil_localtime -DSQLITE_ENABLE_LOCKING_STYLE=0 -c $(SRCDIR)/sqlite3.c -o $(OBJDIR)/sqlite3.o
895
896 $(OBJDIR)/shell.o: $(SRCDIR)/shell.c
897 $(XTCC) -Dmain=sqlite3_shell -DSQLITE_OMIT_LOAD_EXTENSION=1 -c $(SRCDIR)/shell.c -o $(OBJDIR)/shell.o
898
899 $(OBJDIR)/th.o: $(SRCDIR)/th.c
900 $(XTCC) -I$(SRCDIR) -c $(SRCDIR)/th.c -o $(OBJDIR)/th.o
901
902 $(OBJDIR)/th_lang.o: $(SRCDIR)/th_lang.c
903
--- src/main.mk
+++ src/main.mk
@@ -892,11 +892,11 @@
892 $(OBJDIR)/zip.h: $(OBJDIR)/headers
893 $(OBJDIR)/sqlite3.o: $(SRCDIR)/sqlite3.c
894 $(XTCC) -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_STAT2 -Dlocaltime=fossil_localtime -DSQLITE_ENABLE_LOCKING_STYLE=0 -c $(SRCDIR)/sqlite3.c -o $(OBJDIR)/sqlite3.o
895
896 $(OBJDIR)/shell.o: $(SRCDIR)/shell.c
897 $(XTCC) -Dmain=sqlite3_shell -DSQLITE_OMIT_LOAD_EXTENSION=1 -Dfopen=fossil_fopen -c $(SRCDIR)/shell.c -o $(OBJDIR)/shell.o
898
899 $(OBJDIR)/th.o: $(SRCDIR)/th.c
900 $(XTCC) -I$(SRCDIR) -c $(SRCDIR)/th.c -o $(OBJDIR)/th.o
901
902 $(OBJDIR)/th_lang.o: $(SRCDIR)/th_lang.c
903
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -250,10 +250,11 @@
250250
writeln "\t\$(XTCC) $opt -c \$(SRCDIR)/sqlite3.c -o \$(OBJDIR)/sqlite3.o\n"
251251
252252
writeln "\$(OBJDIR)/shell.o:\t\$(SRCDIR)/shell.c"
253253
set opt {-Dmain=sqlite3_shell}
254254
append opt " -DSQLITE_OMIT_LOAD_EXTENSION=1"
255
+append opt " -Dfopen=fossil_fopen"
255256
writeln "\t\$(XTCC) $opt -c \$(SRCDIR)/shell.c -o \$(OBJDIR)/shell.o\n"
256257
257258
writeln "\$(OBJDIR)/th.o:\t\$(SRCDIR)/th.c"
258259
writeln "\t\$(XTCC) -I\$(SRCDIR) -c \$(SRCDIR)/th.c -o \$(OBJDIR)/th.o\n"
259260
260261
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -250,10 +250,11 @@
250 writeln "\t\$(XTCC) $opt -c \$(SRCDIR)/sqlite3.c -o \$(OBJDIR)/sqlite3.o\n"
251
252 writeln "\$(OBJDIR)/shell.o:\t\$(SRCDIR)/shell.c"
253 set opt {-Dmain=sqlite3_shell}
254 append opt " -DSQLITE_OMIT_LOAD_EXTENSION=1"
 
255 writeln "\t\$(XTCC) $opt -c \$(SRCDIR)/shell.c -o \$(OBJDIR)/shell.o\n"
256
257 writeln "\$(OBJDIR)/th.o:\t\$(SRCDIR)/th.c"
258 writeln "\t\$(XTCC) -I\$(SRCDIR) -c \$(SRCDIR)/th.c -o \$(OBJDIR)/th.o\n"
259
260
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -250,10 +250,11 @@
250 writeln "\t\$(XTCC) $opt -c \$(SRCDIR)/sqlite3.c -o \$(OBJDIR)/sqlite3.o\n"
251
252 writeln "\$(OBJDIR)/shell.o:\t\$(SRCDIR)/shell.c"
253 set opt {-Dmain=sqlite3_shell}
254 append opt " -DSQLITE_OMIT_LOAD_EXTENSION=1"
255 append opt " -Dfopen=fossil_fopen"
256 writeln "\t\$(XTCC) $opt -c \$(SRCDIR)/shell.c -o \$(OBJDIR)/shell.o\n"
257
258 writeln "\$(OBJDIR)/th.o:\t\$(SRCDIR)/th.c"
259 writeln "\t\$(XTCC) -I\$(SRCDIR) -c \$(SRCDIR)/th.c -o \$(OBJDIR)/th.o\n"
260
261
+2 -2
--- src/md5.c
+++ src/md5.c
@@ -376,11 +376,11 @@
376376
FILE *in;
377377
MD5Context ctx;
378378
unsigned char zResult[16];
379379
char zBuf[10240];
380380
381
- in = fopen(zFilename,"rb");
381
+ in = fossil_fopen(zFilename,"rb");
382382
if( in==0 ){
383383
return 1;
384384
}
385385
MD5Init(&ctx);
386386
for(;;){
@@ -438,9 +438,9 @@
438438
blob_read_from_channel(&in, stdin, -1);
439439
md5sum_blob(&in, &cksum);
440440
}else{
441441
md5sum_file(g.argv[i], &cksum);
442442
}
443
- printf("%s %s\n", blob_str(&cksum), g.argv[i]);
443
+ fossil_print("%s %s\n", blob_str(&cksum), g.argv[i]);
444444
blob_reset(&cksum);
445445
}
446446
}
447447
--- src/md5.c
+++ src/md5.c
@@ -376,11 +376,11 @@
376 FILE *in;
377 MD5Context ctx;
378 unsigned char zResult[16];
379 char zBuf[10240];
380
381 in = fopen(zFilename,"rb");
382 if( in==0 ){
383 return 1;
384 }
385 MD5Init(&ctx);
386 for(;;){
@@ -438,9 +438,9 @@
438 blob_read_from_channel(&in, stdin, -1);
439 md5sum_blob(&in, &cksum);
440 }else{
441 md5sum_file(g.argv[i], &cksum);
442 }
443 printf("%s %s\n", blob_str(&cksum), g.argv[i]);
444 blob_reset(&cksum);
445 }
446 }
447
--- src/md5.c
+++ src/md5.c
@@ -376,11 +376,11 @@
376 FILE *in;
377 MD5Context ctx;
378 unsigned char zResult[16];
379 char zBuf[10240];
380
381 in = fossil_fopen(zFilename,"rb");
382 if( in==0 ){
383 return 1;
384 }
385 MD5Init(&ctx);
386 for(;;){
@@ -438,9 +438,9 @@
438 blob_read_from_channel(&in, stdin, -1);
439 md5sum_blob(&in, &cksum);
440 }else{
441 md5sum_file(g.argv[i], &cksum);
442 }
443 fossil_print("%s %s\n", blob_str(&cksum), g.argv[i]);
444 blob_reset(&cksum);
445 }
446 }
447
+19 -17
--- src/merge.c
+++ src/merge.c
@@ -249,20 +249,20 @@
249249
if( debugFlag ){
250250
db_prepare(&q,
251251
"SELECT rowid, fn, fnp, fnm, chnged, ridv, ridp, ridm, isexe FROM fv"
252252
);
253253
while( db_step(&q)==SQLITE_ROW ){
254
- printf("%3d: ridv=%-4d ridp=%-4d ridm=%-4d chnged=%d isexe=%d\n",
254
+ fossil_print("%3d: ridv=%-4d ridp=%-4d ridm=%-4d chnged=%d isexe=%d\n",
255255
db_column_int(&q, 0),
256256
db_column_int(&q, 5),
257257
db_column_int(&q, 6),
258258
db_column_int(&q, 7),
259259
db_column_int(&q, 4),
260260
db_column_int(&q, 8));
261
- printf(" fn = [%s]\n", db_column_text(&q, 1));
262
- printf(" fnp = [%s]\n", db_column_text(&q, 2));
263
- printf(" fnm = [%s]\n", db_column_text(&q, 3));
261
+ fossil_print(" fn = [%s]\n", db_column_text(&q, 1));
262
+ fossil_print(" fnp = [%s]\n", db_column_text(&q, 2));
263
+ fossil_print(" fnm = [%s]\n", db_column_text(&q, 3));
264264
}
265265
db_finalize(&q);
266266
}
267267
268268
/*
@@ -274,11 +274,11 @@
274274
"SELECT idm FROM fv WHERE idp=0 AND idv>0 AND idm>0"
275275
);
276276
while( db_step(&q)==SQLITE_ROW ){
277277
int idm = db_column_int(&q, 0);
278278
char *zName = db_text(0, "SELECT pathname FROM vfile WHERE id=%d", idm);
279
- printf("WARNING - no common ancestor: %s\n", zName);
279
+ fossil_warning("WARNING - no common ancestor: %s\n", zName);
280280
free(zName);
281281
db_multi_exec("UPDATE fv SET idm=0 WHERE idm=%d", idm);
282282
}
283283
db_finalize(&q);
284284
@@ -300,11 +300,11 @@
300300
vid, idm
301301
);
302302
idv = db_last_insert_rowid();
303303
db_multi_exec("UPDATE fv SET idv=%d WHERE rowid=%d", idv, rowid);
304304
zName = db_column_text(&q, 2);
305
- printf("ADDED %s\n", zName);
305
+ fossil_print("ADDED %s\n", zName);
306306
if( !nochangeFlag ){
307307
undo_save(zName);
308308
vfile_to_disk(0, idm, 0, 0);
309309
}
310310
}
@@ -322,11 +322,11 @@
322322
while( db_step(&q)==SQLITE_ROW ){
323323
int idv = db_column_int(&q, 0);
324324
int ridm = db_column_int(&q, 1);
325325
const char *zName = db_column_text(&q, 2);
326326
/* Copy content from idm over into idv. Overwrite idv. */
327
- printf("UPDATE %s\n", zName);
327
+ fossil_print("UPDATE %s\n", zName);
328328
if( !nochangeFlag ){
329329
undo_save(zName);
330330
db_multi_exec(
331331
"UPDATE vfile SET mtime=0, mrid=%d, chnged=2 WHERE id=%d", ridm, idv
332332
);
@@ -355,13 +355,14 @@
355355
int rc;
356356
char *zFullPath;
357357
Blob m, p, r;
358358
/* Do a 3-way merge of idp->idm into idp->idv. The results go into idv. */
359359
if( detailFlag ){
360
- printf("MERGE %s (pivot=%d v1=%d v2=%d)\n", zName, ridp, ridm, ridv);
360
+ fossil_print("MERGE %s (pivot=%d v1=%d v2=%d)\n",
361
+ zName, ridp, ridm, ridv);
361362
}else{
362
- printf("MERGE %s\n", zName);
363
+ fossil_print("MERGE %s\n", zName);
363364
}
364365
undo_save(zName);
365366
zFullPath = mprintf("%s/%s", g.zLocalRoot, zName);
366367
content_get(ridp, &p);
367368
content_get(ridm, &m);
@@ -376,15 +377,15 @@
376377
blob_write_to_file(&r, zFullPath);
377378
file_setexe(zFullPath, isExe);
378379
}
379380
db_multi_exec("UPDATE vfile SET mtime=0 WHERE id=%d", idv);
380381
if( rc>0 ){
381
- printf("***** %d merge conflicts in %s\n", rc, zName);
382
+ fossil_print("***** %d merge conflicts in %s\n", rc, zName);
382383
nConflict++;
383384
}
384385
}else{
385
- printf("***** Cannot merge binary file %s\n", zName);
386
+ fossil_print("***** Cannot merge binary file %s\n", zName);
386387
nConflict++;
387388
}
388389
blob_reset(&p);
389390
blob_reset(&m);
390391
blob_reset(&r);
@@ -403,22 +404,22 @@
403404
while( db_step(&q)==SQLITE_ROW ){
404405
int idv = db_column_int(&q, 0);
405406
const char *zName = db_column_text(&q, 1);
406407
int chnged = db_column_int(&q, 2);
407408
/* Delete the file idv */
408
- printf("DELETE %s\n", zName);
409
+ fossil_print("DELETE %s\n", zName);
409410
if( chnged ){
410
- printf("WARNING: local edits lost for %s\n", zName);
411
+ fossil_warning("WARNING: local edits lost for %s\n", zName);
411412
nConflict++;
412413
}
413414
undo_save(zName);
414415
db_multi_exec(
415416
"UPDATE vfile SET deleted=1 WHERE id=%d", idv
416417
);
417418
if( !nochangeFlag ){
418419
char *zFullPath = mprintf("%s%s", g.zLocalRoot, zName);
419
- unlink(zFullPath);
420
+ file_delete(zFullPath);
420421
free(zFullPath);
421422
}
422423
}
423424
db_finalize(&q);
424425
@@ -433,11 +434,11 @@
433434
);
434435
while( db_step(&q)==SQLITE_ROW ){
435436
int idv = db_column_int(&q, 0);
436437
const char *zOldName = db_column_text(&q, 1);
437438
const char *zNewName = db_column_text(&q, 2);
438
- printf("RENAME %s -> %s\n", zOldName, zNewName);
439
+ fossil_print("RENAME %s -> %s\n", zOldName, zNewName);
439440
undo_save(zOldName);
440441
undo_save(zNewName);
441442
db_multi_exec(
442443
"UPDATE vfile SET pathname=%Q, origname=coalesce(origname,pathname)"
443444
" WHERE id=%d AND vid=%d", zNewName, idv, vid
@@ -444,11 +445,11 @@
444445
);
445446
if( !nochangeFlag ){
446447
char *zFullOldPath = mprintf("%s%s", g.zLocalRoot, zOldName);
447448
char *zFullNewPath = mprintf("%s%s", g.zLocalRoot, zNewName);
448449
file_copy(zFullOldPath, zFullNewPath);
449
- unlink(zFullOldPath);
450
+ file_delete(zFullOldPath);
450451
free(zFullNewPath);
451452
free(zFullOldPath);
452453
}
453454
}
454455
db_finalize(&q);
@@ -455,11 +456,12 @@
455456
456457
457458
/* Report on conflicts
458459
*/
459460
if( nConflict && !nochangeFlag ){
460
- printf("WARNING: merge conflicts - see messages above for details.\n");
461
+ fossil_warning(
462
+ "WARNING: merge conflicts - see messages above for details.\n");
461463
}
462464
463465
/*
464466
** Clean up the mid and pid VFILE entries. Then commit the changes.
465467
*/
466468
--- src/merge.c
+++ src/merge.c
@@ -249,20 +249,20 @@
249 if( debugFlag ){
250 db_prepare(&q,
251 "SELECT rowid, fn, fnp, fnm, chnged, ridv, ridp, ridm, isexe FROM fv"
252 );
253 while( db_step(&q)==SQLITE_ROW ){
254 printf("%3d: ridv=%-4d ridp=%-4d ridm=%-4d chnged=%d isexe=%d\n",
255 db_column_int(&q, 0),
256 db_column_int(&q, 5),
257 db_column_int(&q, 6),
258 db_column_int(&q, 7),
259 db_column_int(&q, 4),
260 db_column_int(&q, 8));
261 printf(" fn = [%s]\n", db_column_text(&q, 1));
262 printf(" fnp = [%s]\n", db_column_text(&q, 2));
263 printf(" fnm = [%s]\n", db_column_text(&q, 3));
264 }
265 db_finalize(&q);
266 }
267
268 /*
@@ -274,11 +274,11 @@
274 "SELECT idm FROM fv WHERE idp=0 AND idv>0 AND idm>0"
275 );
276 while( db_step(&q)==SQLITE_ROW ){
277 int idm = db_column_int(&q, 0);
278 char *zName = db_text(0, "SELECT pathname FROM vfile WHERE id=%d", idm);
279 printf("WARNING - no common ancestor: %s\n", zName);
280 free(zName);
281 db_multi_exec("UPDATE fv SET idm=0 WHERE idm=%d", idm);
282 }
283 db_finalize(&q);
284
@@ -300,11 +300,11 @@
300 vid, idm
301 );
302 idv = db_last_insert_rowid();
303 db_multi_exec("UPDATE fv SET idv=%d WHERE rowid=%d", idv, rowid);
304 zName = db_column_text(&q, 2);
305 printf("ADDED %s\n", zName);
306 if( !nochangeFlag ){
307 undo_save(zName);
308 vfile_to_disk(0, idm, 0, 0);
309 }
310 }
@@ -322,11 +322,11 @@
322 while( db_step(&q)==SQLITE_ROW ){
323 int idv = db_column_int(&q, 0);
324 int ridm = db_column_int(&q, 1);
325 const char *zName = db_column_text(&q, 2);
326 /* Copy content from idm over into idv. Overwrite idv. */
327 printf("UPDATE %s\n", zName);
328 if( !nochangeFlag ){
329 undo_save(zName);
330 db_multi_exec(
331 "UPDATE vfile SET mtime=0, mrid=%d, chnged=2 WHERE id=%d", ridm, idv
332 );
@@ -355,13 +355,14 @@
355 int rc;
356 char *zFullPath;
357 Blob m, p, r;
358 /* Do a 3-way merge of idp->idm into idp->idv. The results go into idv. */
359 if( detailFlag ){
360 printf("MERGE %s (pivot=%d v1=%d v2=%d)\n", zName, ridp, ridm, ridv);
 
361 }else{
362 printf("MERGE %s\n", zName);
363 }
364 undo_save(zName);
365 zFullPath = mprintf("%s/%s", g.zLocalRoot, zName);
366 content_get(ridp, &p);
367 content_get(ridm, &m);
@@ -376,15 +377,15 @@
376 blob_write_to_file(&r, zFullPath);
377 file_setexe(zFullPath, isExe);
378 }
379 db_multi_exec("UPDATE vfile SET mtime=0 WHERE id=%d", idv);
380 if( rc>0 ){
381 printf("***** %d merge conflicts in %s\n", rc, zName);
382 nConflict++;
383 }
384 }else{
385 printf("***** Cannot merge binary file %s\n", zName);
386 nConflict++;
387 }
388 blob_reset(&p);
389 blob_reset(&m);
390 blob_reset(&r);
@@ -403,22 +404,22 @@
403 while( db_step(&q)==SQLITE_ROW ){
404 int idv = db_column_int(&q, 0);
405 const char *zName = db_column_text(&q, 1);
406 int chnged = db_column_int(&q, 2);
407 /* Delete the file idv */
408 printf("DELETE %s\n", zName);
409 if( chnged ){
410 printf("WARNING: local edits lost for %s\n", zName);
411 nConflict++;
412 }
413 undo_save(zName);
414 db_multi_exec(
415 "UPDATE vfile SET deleted=1 WHERE id=%d", idv
416 );
417 if( !nochangeFlag ){
418 char *zFullPath = mprintf("%s%s", g.zLocalRoot, zName);
419 unlink(zFullPath);
420 free(zFullPath);
421 }
422 }
423 db_finalize(&q);
424
@@ -433,11 +434,11 @@
433 );
434 while( db_step(&q)==SQLITE_ROW ){
435 int idv = db_column_int(&q, 0);
436 const char *zOldName = db_column_text(&q, 1);
437 const char *zNewName = db_column_text(&q, 2);
438 printf("RENAME %s -> %s\n", zOldName, zNewName);
439 undo_save(zOldName);
440 undo_save(zNewName);
441 db_multi_exec(
442 "UPDATE vfile SET pathname=%Q, origname=coalesce(origname,pathname)"
443 " WHERE id=%d AND vid=%d", zNewName, idv, vid
@@ -444,11 +445,11 @@
444 );
445 if( !nochangeFlag ){
446 char *zFullOldPath = mprintf("%s%s", g.zLocalRoot, zOldName);
447 char *zFullNewPath = mprintf("%s%s", g.zLocalRoot, zNewName);
448 file_copy(zFullOldPath, zFullNewPath);
449 unlink(zFullOldPath);
450 free(zFullNewPath);
451 free(zFullOldPath);
452 }
453 }
454 db_finalize(&q);
@@ -455,11 +456,12 @@
455
456
457 /* Report on conflicts
458 */
459 if( nConflict && !nochangeFlag ){
460 printf("WARNING: merge conflicts - see messages above for details.\n");
 
461 }
462
463 /*
464 ** Clean up the mid and pid VFILE entries. Then commit the changes.
465 */
466
--- src/merge.c
+++ src/merge.c
@@ -249,20 +249,20 @@
249 if( debugFlag ){
250 db_prepare(&q,
251 "SELECT rowid, fn, fnp, fnm, chnged, ridv, ridp, ridm, isexe FROM fv"
252 );
253 while( db_step(&q)==SQLITE_ROW ){
254 fossil_print("%3d: ridv=%-4d ridp=%-4d ridm=%-4d chnged=%d isexe=%d\n",
255 db_column_int(&q, 0),
256 db_column_int(&q, 5),
257 db_column_int(&q, 6),
258 db_column_int(&q, 7),
259 db_column_int(&q, 4),
260 db_column_int(&q, 8));
261 fossil_print(" fn = [%s]\n", db_column_text(&q, 1));
262 fossil_print(" fnp = [%s]\n", db_column_text(&q, 2));
263 fossil_print(" fnm = [%s]\n", db_column_text(&q, 3));
264 }
265 db_finalize(&q);
266 }
267
268 /*
@@ -274,11 +274,11 @@
274 "SELECT idm FROM fv WHERE idp=0 AND idv>0 AND idm>0"
275 );
276 while( db_step(&q)==SQLITE_ROW ){
277 int idm = db_column_int(&q, 0);
278 char *zName = db_text(0, "SELECT pathname FROM vfile WHERE id=%d", idm);
279 fossil_warning("WARNING - no common ancestor: %s\n", zName);
280 free(zName);
281 db_multi_exec("UPDATE fv SET idm=0 WHERE idm=%d", idm);
282 }
283 db_finalize(&q);
284
@@ -300,11 +300,11 @@
300 vid, idm
301 );
302 idv = db_last_insert_rowid();
303 db_multi_exec("UPDATE fv SET idv=%d WHERE rowid=%d", idv, rowid);
304 zName = db_column_text(&q, 2);
305 fossil_print("ADDED %s\n", zName);
306 if( !nochangeFlag ){
307 undo_save(zName);
308 vfile_to_disk(0, idm, 0, 0);
309 }
310 }
@@ -322,11 +322,11 @@
322 while( db_step(&q)==SQLITE_ROW ){
323 int idv = db_column_int(&q, 0);
324 int ridm = db_column_int(&q, 1);
325 const char *zName = db_column_text(&q, 2);
326 /* Copy content from idm over into idv. Overwrite idv. */
327 fossil_print("UPDATE %s\n", zName);
328 if( !nochangeFlag ){
329 undo_save(zName);
330 db_multi_exec(
331 "UPDATE vfile SET mtime=0, mrid=%d, chnged=2 WHERE id=%d", ridm, idv
332 );
@@ -355,13 +355,14 @@
355 int rc;
356 char *zFullPath;
357 Blob m, p, r;
358 /* Do a 3-way merge of idp->idm into idp->idv. The results go into idv. */
359 if( detailFlag ){
360 fossil_print("MERGE %s (pivot=%d v1=%d v2=%d)\n",
361 zName, ridp, ridm, ridv);
362 }else{
363 fossil_print("MERGE %s\n", zName);
364 }
365 undo_save(zName);
366 zFullPath = mprintf("%s/%s", g.zLocalRoot, zName);
367 content_get(ridp, &p);
368 content_get(ridm, &m);
@@ -376,15 +377,15 @@
377 blob_write_to_file(&r, zFullPath);
378 file_setexe(zFullPath, isExe);
379 }
380 db_multi_exec("UPDATE vfile SET mtime=0 WHERE id=%d", idv);
381 if( rc>0 ){
382 fossil_print("***** %d merge conflicts in %s\n", rc, zName);
383 nConflict++;
384 }
385 }else{
386 fossil_print("***** Cannot merge binary file %s\n", zName);
387 nConflict++;
388 }
389 blob_reset(&p);
390 blob_reset(&m);
391 blob_reset(&r);
@@ -403,22 +404,22 @@
404 while( db_step(&q)==SQLITE_ROW ){
405 int idv = db_column_int(&q, 0);
406 const char *zName = db_column_text(&q, 1);
407 int chnged = db_column_int(&q, 2);
408 /* Delete the file idv */
409 fossil_print("DELETE %s\n", zName);
410 if( chnged ){
411 fossil_warning("WARNING: local edits lost for %s\n", zName);
412 nConflict++;
413 }
414 undo_save(zName);
415 db_multi_exec(
416 "UPDATE vfile SET deleted=1 WHERE id=%d", idv
417 );
418 if( !nochangeFlag ){
419 char *zFullPath = mprintf("%s%s", g.zLocalRoot, zName);
420 file_delete(zFullPath);
421 free(zFullPath);
422 }
423 }
424 db_finalize(&q);
425
@@ -433,11 +434,11 @@
434 );
435 while( db_step(&q)==SQLITE_ROW ){
436 int idv = db_column_int(&q, 0);
437 const char *zOldName = db_column_text(&q, 1);
438 const char *zNewName = db_column_text(&q, 2);
439 fossil_print("RENAME %s -> %s\n", zOldName, zNewName);
440 undo_save(zOldName);
441 undo_save(zNewName);
442 db_multi_exec(
443 "UPDATE vfile SET pathname=%Q, origname=coalesce(origname,pathname)"
444 " WHERE id=%d AND vid=%d", zNewName, idv, vid
@@ -444,11 +445,11 @@
445 );
446 if( !nochangeFlag ){
447 char *zFullOldPath = mprintf("%s%s", g.zLocalRoot, zOldName);
448 char *zFullNewPath = mprintf("%s%s", g.zLocalRoot, zNewName);
449 file_copy(zFullOldPath, zFullNewPath);
450 file_delete(zFullOldPath);
451 free(zFullNewPath);
452 free(zFullOldPath);
453 }
454 }
455 db_finalize(&q);
@@ -455,11 +456,12 @@
456
457
458 /* Report on conflicts
459 */
460 if( nConflict && !nochangeFlag ){
461 fossil_warning(
462 "WARNING: merge conflicts - see messages above for details.\n");
463 }
464
465 /*
466 ** Clean up the mid and pid VFILE entries. Then commit the changes.
467 */
468
+8 -12
--- src/merge3.c
+++ src/merge3.c
@@ -314,25 +314,21 @@
314314
Blob pivot, v1, v2, merged;
315315
if( g.argc!=6 ){
316316
usage("PIVOT V1 V2 MERGED");
317317
}
318318
if( blob_read_from_file(&pivot, g.argv[2])<0 ){
319
- fprintf(stderr,"cannot read %s\n", g.argv[2]);
320
- fossil_exit(1);
319
+ fossil_fatal("cannot read %s\n", g.argv[2]);
321320
}
322321
if( blob_read_from_file(&v1, g.argv[3])<0 ){
323
- fprintf(stderr,"cannot read %s\n", g.argv[3]);
324
- fossil_exit(1);
322
+ fossil_fatal("cannot read %s\n", g.argv[3]);
325323
}
326324
if( blob_read_from_file(&v2, g.argv[4])<0 ){
327
- fprintf(stderr,"cannot read %s\n", g.argv[4]);
328
- fossil_exit(1);
325
+ fossil_fatal("cannot read %s\n", g.argv[4]);
329326
}
330327
blob_merge(&pivot, &v1, &v2, &merged);
331328
if( blob_write_to_file(&merged, g.argv[5])<blob_size(&merged) ){
332
- fprintf(stderr,"cannot write %s\n", g.argv[4]);
333
- fossil_exit(1);
329
+ fossil_fatal("cannot write %s\n", g.argv[4]);
334330
}
335331
blob_reset(&pivot);
336332
blob_reset(&v1);
337333
blob_reset(&v2);
338334
blob_reset(&merged);
@@ -428,14 +424,14 @@
428424
zCmd = string_subst(zGMerge, 8, azSubst);
429425
printf("%s\n", zCmd); fflush(stdout);
430426
fossil_system(zCmd);
431427
if( file_size(zOut)>=0 ){
432428
blob_read_from_file(pOut, zOut);
433
- unlink(zPivot);
434
- unlink(zOrig);
435
- unlink(zOther);
436
- unlink(zOut);
429
+ file_delete(zPivot);
430
+ file_delete(zOrig);
431
+ file_delete(zOther);
432
+ file_delete(zOut);
437433
}
438434
fossil_free(zCmd);
439435
fossil_free(zOut);
440436
}
441437
fossil_free(zPivot);
442438
--- src/merge3.c
+++ src/merge3.c
@@ -314,25 +314,21 @@
314 Blob pivot, v1, v2, merged;
315 if( g.argc!=6 ){
316 usage("PIVOT V1 V2 MERGED");
317 }
318 if( blob_read_from_file(&pivot, g.argv[2])<0 ){
319 fprintf(stderr,"cannot read %s\n", g.argv[2]);
320 fossil_exit(1);
321 }
322 if( blob_read_from_file(&v1, g.argv[3])<0 ){
323 fprintf(stderr,"cannot read %s\n", g.argv[3]);
324 fossil_exit(1);
325 }
326 if( blob_read_from_file(&v2, g.argv[4])<0 ){
327 fprintf(stderr,"cannot read %s\n", g.argv[4]);
328 fossil_exit(1);
329 }
330 blob_merge(&pivot, &v1, &v2, &merged);
331 if( blob_write_to_file(&merged, g.argv[5])<blob_size(&merged) ){
332 fprintf(stderr,"cannot write %s\n", g.argv[4]);
333 fossil_exit(1);
334 }
335 blob_reset(&pivot);
336 blob_reset(&v1);
337 blob_reset(&v2);
338 blob_reset(&merged);
@@ -428,14 +424,14 @@
428 zCmd = string_subst(zGMerge, 8, azSubst);
429 printf("%s\n", zCmd); fflush(stdout);
430 fossil_system(zCmd);
431 if( file_size(zOut)>=0 ){
432 blob_read_from_file(pOut, zOut);
433 unlink(zPivot);
434 unlink(zOrig);
435 unlink(zOther);
436 unlink(zOut);
437 }
438 fossil_free(zCmd);
439 fossil_free(zOut);
440 }
441 fossil_free(zPivot);
442
--- src/merge3.c
+++ src/merge3.c
@@ -314,25 +314,21 @@
314 Blob pivot, v1, v2, merged;
315 if( g.argc!=6 ){
316 usage("PIVOT V1 V2 MERGED");
317 }
318 if( blob_read_from_file(&pivot, g.argv[2])<0 ){
319 fossil_fatal("cannot read %s\n", g.argv[2]);
 
320 }
321 if( blob_read_from_file(&v1, g.argv[3])<0 ){
322 fossil_fatal("cannot read %s\n", g.argv[3]);
 
323 }
324 if( blob_read_from_file(&v2, g.argv[4])<0 ){
325 fossil_fatal("cannot read %s\n", g.argv[4]);
 
326 }
327 blob_merge(&pivot, &v1, &v2, &merged);
328 if( blob_write_to_file(&merged, g.argv[5])<blob_size(&merged) ){
329 fossil_fatal("cannot write %s\n", g.argv[4]);
 
330 }
331 blob_reset(&pivot);
332 blob_reset(&v1);
333 blob_reset(&v2);
334 blob_reset(&merged);
@@ -428,14 +424,14 @@
424 zCmd = string_subst(zGMerge, 8, azSubst);
425 printf("%s\n", zCmd); fflush(stdout);
426 fossil_system(zCmd);
427 if( file_size(zOut)>=0 ){
428 blob_read_from_file(pOut, zOut);
429 file_delete(zPivot);
430 file_delete(zOrig);
431 file_delete(zOther);
432 file_delete(zOut);
433 }
434 fossil_free(zCmd);
435 fossil_free(zOut);
436 }
437 fossil_free(zPivot);
438
+3 -3
--- src/name.c
+++ src/name.c
@@ -267,16 +267,16 @@
267267
int i;
268268
Blob name;
269269
db_must_be_within_tree();
270270
for(i=2; i<g.argc; i++){
271271
blob_init(&name, g.argv[i], -1);
272
- printf("%s -> ", g.argv[i]);
272
+ fossil_print("%s -> ", g.argv[i]);
273273
if( name_to_uuid(&name, 1) ){
274
- printf("ERROR: %s\n", g.zErrMsg);
274
+ fossil_print("ERROR: %s\n", g.zErrMsg);
275275
fossil_error_reset();
276276
}else{
277
- printf("%s\n", blob_buffer(&name));
277
+ fossil_print("%s\n", blob_buffer(&name));
278278
}
279279
blob_reset(&name);
280280
}
281281
}
282282
283283
--- src/name.c
+++ src/name.c
@@ -267,16 +267,16 @@
267 int i;
268 Blob name;
269 db_must_be_within_tree();
270 for(i=2; i<g.argc; i++){
271 blob_init(&name, g.argv[i], -1);
272 printf("%s -> ", g.argv[i]);
273 if( name_to_uuid(&name, 1) ){
274 printf("ERROR: %s\n", g.zErrMsg);
275 fossil_error_reset();
276 }else{
277 printf("%s\n", blob_buffer(&name));
278 }
279 blob_reset(&name);
280 }
281 }
282
283
--- src/name.c
+++ src/name.c
@@ -267,16 +267,16 @@
267 int i;
268 Blob name;
269 db_must_be_within_tree();
270 for(i=2; i<g.argc; i++){
271 blob_init(&name, g.argv[i], -1);
272 fossil_print("%s -> ", g.argv[i]);
273 if( name_to_uuid(&name, 1) ){
274 fossil_print("ERROR: %s\n", g.zErrMsg);
275 fossil_error_reset();
276 }else{
277 fossil_print("%s\n", blob_buffer(&name));
278 }
279 blob_reset(&name);
280 }
281 }
282
283
+10 -9
--- src/path.c
+++ src/path.c
@@ -213,16 +213,17 @@
213213
z = db_text(0,
214214
"SELECT substr(uuid,1,12) || ' ' || datetime(mtime)"
215215
" FROM blob, event"
216216
" WHERE blob.rid=%d AND event.objid=%d AND event.type='ci'",
217217
p->rid, p->rid);
218
- printf("%4d: %s", n, z);
218
+ fossil_print("%4d: %s", n, z);
219219
fossil_free(z);
220220
if( p->u.pTo ){
221
- printf(" is a %s of\n", p->u.pTo->fromIsParent ? "parent" : "child");
221
+ fossil_print(" is a %s of\n",
222
+ p->u.pTo->fromIsParent ? "parent" : "child");
222223
}else{
223
- printf("\n");
224
+ fossil_print("\n");
224225
}
225226
}
226227
}
227228
228229
/*
@@ -312,16 +313,16 @@
312313
z = db_text(0,
313314
"SELECT substr(uuid,1,12) || ' ' || datetime(mtime)"
314315
" FROM blob, event"
315316
" WHERE blob.rid=%d AND event.objid=%d AND event.type='ci'",
316317
p->rid, p->rid);
317
- printf("%4d: %s", n, z);
318
+ fossil_print("%4d: %s", n, z);
318319
fossil_free(z);
319
- if( p->rid==iFrom ) printf(" VERSION1");
320
- if( p->rid==iTo ) printf(" VERSION2");
321
- if( p->rid==iPivot ) printf(" PIVOT");
322
- printf("\n");
320
+ if( p->rid==iFrom ) fossil_print(" VERSION1");
321
+ if( p->rid==iTo ) fossil_print(" VERSION2");
322
+ if( p->rid==iPivot ) fossil_print(" PIVOT");
323
+ fossil_print("\n");
323324
}
324325
}
325326
326327
327328
/*
@@ -445,11 +446,11 @@
445446
for(i=0; i<nChng; i++){
446447
char *zFrom, *zTo;
447448
448449
zFrom = db_text(0, "SELECT name FROM filename WHERE fnid=%d", aChng[i*2]);
449450
zTo = db_text(0, "SELECT name FROM filename WHERE fnid=%d", aChng[i*2+1]);
450
- printf("[%s] -> [%s]\n", zFrom, zTo);
451
+ fossil_print("[%s] -> [%s]\n", zFrom, zTo);
451452
fossil_free(zFrom);
452453
fossil_free(zTo);
453454
}
454455
fossil_free(aChng);
455456
}
456457
--- src/path.c
+++ src/path.c
@@ -213,16 +213,17 @@
213 z = db_text(0,
214 "SELECT substr(uuid,1,12) || ' ' || datetime(mtime)"
215 " FROM blob, event"
216 " WHERE blob.rid=%d AND event.objid=%d AND event.type='ci'",
217 p->rid, p->rid);
218 printf("%4d: %s", n, z);
219 fossil_free(z);
220 if( p->u.pTo ){
221 printf(" is a %s of\n", p->u.pTo->fromIsParent ? "parent" : "child");
 
222 }else{
223 printf("\n");
224 }
225 }
226 }
227
228 /*
@@ -312,16 +313,16 @@
312 z = db_text(0,
313 "SELECT substr(uuid,1,12) || ' ' || datetime(mtime)"
314 " FROM blob, event"
315 " WHERE blob.rid=%d AND event.objid=%d AND event.type='ci'",
316 p->rid, p->rid);
317 printf("%4d: %s", n, z);
318 fossil_free(z);
319 if( p->rid==iFrom ) printf(" VERSION1");
320 if( p->rid==iTo ) printf(" VERSION2");
321 if( p->rid==iPivot ) printf(" PIVOT");
322 printf("\n");
323 }
324 }
325
326
327 /*
@@ -445,11 +446,11 @@
445 for(i=0; i<nChng; i++){
446 char *zFrom, *zTo;
447
448 zFrom = db_text(0, "SELECT name FROM filename WHERE fnid=%d", aChng[i*2]);
449 zTo = db_text(0, "SELECT name FROM filename WHERE fnid=%d", aChng[i*2+1]);
450 printf("[%s] -> [%s]\n", zFrom, zTo);
451 fossil_free(zFrom);
452 fossil_free(zTo);
453 }
454 fossil_free(aChng);
455 }
456
--- src/path.c
+++ src/path.c
@@ -213,16 +213,17 @@
213 z = db_text(0,
214 "SELECT substr(uuid,1,12) || ' ' || datetime(mtime)"
215 " FROM blob, event"
216 " WHERE blob.rid=%d AND event.objid=%d AND event.type='ci'",
217 p->rid, p->rid);
218 fossil_print("%4d: %s", n, z);
219 fossil_free(z);
220 if( p->u.pTo ){
221 fossil_print(" is a %s of\n",
222 p->u.pTo->fromIsParent ? "parent" : "child");
223 }else{
224 fossil_print("\n");
225 }
226 }
227 }
228
229 /*
@@ -312,16 +313,16 @@
313 z = db_text(0,
314 "SELECT substr(uuid,1,12) || ' ' || datetime(mtime)"
315 " FROM blob, event"
316 " WHERE blob.rid=%d AND event.objid=%d AND event.type='ci'",
317 p->rid, p->rid);
318 fossil_print("%4d: %s", n, z);
319 fossil_free(z);
320 if( p->rid==iFrom ) fossil_print(" VERSION1");
321 if( p->rid==iTo ) fossil_print(" VERSION2");
322 if( p->rid==iPivot ) fossil_print(" PIVOT");
323 fossil_print("\n");
324 }
325 }
326
327
328 /*
@@ -445,11 +446,11 @@
446 for(i=0; i<nChng; i++){
447 char *zFrom, *zTo;
448
449 zFrom = db_text(0, "SELECT name FROM filename WHERE fnid=%d", aChng[i*2]);
450 zTo = db_text(0, "SELECT name FROM filename WHERE fnid=%d", aChng[i*2+1]);
451 fossil_print("[%s] -> [%s]\n", zFrom, zTo);
452 fossil_free(zFrom);
453 fossil_free(zTo);
454 }
455 fossil_free(aChng);
456 }
457
+27 -1
--- src/printf.c
+++ src/printf.c
@@ -797,10 +797,36 @@
797797
void fossil_error_reset(void){
798798
free(g.zErrMsg);
799799
g.zErrMsg = 0;
800800
g.iErrPriority = 0;
801801
}
802
+
803
+/*
804
+** Write to standard output or standard error.
805
+**
806
+** On windows, transform the output into the current terminal encoding
807
+** if the output is going to the screen. If output is redirected into
808
+** a file, no translation occurs. No translation ever occurs on unix.
809
+*/
810
+void fossil_puts(const char *z, int toStdErr){
811
+#if defined(_WIN32)
812
+ static int once = 1;
813
+ static int istty[2];
814
+ char *zToFree = 0;
815
+ if( once ){
816
+ istty[0] = _isatty(fileno(stdout));
817
+ istty[1] = _isatty(fileno(stderr));
818
+ once = 0;
819
+ }
820
+ assert( toStdErr==0 || toStdErr==1 );
821
+ if( istty[toStdErr] ) z = zToFree = fossil_utf8_to_console(z);
822
+ fwrite(z, 1, strlen(z), toStdErr ? stderr : stdout);
823
+ free(zToFree);
824
+#else
825
+ fwrite(z, 1, strlen(z), toStdErr ? stderr : stdout);
826
+#endif
827
+}
802828
803829
/*
804830
** Write output for user consumption. If g.cgiOutput is enabled, then
805831
** send the output as part of the CGI reply. If g.cgiOutput is false,
806832
** then write on standard output.
@@ -811,11 +837,11 @@
811837
if( g.cgiOutput ){
812838
cgi_vprintf(zFormat, ap);
813839
}else{
814840
Blob b = empty_blob;
815841
vxprintf(&b, zFormat, ap);
816
- fwrite(blob_buffer(&b), 1, blob_size(&b), stdout);
842
+ fossil_puts(blob_str(&b), 0);
817843
blob_reset(&b);
818844
}
819845
}
820846
821847
/*
822848
--- src/printf.c
+++ src/printf.c
@@ -797,10 +797,36 @@
797 void fossil_error_reset(void){
798 free(g.zErrMsg);
799 g.zErrMsg = 0;
800 g.iErrPriority = 0;
801 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
802
803 /*
804 ** Write output for user consumption. If g.cgiOutput is enabled, then
805 ** send the output as part of the CGI reply. If g.cgiOutput is false,
806 ** then write on standard output.
@@ -811,11 +837,11 @@
811 if( g.cgiOutput ){
812 cgi_vprintf(zFormat, ap);
813 }else{
814 Blob b = empty_blob;
815 vxprintf(&b, zFormat, ap);
816 fwrite(blob_buffer(&b), 1, blob_size(&b), stdout);
817 blob_reset(&b);
818 }
819 }
820
821 /*
822
--- src/printf.c
+++ src/printf.c
@@ -797,10 +797,36 @@
797 void fossil_error_reset(void){
798 free(g.zErrMsg);
799 g.zErrMsg = 0;
800 g.iErrPriority = 0;
801 }
802
803 /*
804 ** Write to standard output or standard error.
805 **
806 ** On windows, transform the output into the current terminal encoding
807 ** if the output is going to the screen. If output is redirected into
808 ** a file, no translation occurs. No translation ever occurs on unix.
809 */
810 void fossil_puts(const char *z, int toStdErr){
811 #if defined(_WIN32)
812 static int once = 1;
813 static int istty[2];
814 char *zToFree = 0;
815 if( once ){
816 istty[0] = _isatty(fileno(stdout));
817 istty[1] = _isatty(fileno(stderr));
818 once = 0;
819 }
820 assert( toStdErr==0 || toStdErr==1 );
821 if( istty[toStdErr] ) z = zToFree = fossil_utf8_to_console(z);
822 fwrite(z, 1, strlen(z), toStdErr ? stderr : stdout);
823 free(zToFree);
824 #else
825 fwrite(z, 1, strlen(z), toStdErr ? stderr : stdout);
826 #endif
827 }
828
829 /*
830 ** Write output for user consumption. If g.cgiOutput is enabled, then
831 ** send the output as part of the CGI reply. If g.cgiOutput is false,
832 ** then write on standard output.
@@ -811,11 +837,11 @@
837 if( g.cgiOutput ){
838 cgi_vprintf(zFormat, ap);
839 }else{
840 Blob b = empty_blob;
841 vxprintf(&b, zFormat, ap);
842 fossil_puts(blob_str(&b), 0);
843 blob_reset(&b);
844 }
845 }
846
847 /*
848
+23 -21
--- src/rebuild.c
+++ src/rebuild.c
@@ -176,11 +176,11 @@
176176
** The input is actually the permill complete.
177177
*/
178178
static void percent_complete(int permill){
179179
static int lastOutput = -1;
180180
if( permill>lastOutput ){
181
- printf(" %d.%d%% complete...\r", permill/10, permill%10);
181
+ fossil_print(" %d.%d%% complete...\r", permill/10, permill%10);
182182
fflush(stdout);
183183
lastOutput = permill;
184184
}
185185
}
186186
@@ -420,11 +420,11 @@
420420
if( !g.fQuiet && totalSize>0 ){
421421
processCnt += incrSize;
422422
percent_complete((processCnt*1000)/totalSize);
423423
}
424424
if(!g.fQuiet && ttyOutput ){
425
- printf("\n");
425
+ fossil_print("\n");
426426
}
427427
return errCnt;
428428
}
429429
430430
/*
@@ -549,32 +549,34 @@
549549
"REPLACE INTO config(name,value,mtime) VALUES('content-schema','%s',now());"
550550
"REPLACE INTO config(name,value,mtime) VALUES('aux-schema','%s',now());",
551551
CONTENT_SCHEMA, AUX_SCHEMA
552552
);
553553
if( errCnt && !forceFlag ){
554
- printf("%d errors. Rolling back changes. Use --force to force a commit.\n",
555
- errCnt);
554
+ fossil_print(
555
+ "%d errors. Rolling back changes. Use --force to force a commit.\n",
556
+ errCnt
557
+ );
556558
db_end_transaction(1);
557559
}else{
558560
if( runCompress ){
559
- printf("Extra delta compression... "); fflush(stdout);
561
+ fossil_print("Extra delta compression... "); fflush(stdout);
560562
extra_deltification();
561563
runVacuum = 1;
562564
}
563565
if( omitVerify ) verify_cancel();
564566
db_end_transaction(0);
565
- if( runCompress ) printf("done\n");
567
+ if( runCompress ) fossil_print("done\n");
566568
db_close(0);
567569
db_open_repository(g.zRepositoryName);
568570
if( newPagesize ){
569571
db_multi_exec("PRAGMA page_size=%d", newPagesize);
570572
runVacuum = 1;
571573
}
572574
if( runVacuum ){
573
- printf("Vacuuming the database... "); fflush(stdout);
575
+ fossil_print("Vacuuming the database... "); fflush(stdout);
574576
db_multi_exec("VACUUM");
575
- printf("done\n");
577
+ fossil_print("done\n");
576578
}
577579
if( activateWal ){
578580
db_multi_exec("PRAGMA journal_mode=WAL;");
579581
}
580582
}
@@ -678,16 +680,16 @@
678680
manifest_destroy(p);
679681
}
680682
n = db_int(0, "SELECT count(*) FROM /*scan*/"
681683
" (SELECT rid FROM blob EXCEPT SELECT x FROM xdone)");
682684
if( n==0 ){
683
- printf("all artifacts reachable through clusters\n");
685
+ fossil_print("all artifacts reachable through clusters\n");
684686
}else{
685
- printf("%d unreachable artifacts:\n", n);
687
+ fossil_print("%d unreachable artifacts:\n", n);
686688
db_prepare(&q, "SELECT rid, uuid FROM blob WHERE rid NOT IN xdone");
687689
while( db_step(&q)==SQLITE_ROW ){
688
- printf(" %3d %s\n", db_column_int(&q,0), db_column_text(&q,1));
690
+ fossil_print(" %3d %s\n", db_column_int(&q,0), db_column_text(&q,1));
689691
}
690692
db_finalize(&q);
691693
}
692694
}
693695
@@ -797,11 +799,11 @@
797799
}
798800
content_put(&aContent);
799801
blob_reset(&path);
800802
blob_reset(&aContent);
801803
free(zSubpath);
802
- printf("\r%d", ++nFileRead);
804
+ fossil_print("\r%d", ++nFileRead);
803805
fflush(stdout);
804806
}
805807
closedir(d);
806808
}else {
807809
fossil_panic("encountered error %d while trying to open \"%s\".",
@@ -824,22 +826,22 @@
824826
char *zPassword;
825827
if( g.argc!=4 ){
826828
usage("FILENAME DIRECTORY");
827829
}
828830
if( file_isdir(g.argv[3])!=1 ){
829
- printf("\"%s\" is not a directory\n\n", g.argv[3]);
831
+ fossil_print("\"%s\" is not a directory\n\n", g.argv[3]);
830832
usage("FILENAME DIRECTORY");
831833
}
832834
db_create_repository(g.argv[2]);
833835
db_open_repository(g.argv[2]);
834836
db_open_config(0);
835837
db_begin_transaction();
836838
db_initial_setup(0, 0, 1);
837839
838
- printf("Reading files from directory \"%s\"...\n", g.argv[3]);
840
+ fossil_print("Reading files from directory \"%s\"...\n", g.argv[3]);
839841
recon_read_dir(g.argv[3]);
840
- printf("\nBuilding the Fossil repository...\n");
842
+ fossil_print("\nBuilding the Fossil repository...\n");
841843
842844
rebuild_db(0, 1, 1);
843845
844846
/* Reconstruct the private table. The private table contains the rid
845847
** of every manifest that is tagged with "private" and every file that
@@ -861,14 +863,14 @@
861863
** long time.
862864
*/
863865
verify_cancel();
864866
865867
db_end_transaction(0);
866
- printf("project-id: %s\n", db_get("project-code", 0));
867
- printf("server-id: %s\n", db_get("server-code", 0));
868
+ fossil_print("project-id: %s\n", db_get("project-code", 0));
869
+ fossil_print("server-id: %s\n", db_get("server-code", 0));
868870
zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin);
869
- printf("admin-user: %s (initial password is \"%s\")\n", g.zLogin, zPassword);
871
+ fossil_print("admin-user: %s (initial password is \"%s\")\n", g.zLogin, zPassword);
870872
}
871873
872874
/*
873875
** COMMAND: deconstruct
874876
**
@@ -909,11 +911,11 @@
909911
}else{
910912
fossil_fatal("N(%s) is not a a valid prefix length!",zPrefixOpt);
911913
}
912914
}
913915
#ifndef _WIN32
914
- if( access(zDestDir, W_OK) ){
916
+ if( file_access(zDestDir, W_OK) ){
915917
fossil_fatal("DESTINATION(%s) is not writeable!",zDestDir);
916918
}
917919
#else
918920
/* write access on windows is not checked, errors will be
919921
** dected on blob_write_to_file
@@ -928,11 +930,11 @@
928930
db_find_and_open_repository(OPEN_ANY_SCHEMA, 0);
929931
bag_init(&bagDone);
930932
ttyOutput = 1;
931933
processCnt = 0;
932934
if (!g.fQuiet) {
933
- printf("0 (0%%)...\r");
935
+ fossil_print("0 (0%%)...\r");
934936
fflush(stdout);
935937
}
936938
totalSize = db_int(0, "SELECT count(*) FROM blob");
937939
db_prepare(&s,
938940
"SELECT rid, size FROM blob /*scan*/"
@@ -964,12 +966,12 @@
964966
}
965967
}
966968
}
967969
db_finalize(&s);
968970
if(!g.fQuiet && ttyOutput ){
969
- printf("\n");
971
+ fossil_print("\n");
970972
}
971973
972974
/* free filename format string */
973975
free(zFNameFormat);
974976
zFNameFormat = 0;
975977
}
976978
--- src/rebuild.c
+++ src/rebuild.c
@@ -176,11 +176,11 @@
176 ** The input is actually the permill complete.
177 */
178 static void percent_complete(int permill){
179 static int lastOutput = -1;
180 if( permill>lastOutput ){
181 printf(" %d.%d%% complete...\r", permill/10, permill%10);
182 fflush(stdout);
183 lastOutput = permill;
184 }
185 }
186
@@ -420,11 +420,11 @@
420 if( !g.fQuiet && totalSize>0 ){
421 processCnt += incrSize;
422 percent_complete((processCnt*1000)/totalSize);
423 }
424 if(!g.fQuiet && ttyOutput ){
425 printf("\n");
426 }
427 return errCnt;
428 }
429
430 /*
@@ -549,32 +549,34 @@
549 "REPLACE INTO config(name,value,mtime) VALUES('content-schema','%s',now());"
550 "REPLACE INTO config(name,value,mtime) VALUES('aux-schema','%s',now());",
551 CONTENT_SCHEMA, AUX_SCHEMA
552 );
553 if( errCnt && !forceFlag ){
554 printf("%d errors. Rolling back changes. Use --force to force a commit.\n",
555 errCnt);
 
 
556 db_end_transaction(1);
557 }else{
558 if( runCompress ){
559 printf("Extra delta compression... "); fflush(stdout);
560 extra_deltification();
561 runVacuum = 1;
562 }
563 if( omitVerify ) verify_cancel();
564 db_end_transaction(0);
565 if( runCompress ) printf("done\n");
566 db_close(0);
567 db_open_repository(g.zRepositoryName);
568 if( newPagesize ){
569 db_multi_exec("PRAGMA page_size=%d", newPagesize);
570 runVacuum = 1;
571 }
572 if( runVacuum ){
573 printf("Vacuuming the database... "); fflush(stdout);
574 db_multi_exec("VACUUM");
575 printf("done\n");
576 }
577 if( activateWal ){
578 db_multi_exec("PRAGMA journal_mode=WAL;");
579 }
580 }
@@ -678,16 +680,16 @@
678 manifest_destroy(p);
679 }
680 n = db_int(0, "SELECT count(*) FROM /*scan*/"
681 " (SELECT rid FROM blob EXCEPT SELECT x FROM xdone)");
682 if( n==0 ){
683 printf("all artifacts reachable through clusters\n");
684 }else{
685 printf("%d unreachable artifacts:\n", n);
686 db_prepare(&q, "SELECT rid, uuid FROM blob WHERE rid NOT IN xdone");
687 while( db_step(&q)==SQLITE_ROW ){
688 printf(" %3d %s\n", db_column_int(&q,0), db_column_text(&q,1));
689 }
690 db_finalize(&q);
691 }
692 }
693
@@ -797,11 +799,11 @@
797 }
798 content_put(&aContent);
799 blob_reset(&path);
800 blob_reset(&aContent);
801 free(zSubpath);
802 printf("\r%d", ++nFileRead);
803 fflush(stdout);
804 }
805 closedir(d);
806 }else {
807 fossil_panic("encountered error %d while trying to open \"%s\".",
@@ -824,22 +826,22 @@
824 char *zPassword;
825 if( g.argc!=4 ){
826 usage("FILENAME DIRECTORY");
827 }
828 if( file_isdir(g.argv[3])!=1 ){
829 printf("\"%s\" is not a directory\n\n", g.argv[3]);
830 usage("FILENAME DIRECTORY");
831 }
832 db_create_repository(g.argv[2]);
833 db_open_repository(g.argv[2]);
834 db_open_config(0);
835 db_begin_transaction();
836 db_initial_setup(0, 0, 1);
837
838 printf("Reading files from directory \"%s\"...\n", g.argv[3]);
839 recon_read_dir(g.argv[3]);
840 printf("\nBuilding the Fossil repository...\n");
841
842 rebuild_db(0, 1, 1);
843
844 /* Reconstruct the private table. The private table contains the rid
845 ** of every manifest that is tagged with "private" and every file that
@@ -861,14 +863,14 @@
861 ** long time.
862 */
863 verify_cancel();
864
865 db_end_transaction(0);
866 printf("project-id: %s\n", db_get("project-code", 0));
867 printf("server-id: %s\n", db_get("server-code", 0));
868 zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin);
869 printf("admin-user: %s (initial password is \"%s\")\n", g.zLogin, zPassword);
870 }
871
872 /*
873 ** COMMAND: deconstruct
874 **
@@ -909,11 +911,11 @@
909 }else{
910 fossil_fatal("N(%s) is not a a valid prefix length!",zPrefixOpt);
911 }
912 }
913 #ifndef _WIN32
914 if( access(zDestDir, W_OK) ){
915 fossil_fatal("DESTINATION(%s) is not writeable!",zDestDir);
916 }
917 #else
918 /* write access on windows is not checked, errors will be
919 ** dected on blob_write_to_file
@@ -928,11 +930,11 @@
928 db_find_and_open_repository(OPEN_ANY_SCHEMA, 0);
929 bag_init(&bagDone);
930 ttyOutput = 1;
931 processCnt = 0;
932 if (!g.fQuiet) {
933 printf("0 (0%%)...\r");
934 fflush(stdout);
935 }
936 totalSize = db_int(0, "SELECT count(*) FROM blob");
937 db_prepare(&s,
938 "SELECT rid, size FROM blob /*scan*/"
@@ -964,12 +966,12 @@
964 }
965 }
966 }
967 db_finalize(&s);
968 if(!g.fQuiet && ttyOutput ){
969 printf("\n");
970 }
971
972 /* free filename format string */
973 free(zFNameFormat);
974 zFNameFormat = 0;
975 }
976
--- src/rebuild.c
+++ src/rebuild.c
@@ -176,11 +176,11 @@
176 ** The input is actually the permill complete.
177 */
178 static void percent_complete(int permill){
179 static int lastOutput = -1;
180 if( permill>lastOutput ){
181 fossil_print(" %d.%d%% complete...\r", permill/10, permill%10);
182 fflush(stdout);
183 lastOutput = permill;
184 }
185 }
186
@@ -420,11 +420,11 @@
420 if( !g.fQuiet && totalSize>0 ){
421 processCnt += incrSize;
422 percent_complete((processCnt*1000)/totalSize);
423 }
424 if(!g.fQuiet && ttyOutput ){
425 fossil_print("\n");
426 }
427 return errCnt;
428 }
429
430 /*
@@ -549,32 +549,34 @@
549 "REPLACE INTO config(name,value,mtime) VALUES('content-schema','%s',now());"
550 "REPLACE INTO config(name,value,mtime) VALUES('aux-schema','%s',now());",
551 CONTENT_SCHEMA, AUX_SCHEMA
552 );
553 if( errCnt && !forceFlag ){
554 fossil_print(
555 "%d errors. Rolling back changes. Use --force to force a commit.\n",
556 errCnt
557 );
558 db_end_transaction(1);
559 }else{
560 if( runCompress ){
561 fossil_print("Extra delta compression... "); fflush(stdout);
562 extra_deltification();
563 runVacuum = 1;
564 }
565 if( omitVerify ) verify_cancel();
566 db_end_transaction(0);
567 if( runCompress ) fossil_print("done\n");
568 db_close(0);
569 db_open_repository(g.zRepositoryName);
570 if( newPagesize ){
571 db_multi_exec("PRAGMA page_size=%d", newPagesize);
572 runVacuum = 1;
573 }
574 if( runVacuum ){
575 fossil_print("Vacuuming the database... "); fflush(stdout);
576 db_multi_exec("VACUUM");
577 fossil_print("done\n");
578 }
579 if( activateWal ){
580 db_multi_exec("PRAGMA journal_mode=WAL;");
581 }
582 }
@@ -678,16 +680,16 @@
680 manifest_destroy(p);
681 }
682 n = db_int(0, "SELECT count(*) FROM /*scan*/"
683 " (SELECT rid FROM blob EXCEPT SELECT x FROM xdone)");
684 if( n==0 ){
685 fossil_print("all artifacts reachable through clusters\n");
686 }else{
687 fossil_print("%d unreachable artifacts:\n", n);
688 db_prepare(&q, "SELECT rid, uuid FROM blob WHERE rid NOT IN xdone");
689 while( db_step(&q)==SQLITE_ROW ){
690 fossil_print(" %3d %s\n", db_column_int(&q,0), db_column_text(&q,1));
691 }
692 db_finalize(&q);
693 }
694 }
695
@@ -797,11 +799,11 @@
799 }
800 content_put(&aContent);
801 blob_reset(&path);
802 blob_reset(&aContent);
803 free(zSubpath);
804 fossil_print("\r%d", ++nFileRead);
805 fflush(stdout);
806 }
807 closedir(d);
808 }else {
809 fossil_panic("encountered error %d while trying to open \"%s\".",
@@ -824,22 +826,22 @@
826 char *zPassword;
827 if( g.argc!=4 ){
828 usage("FILENAME DIRECTORY");
829 }
830 if( file_isdir(g.argv[3])!=1 ){
831 fossil_print("\"%s\" is not a directory\n\n", g.argv[3]);
832 usage("FILENAME DIRECTORY");
833 }
834 db_create_repository(g.argv[2]);
835 db_open_repository(g.argv[2]);
836 db_open_config(0);
837 db_begin_transaction();
838 db_initial_setup(0, 0, 1);
839
840 fossil_print("Reading files from directory \"%s\"...\n", g.argv[3]);
841 recon_read_dir(g.argv[3]);
842 fossil_print("\nBuilding the Fossil repository...\n");
843
844 rebuild_db(0, 1, 1);
845
846 /* Reconstruct the private table. The private table contains the rid
847 ** of every manifest that is tagged with "private" and every file that
@@ -861,14 +863,14 @@
863 ** long time.
864 */
865 verify_cancel();
866
867 db_end_transaction(0);
868 fossil_print("project-id: %s\n", db_get("project-code", 0));
869 fossil_print("server-id: %s\n", db_get("server-code", 0));
870 zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin);
871 fossil_print("admin-user: %s (initial password is \"%s\")\n", g.zLogin, zPassword);
872 }
873
874 /*
875 ** COMMAND: deconstruct
876 **
@@ -909,11 +911,11 @@
911 }else{
912 fossil_fatal("N(%s) is not a a valid prefix length!",zPrefixOpt);
913 }
914 }
915 #ifndef _WIN32
916 if( file_access(zDestDir, W_OK) ){
917 fossil_fatal("DESTINATION(%s) is not writeable!",zDestDir);
918 }
919 #else
920 /* write access on windows is not checked, errors will be
921 ** dected on blob_write_to_file
@@ -928,11 +930,11 @@
930 db_find_and_open_repository(OPEN_ANY_SCHEMA, 0);
931 bag_init(&bagDone);
932 ttyOutput = 1;
933 processCnt = 0;
934 if (!g.fQuiet) {
935 fossil_print("0 (0%%)...\r");
936 fflush(stdout);
937 }
938 totalSize = db_int(0, "SELECT count(*) FROM blob");
939 db_prepare(&s,
940 "SELECT rid, size FROM blob /*scan*/"
@@ -964,12 +966,12 @@
966 }
967 }
968 }
969 db_finalize(&s);
970 if(!g.fQuiet && ttyOutput ){
971 fossil_print("\n");
972 }
973
974 /* free filename format string */
975 free(zFNameFormat);
976 zFNameFormat = 0;
977 }
978
+9 -9
--- src/report.c
+++ src/report.c
@@ -1000,19 +1000,19 @@
10001000
*/
10011001
void rpt_list_reports(void){
10021002
Stmt q;
10031003
char const aRptOutFrmt[] = "%s\t%s\n";
10041004
1005
- printf("Available reports:\n");
1006
- printf(aRptOutFrmt,"report number","report title");
1007
- printf(aRptOutFrmt,zFullTicketRptRn,zFullTicketRptTitle);
1005
+ fossil_print("Available reports:\n");
1006
+ fossil_print(aRptOutFrmt,"report number","report title");
1007
+ fossil_print(aRptOutFrmt,zFullTicketRptRn,zFullTicketRptTitle);
10081008
db_prepare(&q,"SELECT rn,title FROM reportfmt ORDER BY rn");
10091009
while( db_step(&q)==SQLITE_ROW ){
10101010
const char *zRn = db_column_text(&q, 0);
10111011
const char *zTitle = db_column_text(&q, 1);
10121012
1013
- printf(aRptOutFrmt,zRn,zTitle);
1013
+ fossil_print(aRptOutFrmt,zRn,zTitle);
10141014
}
10151015
db_finalize(&q);
10161016
}
10171017
10181018
/*
@@ -1037,25 +1037,25 @@
10371037
case tktFossilize:
10381038
{ char *zFosZ;
10391039
10401040
if( z && *z ){
10411041
zFosZ = fossilize(z,-1);
1042
- printf("%s",zFosZ);
1042
+ fossil_print("%s",zFosZ);
10431043
free(zFosZ);
10441044
}
10451045
break;
10461046
}
10471047
default:
10481048
while( z && z[0] ){
10491049
int i, j;
10501050
for(i=0; z[i] && (!fossil_isspace(z[i]) || z[i]==' '); i++){}
10511051
if( i>0 ){
1052
- printf("%.*s", i, z);
1052
+ fossil_print("%.*s", i, z);
10531053
}
10541054
for(j=i; fossil_isspace(z[j]); j++){}
10551055
if( j>i ){
1056
- printf("%*s", j-i, "");
1056
+ fossil_print("%*s", j-i, "");
10571057
}
10581058
z += j;
10591059
}
10601060
break;
10611061
}
@@ -1074,17 +1074,17 @@
10741074
int i;
10751075
10761076
if( *pCount==0 ){
10771077
for(i=0; i<nArg; i++){
10781078
output_no_tabs_file(azName[i]);
1079
- printf("%s", i<nArg-1 ? (zSep?zSep:"\t") : "\n");
1079
+ fossil_print("%s", i<nArg-1 ? (zSep?zSep:"\t") : "\n");
10801080
}
10811081
}
10821082
++*pCount;
10831083
for(i=0; i<nArg; i++){
10841084
output_no_tabs_file(azArg[i]);
1085
- printf("%s", i<nArg-1 ? (zSep?zSep:"\t") : "\n");
1085
+ fossil_print("%s", i<nArg-1 ? (zSep?zSep:"\t") : "\n");
10861086
}
10871087
return 0;
10881088
}
10891089
10901090
/*
10911091
--- src/report.c
+++ src/report.c
@@ -1000,19 +1000,19 @@
1000 */
1001 void rpt_list_reports(void){
1002 Stmt q;
1003 char const aRptOutFrmt[] = "%s\t%s\n";
1004
1005 printf("Available reports:\n");
1006 printf(aRptOutFrmt,"report number","report title");
1007 printf(aRptOutFrmt,zFullTicketRptRn,zFullTicketRptTitle);
1008 db_prepare(&q,"SELECT rn,title FROM reportfmt ORDER BY rn");
1009 while( db_step(&q)==SQLITE_ROW ){
1010 const char *zRn = db_column_text(&q, 0);
1011 const char *zTitle = db_column_text(&q, 1);
1012
1013 printf(aRptOutFrmt,zRn,zTitle);
1014 }
1015 db_finalize(&q);
1016 }
1017
1018 /*
@@ -1037,25 +1037,25 @@
1037 case tktFossilize:
1038 { char *zFosZ;
1039
1040 if( z && *z ){
1041 zFosZ = fossilize(z,-1);
1042 printf("%s",zFosZ);
1043 free(zFosZ);
1044 }
1045 break;
1046 }
1047 default:
1048 while( z && z[0] ){
1049 int i, j;
1050 for(i=0; z[i] && (!fossil_isspace(z[i]) || z[i]==' '); i++){}
1051 if( i>0 ){
1052 printf("%.*s", i, z);
1053 }
1054 for(j=i; fossil_isspace(z[j]); j++){}
1055 if( j>i ){
1056 printf("%*s", j-i, "");
1057 }
1058 z += j;
1059 }
1060 break;
1061 }
@@ -1074,17 +1074,17 @@
1074 int i;
1075
1076 if( *pCount==0 ){
1077 for(i=0; i<nArg; i++){
1078 output_no_tabs_file(azName[i]);
1079 printf("%s", i<nArg-1 ? (zSep?zSep:"\t") : "\n");
1080 }
1081 }
1082 ++*pCount;
1083 for(i=0; i<nArg; i++){
1084 output_no_tabs_file(azArg[i]);
1085 printf("%s", i<nArg-1 ? (zSep?zSep:"\t") : "\n");
1086 }
1087 return 0;
1088 }
1089
1090 /*
1091
--- src/report.c
+++ src/report.c
@@ -1000,19 +1000,19 @@
1000 */
1001 void rpt_list_reports(void){
1002 Stmt q;
1003 char const aRptOutFrmt[] = "%s\t%s\n";
1004
1005 fossil_print("Available reports:\n");
1006 fossil_print(aRptOutFrmt,"report number","report title");
1007 fossil_print(aRptOutFrmt,zFullTicketRptRn,zFullTicketRptTitle);
1008 db_prepare(&q,"SELECT rn,title FROM reportfmt ORDER BY rn");
1009 while( db_step(&q)==SQLITE_ROW ){
1010 const char *zRn = db_column_text(&q, 0);
1011 const char *zTitle = db_column_text(&q, 1);
1012
1013 fossil_print(aRptOutFrmt,zRn,zTitle);
1014 }
1015 db_finalize(&q);
1016 }
1017
1018 /*
@@ -1037,25 +1037,25 @@
1037 case tktFossilize:
1038 { char *zFosZ;
1039
1040 if( z && *z ){
1041 zFosZ = fossilize(z,-1);
1042 fossil_print("%s",zFosZ);
1043 free(zFosZ);
1044 }
1045 break;
1046 }
1047 default:
1048 while( z && z[0] ){
1049 int i, j;
1050 for(i=0; z[i] && (!fossil_isspace(z[i]) || z[i]==' '); i++){}
1051 if( i>0 ){
1052 fossil_print("%.*s", i, z);
1053 }
1054 for(j=i; fossil_isspace(z[j]); j++){}
1055 if( j>i ){
1056 fossil_print("%*s", j-i, "");
1057 }
1058 z += j;
1059 }
1060 break;
1061 }
@@ -1074,17 +1074,17 @@
1074 int i;
1075
1076 if( *pCount==0 ){
1077 for(i=0; i<nArg; i++){
1078 output_no_tabs_file(azName[i]);
1079 fossil_print("%s", i<nArg-1 ? (zSep?zSep:"\t") : "\n");
1080 }
1081 }
1082 ++*pCount;
1083 for(i=0; i<nArg; i++){
1084 output_no_tabs_file(azArg[i]);
1085 fossil_print("%s", i<nArg-1 ? (zSep?zSep:"\t") : "\n");
1086 }
1087 return 0;
1088 }
1089
1090 /*
1091
+2 -2
--- src/sha1.c
+++ src/sha1.c
@@ -266,11 +266,11 @@
266266
FILE *in;
267267
SHA1Context ctx;
268268
unsigned char zResult[20];
269269
char zBuf[10240];
270270
271
- in = fopen(zFilename,"rb");
271
+ in = fossil_fopen(zFilename,"rb");
272272
if( in==0 ){
273273
return 1;
274274
}
275275
SHA1Init(&ctx);
276276
for(;;){
@@ -430,9 +430,9 @@
430430
blob_read_from_channel(&in, stdin, -1);
431431
sha1sum_blob(&in, &cksum);
432432
}else{
433433
sha1sum_file(g.argv[i], &cksum);
434434
}
435
- printf("%s %s\n", blob_str(&cksum), g.argv[i]);
435
+ fossil_print("%s %s\n", blob_str(&cksum), g.argv[i]);
436436
blob_reset(&cksum);
437437
}
438438
}
439439
--- src/sha1.c
+++ src/sha1.c
@@ -266,11 +266,11 @@
266 FILE *in;
267 SHA1Context ctx;
268 unsigned char zResult[20];
269 char zBuf[10240];
270
271 in = fopen(zFilename,"rb");
272 if( in==0 ){
273 return 1;
274 }
275 SHA1Init(&ctx);
276 for(;;){
@@ -430,9 +430,9 @@
430 blob_read_from_channel(&in, stdin, -1);
431 sha1sum_blob(&in, &cksum);
432 }else{
433 sha1sum_file(g.argv[i], &cksum);
434 }
435 printf("%s %s\n", blob_str(&cksum), g.argv[i]);
436 blob_reset(&cksum);
437 }
438 }
439
--- src/sha1.c
+++ src/sha1.c
@@ -266,11 +266,11 @@
266 FILE *in;
267 SHA1Context ctx;
268 unsigned char zResult[20];
269 char zBuf[10240];
270
271 in = fossil_fopen(zFilename,"rb");
272 if( in==0 ){
273 return 1;
274 }
275 SHA1Init(&ctx);
276 for(;;){
@@ -430,9 +430,9 @@
430 blob_read_from_channel(&in, stdin, -1);
431 sha1sum_blob(&in, &cksum);
432 }else{
433 sha1sum_file(g.argv[i], &cksum);
434 }
435 fossil_print("%s %s\n", blob_str(&cksum), g.argv[i]);
436 blob_reset(&cksum);
437 }
438 }
439
+14 -14
--- src/stash.c
+++ src/stash.c
@@ -185,33 +185,33 @@
185185
blob_zero(&delta);
186186
if( rid==0 ){
187187
db_ephemeral_blob(&q, 5, &delta);
188188
blob_write_to_file(&delta, zNPath);
189189
file_setexe(zNPath, isExec);
190
- printf("ADD %s\n", zNew);
190
+ fossil_print("ADD %s\n", zNew);
191191
}else if( isRemoved ){
192
- printf("DELETE %s\n", zOrig);
193
- unlink(zOPath);
192
+ fossil_print("DELETE %s\n", zOrig);
193
+ file_delete(zOPath);
194194
}else{
195195
Blob a, b, out, disk;
196196
db_ephemeral_blob(&q, 5, &delta);
197197
blob_read_from_file(&disk, zOPath);
198198
content_get(rid, &a);
199199
blob_delta_apply(&a, &delta, &b);
200200
if( blob_compare(&disk, &a)==0 ){
201201
blob_write_to_file(&b, zNPath);
202202
file_setexe(zNPath, isExec);
203
- printf("UPDATE %s\n", zNew);
203
+ fossil_print("UPDATE %s\n", zNew);
204204
}else{
205205
int rc = merge_3way(&a, zOPath, &b, &out);
206206
blob_write_to_file(&out, zNPath);
207207
file_setexe(zNPath, isExec);
208208
if( rc ){
209
- printf("CONFLICT %s\n", zNew);
209
+ fossil_print("CONFLICT %s\n", zNew);
210210
nConflict++;
211211
}else{
212
- printf("MERGE %s\n", zNew);
212
+ fossil_print("MERGE %s\n", zNew);
213213
}
214214
blob_reset(&out);
215215
}
216216
blob_reset(&a);
217217
blob_reset(&b);
@@ -218,16 +218,16 @@
218218
blob_reset(&disk);
219219
}
220220
blob_reset(&delta);
221221
if( fossil_strcmp(zOrig,zNew)!=0 ){
222222
undo_save(zOrig);
223
- unlink(zOPath);
223
+ file_delete(zOPath);
224224
}
225225
}
226226
db_finalize(&q);
227227
if( nConflict ){
228
- printf("WARNING: merge conflicts - see messages above for details.\n");
228
+ fossil_print("WARNING: merge conflicts - see messages above for details.\n");
229229
}
230230
}
231231
232232
/*
233233
** Show the diffs associate with a single stash.
@@ -248,25 +248,25 @@
248248
const char *zNew = db_column_text(&q, 4);
249249
char *zOPath = mprintf("%s%s", g.zLocalRoot, zOrig);
250250
Blob delta;
251251
if( rid==0 ){
252252
db_ephemeral_blob(&q, 5, &delta);
253
- printf("ADDED %s\n", zNew);
253
+ fossil_print("ADDED %s\n", zNew);
254254
diff_print_index(zNew);
255255
diff_file_mem(&empty, &delta, zNew, zDiffCmd, 0);
256256
}else if( isRemoved ){
257
- printf("DELETE %s\n", zOrig);
257
+ fossil_print("DELETE %s\n", zOrig);
258258
blob_read_from_file(&delta, zOPath);
259259
diff_print_index(zNew);
260260
diff_file_mem(&delta, &empty, zOrig, zDiffCmd, 0);
261261
}else{
262262
Blob a, b, disk;
263263
db_ephemeral_blob(&q, 5, &delta);
264264
blob_read_from_file(&disk, zOPath);
265265
content_get(rid, &a);
266266
blob_delta_apply(&a, &delta, &b);
267
- printf("CHANGED %s\n", zNew);
267
+ fossil_print("CHANGED %s\n", zNew);
268268
diff_file_mem(&disk, &b, zNew, zDiffCmd, 0);
269269
blob_reset(&a);
270270
blob_reset(&b);
271271
blob_reset(&disk);
272272
}
@@ -413,23 +413,23 @@
413413
" ORDER BY ctime DESC"
414414
);
415415
while( db_step(&q)==SQLITE_ROW ){
416416
const char *zCom;
417417
n++;
418
- printf("%5d: [%.14s] on %s\n",
418
+ fossil_print("%5d: [%.14s] on %s\n",
419419
db_column_int(&q, 0),
420420
db_column_text(&q, 1),
421421
db_column_text(&q, 3)
422422
);
423423
zCom = db_column_text(&q, 2);
424424
if( zCom && zCom[0] ){
425
- printf(" ");
425
+ fossil_print(" ");
426426
comment_print(zCom, 7, 79);
427427
}
428428
}
429429
db_finalize(&q);
430
- if( n==0 ) printf("empty stash\n");
430
+ if( n==0 ) fossil_print("empty stash\n");
431431
}else
432432
if( memcmp(zCmd, "drop", nCmd)==0 ){
433433
int allFlag = find_option("all", 0, 0)!=0;
434434
if( g.argc>4 ) usage("stash apply STASHID");
435435
if( allFlag ){
436436
--- src/stash.c
+++ src/stash.c
@@ -185,33 +185,33 @@
185 blob_zero(&delta);
186 if( rid==0 ){
187 db_ephemeral_blob(&q, 5, &delta);
188 blob_write_to_file(&delta, zNPath);
189 file_setexe(zNPath, isExec);
190 printf("ADD %s\n", zNew);
191 }else if( isRemoved ){
192 printf("DELETE %s\n", zOrig);
193 unlink(zOPath);
194 }else{
195 Blob a, b, out, disk;
196 db_ephemeral_blob(&q, 5, &delta);
197 blob_read_from_file(&disk, zOPath);
198 content_get(rid, &a);
199 blob_delta_apply(&a, &delta, &b);
200 if( blob_compare(&disk, &a)==0 ){
201 blob_write_to_file(&b, zNPath);
202 file_setexe(zNPath, isExec);
203 printf("UPDATE %s\n", zNew);
204 }else{
205 int rc = merge_3way(&a, zOPath, &b, &out);
206 blob_write_to_file(&out, zNPath);
207 file_setexe(zNPath, isExec);
208 if( rc ){
209 printf("CONFLICT %s\n", zNew);
210 nConflict++;
211 }else{
212 printf("MERGE %s\n", zNew);
213 }
214 blob_reset(&out);
215 }
216 blob_reset(&a);
217 blob_reset(&b);
@@ -218,16 +218,16 @@
218 blob_reset(&disk);
219 }
220 blob_reset(&delta);
221 if( fossil_strcmp(zOrig,zNew)!=0 ){
222 undo_save(zOrig);
223 unlink(zOPath);
224 }
225 }
226 db_finalize(&q);
227 if( nConflict ){
228 printf("WARNING: merge conflicts - see messages above for details.\n");
229 }
230 }
231
232 /*
233 ** Show the diffs associate with a single stash.
@@ -248,25 +248,25 @@
248 const char *zNew = db_column_text(&q, 4);
249 char *zOPath = mprintf("%s%s", g.zLocalRoot, zOrig);
250 Blob delta;
251 if( rid==0 ){
252 db_ephemeral_blob(&q, 5, &delta);
253 printf("ADDED %s\n", zNew);
254 diff_print_index(zNew);
255 diff_file_mem(&empty, &delta, zNew, zDiffCmd, 0);
256 }else if( isRemoved ){
257 printf("DELETE %s\n", zOrig);
258 blob_read_from_file(&delta, zOPath);
259 diff_print_index(zNew);
260 diff_file_mem(&delta, &empty, zOrig, zDiffCmd, 0);
261 }else{
262 Blob a, b, disk;
263 db_ephemeral_blob(&q, 5, &delta);
264 blob_read_from_file(&disk, zOPath);
265 content_get(rid, &a);
266 blob_delta_apply(&a, &delta, &b);
267 printf("CHANGED %s\n", zNew);
268 diff_file_mem(&disk, &b, zNew, zDiffCmd, 0);
269 blob_reset(&a);
270 blob_reset(&b);
271 blob_reset(&disk);
272 }
@@ -413,23 +413,23 @@
413 " ORDER BY ctime DESC"
414 );
415 while( db_step(&q)==SQLITE_ROW ){
416 const char *zCom;
417 n++;
418 printf("%5d: [%.14s] on %s\n",
419 db_column_int(&q, 0),
420 db_column_text(&q, 1),
421 db_column_text(&q, 3)
422 );
423 zCom = db_column_text(&q, 2);
424 if( zCom && zCom[0] ){
425 printf(" ");
426 comment_print(zCom, 7, 79);
427 }
428 }
429 db_finalize(&q);
430 if( n==0 ) printf("empty stash\n");
431 }else
432 if( memcmp(zCmd, "drop", nCmd)==0 ){
433 int allFlag = find_option("all", 0, 0)!=0;
434 if( g.argc>4 ) usage("stash apply STASHID");
435 if( allFlag ){
436
--- src/stash.c
+++ src/stash.c
@@ -185,33 +185,33 @@
185 blob_zero(&delta);
186 if( rid==0 ){
187 db_ephemeral_blob(&q, 5, &delta);
188 blob_write_to_file(&delta, zNPath);
189 file_setexe(zNPath, isExec);
190 fossil_print("ADD %s\n", zNew);
191 }else if( isRemoved ){
192 fossil_print("DELETE %s\n", zOrig);
193 file_delete(zOPath);
194 }else{
195 Blob a, b, out, disk;
196 db_ephemeral_blob(&q, 5, &delta);
197 blob_read_from_file(&disk, zOPath);
198 content_get(rid, &a);
199 blob_delta_apply(&a, &delta, &b);
200 if( blob_compare(&disk, &a)==0 ){
201 blob_write_to_file(&b, zNPath);
202 file_setexe(zNPath, isExec);
203 fossil_print("UPDATE %s\n", zNew);
204 }else{
205 int rc = merge_3way(&a, zOPath, &b, &out);
206 blob_write_to_file(&out, zNPath);
207 file_setexe(zNPath, isExec);
208 if( rc ){
209 fossil_print("CONFLICT %s\n", zNew);
210 nConflict++;
211 }else{
212 fossil_print("MERGE %s\n", zNew);
213 }
214 blob_reset(&out);
215 }
216 blob_reset(&a);
217 blob_reset(&b);
@@ -218,16 +218,16 @@
218 blob_reset(&disk);
219 }
220 blob_reset(&delta);
221 if( fossil_strcmp(zOrig,zNew)!=0 ){
222 undo_save(zOrig);
223 file_delete(zOPath);
224 }
225 }
226 db_finalize(&q);
227 if( nConflict ){
228 fossil_print("WARNING: merge conflicts - see messages above for details.\n");
229 }
230 }
231
232 /*
233 ** Show the diffs associate with a single stash.
@@ -248,25 +248,25 @@
248 const char *zNew = db_column_text(&q, 4);
249 char *zOPath = mprintf("%s%s", g.zLocalRoot, zOrig);
250 Blob delta;
251 if( rid==0 ){
252 db_ephemeral_blob(&q, 5, &delta);
253 fossil_print("ADDED %s\n", zNew);
254 diff_print_index(zNew);
255 diff_file_mem(&empty, &delta, zNew, zDiffCmd, 0);
256 }else if( isRemoved ){
257 fossil_print("DELETE %s\n", zOrig);
258 blob_read_from_file(&delta, zOPath);
259 diff_print_index(zNew);
260 diff_file_mem(&delta, &empty, zOrig, zDiffCmd, 0);
261 }else{
262 Blob a, b, disk;
263 db_ephemeral_blob(&q, 5, &delta);
264 blob_read_from_file(&disk, zOPath);
265 content_get(rid, &a);
266 blob_delta_apply(&a, &delta, &b);
267 fossil_print("CHANGED %s\n", zNew);
268 diff_file_mem(&disk, &b, zNew, zDiffCmd, 0);
269 blob_reset(&a);
270 blob_reset(&b);
271 blob_reset(&disk);
272 }
@@ -413,23 +413,23 @@
413 " ORDER BY ctime DESC"
414 );
415 while( db_step(&q)==SQLITE_ROW ){
416 const char *zCom;
417 n++;
418 fossil_print("%5d: [%.14s] on %s\n",
419 db_column_int(&q, 0),
420 db_column_text(&q, 1),
421 db_column_text(&q, 3)
422 );
423 zCom = db_column_text(&q, 2);
424 if( zCom && zCom[0] ){
425 fossil_print(" ");
426 comment_print(zCom, 7, 79);
427 }
428 }
429 db_finalize(&q);
430 if( n==0 ) fossil_print("empty stash\n");
431 }else
432 if( memcmp(zCmd, "drop", nCmd)==0 ){
433 int allFlag = find_option("all", 0, 0)!=0;
434 if( g.argc>4 ) usage("stash apply STASHID");
435 if( allFlag ){
436
+4 -4
--- src/sync.c
+++ src/sync.c
@@ -76,11 +76,11 @@
7676
** autosync, or something?
7777
*/
7878
configSync = CONFIGSET_SHUN;
7979
}
8080
#endif
81
- printf("Autosync: %s\n", g.urlCanonical);
81
+ fossil_print("Autosync: %s\n", g.urlCanonical);
8282
url_enable_proxy("via proxy: ");
8383
rc = client_sync((flags & AUTOSYNC_PUSH)!=0, 1, 0, 0, configSync, 0);
8484
if( rc ) fossil_warning("Autosync failed");
8585
return rc;
8686
}
@@ -124,11 +124,11 @@
124124
db_set("last-sync-url", g.urlCanonical, 0);
125125
if( g.urlPasswd ) db_set("last-sync-pw", obscure(g.urlPasswd), 0);
126126
}
127127
user_select();
128128
if( g.argc==2 ){
129
- printf("Server: %s\n", g.urlCanonical);
129
+ fossil_print("Server: %s\n", g.urlCanonical);
130130
}
131131
url_enable_proxy("via proxy: ");
132132
*pConfigSync = configSync;
133133
}
134134
@@ -263,12 +263,12 @@
263263
}
264264
}
265265
}
266266
zUrl = db_get("last-sync-url", 0);
267267
if( zUrl==0 ){
268
- printf("off\n");
268
+ fossil_print("off\n");
269269
return;
270270
}else{
271271
url_parse(zUrl);
272
- printf("%s\n", g.urlCanonical);
272
+ fossil_print("%s\n", g.urlCanonical);
273273
}
274274
}
275275
--- src/sync.c
+++ src/sync.c
@@ -76,11 +76,11 @@
76 ** autosync, or something?
77 */
78 configSync = CONFIGSET_SHUN;
79 }
80 #endif
81 printf("Autosync: %s\n", g.urlCanonical);
82 url_enable_proxy("via proxy: ");
83 rc = client_sync((flags & AUTOSYNC_PUSH)!=0, 1, 0, 0, configSync, 0);
84 if( rc ) fossil_warning("Autosync failed");
85 return rc;
86 }
@@ -124,11 +124,11 @@
124 db_set("last-sync-url", g.urlCanonical, 0);
125 if( g.urlPasswd ) db_set("last-sync-pw", obscure(g.urlPasswd), 0);
126 }
127 user_select();
128 if( g.argc==2 ){
129 printf("Server: %s\n", g.urlCanonical);
130 }
131 url_enable_proxy("via proxy: ");
132 *pConfigSync = configSync;
133 }
134
@@ -263,12 +263,12 @@
263 }
264 }
265 }
266 zUrl = db_get("last-sync-url", 0);
267 if( zUrl==0 ){
268 printf("off\n");
269 return;
270 }else{
271 url_parse(zUrl);
272 printf("%s\n", g.urlCanonical);
273 }
274 }
275
--- src/sync.c
+++ src/sync.c
@@ -76,11 +76,11 @@
76 ** autosync, or something?
77 */
78 configSync = CONFIGSET_SHUN;
79 }
80 #endif
81 fossil_print("Autosync: %s\n", g.urlCanonical);
82 url_enable_proxy("via proxy: ");
83 rc = client_sync((flags & AUTOSYNC_PUSH)!=0, 1, 0, 0, configSync, 0);
84 if( rc ) fossil_warning("Autosync failed");
85 return rc;
86 }
@@ -124,11 +124,11 @@
124 db_set("last-sync-url", g.urlCanonical, 0);
125 if( g.urlPasswd ) db_set("last-sync-pw", obscure(g.urlPasswd), 0);
126 }
127 user_select();
128 if( g.argc==2 ){
129 fossil_print("Server: %s\n", g.urlCanonical);
130 }
131 url_enable_proxy("via proxy: ");
132 *pConfigSync = configSync;
133 }
134
@@ -263,12 +263,12 @@
263 }
264 }
265 }
266 zUrl = db_get("last-sync-url", 0);
267 if( zUrl==0 ){
268 fossil_print("off\n");
269 return;
270 }else{
271 url_parse(zUrl);
272 fossil_print("%s\n", g.urlCanonical);
273 }
274 }
275
+5 -5
--- src/tag.c
+++ src/tag.c
@@ -438,11 +438,11 @@
438438
" AND tagxref.tagtype>0"
439439
" AND blob.rid=tagxref.rid",
440440
g.argv[3]
441441
);
442442
while( db_step(&q)==SQLITE_ROW ){
443
- printf("%s\n", db_column_text(&q, 0));
443
+ fossil_print("%s\n", db_column_text(&q, 0));
444444
}
445445
db_finalize(&q);
446446
}else{
447447
int tagid = db_int(0, "SELECT tagid FROM tag WHERE tagname='sym-%q'",
448448
g.argv[3]);
@@ -473,13 +473,13 @@
473473
" ORDER BY tagname"
474474
);
475475
while( db_step(&q)==SQLITE_ROW ){
476476
const char *zName = db_column_text(&q, 0);
477477
if( fRaw ){
478
- printf("%s\n", zName);
478
+ fossil_print("%s\n", zName);
479479
}else if( strncmp(zName, "sym-", 4)==0 ){
480
- printf("%s\n", &zName[4]);
480
+ fossil_print("%s\n", &zName[4]);
481481
}
482482
}
483483
db_finalize(&q);
484484
}else if( g.argc==4 ){
485485
int rid = name_to_rid(g.argv[3]);
@@ -497,13 +497,13 @@
497497
if( fRaw==0 ){
498498
if( strncmp(zName, "sym-", 4)!=0 ) continue;
499499
zName += 4;
500500
}
501501
if( zValue && zValue[0] ){
502
- printf("%s=%s\n", zName, zValue);
502
+ fossil_print("%s=%s\n", zName, zValue);
503503
}else{
504
- printf("%s\n", zName);
504
+ fossil_print("%s\n", zName);
505505
}
506506
}
507507
db_finalize(&q);
508508
}else{
509509
usage("tag list ?CHECK-IN?");
510510
--- src/tag.c
+++ src/tag.c
@@ -438,11 +438,11 @@
438 " AND tagxref.tagtype>0"
439 " AND blob.rid=tagxref.rid",
440 g.argv[3]
441 );
442 while( db_step(&q)==SQLITE_ROW ){
443 printf("%s\n", db_column_text(&q, 0));
444 }
445 db_finalize(&q);
446 }else{
447 int tagid = db_int(0, "SELECT tagid FROM tag WHERE tagname='sym-%q'",
448 g.argv[3]);
@@ -473,13 +473,13 @@
473 " ORDER BY tagname"
474 );
475 while( db_step(&q)==SQLITE_ROW ){
476 const char *zName = db_column_text(&q, 0);
477 if( fRaw ){
478 printf("%s\n", zName);
479 }else if( strncmp(zName, "sym-", 4)==0 ){
480 printf("%s\n", &zName[4]);
481 }
482 }
483 db_finalize(&q);
484 }else if( g.argc==4 ){
485 int rid = name_to_rid(g.argv[3]);
@@ -497,13 +497,13 @@
497 if( fRaw==0 ){
498 if( strncmp(zName, "sym-", 4)!=0 ) continue;
499 zName += 4;
500 }
501 if( zValue && zValue[0] ){
502 printf("%s=%s\n", zName, zValue);
503 }else{
504 printf("%s\n", zName);
505 }
506 }
507 db_finalize(&q);
508 }else{
509 usage("tag list ?CHECK-IN?");
510
--- src/tag.c
+++ src/tag.c
@@ -438,11 +438,11 @@
438 " AND tagxref.tagtype>0"
439 " AND blob.rid=tagxref.rid",
440 g.argv[3]
441 );
442 while( db_step(&q)==SQLITE_ROW ){
443 fossil_print("%s\n", db_column_text(&q, 0));
444 }
445 db_finalize(&q);
446 }else{
447 int tagid = db_int(0, "SELECT tagid FROM tag WHERE tagname='sym-%q'",
448 g.argv[3]);
@@ -473,13 +473,13 @@
473 " ORDER BY tagname"
474 );
475 while( db_step(&q)==SQLITE_ROW ){
476 const char *zName = db_column_text(&q, 0);
477 if( fRaw ){
478 fossil_print("%s\n", zName);
479 }else if( strncmp(zName, "sym-", 4)==0 ){
480 fossil_print("%s\n", &zName[4]);
481 }
482 }
483 db_finalize(&q);
484 }else if( g.argc==4 ){
485 int rid = name_to_rid(g.argv[3]);
@@ -497,13 +497,13 @@
497 if( fRaw==0 ){
498 if( strncmp(zName, "sym-", 4)!=0 ) continue;
499 zName += 4;
500 }
501 if( zValue && zValue[0] ){
502 fossil_print("%s=%s\n", zName, zValue);
503 }else{
504 fossil_print("%s\n", zName);
505 }
506 }
507 db_finalize(&q);
508 }else{
509 usage("tag list ?CHECK-IN?");
510
+4 -4
--- src/timeline.c
+++ src/timeline.c
@@ -1203,16 +1203,16 @@
12031203
char zPrefix[80];
12041204
char zUuid[UUID_SIZE+1];
12051205
12061206
sqlite3_snprintf(sizeof(zUuid), zUuid, "%.10s", zId);
12071207
if( memcmp(zDate, zPrevDate, 10) ){
1208
- printf("=== %.10s ===\n", zDate);
1208
+ fossil_print("=== %.10s ===\n", zDate);
12091209
memcpy(zPrevDate, zDate, 10);
12101210
nLine++;
12111211
}
12121212
if( zCom==0 ) zCom = "";
1213
- printf("%.8s ", &zDate[11]);
1213
+ fossil_print("%.8s ", &zDate[11]);
12141214
zPrefix[0] = 0;
12151215
if( nParent>1 ){
12161216
sqlite3_snprintf(sizeof(zPrefix), zPrefix, "*MERGE* ");
12171217
n = strlen(zPrefix);
12181218
}
@@ -1453,13 +1453,13 @@
14531453
" FROM plink p, plink c"
14541454
" WHERE p.cid=c.pid AND p.mtime>c.mtime"
14551455
);
14561456
while( db_step(&q)==SQLITE_ROW ){
14571457
if( !showDetail ){
1458
- printf("%s\n", db_column_text(&q, 1));
1458
+ fossil_print("%s\n", db_column_text(&q, 1));
14591459
}else{
1460
- printf("%.14s -> %.14s %s -> %s\n",
1460
+ fossil_print("%.14s -> %.14s %s -> %s\n",
14611461
db_column_text(&q, 0),
14621462
db_column_text(&q, 1),
14631463
db_column_text(&q, 2),
14641464
db_column_text(&q, 3));
14651465
}
14661466
--- src/timeline.c
+++ src/timeline.c
@@ -1203,16 +1203,16 @@
1203 char zPrefix[80];
1204 char zUuid[UUID_SIZE+1];
1205
1206 sqlite3_snprintf(sizeof(zUuid), zUuid, "%.10s", zId);
1207 if( memcmp(zDate, zPrevDate, 10) ){
1208 printf("=== %.10s ===\n", zDate);
1209 memcpy(zPrevDate, zDate, 10);
1210 nLine++;
1211 }
1212 if( zCom==0 ) zCom = "";
1213 printf("%.8s ", &zDate[11]);
1214 zPrefix[0] = 0;
1215 if( nParent>1 ){
1216 sqlite3_snprintf(sizeof(zPrefix), zPrefix, "*MERGE* ");
1217 n = strlen(zPrefix);
1218 }
@@ -1453,13 +1453,13 @@
1453 " FROM plink p, plink c"
1454 " WHERE p.cid=c.pid AND p.mtime>c.mtime"
1455 );
1456 while( db_step(&q)==SQLITE_ROW ){
1457 if( !showDetail ){
1458 printf("%s\n", db_column_text(&q, 1));
1459 }else{
1460 printf("%.14s -> %.14s %s -> %s\n",
1461 db_column_text(&q, 0),
1462 db_column_text(&q, 1),
1463 db_column_text(&q, 2),
1464 db_column_text(&q, 3));
1465 }
1466
--- src/timeline.c
+++ src/timeline.c
@@ -1203,16 +1203,16 @@
1203 char zPrefix[80];
1204 char zUuid[UUID_SIZE+1];
1205
1206 sqlite3_snprintf(sizeof(zUuid), zUuid, "%.10s", zId);
1207 if( memcmp(zDate, zPrevDate, 10) ){
1208 fossil_print("=== %.10s ===\n", zDate);
1209 memcpy(zPrevDate, zDate, 10);
1210 nLine++;
1211 }
1212 if( zCom==0 ) zCom = "";
1213 fossil_print("%.8s ", &zDate[11]);
1214 zPrefix[0] = 0;
1215 if( nParent>1 ){
1216 sqlite3_snprintf(sizeof(zPrefix), zPrefix, "*MERGE* ");
1217 n = strlen(zPrefix);
1218 }
@@ -1453,13 +1453,13 @@
1453 " FROM plink p, plink c"
1454 " WHERE p.cid=c.pid AND p.mtime>c.mtime"
1455 );
1456 while( db_step(&q)==SQLITE_ROW ){
1457 if( !showDetail ){
1458 fossil_print("%s\n", db_column_text(&q, 1));
1459 }else{
1460 fossil_print("%.14s -> %.14s %s -> %s\n",
1461 db_column_text(&q, 0),
1462 db_column_text(&q, 1),
1463 db_column_text(&q, 2),
1464 db_column_text(&q, 3));
1465 }
1466
+2 -1
--- src/tkt.c
+++ src/tkt.c
@@ -216,11 +216,12 @@
216216
char *zTag = mprintf("tkt-%s", zTktUuid);
217217
int tagid = tag_findid(zTag, 1);
218218
Stmt q;
219219
Manifest *pTicket;
220220
int createFlag = 1;
221
-
221
+
222
+ fossil_free(zTag);
222223
db_multi_exec(
223224
"DELETE FROM ticket WHERE tkt_uuid=%Q", zTktUuid
224225
);
225226
db_prepare(&q, "SELECT rid FROM tagxref WHERE tagid=%d ORDER BY mtime",tagid);
226227
while( db_step(&q)==SQLITE_ROW ){
227228
--- src/tkt.c
+++ src/tkt.c
@@ -216,11 +216,12 @@
216 char *zTag = mprintf("tkt-%s", zTktUuid);
217 int tagid = tag_findid(zTag, 1);
218 Stmt q;
219 Manifest *pTicket;
220 int createFlag = 1;
221
 
222 db_multi_exec(
223 "DELETE FROM ticket WHERE tkt_uuid=%Q", zTktUuid
224 );
225 db_prepare(&q, "SELECT rid FROM tagxref WHERE tagid=%d ORDER BY mtime",tagid);
226 while( db_step(&q)==SQLITE_ROW ){
227
--- src/tkt.c
+++ src/tkt.c
@@ -216,11 +216,12 @@
216 char *zTag = mprintf("tkt-%s", zTktUuid);
217 int tagid = tag_findid(zTag, 1);
218 Stmt q;
219 Manifest *pTicket;
220 int createFlag = 1;
221
222 fossil_free(zTag);
223 db_multi_exec(
224 "DELETE FROM ticket WHERE tkt_uuid=%Q", zTktUuid
225 );
226 db_prepare(&q, "SELECT rid FROM tagxref WHERE tagid=%d ORDER BY mtime",tagid);
227 while( db_step(&q)==SQLITE_ROW ){
228
+15 -14
--- src/undo.c
+++ src/undo.c
@@ -58,19 +58,19 @@
5858
if( old_exists ){
5959
db_ephemeral_blob(&q, 0, &new);
6060
}
6161
if( old_exists ){
6262
if( new_exists ){
63
- printf("%s %s\n", redoFlag ? "REDO" : "UNDO", zPathname);
63
+ fossil_print("%s %s\n", redoFlag ? "REDO" : "UNDO", zPathname);
6464
}else{
65
- printf("NEW %s\n", zPathname);
65
+ fossil_print("NEW %s\n", zPathname);
6666
}
6767
blob_write_to_file(&new, zFullname);
6868
file_setexe(zFullname, old_exe);
6969
}else{
70
- printf("DELETE %s\n", zPathname);
71
- unlink(zFullname);
70
+ fossil_print("DELETE %s\n", zPathname);
71
+ file_delete(zFullname);
7272
}
7373
blob_reset(&new);
7474
free(zFullname);
7575
db_finalize(&q);
7676
db_prepare(&q,
@@ -297,11 +297,11 @@
297297
** Complete the undo process is one is currently in process.
298298
*/
299299
void undo_finish(void){
300300
if( undoActive ){
301301
if( undoNeedRollback ){
302
- printf("\"fossil undo\" is available to undo changes"
302
+ fossil_print("\"fossil undo\" is available to undo changes"
303303
" to the working checkout.\n");
304304
}
305305
undoActive = 0;
306306
undoNeedRollback = 0;
307307
}
@@ -319,11 +319,11 @@
319319
void undo_rollback(void){
320320
if( !undoNeedRollback ) return;
321321
assert( undoActive );
322322
undoNeedRollback = 0;
323323
undoActive = 0;
324
- printf("Rolling back prior filesystem changes...\n");
324
+ fossil_print("Rolling back prior filesystem changes...\n");
325325
undo_all_filesystem(0);
326326
}
327327
328328
/*
329329
** COMMAND: undo
@@ -360,34 +360,35 @@
360360
verify_all_options();
361361
db_begin_transaction();
362362
undo_available = db_lget_int("undo_available", 0);
363363
if( explainFlag ){
364364
if( undo_available==0 ){
365
- printf("No undo or redo is available\n");
365
+ fossil_print("No undo or redo is available\n");
366366
}else{
367367
Stmt q;
368368
int nChng = 0;
369369
zCmd = undo_available==1 ? "undo" : "redo";
370
- printf("A %s is available for the following command:\n\n %s %s\n\n",
371
- zCmd, g.argv[0], db_lget("undo_cmdline", "???"));
370
+ fossil_print("A %s is available for the following command:\n\n"
371
+ " %s %s\n\n",
372
+ zCmd, g.argv[0], db_lget("undo_cmdline", "???"));
372373
db_prepare(&q,
373374
"SELECT existsflag, pathname FROM undo ORDER BY pathname"
374375
);
375376
while( db_step(&q)==SQLITE_ROW ){
376377
if( nChng==0 ){
377
- printf("The following file changes would occur if the "
378
- "command above is %sne:\n\n", zCmd);
378
+ fossil_print("The following file changes would occur if the "
379
+ "command above is %sne:\n\n", zCmd);
379380
}
380381
nChng++;
381
- printf("%s %s\n",
382
+ fossil_print("%s %s\n",
382383
db_column_int(&q,0) ? "UPDATE" : "DELETE",
383384
db_column_text(&q, 1)
384385
);
385386
}
386387
db_finalize(&q);
387388
if( nChng==0 ){
388
- printf("No file changes would occur with this undo/redo.\n");
389
+ fossil_print("No file changes would occur with this undo/redo.\n");
389390
}
390391
}
391392
}else{
392393
int vid1 = db_lget_int("checkout", 0);
393394
int vid2;
@@ -410,11 +411,11 @@
410411
blob_reset(&path);
411412
}
412413
}
413414
vid2 = db_lget_int("checkout", 0);
414415
if( vid1!=vid2 ){
415
- printf("--------------------\n");
416
+ fossil_print("--------------------\n");
416417
show_common_info(vid2, "updated-to:", 1, 0);
417418
}
418419
}
419420
db_end_transaction(0);
420421
}
421422
--- src/undo.c
+++ src/undo.c
@@ -58,19 +58,19 @@
58 if( old_exists ){
59 db_ephemeral_blob(&q, 0, &new);
60 }
61 if( old_exists ){
62 if( new_exists ){
63 printf("%s %s\n", redoFlag ? "REDO" : "UNDO", zPathname);
64 }else{
65 printf("NEW %s\n", zPathname);
66 }
67 blob_write_to_file(&new, zFullname);
68 file_setexe(zFullname, old_exe);
69 }else{
70 printf("DELETE %s\n", zPathname);
71 unlink(zFullname);
72 }
73 blob_reset(&new);
74 free(zFullname);
75 db_finalize(&q);
76 db_prepare(&q,
@@ -297,11 +297,11 @@
297 ** Complete the undo process is one is currently in process.
298 */
299 void undo_finish(void){
300 if( undoActive ){
301 if( undoNeedRollback ){
302 printf("\"fossil undo\" is available to undo changes"
303 " to the working checkout.\n");
304 }
305 undoActive = 0;
306 undoNeedRollback = 0;
307 }
@@ -319,11 +319,11 @@
319 void undo_rollback(void){
320 if( !undoNeedRollback ) return;
321 assert( undoActive );
322 undoNeedRollback = 0;
323 undoActive = 0;
324 printf("Rolling back prior filesystem changes...\n");
325 undo_all_filesystem(0);
326 }
327
328 /*
329 ** COMMAND: undo
@@ -360,34 +360,35 @@
360 verify_all_options();
361 db_begin_transaction();
362 undo_available = db_lget_int("undo_available", 0);
363 if( explainFlag ){
364 if( undo_available==0 ){
365 printf("No undo or redo is available\n");
366 }else{
367 Stmt q;
368 int nChng = 0;
369 zCmd = undo_available==1 ? "undo" : "redo";
370 printf("A %s is available for the following command:\n\n %s %s\n\n",
371 zCmd, g.argv[0], db_lget("undo_cmdline", "???"));
 
372 db_prepare(&q,
373 "SELECT existsflag, pathname FROM undo ORDER BY pathname"
374 );
375 while( db_step(&q)==SQLITE_ROW ){
376 if( nChng==0 ){
377 printf("The following file changes would occur if the "
378 "command above is %sne:\n\n", zCmd);
379 }
380 nChng++;
381 printf("%s %s\n",
382 db_column_int(&q,0) ? "UPDATE" : "DELETE",
383 db_column_text(&q, 1)
384 );
385 }
386 db_finalize(&q);
387 if( nChng==0 ){
388 printf("No file changes would occur with this undo/redo.\n");
389 }
390 }
391 }else{
392 int vid1 = db_lget_int("checkout", 0);
393 int vid2;
@@ -410,11 +411,11 @@
410 blob_reset(&path);
411 }
412 }
413 vid2 = db_lget_int("checkout", 0);
414 if( vid1!=vid2 ){
415 printf("--------------------\n");
416 show_common_info(vid2, "updated-to:", 1, 0);
417 }
418 }
419 db_end_transaction(0);
420 }
421
--- src/undo.c
+++ src/undo.c
@@ -58,19 +58,19 @@
58 if( old_exists ){
59 db_ephemeral_blob(&q, 0, &new);
60 }
61 if( old_exists ){
62 if( new_exists ){
63 fossil_print("%s %s\n", redoFlag ? "REDO" : "UNDO", zPathname);
64 }else{
65 fossil_print("NEW %s\n", zPathname);
66 }
67 blob_write_to_file(&new, zFullname);
68 file_setexe(zFullname, old_exe);
69 }else{
70 fossil_print("DELETE %s\n", zPathname);
71 file_delete(zFullname);
72 }
73 blob_reset(&new);
74 free(zFullname);
75 db_finalize(&q);
76 db_prepare(&q,
@@ -297,11 +297,11 @@
297 ** Complete the undo process is one is currently in process.
298 */
299 void undo_finish(void){
300 if( undoActive ){
301 if( undoNeedRollback ){
302 fossil_print("\"fossil undo\" is available to undo changes"
303 " to the working checkout.\n");
304 }
305 undoActive = 0;
306 undoNeedRollback = 0;
307 }
@@ -319,11 +319,11 @@
319 void undo_rollback(void){
320 if( !undoNeedRollback ) return;
321 assert( undoActive );
322 undoNeedRollback = 0;
323 undoActive = 0;
324 fossil_print("Rolling back prior filesystem changes...\n");
325 undo_all_filesystem(0);
326 }
327
328 /*
329 ** COMMAND: undo
@@ -360,34 +360,35 @@
360 verify_all_options();
361 db_begin_transaction();
362 undo_available = db_lget_int("undo_available", 0);
363 if( explainFlag ){
364 if( undo_available==0 ){
365 fossil_print("No undo or redo is available\n");
366 }else{
367 Stmt q;
368 int nChng = 0;
369 zCmd = undo_available==1 ? "undo" : "redo";
370 fossil_print("A %s is available for the following command:\n\n"
371 " %s %s\n\n",
372 zCmd, g.argv[0], db_lget("undo_cmdline", "???"));
373 db_prepare(&q,
374 "SELECT existsflag, pathname FROM undo ORDER BY pathname"
375 );
376 while( db_step(&q)==SQLITE_ROW ){
377 if( nChng==0 ){
378 fossil_print("The following file changes would occur if the "
379 "command above is %sne:\n\n", zCmd);
380 }
381 nChng++;
382 fossil_print("%s %s\n",
383 db_column_int(&q,0) ? "UPDATE" : "DELETE",
384 db_column_text(&q, 1)
385 );
386 }
387 db_finalize(&q);
388 if( nChng==0 ){
389 fossil_print("No file changes would occur with this undo/redo.\n");
390 }
391 }
392 }else{
393 int vid1 = db_lget_int("checkout", 0);
394 int vid2;
@@ -410,11 +411,11 @@
411 blob_reset(&path);
412 }
413 }
414 vid2 = db_lget_int("checkout", 0);
415 if( vid1!=vid2 ){
416 fossil_print("--------------------\n");
417 show_common_info(vid2, "updated-to:", 1, 0);
418 }
419 }
420 db_end_transaction(0);
421 }
422
+24 -23
--- src/update.c
+++ src/update.c
@@ -253,18 +253,18 @@
253253
if( debugFlag ){
254254
db_prepare(&q,
255255
"SELECT rowid, fn, fnt, chnged, ridv, ridt, isexe FROM fv"
256256
);
257257
while( db_step(&q)==SQLITE_ROW ){
258
- printf("%3d: ridv=%-4d ridt=%-4d chnged=%d isexe=%d\n",
258
+ fossil_print("%3d: ridv=%-4d ridt=%-4d chnged=%d isexe=%d\n",
259259
db_column_int(&q, 0),
260260
db_column_int(&q, 4),
261261
db_column_int(&q, 5),
262262
db_column_int(&q, 3),
263263
db_column_int(&q, 6));
264
- printf(" fnv = [%s]\n", db_column_text(&q, 1));
265
- printf(" fnt = [%s]\n", db_column_text(&q, 2));
264
+ fossil_print(" fnv = [%s]\n", db_column_text(&q, 1));
265
+ fossil_print(" fnt = [%s]\n", db_column_text(&q, 2));
266266
}
267267
db_finalize(&q);
268268
}
269269
270270
/* If FILES appear on the command-line, remove from the "fv" table
@@ -331,26 +331,26 @@
331331
nameChng = fossil_strcmp(zName, zNewName);
332332
if( idv>0 && ridv==0 && idt>0 && ridt>0 ){
333333
/* Conflict. This file has been added to the current checkout
334334
** but also exists in the target checkout. Use the current version.
335335
*/
336
- printf("CONFLICT %s\n", zName);
336
+ fossil_print("CONFLICT %s\n", zName);
337337
nConflict++;
338338
}else if( idt>0 && idv==0 ){
339339
/* File added in the target. */
340
- printf("ADD %s\n", zName);
340
+ fossil_print("ADD %s\n", zName);
341341
undo_save(zName);
342342
if( !nochangeFlag ) vfile_to_disk(0, idt, 0, 0);
343343
}else if( idt>0 && idv>0 && ridt!=ridv && chnged==0 ){
344344
/* The file is unedited. Change it to the target version */
345345
undo_save(zName);
346
- printf("UPDATE %s\n", zName);
346
+ fossil_print("UPDATE %s\n", zName);
347347
if( !nochangeFlag ) vfile_to_disk(0, idt, 0, 0);
348348
}else if( idt>0 && idv>0 && file_size(zFullPath)<0 ){
349349
/* The file missing from the local check-out. Restore it to the
350350
** version that appears in the target. */
351
- printf("UPDATE %s\n", zName);
351
+ fossil_print("UPDATE %s\n", zName);
352352
undo_save(zName);
353353
if( !nochangeFlag ) vfile_to_disk(0, idt, 0, 0);
354354
}else if( idt==0 && idv>0 ){
355355
if( ridv==0 ){
356356
/* Added in current checkout. Continue to hold the file as
@@ -357,25 +357,26 @@
357357
** as an addition */
358358
db_multi_exec("UPDATE vfile SET vid=%d WHERE id=%d", tid, idv);
359359
}else if( chnged ){
360360
/* Edited locally but deleted from the target. Do not track the
361361
** file but keep the edited version around. */
362
- printf("CONFLICT %s - edited locally but deleted by update\n", zName);
362
+ fossil_print("CONFLICT %s - edited locally but deleted by update\n",
363
+ zName);
363364
nConflict++;
364365
}else{
365
- printf("REMOVE %s\n", zName);
366
+ fossil_print("REMOVE %s\n", zName);
366367
undo_save(zName);
367
- if( !nochangeFlag ) unlink(zFullPath);
368
+ if( !nochangeFlag ) file_delete(zFullPath);
368369
}
369370
}else if( idt>0 && idv>0 && ridt!=ridv && chnged ){
370371
/* Merge the changes in the current tree into the target version */
371372
Blob r, t, v;
372373
int rc;
373374
if( nameChng ){
374
- printf("MERGE %s -> %s\n", zName, zNewName);
375
+ fossil_print("MERGE %s -> %s\n", zName, zNewName);
375376
}else{
376
- printf("MERGE %s\n", zName);
377
+ fossil_print("MERGE %s\n", zName);
377378
}
378379
undo_save(zName);
379380
content_get(ridt, &t);
380381
content_get(ridv, &v);
381382
rc = merge_3way(&v, zFullPath, &t, &r);
@@ -383,51 +384,51 @@
383384
if( !nochangeFlag ){
384385
blob_write_to_file(&r, zFullNewPath);
385386
file_setexe(zFullNewPath, isexe);
386387
}
387388
if( rc>0 ){
388
- printf("***** %d merge conflicts in %s\n", rc, zNewName);
389
+ fossil_print("***** %d merge conflicts in %s\n", rc, zNewName);
389390
nConflict++;
390391
}
391392
}else{
392393
if( !nochangeFlag ){
393394
blob_write_to_file(&t, zFullNewPath);
394395
file_setexe(zFullNewPath, isexe);
395396
}
396
- printf("***** Cannot merge binary file %s\n", zNewName);
397
+ fossil_print("***** Cannot merge binary file %s\n", zNewName);
397398
nConflict++;
398399
}
399
- if( nameChng && !nochangeFlag ) unlink(zFullPath);
400
+ if( nameChng && !nochangeFlag ) file_delete(zFullPath);
400401
blob_reset(&v);
401402
blob_reset(&t);
402403
blob_reset(&r);
403404
}else{
404405
if( chnged ){
405
- if( verboseFlag ) printf("EDITED %s\n", zName);
406
+ if( verboseFlag ) fossil_print("EDITED %s\n", zName);
406407
}else{
407408
db_bind_int(&mtimeXfer, ":idv", idv);
408409
db_bind_int(&mtimeXfer, ":idt", idt);
409410
db_step(&mtimeXfer);
410411
db_reset(&mtimeXfer);
411
- if( verboseFlag ) printf("UNCHANGED %s\n", zName);
412
+ if( verboseFlag ) fossil_print("UNCHANGED %s\n", zName);
412413
}
413414
}
414415
free(zFullPath);
415416
free(zFullNewPath);
416417
}
417418
db_finalize(&q);
418419
db_finalize(&mtimeXfer);
419
- printf("--------------\n");
420
+ fossil_print("--------------\n");
420421
show_common_info(tid, "updated-to:", 1, 0);
421422
422423
/* Report on conflicts
423424
*/
424425
if( nConflict && !nochangeFlag ){
425426
if( internalUpdate ){
426427
internalConflictCnt = nConflict;
427428
}else{
428
- printf("WARNING: %d merge conflicts - see messages above for details.\n",
429
+ fossil_print("WARNING: %d merge conflicts - see messages above for details.\n",
429430
nConflict);
430431
}
431432
}
432433
433434
/*
@@ -570,23 +571,23 @@
570571
zFile = db_column_text(&q, 0);
571572
zFull = mprintf("%/%/", g.zLocalRoot, zFile);
572573
errCode = historical_version_of_file(zRevision, zFile, &record, &isExe,2);
573574
if( errCode==2 ){
574575
if( db_int(0, "SELECT rid FROM vfile WHERE pathname=%Q", zFile)==0 ){
575
- printf("UNMANAGE: %s\n", zFile);
576
+ fossil_print("UNMANAGE: %s\n", zFile);
576577
}else{
577578
undo_save(zFile);
578
- unlink(zFull);
579
- printf("DELETE: %s\n", zFile);
579
+ file_delete(zFull);
580
+ fossil_print("DELETE: %s\n", zFile);
580581
}
581582
db_multi_exec("DELETE FROM vfile WHERE pathname=%Q", zFile);
582583
}else{
583584
sqlite3_int64 mtime;
584585
undo_save(zFile);
585586
blob_write_to_file(&record, zFull);
586587
file_setexe(zFull, isExe);
587
- printf("REVERTED: %s\n", zFile);
588
+ fossil_print("REVERTED: %s\n", zFile);
588589
mtime = file_mtime(zFull);
589590
db_multi_exec(
590591
"UPDATE vfile"
591592
" SET mtime=%lld, chnged=0, deleted=0, isexe=%d, mrid=rid,"
592593
" pathname=coalesce(origname,pathname), origname=NULL"
593594
--- src/update.c
+++ src/update.c
@@ -253,18 +253,18 @@
253 if( debugFlag ){
254 db_prepare(&q,
255 "SELECT rowid, fn, fnt, chnged, ridv, ridt, isexe FROM fv"
256 );
257 while( db_step(&q)==SQLITE_ROW ){
258 printf("%3d: ridv=%-4d ridt=%-4d chnged=%d isexe=%d\n",
259 db_column_int(&q, 0),
260 db_column_int(&q, 4),
261 db_column_int(&q, 5),
262 db_column_int(&q, 3),
263 db_column_int(&q, 6));
264 printf(" fnv = [%s]\n", db_column_text(&q, 1));
265 printf(" fnt = [%s]\n", db_column_text(&q, 2));
266 }
267 db_finalize(&q);
268 }
269
270 /* If FILES appear on the command-line, remove from the "fv" table
@@ -331,26 +331,26 @@
331 nameChng = fossil_strcmp(zName, zNewName);
332 if( idv>0 && ridv==0 && idt>0 && ridt>0 ){
333 /* Conflict. This file has been added to the current checkout
334 ** but also exists in the target checkout. Use the current version.
335 */
336 printf("CONFLICT %s\n", zName);
337 nConflict++;
338 }else if( idt>0 && idv==0 ){
339 /* File added in the target. */
340 printf("ADD %s\n", zName);
341 undo_save(zName);
342 if( !nochangeFlag ) vfile_to_disk(0, idt, 0, 0);
343 }else if( idt>0 && idv>0 && ridt!=ridv && chnged==0 ){
344 /* The file is unedited. Change it to the target version */
345 undo_save(zName);
346 printf("UPDATE %s\n", zName);
347 if( !nochangeFlag ) vfile_to_disk(0, idt, 0, 0);
348 }else if( idt>0 && idv>0 && file_size(zFullPath)<0 ){
349 /* The file missing from the local check-out. Restore it to the
350 ** version that appears in the target. */
351 printf("UPDATE %s\n", zName);
352 undo_save(zName);
353 if( !nochangeFlag ) vfile_to_disk(0, idt, 0, 0);
354 }else if( idt==0 && idv>0 ){
355 if( ridv==0 ){
356 /* Added in current checkout. Continue to hold the file as
@@ -357,25 +357,26 @@
357 ** as an addition */
358 db_multi_exec("UPDATE vfile SET vid=%d WHERE id=%d", tid, idv);
359 }else if( chnged ){
360 /* Edited locally but deleted from the target. Do not track the
361 ** file but keep the edited version around. */
362 printf("CONFLICT %s - edited locally but deleted by update\n", zName);
 
363 nConflict++;
364 }else{
365 printf("REMOVE %s\n", zName);
366 undo_save(zName);
367 if( !nochangeFlag ) unlink(zFullPath);
368 }
369 }else if( idt>0 && idv>0 && ridt!=ridv && chnged ){
370 /* Merge the changes in the current tree into the target version */
371 Blob r, t, v;
372 int rc;
373 if( nameChng ){
374 printf("MERGE %s -> %s\n", zName, zNewName);
375 }else{
376 printf("MERGE %s\n", zName);
377 }
378 undo_save(zName);
379 content_get(ridt, &t);
380 content_get(ridv, &v);
381 rc = merge_3way(&v, zFullPath, &t, &r);
@@ -383,51 +384,51 @@
383 if( !nochangeFlag ){
384 blob_write_to_file(&r, zFullNewPath);
385 file_setexe(zFullNewPath, isexe);
386 }
387 if( rc>0 ){
388 printf("***** %d merge conflicts in %s\n", rc, zNewName);
389 nConflict++;
390 }
391 }else{
392 if( !nochangeFlag ){
393 blob_write_to_file(&t, zFullNewPath);
394 file_setexe(zFullNewPath, isexe);
395 }
396 printf("***** Cannot merge binary file %s\n", zNewName);
397 nConflict++;
398 }
399 if( nameChng && !nochangeFlag ) unlink(zFullPath);
400 blob_reset(&v);
401 blob_reset(&t);
402 blob_reset(&r);
403 }else{
404 if( chnged ){
405 if( verboseFlag ) printf("EDITED %s\n", zName);
406 }else{
407 db_bind_int(&mtimeXfer, ":idv", idv);
408 db_bind_int(&mtimeXfer, ":idt", idt);
409 db_step(&mtimeXfer);
410 db_reset(&mtimeXfer);
411 if( verboseFlag ) printf("UNCHANGED %s\n", zName);
412 }
413 }
414 free(zFullPath);
415 free(zFullNewPath);
416 }
417 db_finalize(&q);
418 db_finalize(&mtimeXfer);
419 printf("--------------\n");
420 show_common_info(tid, "updated-to:", 1, 0);
421
422 /* Report on conflicts
423 */
424 if( nConflict && !nochangeFlag ){
425 if( internalUpdate ){
426 internalConflictCnt = nConflict;
427 }else{
428 printf("WARNING: %d merge conflicts - see messages above for details.\n",
429 nConflict);
430 }
431 }
432
433 /*
@@ -570,23 +571,23 @@
570 zFile = db_column_text(&q, 0);
571 zFull = mprintf("%/%/", g.zLocalRoot, zFile);
572 errCode = historical_version_of_file(zRevision, zFile, &record, &isExe,2);
573 if( errCode==2 ){
574 if( db_int(0, "SELECT rid FROM vfile WHERE pathname=%Q", zFile)==0 ){
575 printf("UNMANAGE: %s\n", zFile);
576 }else{
577 undo_save(zFile);
578 unlink(zFull);
579 printf("DELETE: %s\n", zFile);
580 }
581 db_multi_exec("DELETE FROM vfile WHERE pathname=%Q", zFile);
582 }else{
583 sqlite3_int64 mtime;
584 undo_save(zFile);
585 blob_write_to_file(&record, zFull);
586 file_setexe(zFull, isExe);
587 printf("REVERTED: %s\n", zFile);
588 mtime = file_mtime(zFull);
589 db_multi_exec(
590 "UPDATE vfile"
591 " SET mtime=%lld, chnged=0, deleted=0, isexe=%d, mrid=rid,"
592 " pathname=coalesce(origname,pathname), origname=NULL"
593
--- src/update.c
+++ src/update.c
@@ -253,18 +253,18 @@
253 if( debugFlag ){
254 db_prepare(&q,
255 "SELECT rowid, fn, fnt, chnged, ridv, ridt, isexe FROM fv"
256 );
257 while( db_step(&q)==SQLITE_ROW ){
258 fossil_print("%3d: ridv=%-4d ridt=%-4d chnged=%d isexe=%d\n",
259 db_column_int(&q, 0),
260 db_column_int(&q, 4),
261 db_column_int(&q, 5),
262 db_column_int(&q, 3),
263 db_column_int(&q, 6));
264 fossil_print(" fnv = [%s]\n", db_column_text(&q, 1));
265 fossil_print(" fnt = [%s]\n", db_column_text(&q, 2));
266 }
267 db_finalize(&q);
268 }
269
270 /* If FILES appear on the command-line, remove from the "fv" table
@@ -331,26 +331,26 @@
331 nameChng = fossil_strcmp(zName, zNewName);
332 if( idv>0 && ridv==0 && idt>0 && ridt>0 ){
333 /* Conflict. This file has been added to the current checkout
334 ** but also exists in the target checkout. Use the current version.
335 */
336 fossil_print("CONFLICT %s\n", zName);
337 nConflict++;
338 }else if( idt>0 && idv==0 ){
339 /* File added in the target. */
340 fossil_print("ADD %s\n", zName);
341 undo_save(zName);
342 if( !nochangeFlag ) vfile_to_disk(0, idt, 0, 0);
343 }else if( idt>0 && idv>0 && ridt!=ridv && chnged==0 ){
344 /* The file is unedited. Change it to the target version */
345 undo_save(zName);
346 fossil_print("UPDATE %s\n", zName);
347 if( !nochangeFlag ) vfile_to_disk(0, idt, 0, 0);
348 }else if( idt>0 && idv>0 && file_size(zFullPath)<0 ){
349 /* The file missing from the local check-out. Restore it to the
350 ** version that appears in the target. */
351 fossil_print("UPDATE %s\n", zName);
352 undo_save(zName);
353 if( !nochangeFlag ) vfile_to_disk(0, idt, 0, 0);
354 }else if( idt==0 && idv>0 ){
355 if( ridv==0 ){
356 /* Added in current checkout. Continue to hold the file as
@@ -357,25 +357,26 @@
357 ** as an addition */
358 db_multi_exec("UPDATE vfile SET vid=%d WHERE id=%d", tid, idv);
359 }else if( chnged ){
360 /* Edited locally but deleted from the target. Do not track the
361 ** file but keep the edited version around. */
362 fossil_print("CONFLICT %s - edited locally but deleted by update\n",
363 zName);
364 nConflict++;
365 }else{
366 fossil_print("REMOVE %s\n", zName);
367 undo_save(zName);
368 if( !nochangeFlag ) file_delete(zFullPath);
369 }
370 }else if( idt>0 && idv>0 && ridt!=ridv && chnged ){
371 /* Merge the changes in the current tree into the target version */
372 Blob r, t, v;
373 int rc;
374 if( nameChng ){
375 fossil_print("MERGE %s -> %s\n", zName, zNewName);
376 }else{
377 fossil_print("MERGE %s\n", zName);
378 }
379 undo_save(zName);
380 content_get(ridt, &t);
381 content_get(ridv, &v);
382 rc = merge_3way(&v, zFullPath, &t, &r);
@@ -383,51 +384,51 @@
384 if( !nochangeFlag ){
385 blob_write_to_file(&r, zFullNewPath);
386 file_setexe(zFullNewPath, isexe);
387 }
388 if( rc>0 ){
389 fossil_print("***** %d merge conflicts in %s\n", rc, zNewName);
390 nConflict++;
391 }
392 }else{
393 if( !nochangeFlag ){
394 blob_write_to_file(&t, zFullNewPath);
395 file_setexe(zFullNewPath, isexe);
396 }
397 fossil_print("***** Cannot merge binary file %s\n", zNewName);
398 nConflict++;
399 }
400 if( nameChng && !nochangeFlag ) file_delete(zFullPath);
401 blob_reset(&v);
402 blob_reset(&t);
403 blob_reset(&r);
404 }else{
405 if( chnged ){
406 if( verboseFlag ) fossil_print("EDITED %s\n", zName);
407 }else{
408 db_bind_int(&mtimeXfer, ":idv", idv);
409 db_bind_int(&mtimeXfer, ":idt", idt);
410 db_step(&mtimeXfer);
411 db_reset(&mtimeXfer);
412 if( verboseFlag ) fossil_print("UNCHANGED %s\n", zName);
413 }
414 }
415 free(zFullPath);
416 free(zFullNewPath);
417 }
418 db_finalize(&q);
419 db_finalize(&mtimeXfer);
420 fossil_print("--------------\n");
421 show_common_info(tid, "updated-to:", 1, 0);
422
423 /* Report on conflicts
424 */
425 if( nConflict && !nochangeFlag ){
426 if( internalUpdate ){
427 internalConflictCnt = nConflict;
428 }else{
429 fossil_print("WARNING: %d merge conflicts - see messages above for details.\n",
430 nConflict);
431 }
432 }
433
434 /*
@@ -570,23 +571,23 @@
571 zFile = db_column_text(&q, 0);
572 zFull = mprintf("%/%/", g.zLocalRoot, zFile);
573 errCode = historical_version_of_file(zRevision, zFile, &record, &isExe,2);
574 if( errCode==2 ){
575 if( db_int(0, "SELECT rid FROM vfile WHERE pathname=%Q", zFile)==0 ){
576 fossil_print("UNMANAGE: %s\n", zFile);
577 }else{
578 undo_save(zFile);
579 file_delete(zFull);
580 fossil_print("DELETE: %s\n", zFile);
581 }
582 db_multi_exec("DELETE FROM vfile WHERE pathname=%Q", zFile);
583 }else{
584 sqlite3_int64 mtime;
585 undo_save(zFile);
586 blob_write_to_file(&record, zFull);
587 file_setexe(zFull, isExe);
588 fossil_print("REVERTED: %s\n", zFile);
589 mtime = file_mtime(zFull);
590 db_multi_exec(
591 "UPDATE vfile"
592 " SET mtime=%lld, chnged=0, deleted=0, isexe=%d, mrid=rid,"
593 " pathname=coalesce(origname,pathname), origname=NULL"
594
+15 -15
--- src/url.c
+++ src/url.c
@@ -208,26 +208,26 @@
208208
if( g.argc!=3 && g.argc!=4 ){
209209
usage("URL");
210210
}
211211
url_parse(g.argv[2]);
212212
for(i=0; i<2; i++){
213
- printf("g.urlIsFile = %d\n", g.urlIsFile);
214
- printf("g.urlIsHttps = %d\n", g.urlIsHttps);
215
- printf("g.urlIsSsh = %d\n", g.urlIsSsh);
216
- printf("g.urlProtocol = %s\n", g.urlProtocol);
217
- printf("g.urlName = %s\n", g.urlName);
218
- printf("g.urlPort = %d\n", g.urlPort);
219
- printf("g.urlDfltPort = %d\n", g.urlDfltPort);
220
- printf("g.urlHostname = %s\n", g.urlHostname);
221
- printf("g.urlPath = %s\n", g.urlPath);
222
- printf("g.urlUser = %s\n", g.urlUser);
223
- printf("g.urlPasswd = %s\n", g.urlPasswd);
224
- printf("g.urlCanonical = %s\n", g.urlCanonical);
225
- printf("g.urlFossil = %s\n", g.urlFossil);
213
+ fossil_print("g.urlIsFile = %d\n", g.urlIsFile);
214
+ fossil_print("g.urlIsHttps = %d\n", g.urlIsHttps);
215
+ fossil_print("g.urlIsSsh = %d\n", g.urlIsSsh);
216
+ fossil_print("g.urlProtocol = %s\n", g.urlProtocol);
217
+ fossil_print("g.urlName = %s\n", g.urlName);
218
+ fossil_print("g.urlPort = %d\n", g.urlPort);
219
+ fossil_print("g.urlDfltPort = %d\n", g.urlDfltPort);
220
+ fossil_print("g.urlHostname = %s\n", g.urlHostname);
221
+ fossil_print("g.urlPath = %s\n", g.urlPath);
222
+ fossil_print("g.urlUser = %s\n", g.urlUser);
223
+ fossil_print("g.urlPasswd = %s\n", g.urlPasswd);
224
+ fossil_print("g.urlCanonical = %s\n", g.urlCanonical);
225
+ fossil_print("g.urlFossil = %s\n", g.urlFossil);
226226
if( g.urlIsFile || g.urlIsSsh ) break;
227227
if( i==0 ){
228
- printf("********\n");
228
+ fossil_print("********\n");
229229
url_enable_proxy("Using proxy: ");
230230
}
231231
}
232232
}
233233
@@ -276,11 +276,11 @@
276276
char *zOriginalUser = g.urlUser;
277277
char *zOriginalPasswd = g.urlPasswd;
278278
g.urlUser = 0;
279279
g.urlPasswd = "";
280280
url_parse(zProxy);
281
- if( zMsg ) printf("%s%s\n", zMsg, g.urlCanonical);
281
+ if( zMsg ) fossil_print("%s%s\n", zMsg, g.urlCanonical);
282282
g.urlPath = zOriginalUrl;
283283
g.urlHostname = zOriginalHost;
284284
if( g.urlUser ){
285285
char *zCredentials1 = mprintf("%s:%s", g.urlUser, g.urlPasswd);
286286
char *zCredentials2 = encode64(zCredentials1, -1);
287287
--- src/url.c
+++ src/url.c
@@ -208,26 +208,26 @@
208 if( g.argc!=3 && g.argc!=4 ){
209 usage("URL");
210 }
211 url_parse(g.argv[2]);
212 for(i=0; i<2; i++){
213 printf("g.urlIsFile = %d\n", g.urlIsFile);
214 printf("g.urlIsHttps = %d\n", g.urlIsHttps);
215 printf("g.urlIsSsh = %d\n", g.urlIsSsh);
216 printf("g.urlProtocol = %s\n", g.urlProtocol);
217 printf("g.urlName = %s\n", g.urlName);
218 printf("g.urlPort = %d\n", g.urlPort);
219 printf("g.urlDfltPort = %d\n", g.urlDfltPort);
220 printf("g.urlHostname = %s\n", g.urlHostname);
221 printf("g.urlPath = %s\n", g.urlPath);
222 printf("g.urlUser = %s\n", g.urlUser);
223 printf("g.urlPasswd = %s\n", g.urlPasswd);
224 printf("g.urlCanonical = %s\n", g.urlCanonical);
225 printf("g.urlFossil = %s\n", g.urlFossil);
226 if( g.urlIsFile || g.urlIsSsh ) break;
227 if( i==0 ){
228 printf("********\n");
229 url_enable_proxy("Using proxy: ");
230 }
231 }
232 }
233
@@ -276,11 +276,11 @@
276 char *zOriginalUser = g.urlUser;
277 char *zOriginalPasswd = g.urlPasswd;
278 g.urlUser = 0;
279 g.urlPasswd = "";
280 url_parse(zProxy);
281 if( zMsg ) printf("%s%s\n", zMsg, g.urlCanonical);
282 g.urlPath = zOriginalUrl;
283 g.urlHostname = zOriginalHost;
284 if( g.urlUser ){
285 char *zCredentials1 = mprintf("%s:%s", g.urlUser, g.urlPasswd);
286 char *zCredentials2 = encode64(zCredentials1, -1);
287
--- src/url.c
+++ src/url.c
@@ -208,26 +208,26 @@
208 if( g.argc!=3 && g.argc!=4 ){
209 usage("URL");
210 }
211 url_parse(g.argv[2]);
212 for(i=0; i<2; i++){
213 fossil_print("g.urlIsFile = %d\n", g.urlIsFile);
214 fossil_print("g.urlIsHttps = %d\n", g.urlIsHttps);
215 fossil_print("g.urlIsSsh = %d\n", g.urlIsSsh);
216 fossil_print("g.urlProtocol = %s\n", g.urlProtocol);
217 fossil_print("g.urlName = %s\n", g.urlName);
218 fossil_print("g.urlPort = %d\n", g.urlPort);
219 fossil_print("g.urlDfltPort = %d\n", g.urlDfltPort);
220 fossil_print("g.urlHostname = %s\n", g.urlHostname);
221 fossil_print("g.urlPath = %s\n", g.urlPath);
222 fossil_print("g.urlUser = %s\n", g.urlUser);
223 fossil_print("g.urlPasswd = %s\n", g.urlPasswd);
224 fossil_print("g.urlCanonical = %s\n", g.urlCanonical);
225 fossil_print("g.urlFossil = %s\n", g.urlFossil);
226 if( g.urlIsFile || g.urlIsSsh ) break;
227 if( i==0 ){
228 fossil_print("********\n");
229 url_enable_proxy("Using proxy: ");
230 }
231 }
232 }
233
@@ -276,11 +276,11 @@
276 char *zOriginalUser = g.urlUser;
277 char *zOriginalPasswd = g.urlPasswd;
278 g.urlUser = 0;
279 g.urlPasswd = "";
280 url_parse(zProxy);
281 if( zMsg ) fossil_print("%s%s\n", zMsg, g.urlCanonical);
282 g.urlPath = zOriginalUrl;
283 g.urlHostname = zOriginalHost;
284 if( g.urlUser ){
285 char *zCredentials1 = mprintf("%s:%s", g.urlUser, g.urlPasswd);
286 char *zCredentials2 = encode64(zCredentials1, -1);
287
+6 -6
--- src/user.c
+++ src/user.c
@@ -117,11 +117,11 @@
117117
prompt_for_passphrase(zPrompt, pPassphrase);
118118
if( verify==0 ) break;
119119
if( verify==1 && blob_size(pPassphrase)==0 ) break;
120120
prompt_for_passphrase("Retype new password: ", &secondTry);
121121
if( blob_compare(pPassphrase, &secondTry) ){
122
- printf("Passphrases do not match. Try again...\n");
122
+ fossil_print("Passphrases do not match. Try again...\n");
123123
}else{
124124
break;
125125
}
126126
}
127127
blob_reset(&secondTry);
@@ -132,11 +132,11 @@
132132
*/
133133
void prompt_user(const char *zPrompt, Blob *pIn){
134134
char *z;
135135
char zLine[1000];
136136
blob_zero(pIn);
137
- printf("%s", zPrompt);
137
+ fossil_print("%s", zPrompt);
138138
fflush(stdout);
139139
z = fgets(zLine, sizeof(zLine), stdin);
140140
if( z ){
141141
strip_string(pIn, z);
142142
}
@@ -212,11 +212,11 @@
212212
);
213213
free(zPw);
214214
}else if( n>=2 && strncmp(g.argv[2],"default",n)==0 ){
215215
user_select();
216216
if( g.argc==3 ){
217
- printf("%s\n", g.zLogin);
217
+ fossil_print("%s\n", g.zLogin);
218218
}else{
219219
if( !db_exists("SELECT 1 FROM user WHERE login=%Q", g.argv[3]) ){
220220
fossil_fatal("no such user: %s", g.argv[3]);
221221
}
222222
if( g.localOpen ){
@@ -227,11 +227,11 @@
227227
}
228228
}else if( n>=2 && strncmp(g.argv[2],"list",n)==0 ){
229229
Stmt q;
230230
db_prepare(&q, "SELECT login, info FROM user ORDER BY login");
231231
while( db_step(&q)==SQLITE_ROW ){
232
- printf("%-12s %s\n", db_column_text(&q, 0), db_column_text(&q, 1));
232
+ fossil_print("%-12s %s\n", db_column_text(&q, 0), db_column_text(&q, 1));
233233
}
234234
db_finalize(&q);
235235
}else if( n>=2 && strncmp(g.argv[2],"password",2)==0 ){
236236
char *zPrompt;
237237
int uid;
@@ -246,11 +246,11 @@
246246
}else{
247247
zPrompt = mprintf("New password for %s: ", g.argv[3]);
248248
prompt_for_password(zPrompt, &pw, 1);
249249
}
250250
if( blob_size(&pw)==0 ){
251
- printf("password unchanged\n");
251
+ fossil_print("password unchanged\n");
252252
}else{
253253
char *zSecret = sha1_shared_secret(blob_str(&pw), g.argv[3], 0);
254254
db_multi_exec("UPDATE user SET pw=%Q, mtime=now() WHERE uid=%d",
255255
zSecret, uid);
256256
free(zSecret);
@@ -268,11 +268,11 @@
268268
db_multi_exec(
269269
"UPDATE user SET cap=%Q, mtime=now() WHERE uid=%d",
270270
g.argv[4], uid
271271
);
272272
}
273
- printf("%s\n", db_text(0, "SELECT cap FROM user WHERE uid=%d", uid));
273
+ fossil_print("%s\n", db_text(0, "SELECT cap FROM user WHERE uid=%d", uid));
274274
}else{
275275
fossil_panic("user subcommand should be one of: "
276276
"capabilities default list new password");
277277
}
278278
}
279279
--- src/user.c
+++ src/user.c
@@ -117,11 +117,11 @@
117 prompt_for_passphrase(zPrompt, pPassphrase);
118 if( verify==0 ) break;
119 if( verify==1 && blob_size(pPassphrase)==0 ) break;
120 prompt_for_passphrase("Retype new password: ", &secondTry);
121 if( blob_compare(pPassphrase, &secondTry) ){
122 printf("Passphrases do not match. Try again...\n");
123 }else{
124 break;
125 }
126 }
127 blob_reset(&secondTry);
@@ -132,11 +132,11 @@
132 */
133 void prompt_user(const char *zPrompt, Blob *pIn){
134 char *z;
135 char zLine[1000];
136 blob_zero(pIn);
137 printf("%s", zPrompt);
138 fflush(stdout);
139 z = fgets(zLine, sizeof(zLine), stdin);
140 if( z ){
141 strip_string(pIn, z);
142 }
@@ -212,11 +212,11 @@
212 );
213 free(zPw);
214 }else if( n>=2 && strncmp(g.argv[2],"default",n)==0 ){
215 user_select();
216 if( g.argc==3 ){
217 printf("%s\n", g.zLogin);
218 }else{
219 if( !db_exists("SELECT 1 FROM user WHERE login=%Q", g.argv[3]) ){
220 fossil_fatal("no such user: %s", g.argv[3]);
221 }
222 if( g.localOpen ){
@@ -227,11 +227,11 @@
227 }
228 }else if( n>=2 && strncmp(g.argv[2],"list",n)==0 ){
229 Stmt q;
230 db_prepare(&q, "SELECT login, info FROM user ORDER BY login");
231 while( db_step(&q)==SQLITE_ROW ){
232 printf("%-12s %s\n", db_column_text(&q, 0), db_column_text(&q, 1));
233 }
234 db_finalize(&q);
235 }else if( n>=2 && strncmp(g.argv[2],"password",2)==0 ){
236 char *zPrompt;
237 int uid;
@@ -246,11 +246,11 @@
246 }else{
247 zPrompt = mprintf("New password for %s: ", g.argv[3]);
248 prompt_for_password(zPrompt, &pw, 1);
249 }
250 if( blob_size(&pw)==0 ){
251 printf("password unchanged\n");
252 }else{
253 char *zSecret = sha1_shared_secret(blob_str(&pw), g.argv[3], 0);
254 db_multi_exec("UPDATE user SET pw=%Q, mtime=now() WHERE uid=%d",
255 zSecret, uid);
256 free(zSecret);
@@ -268,11 +268,11 @@
268 db_multi_exec(
269 "UPDATE user SET cap=%Q, mtime=now() WHERE uid=%d",
270 g.argv[4], uid
271 );
272 }
273 printf("%s\n", db_text(0, "SELECT cap FROM user WHERE uid=%d", uid));
274 }else{
275 fossil_panic("user subcommand should be one of: "
276 "capabilities default list new password");
277 }
278 }
279
--- src/user.c
+++ src/user.c
@@ -117,11 +117,11 @@
117 prompt_for_passphrase(zPrompt, pPassphrase);
118 if( verify==0 ) break;
119 if( verify==1 && blob_size(pPassphrase)==0 ) break;
120 prompt_for_passphrase("Retype new password: ", &secondTry);
121 if( blob_compare(pPassphrase, &secondTry) ){
122 fossil_print("Passphrases do not match. Try again...\n");
123 }else{
124 break;
125 }
126 }
127 blob_reset(&secondTry);
@@ -132,11 +132,11 @@
132 */
133 void prompt_user(const char *zPrompt, Blob *pIn){
134 char *z;
135 char zLine[1000];
136 blob_zero(pIn);
137 fossil_print("%s", zPrompt);
138 fflush(stdout);
139 z = fgets(zLine, sizeof(zLine), stdin);
140 if( z ){
141 strip_string(pIn, z);
142 }
@@ -212,11 +212,11 @@
212 );
213 free(zPw);
214 }else if( n>=2 && strncmp(g.argv[2],"default",n)==0 ){
215 user_select();
216 if( g.argc==3 ){
217 fossil_print("%s\n", g.zLogin);
218 }else{
219 if( !db_exists("SELECT 1 FROM user WHERE login=%Q", g.argv[3]) ){
220 fossil_fatal("no such user: %s", g.argv[3]);
221 }
222 if( g.localOpen ){
@@ -227,11 +227,11 @@
227 }
228 }else if( n>=2 && strncmp(g.argv[2],"list",n)==0 ){
229 Stmt q;
230 db_prepare(&q, "SELECT login, info FROM user ORDER BY login");
231 while( db_step(&q)==SQLITE_ROW ){
232 fossil_print("%-12s %s\n", db_column_text(&q, 0), db_column_text(&q, 1));
233 }
234 db_finalize(&q);
235 }else if( n>=2 && strncmp(g.argv[2],"password",2)==0 ){
236 char *zPrompt;
237 int uid;
@@ -246,11 +246,11 @@
246 }else{
247 zPrompt = mprintf("New password for %s: ", g.argv[3]);
248 prompt_for_password(zPrompt, &pw, 1);
249 }
250 if( blob_size(&pw)==0 ){
251 fossil_print("password unchanged\n");
252 }else{
253 char *zSecret = sha1_shared_secret(blob_str(&pw), g.argv[3], 0);
254 db_multi_exec("UPDATE user SET pw=%Q, mtime=now() WHERE uid=%d",
255 zSecret, uid);
256 free(zSecret);
@@ -268,11 +268,11 @@
268 db_multi_exec(
269 "UPDATE user SET cap=%Q, mtime=now() WHERE uid=%d",
270 g.argv[4], uid
271 );
272 }
273 fossil_print("%s\n", db_text(0, "SELECT cap FROM user WHERE uid=%d", uid));
274 }else{
275 fossil_panic("user subcommand should be one of: "
276 "capabilities default list new password");
277 }
278 }
279
+8 -7
--- src/vfile.c
+++ src/vfile.c
@@ -264,11 +264,11 @@
264264
if( cReply=='n' || cReply=='N' ){
265265
blob_reset(&content);
266266
continue;
267267
}
268268
}
269
- if( verbose ) printf("%s\n", &zName[nRepos]);
269
+ if( verbose ) fossil_print("%s\n", &zName[nRepos]);
270270
blob_write_to_file(&content, zName);
271271
file_setexe(zName, isExe);
272272
blob_reset(&content);
273273
db_multi_exec("UPDATE vfile SET mtime=%lld WHERE id=%d",
274274
file_mtime(zName), id);
@@ -286,11 +286,11 @@
286286
" WHERE vid=%d AND mrid>0", g.zLocalRoot, vid);
287287
while( db_step(&q)==SQLITE_ROW ){
288288
const char *zName;
289289
290290
zName = db_column_text(&q, 0);
291
- unlink(zName);
291
+ file_delete(zName);
292292
}
293293
db_finalize(&q);
294294
db_multi_exec("UPDATE vfile SET mtime=NULL WHERE vid=%d AND mrid>0", vid);
295295
}
296296
@@ -428,11 +428,11 @@
428428
const char *zName = db_column_text(&q, 1);
429429
int isSelected = db_column_int(&q, 3);
430430
431431
if( isSelected ){
432432
md5sum_step_text(zName, -1);
433
- in = fopen(zFullpath,"rb");
433
+ in = fossil_fopen(zFullpath,"rb");
434434
if( in==0 ){
435435
md5sum_step_text(" 0\n", -1);
436436
continue;
437437
}
438438
fseek(in, 0L, SEEK_END);
@@ -491,26 +491,27 @@
491491
int rid = db_column_int(&q, 2);
492492
493493
blob_zero(&disk);
494494
rc = blob_read_from_file(&disk, zFullpath);
495495
if( rc<0 ){
496
- printf("ERROR: cannot read file [%s]\n", zFullpath);
496
+ fossil_print("ERROR: cannot read file [%s]\n", zFullpath);
497497
blob_reset(&disk);
498498
continue;
499499
}
500500
blob_zero(&repo);
501501
content_get(rid, &repo);
502502
if( blob_size(&repo)!=blob_size(&disk) ){
503
- printf("ERROR: [%s] is %d bytes on disk but %d in the repository\n",
503
+ fossil_print("ERROR: [%s] is %d bytes on disk but %d in the repository\n",
504504
zName, blob_size(&disk), blob_size(&repo));
505505
blob_reset(&disk);
506506
blob_reset(&repo);
507507
continue;
508508
}
509509
if( blob_compare(&repo, &disk) ){
510
- printf("ERROR: [%s] is different on disk compared to the repository\n",
511
- zName);
510
+ fossil_print(
511
+ "ERROR: [%s] is different on disk compared to the repository\n",
512
+ zName);
512513
}
513514
blob_reset(&disk);
514515
blob_reset(&repo);
515516
}
516517
db_finalize(&q);
517518
--- src/vfile.c
+++ src/vfile.c
@@ -264,11 +264,11 @@
264 if( cReply=='n' || cReply=='N' ){
265 blob_reset(&content);
266 continue;
267 }
268 }
269 if( verbose ) printf("%s\n", &zName[nRepos]);
270 blob_write_to_file(&content, zName);
271 file_setexe(zName, isExe);
272 blob_reset(&content);
273 db_multi_exec("UPDATE vfile SET mtime=%lld WHERE id=%d",
274 file_mtime(zName), id);
@@ -286,11 +286,11 @@
286 " WHERE vid=%d AND mrid>0", g.zLocalRoot, vid);
287 while( db_step(&q)==SQLITE_ROW ){
288 const char *zName;
289
290 zName = db_column_text(&q, 0);
291 unlink(zName);
292 }
293 db_finalize(&q);
294 db_multi_exec("UPDATE vfile SET mtime=NULL WHERE vid=%d AND mrid>0", vid);
295 }
296
@@ -428,11 +428,11 @@
428 const char *zName = db_column_text(&q, 1);
429 int isSelected = db_column_int(&q, 3);
430
431 if( isSelected ){
432 md5sum_step_text(zName, -1);
433 in = fopen(zFullpath,"rb");
434 if( in==0 ){
435 md5sum_step_text(" 0\n", -1);
436 continue;
437 }
438 fseek(in, 0L, SEEK_END);
@@ -491,26 +491,27 @@
491 int rid = db_column_int(&q, 2);
492
493 blob_zero(&disk);
494 rc = blob_read_from_file(&disk, zFullpath);
495 if( rc<0 ){
496 printf("ERROR: cannot read file [%s]\n", zFullpath);
497 blob_reset(&disk);
498 continue;
499 }
500 blob_zero(&repo);
501 content_get(rid, &repo);
502 if( blob_size(&repo)!=blob_size(&disk) ){
503 printf("ERROR: [%s] is %d bytes on disk but %d in the repository\n",
504 zName, blob_size(&disk), blob_size(&repo));
505 blob_reset(&disk);
506 blob_reset(&repo);
507 continue;
508 }
509 if( blob_compare(&repo, &disk) ){
510 printf("ERROR: [%s] is different on disk compared to the repository\n",
511 zName);
 
512 }
513 blob_reset(&disk);
514 blob_reset(&repo);
515 }
516 db_finalize(&q);
517
--- src/vfile.c
+++ src/vfile.c
@@ -264,11 +264,11 @@
264 if( cReply=='n' || cReply=='N' ){
265 blob_reset(&content);
266 continue;
267 }
268 }
269 if( verbose ) fossil_print("%s\n", &zName[nRepos]);
270 blob_write_to_file(&content, zName);
271 file_setexe(zName, isExe);
272 blob_reset(&content);
273 db_multi_exec("UPDATE vfile SET mtime=%lld WHERE id=%d",
274 file_mtime(zName), id);
@@ -286,11 +286,11 @@
286 " WHERE vid=%d AND mrid>0", g.zLocalRoot, vid);
287 while( db_step(&q)==SQLITE_ROW ){
288 const char *zName;
289
290 zName = db_column_text(&q, 0);
291 file_delete(zName);
292 }
293 db_finalize(&q);
294 db_multi_exec("UPDATE vfile SET mtime=NULL WHERE vid=%d AND mrid>0", vid);
295 }
296
@@ -428,11 +428,11 @@
428 const char *zName = db_column_text(&q, 1);
429 int isSelected = db_column_int(&q, 3);
430
431 if( isSelected ){
432 md5sum_step_text(zName, -1);
433 in = fossil_fopen(zFullpath,"rb");
434 if( in==0 ){
435 md5sum_step_text(" 0\n", -1);
436 continue;
437 }
438 fseek(in, 0L, SEEK_END);
@@ -491,26 +491,27 @@
491 int rid = db_column_int(&q, 2);
492
493 blob_zero(&disk);
494 rc = blob_read_from_file(&disk, zFullpath);
495 if( rc<0 ){
496 fossil_print("ERROR: cannot read file [%s]\n", zFullpath);
497 blob_reset(&disk);
498 continue;
499 }
500 blob_zero(&repo);
501 content_get(rid, &repo);
502 if( blob_size(&repo)!=blob_size(&disk) ){
503 fossil_print("ERROR: [%s] is %d bytes on disk but %d in the repository\n",
504 zName, blob_size(&disk), blob_size(&repo));
505 blob_reset(&disk);
506 blob_reset(&repo);
507 continue;
508 }
509 if( blob_compare(&repo, &disk) ){
510 fossil_print(
511 "ERROR: [%s] is different on disk compared to the repository\n",
512 zName);
513 }
514 blob_reset(&disk);
515 blob_reset(&repo);
516 }
517 db_finalize(&q);
518
+5 -5
--- src/wiki.c
+++ src/wiki.c
@@ -916,20 +916,20 @@
916916
FILE * zF;
917917
short doClose = 0;
918918
if( (1 == strlen(zFile)) && ('-'==zFile[0]) ){
919919
zF = stdout;
920920
}else{
921
- zF = fopen( zFile, "w" );
921
+ zF = fossil_fopen( zFile, "w" );
922922
doClose = zF ? 1 : 0;
923923
}
924924
if( ! zF ){
925925
fossil_fatal("wiki export could not open output file for writing.");
926926
}
927927
fprintf(zF,"%.*s\n", i, zBody);
928928
if( doClose ) fclose(zF);
929929
}else{
930
- printf("%.*s\n", i, zBody);
930
+ fossil_print("%.*s\n", i, zBody);
931931
}
932932
manifest_destroy(pWiki);
933933
return;
934934
}else
935935
if( strncmp(g.argv[2],"commit",n)==0
@@ -945,14 +945,14 @@
945945
}else{
946946
blob_read_from_file(&content, g.argv[4]);
947947
}
948948
if( g.argv[2][1]=='r' ){
949949
wiki_cmd_commit(zPageName, 1, &content);
950
- printf("Created new wiki page %s.\n", zPageName);
950
+ fossil_print("Created new wiki page %s.\n", zPageName);
951951
}else{
952952
wiki_cmd_commit(zPageName, 0, &content);
953
- printf("Updated wiki page %s.\n", zPageName);
953
+ fossil_print("Updated wiki page %s.\n", zPageName);
954954
}
955955
blob_reset(&content);
956956
}else
957957
if( strncmp(g.argv[2],"delete",n)==0 ){
958958
if( g.argc!=5 ){
@@ -966,11 +966,11 @@
966966
"SELECT substr(tagname, 6) FROM tag WHERE tagname GLOB 'wiki-*'"
967967
" ORDER BY lower(tagname) /*sort*/"
968968
);
969969
while( db_step(&q)==SQLITE_ROW ){
970970
const char *zName = db_column_text(&q, 0);
971
- printf( "%s\n",zName);
971
+ fossil_print( "%s\n",zName);
972972
}
973973
db_finalize(&q);
974974
}else
975975
{
976976
goto wiki_cmd_usage;
977977
--- src/wiki.c
+++ src/wiki.c
@@ -916,20 +916,20 @@
916 FILE * zF;
917 short doClose = 0;
918 if( (1 == strlen(zFile)) && ('-'==zFile[0]) ){
919 zF = stdout;
920 }else{
921 zF = fopen( zFile, "w" );
922 doClose = zF ? 1 : 0;
923 }
924 if( ! zF ){
925 fossil_fatal("wiki export could not open output file for writing.");
926 }
927 fprintf(zF,"%.*s\n", i, zBody);
928 if( doClose ) fclose(zF);
929 }else{
930 printf("%.*s\n", i, zBody);
931 }
932 manifest_destroy(pWiki);
933 return;
934 }else
935 if( strncmp(g.argv[2],"commit",n)==0
@@ -945,14 +945,14 @@
945 }else{
946 blob_read_from_file(&content, g.argv[4]);
947 }
948 if( g.argv[2][1]=='r' ){
949 wiki_cmd_commit(zPageName, 1, &content);
950 printf("Created new wiki page %s.\n", zPageName);
951 }else{
952 wiki_cmd_commit(zPageName, 0, &content);
953 printf("Updated wiki page %s.\n", zPageName);
954 }
955 blob_reset(&content);
956 }else
957 if( strncmp(g.argv[2],"delete",n)==0 ){
958 if( g.argc!=5 ){
@@ -966,11 +966,11 @@
966 "SELECT substr(tagname, 6) FROM tag WHERE tagname GLOB 'wiki-*'"
967 " ORDER BY lower(tagname) /*sort*/"
968 );
969 while( db_step(&q)==SQLITE_ROW ){
970 const char *zName = db_column_text(&q, 0);
971 printf( "%s\n",zName);
972 }
973 db_finalize(&q);
974 }else
975 {
976 goto wiki_cmd_usage;
977
--- src/wiki.c
+++ src/wiki.c
@@ -916,20 +916,20 @@
916 FILE * zF;
917 short doClose = 0;
918 if( (1 == strlen(zFile)) && ('-'==zFile[0]) ){
919 zF = stdout;
920 }else{
921 zF = fossil_fopen( zFile, "w" );
922 doClose = zF ? 1 : 0;
923 }
924 if( ! zF ){
925 fossil_fatal("wiki export could not open output file for writing.");
926 }
927 fprintf(zF,"%.*s\n", i, zBody);
928 if( doClose ) fclose(zF);
929 }else{
930 fossil_print("%.*s\n", i, zBody);
931 }
932 manifest_destroy(pWiki);
933 return;
934 }else
935 if( strncmp(g.argv[2],"commit",n)==0
@@ -945,14 +945,14 @@
945 }else{
946 blob_read_from_file(&content, g.argv[4]);
947 }
948 if( g.argv[2][1]=='r' ){
949 wiki_cmd_commit(zPageName, 1, &content);
950 fossil_print("Created new wiki page %s.\n", zPageName);
951 }else{
952 wiki_cmd_commit(zPageName, 0, &content);
953 fossil_print("Updated wiki page %s.\n", zPageName);
954 }
955 blob_reset(&content);
956 }else
957 if( strncmp(g.argv[2],"delete",n)==0 ){
958 if( g.argc!=5 ){
@@ -966,11 +966,11 @@
966 "SELECT substr(tagname, 6) FROM tag WHERE tagname GLOB 'wiki-*'"
967 " ORDER BY lower(tagname) /*sort*/"
968 );
969 while( db_step(&q)==SQLITE_ROW ){
970 const char *zName = db_column_text(&q, 0);
971 fossil_print( "%s\n",zName);
972 }
973 db_finalize(&q);
974 }else
975 {
976 goto wiki_cmd_usage;
977
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -1734,6 +1734,7 @@
17341734
break;
17351735
}
17361736
}
17371737
z += n;
17381738
}
1739
+ free(renderer.aStack);
17391740
}
17401741
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -1734,6 +1734,7 @@
1734 break;
1735 }
1736 }
1737 z += n;
1738 }
 
1739 }
1740
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -1734,6 +1734,7 @@
1734 break;
1735 }
1736 }
1737 z += n;
1738 }
1739 free(renderer.aStack);
1740 }
1741
+8 -8
--- src/winhttp.c
+++ src/winhttp.c
@@ -92,11 +92,11 @@
9292
wanted = find_content_length(zHdr) + (&z[4]-zHdr) - amt;
9393
break;
9494
}
9595
}
9696
if( amt>=sizeof(zHdr) ) goto end_request;
97
- out = fopen(zRequestFName, "wb");
97
+ out = fossil_fopen(zRequestFName, "wb");
9898
if( out==0 ) goto end_request;
9999
fwrite(zHdr, 1, amt, out);
100100
while( wanted>0 ){
101101
got = recv(p->s, zHdr, sizeof(zHdr), 0);
102102
if( got==SOCKET_ERROR ) goto end_request;
@@ -112,11 +112,11 @@
112112
sqlite3_snprintf(sizeof(zCmd), zCmd, "\"%s\" http \"%s\" %s %s %s --nossl%s",
113113
fossil_nameofexe(), g.zRepositoryName, zRequestFName, zReplyFName,
114114
inet_ntoa(p->addr.sin_addr), p->zOptions
115115
);
116116
fossil_system(zCmd);
117
- in = fopen(zReplyFName, "rb");
117
+ in = fossil_fopen(zReplyFName, "rb");
118118
if( in ){
119119
while( (got = fread(zHdr, 1, sizeof(zHdr), in))>0 ){
120120
send(p->s, zHdr, got, 0);
121121
}
122122
}
@@ -123,12 +123,12 @@
123123
124124
end_request:
125125
if( out ) fclose(out);
126126
if( in ) fclose(in);
127127
closesocket(p->s);
128
- unlink(zRequestFName);
129
- unlink(zReplyFName);
128
+ file_delete(zRequestFName);
129
+ file_delete(zReplyFName);
130130
free(p);
131131
}
132132
133133
/*
134134
** Start a listening socket and process incoming HTTP requests on
@@ -146,11 +146,11 @@
146146
SOCKADDR_IN addr;
147147
int idCnt = 0;
148148
int iPort = mnPort;
149149
Blob options;
150150
151
- if( zStopper ) unlink(zStopper);
151
+ if( zStopper ) file_delete(zStopper);
152152
blob_zero(&options);
153153
if( zNotFound ){
154154
blob_appendf(&options, " --notfound %s", zNotFound);
155155
}
156156
if( g.useLocalauth ){
@@ -190,17 +190,17 @@
190190
fossil_fatal("unable to open listening socket on any"
191191
" port in the range %d..%d", mnPort, mxPort);
192192
}
193193
}
194194
zTempPrefix = mprintf("fossil_server_P%d_", iPort);
195
- printf("Listening for HTTP requests on TCP port %d\n", iPort);
195
+ fossil_print("Listening for HTTP requests on TCP port %d\n", iPort);
196196
if( zBrowser ){
197197
zBrowser = mprintf(zBrowser, iPort);
198
- printf("Launch webbrowser: %s\n", zBrowser);
198
+ fossil_print("Launch webbrowser: %s\n", zBrowser);
199199
fossil_system(zBrowser);
200200
}
201
- printf("Type Ctrl-C to stop the HTTP server\n");
201
+ fossil_print("Type Ctrl-C to stop the HTTP server\n");
202202
for(;;){
203203
SOCKET client;
204204
SOCKADDR_IN client_addr;
205205
HttpRequest *p;
206206
int len = sizeof(client_addr);
207207
--- src/winhttp.c
+++ src/winhttp.c
@@ -92,11 +92,11 @@
92 wanted = find_content_length(zHdr) + (&z[4]-zHdr) - amt;
93 break;
94 }
95 }
96 if( amt>=sizeof(zHdr) ) goto end_request;
97 out = fopen(zRequestFName, "wb");
98 if( out==0 ) goto end_request;
99 fwrite(zHdr, 1, amt, out);
100 while( wanted>0 ){
101 got = recv(p->s, zHdr, sizeof(zHdr), 0);
102 if( got==SOCKET_ERROR ) goto end_request;
@@ -112,11 +112,11 @@
112 sqlite3_snprintf(sizeof(zCmd), zCmd, "\"%s\" http \"%s\" %s %s %s --nossl%s",
113 fossil_nameofexe(), g.zRepositoryName, zRequestFName, zReplyFName,
114 inet_ntoa(p->addr.sin_addr), p->zOptions
115 );
116 fossil_system(zCmd);
117 in = fopen(zReplyFName, "rb");
118 if( in ){
119 while( (got = fread(zHdr, 1, sizeof(zHdr), in))>0 ){
120 send(p->s, zHdr, got, 0);
121 }
122 }
@@ -123,12 +123,12 @@
123
124 end_request:
125 if( out ) fclose(out);
126 if( in ) fclose(in);
127 closesocket(p->s);
128 unlink(zRequestFName);
129 unlink(zReplyFName);
130 free(p);
131 }
132
133 /*
134 ** Start a listening socket and process incoming HTTP requests on
@@ -146,11 +146,11 @@
146 SOCKADDR_IN addr;
147 int idCnt = 0;
148 int iPort = mnPort;
149 Blob options;
150
151 if( zStopper ) unlink(zStopper);
152 blob_zero(&options);
153 if( zNotFound ){
154 blob_appendf(&options, " --notfound %s", zNotFound);
155 }
156 if( g.useLocalauth ){
@@ -190,17 +190,17 @@
190 fossil_fatal("unable to open listening socket on any"
191 " port in the range %d..%d", mnPort, mxPort);
192 }
193 }
194 zTempPrefix = mprintf("fossil_server_P%d_", iPort);
195 printf("Listening for HTTP requests on TCP port %d\n", iPort);
196 if( zBrowser ){
197 zBrowser = mprintf(zBrowser, iPort);
198 printf("Launch webbrowser: %s\n", zBrowser);
199 fossil_system(zBrowser);
200 }
201 printf("Type Ctrl-C to stop the HTTP server\n");
202 for(;;){
203 SOCKET client;
204 SOCKADDR_IN client_addr;
205 HttpRequest *p;
206 int len = sizeof(client_addr);
207
--- src/winhttp.c
+++ src/winhttp.c
@@ -92,11 +92,11 @@
92 wanted = find_content_length(zHdr) + (&z[4]-zHdr) - amt;
93 break;
94 }
95 }
96 if( amt>=sizeof(zHdr) ) goto end_request;
97 out = fossil_fopen(zRequestFName, "wb");
98 if( out==0 ) goto end_request;
99 fwrite(zHdr, 1, amt, out);
100 while( wanted>0 ){
101 got = recv(p->s, zHdr, sizeof(zHdr), 0);
102 if( got==SOCKET_ERROR ) goto end_request;
@@ -112,11 +112,11 @@
112 sqlite3_snprintf(sizeof(zCmd), zCmd, "\"%s\" http \"%s\" %s %s %s --nossl%s",
113 fossil_nameofexe(), g.zRepositoryName, zRequestFName, zReplyFName,
114 inet_ntoa(p->addr.sin_addr), p->zOptions
115 );
116 fossil_system(zCmd);
117 in = fossil_fopen(zReplyFName, "rb");
118 if( in ){
119 while( (got = fread(zHdr, 1, sizeof(zHdr), in))>0 ){
120 send(p->s, zHdr, got, 0);
121 }
122 }
@@ -123,12 +123,12 @@
123
124 end_request:
125 if( out ) fclose(out);
126 if( in ) fclose(in);
127 closesocket(p->s);
128 file_delete(zRequestFName);
129 file_delete(zReplyFName);
130 free(p);
131 }
132
133 /*
134 ** Start a listening socket and process incoming HTTP requests on
@@ -146,11 +146,11 @@
146 SOCKADDR_IN addr;
147 int idCnt = 0;
148 int iPort = mnPort;
149 Blob options;
150
151 if( zStopper ) file_delete(zStopper);
152 blob_zero(&options);
153 if( zNotFound ){
154 blob_appendf(&options, " --notfound %s", zNotFound);
155 }
156 if( g.useLocalauth ){
@@ -190,17 +190,17 @@
190 fossil_fatal("unable to open listening socket on any"
191 " port in the range %d..%d", mnPort, mxPort);
192 }
193 }
194 zTempPrefix = mprintf("fossil_server_P%d_", iPort);
195 fossil_print("Listening for HTTP requests on TCP port %d\n", iPort);
196 if( zBrowser ){
197 zBrowser = mprintf(zBrowser, iPort);
198 fossil_print("Launch webbrowser: %s\n", zBrowser);
199 fossil_system(zBrowser);
200 }
201 fossil_print("Type Ctrl-C to stop the HTTP server\n");
202 for(;;){
203 SOCKET client;
204 SOCKADDR_IN client_addr;
205 HttpRequest *p;
206 int len = sizeof(client_addr);
207
+3 -3
--- src/xfer.c
+++ src/xfer.c
@@ -1206,11 +1206,11 @@
12061206
}
12071207
blob_zero(&g.cgiIn);
12081208
blob_read_from_file(&g.cgiIn, g.argc==2 ? "-" : g.argv[2]);
12091209
disableLogin = 1;
12101210
page_xfer();
1211
- printf("%s\n", cgi_extract_content(&notUsed));
1211
+ fossil_print("%s\n", cgi_extract_content(&notUsed));
12121212
}
12131213
12141214
/*
12151215
** Format strings for progress reporting.
12161216
*/
@@ -1390,11 +1390,11 @@
13901390
xfer.nFileSent = 0;
13911391
xfer.nDeltaSent = 0;
13921392
xfer.nGimmeSent = 0;
13931393
xfer.nIGotSent = 0;
13941394
if( !g.cgiOutput && !g.fQuiet ){
1395
- printf("waiting for server...");
1395
+ fossil_print("waiting for server...");
13961396
}
13971397
fflush(stdout);
13981398
if( http_exchange(&send, &recv, cloneFlag==0 || nCycle>0) ){
13991399
nErr++;
14001400
break;
@@ -1446,11 +1446,11 @@
14461446
xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken));
14471447
nCardRcvd++;
14481448
if( !g.cgiOutput && !g.fQuiet && recv.nUsed>0 ){
14491449
pctDone = (recv.iCursor*100)/recv.nUsed;
14501450
if( pctDone!=lastPctDone ){
1451
- printf("\rprocessed: %d%% ", pctDone);
1451
+ fossil_print("\rprocessed: %d%% ", pctDone);
14521452
lastPctDone = pctDone;
14531453
fflush(stdout);
14541454
}
14551455
}
14561456
14571457
--- src/xfer.c
+++ src/xfer.c
@@ -1206,11 +1206,11 @@
1206 }
1207 blob_zero(&g.cgiIn);
1208 blob_read_from_file(&g.cgiIn, g.argc==2 ? "-" : g.argv[2]);
1209 disableLogin = 1;
1210 page_xfer();
1211 printf("%s\n", cgi_extract_content(&notUsed));
1212 }
1213
1214 /*
1215 ** Format strings for progress reporting.
1216 */
@@ -1390,11 +1390,11 @@
1390 xfer.nFileSent = 0;
1391 xfer.nDeltaSent = 0;
1392 xfer.nGimmeSent = 0;
1393 xfer.nIGotSent = 0;
1394 if( !g.cgiOutput && !g.fQuiet ){
1395 printf("waiting for server...");
1396 }
1397 fflush(stdout);
1398 if( http_exchange(&send, &recv, cloneFlag==0 || nCycle>0) ){
1399 nErr++;
1400 break;
@@ -1446,11 +1446,11 @@
1446 xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken));
1447 nCardRcvd++;
1448 if( !g.cgiOutput && !g.fQuiet && recv.nUsed>0 ){
1449 pctDone = (recv.iCursor*100)/recv.nUsed;
1450 if( pctDone!=lastPctDone ){
1451 printf("\rprocessed: %d%% ", pctDone);
1452 lastPctDone = pctDone;
1453 fflush(stdout);
1454 }
1455 }
1456
1457
--- src/xfer.c
+++ src/xfer.c
@@ -1206,11 +1206,11 @@
1206 }
1207 blob_zero(&g.cgiIn);
1208 blob_read_from_file(&g.cgiIn, g.argc==2 ? "-" : g.argv[2]);
1209 disableLogin = 1;
1210 page_xfer();
1211 fossil_print("%s\n", cgi_extract_content(&notUsed));
1212 }
1213
1214 /*
1215 ** Format strings for progress reporting.
1216 */
@@ -1390,11 +1390,11 @@
1390 xfer.nFileSent = 0;
1391 xfer.nDeltaSent = 0;
1392 xfer.nGimmeSent = 0;
1393 xfer.nIGotSent = 0;
1394 if( !g.cgiOutput && !g.fQuiet ){
1395 fossil_print("waiting for server...");
1396 }
1397 fflush(stdout);
1398 if( http_exchange(&send, &recv, cloneFlag==0 || nCycle>0) ){
1399 nErr++;
1400 break;
@@ -1446,11 +1446,11 @@
1446 xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken));
1447 nCardRcvd++;
1448 if( !g.cgiOutput && !g.fQuiet && recv.nUsed>0 ){
1449 pctDone = (recv.iCursor*100)/recv.nUsed;
1450 if( pctDone!=lastPctDone ){
1451 fossil_print("\rprocessed: %d%% ", pctDone);
1452 lastPctDone = pctDone;
1453 fflush(stdout);
1454 }
1455 }
1456
1457

Keyboard Shortcuts

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