Fossil SCM

Now it works ۠

jan.nijtmans 2012-09-26 07:35 use-utf8-in-win-external-editor
Commit 433cb71479912889fcd280c49742679c16e67707
1 file changed +9 -10
+9 -10
--- src/checkin.c
+++ src/checkin.c
@@ -442,17 +442,25 @@
442442
char *zInit,
443443
const char *zBranch,
444444
int parent_rid,
445445
const char *zUserOvrd
446446
){
447
+ static const unsigned char bom[] = { 0xEF, 0xBB, 0xBF };
447448
const char *zEditor;
448449
char *zCmd;
449450
char *zFile;
450451
Blob text, line;
451452
char *zComment;
452453
int i;
454
+#ifdef _WIN32
455
+ blob_init(&text, (const char *) bom, 3);
456
+ if( zInit && zInit[0]) {
457
+ blob_append(&text, zInit, -1);
458
+ }
459
+#else
453460
blob_init(&text, zInit, -1);
461
+#endif
454462
blob_append(&text,
455463
"\n"
456464
"# Enter comments on this check-in. Lines beginning with # are ignored.\n"
457465
"# The check-in comment follows wiki formatting rules.\n"
458466
"#\n", -1
@@ -494,20 +502,11 @@
494502
g.zLocalRoot);
495503
}
496504
#if defined(_WIN32)
497505
blob_add_cr(&text);
498506
#endif
499
- if( zEditor || fossil_utf8_to_console(blob_buffer(&text), blob_size(&text), 0) < 0) {
500
- /* We have an external editor or else we cannot write directly to the
501
- * (windows) console, so write it out in mbcs encoding. */
502
- struct Blob temp;
503
- zComment = fossil_utf8_to_mbcs(blob_str(&text));
504
- blob_set(&temp, zComment);
505
- blob_write_to_file(&temp, zFile);
506
- blob_zero(&temp);
507
- fossil_mbcs_free(zComment);
508
- }
507
+ blob_write_to_file(&text, zFile);
509508
if( zEditor ){
510509
zCmd = mprintf("%s \"%s\"", zEditor, zFile);
511510
fossil_print("%s\n", zCmd);
512511
if( fossil_system(zCmd) ){
513512
fossil_panic("editor aborted");
514513
--- src/checkin.c
+++ src/checkin.c
@@ -442,17 +442,25 @@
442 char *zInit,
443 const char *zBranch,
444 int parent_rid,
445 const char *zUserOvrd
446 ){
 
447 const char *zEditor;
448 char *zCmd;
449 char *zFile;
450 Blob text, line;
451 char *zComment;
452 int i;
 
 
 
 
 
 
453 blob_init(&text, zInit, -1);
 
454 blob_append(&text,
455 "\n"
456 "# Enter comments on this check-in. Lines beginning with # are ignored.\n"
457 "# The check-in comment follows wiki formatting rules.\n"
458 "#\n", -1
@@ -494,20 +502,11 @@
494 g.zLocalRoot);
495 }
496 #if defined(_WIN32)
497 blob_add_cr(&text);
498 #endif
499 if( zEditor || fossil_utf8_to_console(blob_buffer(&text), blob_size(&text), 0) < 0) {
500 /* We have an external editor or else we cannot write directly to the
501 * (windows) console, so write it out in mbcs encoding. */
502 struct Blob temp;
503 zComment = fossil_utf8_to_mbcs(blob_str(&text));
504 blob_set(&temp, zComment);
505 blob_write_to_file(&temp, zFile);
506 blob_zero(&temp);
507 fossil_mbcs_free(zComment);
508 }
509 if( zEditor ){
510 zCmd = mprintf("%s \"%s\"", zEditor, zFile);
511 fossil_print("%s\n", zCmd);
512 if( fossil_system(zCmd) ){
513 fossil_panic("editor aborted");
514
--- src/checkin.c
+++ src/checkin.c
@@ -442,17 +442,25 @@
442 char *zInit,
443 const char *zBranch,
444 int parent_rid,
445 const char *zUserOvrd
446 ){
447 static const unsigned char bom[] = { 0xEF, 0xBB, 0xBF };
448 const char *zEditor;
449 char *zCmd;
450 char *zFile;
451 Blob text, line;
452 char *zComment;
453 int i;
454 #ifdef _WIN32
455 blob_init(&text, (const char *) bom, 3);
456 if( zInit && zInit[0]) {
457 blob_append(&text, zInit, -1);
458 }
459 #else
460 blob_init(&text, zInit, -1);
461 #endif
462 blob_append(&text,
463 "\n"
464 "# Enter comments on this check-in. Lines beginning with # are ignored.\n"
465 "# The check-in comment follows wiki formatting rules.\n"
466 "#\n", -1
@@ -494,20 +502,11 @@
502 g.zLocalRoot);
503 }
504 #if defined(_WIN32)
505 blob_add_cr(&text);
506 #endif
507 blob_write_to_file(&text, zFile);
 
 
 
 
 
 
 
 
 
508 if( zEditor ){
509 zCmd = mprintf("%s \"%s\"", zEditor, zFile);
510 fossil_print("%s\n", zCmd);
511 if( fossil_system(zCmd) ){
512 fossil_panic("editor aborted");
513

Keyboard Shortcuts

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