Fossil SCM

- finally, do the ++j update in looks_like_text() right - More consistancy in prompt handling: accept Capitals everywhere, use '(' not '[', and abbreviate yes/no to y/N everywhere

jan.nijtmans 2012-10-28 21:38 trunk
Commit 7c527165a62cc867cc092ac988b791e4d8b97490
+3 -1
--- src/branch.c
+++ src/branch.c
@@ -138,13 +138,15 @@
138138
blob_appendf(&branch, "U %F\n", zUserOvrd ? zUserOvrd : g.zLogin);
139139
md5sum_blob(&branch, &mcksum);
140140
blob_appendf(&branch, "Z %b\n", &mcksum);
141141
if( !noSign && clearsign(&branch, &branch) ){
142142
Blob ans;
143
+ char cReply;
143144
blob_zero(&ans);
144145
prompt_user("unable to sign manifest. continue (y/N)? ", &ans);
145
- if( blob_str(&ans)[0]!='y' ){
146
+ cReply = blob_str(&ans)[0];
147
+ if( cReply!='y' && cReply!='Y'){
146148
db_end_transaction(1);
147149
fossil_exit(1);
148150
}
149151
}
150152
151153
--- src/branch.c
+++ src/branch.c
@@ -138,13 +138,15 @@
138 blob_appendf(&branch, "U %F\n", zUserOvrd ? zUserOvrd : g.zLogin);
139 md5sum_blob(&branch, &mcksum);
140 blob_appendf(&branch, "Z %b\n", &mcksum);
141 if( !noSign && clearsign(&branch, &branch) ){
142 Blob ans;
 
143 blob_zero(&ans);
144 prompt_user("unable to sign manifest. continue (y/N)? ", &ans);
145 if( blob_str(&ans)[0]!='y' ){
 
146 db_end_transaction(1);
147 fossil_exit(1);
148 }
149 }
150
151
--- src/branch.c
+++ src/branch.c
@@ -138,13 +138,15 @@
138 blob_appendf(&branch, "U %F\n", zUserOvrd ? zUserOvrd : g.zLogin);
139 md5sum_blob(&branch, &mcksum);
140 blob_appendf(&branch, "Z %b\n", &mcksum);
141 if( !noSign && clearsign(&branch, &branch) ){
142 Blob ans;
143 char cReply;
144 blob_zero(&ans);
145 prompt_user("unable to sign manifest. continue (y/N)? ", &ans);
146 cReply = blob_str(&ans)[0];
147 if( cReply!='y' && cReply!='Y'){
148 db_end_transaction(1);
149 fossil_exit(1);
150 }
151 }
152
153
+3 -2
--- src/checkin.c
+++ src/checkin.c
@@ -897,11 +897,11 @@
897897
char cReply;
898898
899899
file_relative_name(zFilename, &fname, 0);
900900
blob_zero(&ans);
901901
zMsg = mprintf(
902
- "%s contains CR/NL line endings; commit anyhow (yes/no/all)?",
902
+ "%s contains CR/NL line endings; commit anyhow (a=all/y/N)?",
903903
blob_str(&fname));
904904
prompt_user(zMsg, &ans);
905905
fossil_free(zMsg);
906906
cReply = blob_str(&ans)[0];
907907
if( cReply=='a' || cReply=='A' ){
@@ -1080,11 +1080,12 @@
10801080
*/
10811081
if( !g.markPrivate ){
10821082
if( autosync(AUTOSYNC_PULL) ){
10831083
blob_zero(&ans);
10841084
prompt_user("continue in spite of sync failure (y/N)? ", &ans);
1085
- if( blob_str(&ans)[0]!='y' ){
1085
+ cReply = blob_str(&ans)[0];
1086
+ if( cReply!='y' && cReply!='Y' ){
10861087
fossil_exit(1);
10871088
}
10881089
}
10891090
}
10901091
10911092
--- src/checkin.c
+++ src/checkin.c
@@ -897,11 +897,11 @@
897 char cReply;
898
899 file_relative_name(zFilename, &fname, 0);
900 blob_zero(&ans);
901 zMsg = mprintf(
902 "%s contains CR/NL line endings; commit anyhow (yes/no/all)?",
903 blob_str(&fname));
904 prompt_user(zMsg, &ans);
905 fossil_free(zMsg);
906 cReply = blob_str(&ans)[0];
907 if( cReply=='a' || cReply=='A' ){
@@ -1080,11 +1080,12 @@
1080 */
1081 if( !g.markPrivate ){
1082 if( autosync(AUTOSYNC_PULL) ){
1083 blob_zero(&ans);
1084 prompt_user("continue in spite of sync failure (y/N)? ", &ans);
1085 if( blob_str(&ans)[0]!='y' ){
 
1086 fossil_exit(1);
1087 }
1088 }
1089 }
1090
1091
--- src/checkin.c
+++ src/checkin.c
@@ -897,11 +897,11 @@
897 char cReply;
898
899 file_relative_name(zFilename, &fname, 0);
900 blob_zero(&ans);
901 zMsg = mprintf(
902 "%s contains CR/NL line endings; commit anyhow (a=all/y/N)?",
903 blob_str(&fname));
904 prompt_user(zMsg, &ans);
905 fossil_free(zMsg);
906 cReply = blob_str(&ans)[0];
907 if( cReply=='a' || cReply=='A' ){
@@ -1080,11 +1080,12 @@
1080 */
1081 if( !g.markPrivate ){
1082 if( autosync(AUTOSYNC_PULL) ){
1083 blob_zero(&ans);
1084 prompt_user("continue in spite of sync failure (y/N)? ", &ans);
1085 cReply = blob_str(&ans)[0];
1086 if( cReply!='y' && cReply!='Y' ){
1087 fossil_exit(1);
1088 }
1089 }
1090 }
1091
1092
+2 -2
--- src/diff.c
+++ src/diff.c
@@ -188,17 +188,17 @@
188188
if( n==0 ) return 1; /* Empty file -> text */
189189
c = *z;
190190
if( c==0 ) return 0; /* \000 byte in a file -> binary */
191191
j = (c!='\n');
192192
while( --n>0 ){
193
- c = *++z;
193
+ c = *++z; ++j;
194194
if( c==0 ) return 0; /* \000 byte in a file -> binary */
195195
if( c=='\n' ){
196196
if( z[-1]=='\r' ){
197197
result = -1; /* Contains CrLf, continue */
198198
}
199
- if( ++j>LENGTH_MASK ){
199
+ if( j>LENGTH_MASK ){
200200
return 0; /* Very long line -> binary */
201201
}
202202
j = 0;
203203
}
204204
}
205205
--- src/diff.c
+++ src/diff.c
@@ -188,17 +188,17 @@
188 if( n==0 ) return 1; /* Empty file -> text */
189 c = *z;
190 if( c==0 ) return 0; /* \000 byte in a file -> binary */
191 j = (c!='\n');
192 while( --n>0 ){
193 c = *++z;
194 if( c==0 ) return 0; /* \000 byte in a file -> binary */
195 if( c=='\n' ){
196 if( z[-1]=='\r' ){
197 result = -1; /* Contains CrLf, continue */
198 }
199 if( ++j>LENGTH_MASK ){
200 return 0; /* Very long line -> binary */
201 }
202 j = 0;
203 }
204 }
205
--- src/diff.c
+++ src/diff.c
@@ -188,17 +188,17 @@
188 if( n==0 ) return 1; /* Empty file -> text */
189 c = *z;
190 if( c==0 ) return 0; /* \000 byte in a file -> binary */
191 j = (c!='\n');
192 while( --n>0 ){
193 c = *++z; ++j;
194 if( c==0 ) return 0; /* \000 byte in a file -> binary */
195 if( c=='\n' ){
196 if( z[-1]=='\r' ){
197 result = -1; /* Contains CrLf, continue */
198 }
199 if( j>LENGTH_MASK ){
200 return 0; /* Very long line -> binary */
201 }
202 j = 0;
203 }
204 }
205
+10 -9
--- src/http_ssl.c
+++ src/http_ssl.c
@@ -284,34 +284,35 @@
284284
"SHA1 fingerprint above\n"
285285
" * use the global ssl-ca-location setting to specify your CA root\n"
286286
" certificates list\n\n"
287287
"If you are not expecting this message, answer no and "
288288
"contact your server\nadministrator.\n\n"
289
- "Accept certificate for host %s [a=always/y/N]? ",
289
+ "Accept certificate for host %s (a=always/y/N)? ",
290290
X509_verify_cert_error_string(e), desc, warning,
291291
g.urlName);
292292
BIO_free(mem);
293293
294294
prompt_user(prompt, &ans);
295295
free(prompt);
296
- if( blob_str(&ans)[0]!='y' && blob_str(&ans)[0]!='a' ) {
296
+ cReply = blob_str(&ans)[0];
297
+ blob_reset(&ans);
298
+ if( cReply!='y' && cReply!='Y' && cReply!='a' && cReply!='A') {
297299
X509_free(cert);
298300
ssl_set_errmsg("SSL certificate declined");
299301
ssl_close();
300302
return 1;
301303
}
302
- if( blob_str(&ans)[0]=='a' ) {
304
+ if( cReply=='a' || cReply=='A') {
303305
if ( trusted==0 ){
304
- Blob ans2;
305
- prompt_user("\nSave this certificate as fully trusted [a=always/N]? ",
306
- &ans2);
307
- trusted = (blob_str(&ans2)[0]=='a');
308
- blob_reset(&ans2);
306
+ prompt_user("\nSave this certificate as fully trusted (a=always/N)? ",
307
+ &ans);
308
+ cReply = blob_str(&ans)[0];
309
+ trusted = ( cReply=='a' || cReply=='A' );
310
+ blob_reset(&ans);
309311
}
310312
ssl_save_certificate(cert, trusted);
311313
}
312
- blob_reset(&ans);
313314
}
314315
315316
/* Set the Global.zIpAddr variable to the server we are talking to.
316317
** This is used to populate the ipaddr column of the rcvfrom table,
317318
** if any files are received from the server.
318319
--- src/http_ssl.c
+++ src/http_ssl.c
@@ -284,34 +284,35 @@
284 "SHA1 fingerprint above\n"
285 " * use the global ssl-ca-location setting to specify your CA root\n"
286 " certificates list\n\n"
287 "If you are not expecting this message, answer no and "
288 "contact your server\nadministrator.\n\n"
289 "Accept certificate for host %s [a=always/y/N]? ",
290 X509_verify_cert_error_string(e), desc, warning,
291 g.urlName);
292 BIO_free(mem);
293
294 prompt_user(prompt, &ans);
295 free(prompt);
296 if( blob_str(&ans)[0]!='y' && blob_str(&ans)[0]!='a' ) {
 
 
297 X509_free(cert);
298 ssl_set_errmsg("SSL certificate declined");
299 ssl_close();
300 return 1;
301 }
302 if( blob_str(&ans)[0]=='a' ) {
303 if ( trusted==0 ){
304 Blob ans2;
305 prompt_user("\nSave this certificate as fully trusted [a=always/N]? ",
306 &ans2);
307 trusted = (blob_str(&ans2)[0]=='a');
308 blob_reset(&ans2);
309 }
310 ssl_save_certificate(cert, trusted);
311 }
312 blob_reset(&ans);
313 }
314
315 /* Set the Global.zIpAddr variable to the server we are talking to.
316 ** This is used to populate the ipaddr column of the rcvfrom table,
317 ** if any files are received from the server.
318
--- src/http_ssl.c
+++ src/http_ssl.c
@@ -284,34 +284,35 @@
284 "SHA1 fingerprint above\n"
285 " * use the global ssl-ca-location setting to specify your CA root\n"
286 " certificates list\n\n"
287 "If you are not expecting this message, answer no and "
288 "contact your server\nadministrator.\n\n"
289 "Accept certificate for host %s (a=always/y/N)? ",
290 X509_verify_cert_error_string(e), desc, warning,
291 g.urlName);
292 BIO_free(mem);
293
294 prompt_user(prompt, &ans);
295 free(prompt);
296 cReply = blob_str(&ans)[0];
297 blob_reset(&ans);
298 if( cReply!='y' && cReply!='Y' && cReply!='a' && cReply!='A') {
299 X509_free(cert);
300 ssl_set_errmsg("SSL certificate declined");
301 ssl_close();
302 return 1;
303 }
304 if( cReply=='a' || cReply=='A') {
305 if ( trusted==0 ){
306 prompt_user("\nSave this certificate as fully trusted (a=always/N)? ",
307 &ans);
308 cReply = blob_str(&ans)[0];
309 trusted = ( cReply=='a' || cReply=='A' );
310 blob_reset(&ans);
311 }
312 ssl_save_certificate(cert, trusted);
313 }
 
314 }
315
316 /* Set the Global.zIpAddr variable to the server we are talking to.
317 ** This is used to populate the ipaddr column of the rcvfrom table,
318 ** if any files are received from the server.
319
+3 -1
--- src/rebuild.c
+++ src/rebuild.c
@@ -779,15 +779,17 @@
779779
int privateOnly = find_option("private",0,0)!=0;
780780
int bNeedRebuild = 0;
781781
db_find_and_open_repository(OPEN_ANY_SCHEMA, 2);
782782
if( !bForce ){
783783
Blob ans;
784
+ char cReply;
784785
blob_zero(&ans);
785786
prompt_user(
786787
"Scrubbing the repository will permanently delete information.\n"
787788
"Changes cannot be undone. Continue (y/N)? ", &ans);
788
- if( blob_str(&ans)[0]!='y' ){
789
+ cReply = blob_str(&ans)[0];
790
+ if( cReply!='y' && cReply!='Y' ){
789791
fossil_exit(1);
790792
}
791793
}
792794
db_begin_transaction();
793795
if( privateOnly || bVerily ){
794796
--- src/rebuild.c
+++ src/rebuild.c
@@ -779,15 +779,17 @@
779 int privateOnly = find_option("private",0,0)!=0;
780 int bNeedRebuild = 0;
781 db_find_and_open_repository(OPEN_ANY_SCHEMA, 2);
782 if( !bForce ){
783 Blob ans;
 
784 blob_zero(&ans);
785 prompt_user(
786 "Scrubbing the repository will permanently delete information.\n"
787 "Changes cannot be undone. Continue (y/N)? ", &ans);
788 if( blob_str(&ans)[0]!='y' ){
 
789 fossil_exit(1);
790 }
791 }
792 db_begin_transaction();
793 if( privateOnly || bVerily ){
794
--- src/rebuild.c
+++ src/rebuild.c
@@ -779,15 +779,17 @@
779 int privateOnly = find_option("private",0,0)!=0;
780 int bNeedRebuild = 0;
781 db_find_and_open_repository(OPEN_ANY_SCHEMA, 2);
782 if( !bForce ){
783 Blob ans;
784 char cReply;
785 blob_zero(&ans);
786 prompt_user(
787 "Scrubbing the repository will permanently delete information.\n"
788 "Changes cannot be undone. Continue (y/N)? ", &ans);
789 cReply = blob_str(&ans)[0];
790 if( cReply!='y' && cReply!='Y' ){
791 fossil_exit(1);
792 }
793 }
794 db_begin_transaction();
795 if( privateOnly || bVerily ){
796
+3 -1
--- src/stash.c
+++ src/stash.c
@@ -562,13 +562,15 @@
562562
}else
563563
if( memcmp(zCmd, "drop", nCmd)==0 || memcmp(zCmd, "rm", nCmd)==0 ){
564564
int allFlag = find_option("all", 0, 0)!=0;
565565
if( allFlag ){
566566
Blob ans;
567
+ char cReply;
567568
blob_zero(&ans);
568569
prompt_user("This action is not undoable. Continue (y/N)? ", &ans);
569
- if( blob_str(&ans)[0]=='y' ){
570
+ cReply = blob_str(&ans)[0];
571
+ if( cReply=='y' || cReply=='Y' ){
570572
db_multi_exec("DELETE FROM stash; DELETE FROM stashfile;");
571573
}
572574
}else if( g.argc>=4 ){
573575
int i;
574576
undo_begin();
575577
--- src/stash.c
+++ src/stash.c
@@ -562,13 +562,15 @@
562 }else
563 if( memcmp(zCmd, "drop", nCmd)==0 || memcmp(zCmd, "rm", nCmd)==0 ){
564 int allFlag = find_option("all", 0, 0)!=0;
565 if( allFlag ){
566 Blob ans;
 
567 blob_zero(&ans);
568 prompt_user("This action is not undoable. Continue (y/N)? ", &ans);
569 if( blob_str(&ans)[0]=='y' ){
 
570 db_multi_exec("DELETE FROM stash; DELETE FROM stashfile;");
571 }
572 }else if( g.argc>=4 ){
573 int i;
574 undo_begin();
575
--- src/stash.c
+++ src/stash.c
@@ -562,13 +562,15 @@
562 }else
563 if( memcmp(zCmd, "drop", nCmd)==0 || memcmp(zCmd, "rm", nCmd)==0 ){
564 int allFlag = find_option("all", 0, 0)!=0;
565 if( allFlag ){
566 Blob ans;
567 char cReply;
568 blob_zero(&ans);
569 prompt_user("This action is not undoable. Continue (y/N)? ", &ans);
570 cReply = blob_str(&ans)[0];
571 if( cReply=='y' || cReply=='Y' ){
572 db_multi_exec("DELETE FROM stash; DELETE FROM stashfile;");
573 }
574 }else if( g.argc>=4 ){
575 int i;
576 undo_begin();
577
+1 -3
--- src/vfile.c
+++ src/vfile.c
@@ -304,13 +304,11 @@
304304
free(zMsg);
305305
cReply = blob_str(&ans)[0];
306306
blob_reset(&ans);
307307
if( cReply=='a' || cReply=='A' ){
308308
promptFlag = 0;
309
- cReply = 'y';
310
- }
311
- if( cReply=='n' || cReply=='N' ){
309
+ } else if( cReply!='y' && cReply!='Y' ){
312310
blob_reset(&content);
313311
continue;
314312
}
315313
}
316314
if( verbose ) fossil_print("%s\n", &zName[nRepos]);
317315
--- src/vfile.c
+++ src/vfile.c
@@ -304,13 +304,11 @@
304 free(zMsg);
305 cReply = blob_str(&ans)[0];
306 blob_reset(&ans);
307 if( cReply=='a' || cReply=='A' ){
308 promptFlag = 0;
309 cReply = 'y';
310 }
311 if( cReply=='n' || cReply=='N' ){
312 blob_reset(&content);
313 continue;
314 }
315 }
316 if( verbose ) fossil_print("%s\n", &zName[nRepos]);
317
--- src/vfile.c
+++ src/vfile.c
@@ -304,13 +304,11 @@
304 free(zMsg);
305 cReply = blob_str(&ans)[0];
306 blob_reset(&ans);
307 if( cReply=='a' || cReply=='A' ){
308 promptFlag = 0;
309 } else if( cReply!='y' && cReply!='Y' ){
 
 
310 blob_reset(&content);
311 continue;
312 }
313 }
314 if( verbose ) fossil_print("%s\n", &zName[nRepos]);
315

Keyboard Shortcuts

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