Fossil SCM

Merge the changes to use various UTF encodings for win32 check-in comment editor into trunk.

drh 2012-10-22 17:29 UTC trunk merge
Commit cc01ec5094264e02489db3636f3cf48c3d101315
2 files changed +66 -5 +66 -5
+66 -5
--- src/checkin.c
+++ src/checkin.c
@@ -477,10 +477,15 @@
477477
zEditor = fossil_getenv("VISUAL");
478478
}
479479
if( zEditor==0 ){
480480
zEditor = fossil_getenv("EDITOR");
481481
}
482
+#ifdef _WIN32
483
+ if( zEditor==0 ){
484
+ zEditor = mprintf("%s\\notepad.exe", fossil_getenv("SystemRoot"));
485
+ }
486
+#endif
482487
if( zEditor==0 ){
483488
blob_append(pPrompt,
484489
"#\n"
485490
"# Since no default text editor is set using EDITOR or VISUAL\n"
486491
"# environment variables or the \"fossil set editor\" command,\n"
@@ -506,17 +511,14 @@
506511
blob_read_from_file(&reply, zFile);
507512
}else{
508513
char zIn[300];
509514
blob_zero(&reply);
510515
while( fgets(zIn, sizeof(zIn), stdin)!=0 ){
511
- char *zUtf8 = fossil_mbcs_to_utf8(zIn);
512
- if( zUtf8[0]=='.' && (zUtf8[1]==0 || zUtf8[1]=='\r' || zUtf8[1]=='\n') ){
513
- fossil_mbcs_free(zUtf8);
516
+ if( zIn[0]=='.' && (zIn[1]==0 || zIn[1]=='\r' || zIn[1]=='\n') ){
514517
break;
515518
}
516
- blob_append(&reply, zUtf8, -1);
517
- fossil_mbcs_free(zUtf8);
519
+ blob_append(&reply, zIn, -1);
518520
}
519521
}
520522
blob_remove_cr(&reply);
521523
file_delete(zFile);
522524
free(zFile);
@@ -562,11 +564,19 @@
562564
const char *zBranch,
563565
int parent_rid,
564566
const char *zUserOvrd
565567
){
566568
Blob prompt;
569
+#ifdef _WIN32
570
+ static const unsigned char bom[] = { 0xEF, 0xBB, 0xBF };
571
+ blob_init(&prompt, (const char *) bom, 3);
572
+ if( zInit && zInit[0]) {
573
+ blob_append(&prompt, zInit, -1);
574
+ }
575
+#else
567576
blob_init(&prompt, zInit, -1);
577
+#endif
568578
blob_append(&prompt,
569579
"\n"
570580
"# Enter comments on this check-in. Lines beginning with # are ignored.\n"
571581
"# The check-in comment follows wiki formatting rules.\n"
572582
"#\n", -1
@@ -1192,10 +1202,61 @@
11921202
prompt_user("empty check-in comment. continue (y/N)? ", &ans);
11931203
if( blob_str(&ans)[0]!='y' ){
11941204
fossil_exit(1);
11951205
}
11961206
}else{
1207
+#ifdef _WIN32
1208
+ /* On windows, the check-in comment might come back from the editor
1209
+ ** in various encodings. Try to figure out the encoding and do the
1210
+ ** right thing. */
1211
+ if( zComment==0 ){
1212
+ static const unsigned char bom[] = { 0xEF, 0xBB, 0xBF };
1213
+ static const unsigned short ubom = 0xfeff;
1214
+ static const unsigned short urbom = 0xfffe;
1215
+ if( blob_size(&comment)>2 && memcmp(blob_buffer(&comment), bom, 3)==0 ) {
1216
+ struct Blob temp;
1217
+ char *zUtf8 = blob_str(&comment) + 3;
1218
+ blob_zero(&temp);
1219
+ blob_append(&temp, zUtf8, -1);
1220
+ fossil_mbcs_free(zUtf8);
1221
+ blob_swap(&temp, &comment);
1222
+ blob_reset(&temp);
1223
+ }else if( blob_size(&comment)>1 && (blob_size(&comment)&1)==0
1224
+ && memcmp(blob_buffer(&comment), &ubom, 2)==0 ) {
1225
+ char *zUtf8;
1226
+ /* Make sure the blob contains two terminating 0-bytes */
1227
+ blob_append(&comment, "", 1);
1228
+ zUtf8 = blob_str(&comment) + 2;
1229
+ zUtf8 = fossil_unicode_to_utf8(zUtf8);
1230
+ blob_zero(&comment);
1231
+ blob_append(&comment, zUtf8, -1);
1232
+ fossil_mbcs_free(zUtf8);
1233
+ }else if( blob_size(&comment)>1 && (blob_size(&comment)&1)==0
1234
+ && memcmp(blob_buffer(&comment), &urbom, 2)==0 ) {
1235
+ char *zUtf8 = blob_buffer(&comment);
1236
+ unsigned int i = blob_size(&comment);
1237
+ while( i > 0 ){
1238
+ /* swap bytes of unicode representation */
1239
+ char temp = zUtf8[--i];
1240
+ zUtf8[i] = zUtf8[i-1];
1241
+ zUtf8[--i] = temp;
1242
+ }
1243
+ /* Make sure the blob contains two terminating 0-bytes */
1244
+ blob_append(&comment, "", 1);
1245
+ zUtf8 = blob_str(&comment) + 2;
1246
+ zUtf8 = fossil_unicode_to_utf8(zUtf8);
1247
+ blob_zero(&comment);
1248
+ blob_append(&comment, zUtf8, -1);
1249
+ fossil_mbcs_free(zUtf8);
1250
+ }else{
1251
+ char *zUtf8 = fossil_mbcs_to_utf8(blob_str(&comment));
1252
+ blob_zero(&comment);
1253
+ blob_append(&comment, zUtf8, -1);
1254
+ fossil_mbcs_free(zUtf8);
1255
+ }
1256
+ }
1257
+#endif /* _WIN32 */
11971258
db_multi_exec("REPLACE INTO vvar VALUES('ci-comment',%B)", &comment);
11981259
db_end_transaction(0);
11991260
db_begin_transaction();
12001261
}
12011262
12021263
--- src/checkin.c
+++ src/checkin.c
@@ -477,10 +477,15 @@
477 zEditor = fossil_getenv("VISUAL");
478 }
479 if( zEditor==0 ){
480 zEditor = fossil_getenv("EDITOR");
481 }
 
 
 
 
 
482 if( zEditor==0 ){
483 blob_append(pPrompt,
484 "#\n"
485 "# Since no default text editor is set using EDITOR or VISUAL\n"
486 "# environment variables or the \"fossil set editor\" command,\n"
@@ -506,17 +511,14 @@
506 blob_read_from_file(&reply, zFile);
507 }else{
508 char zIn[300];
509 blob_zero(&reply);
510 while( fgets(zIn, sizeof(zIn), stdin)!=0 ){
511 char *zUtf8 = fossil_mbcs_to_utf8(zIn);
512 if( zUtf8[0]=='.' && (zUtf8[1]==0 || zUtf8[1]=='\r' || zUtf8[1]=='\n') ){
513 fossil_mbcs_free(zUtf8);
514 break;
515 }
516 blob_append(&reply, zUtf8, -1);
517 fossil_mbcs_free(zUtf8);
518 }
519 }
520 blob_remove_cr(&reply);
521 file_delete(zFile);
522 free(zFile);
@@ -562,11 +564,19 @@
562 const char *zBranch,
563 int parent_rid,
564 const char *zUserOvrd
565 ){
566 Blob prompt;
 
 
 
 
 
 
 
567 blob_init(&prompt, zInit, -1);
 
568 blob_append(&prompt,
569 "\n"
570 "# Enter comments on this check-in. Lines beginning with # are ignored.\n"
571 "# The check-in comment follows wiki formatting rules.\n"
572 "#\n", -1
@@ -1192,10 +1202,61 @@
1192 prompt_user("empty check-in comment. continue (y/N)? ", &ans);
1193 if( blob_str(&ans)[0]!='y' ){
1194 fossil_exit(1);
1195 }
1196 }else{
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1197 db_multi_exec("REPLACE INTO vvar VALUES('ci-comment',%B)", &comment);
1198 db_end_transaction(0);
1199 db_begin_transaction();
1200 }
1201
1202
--- src/checkin.c
+++ src/checkin.c
@@ -477,10 +477,15 @@
477 zEditor = fossil_getenv("VISUAL");
478 }
479 if( zEditor==0 ){
480 zEditor = fossil_getenv("EDITOR");
481 }
482 #ifdef _WIN32
483 if( zEditor==0 ){
484 zEditor = mprintf("%s\\notepad.exe", fossil_getenv("SystemRoot"));
485 }
486 #endif
487 if( zEditor==0 ){
488 blob_append(pPrompt,
489 "#\n"
490 "# Since no default text editor is set using EDITOR or VISUAL\n"
491 "# environment variables or the \"fossil set editor\" command,\n"
@@ -506,17 +511,14 @@
511 blob_read_from_file(&reply, zFile);
512 }else{
513 char zIn[300];
514 blob_zero(&reply);
515 while( fgets(zIn, sizeof(zIn), stdin)!=0 ){
516 if( zIn[0]=='.' && (zIn[1]==0 || zIn[1]=='\r' || zIn[1]=='\n') ){
 
 
517 break;
518 }
519 blob_append(&reply, zIn, -1);
 
520 }
521 }
522 blob_remove_cr(&reply);
523 file_delete(zFile);
524 free(zFile);
@@ -562,11 +564,19 @@
564 const char *zBranch,
565 int parent_rid,
566 const char *zUserOvrd
567 ){
568 Blob prompt;
569 #ifdef _WIN32
570 static const unsigned char bom[] = { 0xEF, 0xBB, 0xBF };
571 blob_init(&prompt, (const char *) bom, 3);
572 if( zInit && zInit[0]) {
573 blob_append(&prompt, zInit, -1);
574 }
575 #else
576 blob_init(&prompt, zInit, -1);
577 #endif
578 blob_append(&prompt,
579 "\n"
580 "# Enter comments on this check-in. Lines beginning with # are ignored.\n"
581 "# The check-in comment follows wiki formatting rules.\n"
582 "#\n", -1
@@ -1192,10 +1202,61 @@
1202 prompt_user("empty check-in comment. continue (y/N)? ", &ans);
1203 if( blob_str(&ans)[0]!='y' ){
1204 fossil_exit(1);
1205 }
1206 }else{
1207 #ifdef _WIN32
1208 /* On windows, the check-in comment might come back from the editor
1209 ** in various encodings. Try to figure out the encoding and do the
1210 ** right thing. */
1211 if( zComment==0 ){
1212 static const unsigned char bom[] = { 0xEF, 0xBB, 0xBF };
1213 static const unsigned short ubom = 0xfeff;
1214 static const unsigned short urbom = 0xfffe;
1215 if( blob_size(&comment)>2 && memcmp(blob_buffer(&comment), bom, 3)==0 ) {
1216 struct Blob temp;
1217 char *zUtf8 = blob_str(&comment) + 3;
1218 blob_zero(&temp);
1219 blob_append(&temp, zUtf8, -1);
1220 fossil_mbcs_free(zUtf8);
1221 blob_swap(&temp, &comment);
1222 blob_reset(&temp);
1223 }else if( blob_size(&comment)>1 && (blob_size(&comment)&1)==0
1224 && memcmp(blob_buffer(&comment), &ubom, 2)==0 ) {
1225 char *zUtf8;
1226 /* Make sure the blob contains two terminating 0-bytes */
1227 blob_append(&comment, "", 1);
1228 zUtf8 = blob_str(&comment) + 2;
1229 zUtf8 = fossil_unicode_to_utf8(zUtf8);
1230 blob_zero(&comment);
1231 blob_append(&comment, zUtf8, -1);
1232 fossil_mbcs_free(zUtf8);
1233 }else if( blob_size(&comment)>1 && (blob_size(&comment)&1)==0
1234 && memcmp(blob_buffer(&comment), &urbom, 2)==0 ) {
1235 char *zUtf8 = blob_buffer(&comment);
1236 unsigned int i = blob_size(&comment);
1237 while( i > 0 ){
1238 /* swap bytes of unicode representation */
1239 char temp = zUtf8[--i];
1240 zUtf8[i] = zUtf8[i-1];
1241 zUtf8[--i] = temp;
1242 }
1243 /* Make sure the blob contains two terminating 0-bytes */
1244 blob_append(&comment, "", 1);
1245 zUtf8 = blob_str(&comment) + 2;
1246 zUtf8 = fossil_unicode_to_utf8(zUtf8);
1247 blob_zero(&comment);
1248 blob_append(&comment, zUtf8, -1);
1249 fossil_mbcs_free(zUtf8);
1250 }else{
1251 char *zUtf8 = fossil_mbcs_to_utf8(blob_str(&comment));
1252 blob_zero(&comment);
1253 blob_append(&comment, zUtf8, -1);
1254 fossil_mbcs_free(zUtf8);
1255 }
1256 }
1257 #endif /* _WIN32 */
1258 db_multi_exec("REPLACE INTO vvar VALUES('ci-comment',%B)", &comment);
1259 db_end_transaction(0);
1260 db_begin_transaction();
1261 }
1262
1263
+66 -5
--- src/checkin.c
+++ src/checkin.c
@@ -477,10 +477,15 @@
477477
zEditor = fossil_getenv("VISUAL");
478478
}
479479
if( zEditor==0 ){
480480
zEditor = fossil_getenv("EDITOR");
481481
}
482
+#ifdef _WIN32
483
+ if( zEditor==0 ){
484
+ zEditor = mprintf("%s\\notepad.exe", fossil_getenv("SystemRoot"));
485
+ }
486
+#endif
482487
if( zEditor==0 ){
483488
blob_append(pPrompt,
484489
"#\n"
485490
"# Since no default text editor is set using EDITOR or VISUAL\n"
486491
"# environment variables or the \"fossil set editor\" command,\n"
@@ -506,17 +511,14 @@
506511
blob_read_from_file(&reply, zFile);
507512
}else{
508513
char zIn[300];
509514
blob_zero(&reply);
510515
while( fgets(zIn, sizeof(zIn), stdin)!=0 ){
511
- char *zUtf8 = fossil_mbcs_to_utf8(zIn);
512
- if( zUtf8[0]=='.' && (zUtf8[1]==0 || zUtf8[1]=='\r' || zUtf8[1]=='\n') ){
513
- fossil_mbcs_free(zUtf8);
516
+ if( zIn[0]=='.' && (zIn[1]==0 || zIn[1]=='\r' || zIn[1]=='\n') ){
514517
break;
515518
}
516
- blob_append(&reply, zUtf8, -1);
517
- fossil_mbcs_free(zUtf8);
519
+ blob_append(&reply, zIn, -1);
518520
}
519521
}
520522
blob_remove_cr(&reply);
521523
file_delete(zFile);
522524
free(zFile);
@@ -562,11 +564,19 @@
562564
const char *zBranch,
563565
int parent_rid,
564566
const char *zUserOvrd
565567
){
566568
Blob prompt;
569
+#ifdef _WIN32
570
+ static const unsigned char bom[] = { 0xEF, 0xBB, 0xBF };
571
+ blob_init(&prompt, (const char *) bom, 3);
572
+ if( zInit && zInit[0]) {
573
+ blob_append(&prompt, zInit, -1);
574
+ }
575
+#else
567576
blob_init(&prompt, zInit, -1);
577
+#endif
568578
blob_append(&prompt,
569579
"\n"
570580
"# Enter comments on this check-in. Lines beginning with # are ignored.\n"
571581
"# The check-in comment follows wiki formatting rules.\n"
572582
"#\n", -1
@@ -1192,10 +1202,61 @@
11921202
prompt_user("empty check-in comment. continue (y/N)? ", &ans);
11931203
if( blob_str(&ans)[0]!='y' ){
11941204
fossil_exit(1);
11951205
}
11961206
}else{
1207
+#ifdef _WIN32
1208
+ /* On windows, the check-in comment might come back from the editor
1209
+ ** in various encodings. Try to figure out the encoding and do the
1210
+ ** right thing. */
1211
+ if( zComment==0 ){
1212
+ static const unsigned char bom[] = { 0xEF, 0xBB, 0xBF };
1213
+ static const unsigned short ubom = 0xfeff;
1214
+ static const unsigned short urbom = 0xfffe;
1215
+ if( blob_size(&comment)>2 && memcmp(blob_buffer(&comment), bom, 3)==0 ) {
1216
+ struct Blob temp;
1217
+ char *zUtf8 = blob_str(&comment) + 3;
1218
+ blob_zero(&temp);
1219
+ blob_append(&temp, zUtf8, -1);
1220
+ fossil_mbcs_free(zUtf8);
1221
+ blob_swap(&temp, &comment);
1222
+ blob_reset(&temp);
1223
+ }else if( blob_size(&comment)>1 && (blob_size(&comment)&1)==0
1224
+ && memcmp(blob_buffer(&comment), &ubom, 2)==0 ) {
1225
+ char *zUtf8;
1226
+ /* Make sure the blob contains two terminating 0-bytes */
1227
+ blob_append(&comment, "", 1);
1228
+ zUtf8 = blob_str(&comment) + 2;
1229
+ zUtf8 = fossil_unicode_to_utf8(zUtf8);
1230
+ blob_zero(&comment);
1231
+ blob_append(&comment, zUtf8, -1);
1232
+ fossil_mbcs_free(zUtf8);
1233
+ }else if( blob_size(&comment)>1 && (blob_size(&comment)&1)==0
1234
+ && memcmp(blob_buffer(&comment), &urbom, 2)==0 ) {
1235
+ char *zUtf8 = blob_buffer(&comment);
1236
+ unsigned int i = blob_size(&comment);
1237
+ while( i > 0 ){
1238
+ /* swap bytes of unicode representation */
1239
+ char temp = zUtf8[--i];
1240
+ zUtf8[i] = zUtf8[i-1];
1241
+ zUtf8[--i] = temp;
1242
+ }
1243
+ /* Make sure the blob contains two terminating 0-bytes */
1244
+ blob_append(&comment, "", 1);
1245
+ zUtf8 = blob_str(&comment) + 2;
1246
+ zUtf8 = fossil_unicode_to_utf8(zUtf8);
1247
+ blob_zero(&comment);
1248
+ blob_append(&comment, zUtf8, -1);
1249
+ fossil_mbcs_free(zUtf8);
1250
+ }else{
1251
+ char *zUtf8 = fossil_mbcs_to_utf8(blob_str(&comment));
1252
+ blob_zero(&comment);
1253
+ blob_append(&comment, zUtf8, -1);
1254
+ fossil_mbcs_free(zUtf8);
1255
+ }
1256
+ }
1257
+#endif /* _WIN32 */
11971258
db_multi_exec("REPLACE INTO vvar VALUES('ci-comment',%B)", &comment);
11981259
db_end_transaction(0);
11991260
db_begin_transaction();
12001261
}
12011262
12021263
--- src/checkin.c
+++ src/checkin.c
@@ -477,10 +477,15 @@
477 zEditor = fossil_getenv("VISUAL");
478 }
479 if( zEditor==0 ){
480 zEditor = fossil_getenv("EDITOR");
481 }
 
 
 
 
 
482 if( zEditor==0 ){
483 blob_append(pPrompt,
484 "#\n"
485 "# Since no default text editor is set using EDITOR or VISUAL\n"
486 "# environment variables or the \"fossil set editor\" command,\n"
@@ -506,17 +511,14 @@
506 blob_read_from_file(&reply, zFile);
507 }else{
508 char zIn[300];
509 blob_zero(&reply);
510 while( fgets(zIn, sizeof(zIn), stdin)!=0 ){
511 char *zUtf8 = fossil_mbcs_to_utf8(zIn);
512 if( zUtf8[0]=='.' && (zUtf8[1]==0 || zUtf8[1]=='\r' || zUtf8[1]=='\n') ){
513 fossil_mbcs_free(zUtf8);
514 break;
515 }
516 blob_append(&reply, zUtf8, -1);
517 fossil_mbcs_free(zUtf8);
518 }
519 }
520 blob_remove_cr(&reply);
521 file_delete(zFile);
522 free(zFile);
@@ -562,11 +564,19 @@
562 const char *zBranch,
563 int parent_rid,
564 const char *zUserOvrd
565 ){
566 Blob prompt;
 
 
 
 
 
 
 
567 blob_init(&prompt, zInit, -1);
 
568 blob_append(&prompt,
569 "\n"
570 "# Enter comments on this check-in. Lines beginning with # are ignored.\n"
571 "# The check-in comment follows wiki formatting rules.\n"
572 "#\n", -1
@@ -1192,10 +1202,61 @@
1192 prompt_user("empty check-in comment. continue (y/N)? ", &ans);
1193 if( blob_str(&ans)[0]!='y' ){
1194 fossil_exit(1);
1195 }
1196 }else{
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1197 db_multi_exec("REPLACE INTO vvar VALUES('ci-comment',%B)", &comment);
1198 db_end_transaction(0);
1199 db_begin_transaction();
1200 }
1201
1202
--- src/checkin.c
+++ src/checkin.c
@@ -477,10 +477,15 @@
477 zEditor = fossil_getenv("VISUAL");
478 }
479 if( zEditor==0 ){
480 zEditor = fossil_getenv("EDITOR");
481 }
482 #ifdef _WIN32
483 if( zEditor==0 ){
484 zEditor = mprintf("%s\\notepad.exe", fossil_getenv("SystemRoot"));
485 }
486 #endif
487 if( zEditor==0 ){
488 blob_append(pPrompt,
489 "#\n"
490 "# Since no default text editor is set using EDITOR or VISUAL\n"
491 "# environment variables or the \"fossil set editor\" command,\n"
@@ -506,17 +511,14 @@
511 blob_read_from_file(&reply, zFile);
512 }else{
513 char zIn[300];
514 blob_zero(&reply);
515 while( fgets(zIn, sizeof(zIn), stdin)!=0 ){
516 if( zIn[0]=='.' && (zIn[1]==0 || zIn[1]=='\r' || zIn[1]=='\n') ){
 
 
517 break;
518 }
519 blob_append(&reply, zIn, -1);
 
520 }
521 }
522 blob_remove_cr(&reply);
523 file_delete(zFile);
524 free(zFile);
@@ -562,11 +564,19 @@
564 const char *zBranch,
565 int parent_rid,
566 const char *zUserOvrd
567 ){
568 Blob prompt;
569 #ifdef _WIN32
570 static const unsigned char bom[] = { 0xEF, 0xBB, 0xBF };
571 blob_init(&prompt, (const char *) bom, 3);
572 if( zInit && zInit[0]) {
573 blob_append(&prompt, zInit, -1);
574 }
575 #else
576 blob_init(&prompt, zInit, -1);
577 #endif
578 blob_append(&prompt,
579 "\n"
580 "# Enter comments on this check-in. Lines beginning with # are ignored.\n"
581 "# The check-in comment follows wiki formatting rules.\n"
582 "#\n", -1
@@ -1192,10 +1202,61 @@
1202 prompt_user("empty check-in comment. continue (y/N)? ", &ans);
1203 if( blob_str(&ans)[0]!='y' ){
1204 fossil_exit(1);
1205 }
1206 }else{
1207 #ifdef _WIN32
1208 /* On windows, the check-in comment might come back from the editor
1209 ** in various encodings. Try to figure out the encoding and do the
1210 ** right thing. */
1211 if( zComment==0 ){
1212 static const unsigned char bom[] = { 0xEF, 0xBB, 0xBF };
1213 static const unsigned short ubom = 0xfeff;
1214 static const unsigned short urbom = 0xfffe;
1215 if( blob_size(&comment)>2 && memcmp(blob_buffer(&comment), bom, 3)==0 ) {
1216 struct Blob temp;
1217 char *zUtf8 = blob_str(&comment) + 3;
1218 blob_zero(&temp);
1219 blob_append(&temp, zUtf8, -1);
1220 fossil_mbcs_free(zUtf8);
1221 blob_swap(&temp, &comment);
1222 blob_reset(&temp);
1223 }else if( blob_size(&comment)>1 && (blob_size(&comment)&1)==0
1224 && memcmp(blob_buffer(&comment), &ubom, 2)==0 ) {
1225 char *zUtf8;
1226 /* Make sure the blob contains two terminating 0-bytes */
1227 blob_append(&comment, "", 1);
1228 zUtf8 = blob_str(&comment) + 2;
1229 zUtf8 = fossil_unicode_to_utf8(zUtf8);
1230 blob_zero(&comment);
1231 blob_append(&comment, zUtf8, -1);
1232 fossil_mbcs_free(zUtf8);
1233 }else if( blob_size(&comment)>1 && (blob_size(&comment)&1)==0
1234 && memcmp(blob_buffer(&comment), &urbom, 2)==0 ) {
1235 char *zUtf8 = blob_buffer(&comment);
1236 unsigned int i = blob_size(&comment);
1237 while( i > 0 ){
1238 /* swap bytes of unicode representation */
1239 char temp = zUtf8[--i];
1240 zUtf8[i] = zUtf8[i-1];
1241 zUtf8[--i] = temp;
1242 }
1243 /* Make sure the blob contains two terminating 0-bytes */
1244 blob_append(&comment, "", 1);
1245 zUtf8 = blob_str(&comment) + 2;
1246 zUtf8 = fossil_unicode_to_utf8(zUtf8);
1247 blob_zero(&comment);
1248 blob_append(&comment, zUtf8, -1);
1249 fossil_mbcs_free(zUtf8);
1250 }else{
1251 char *zUtf8 = fossil_mbcs_to_utf8(blob_str(&comment));
1252 blob_zero(&comment);
1253 blob_append(&comment, zUtf8, -1);
1254 fossil_mbcs_free(zUtf8);
1255 }
1256 }
1257 #endif /* _WIN32 */
1258 db_multi_exec("REPLACE INTO vvar VALUES('ci-comment',%B)", &comment);
1259 db_end_transaction(0);
1260 db_begin_transaction();
1261 }
1262
1263

Keyboard Shortcuts

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