Fossil

Changes On Branch use-utf8-in-win-external-editor
Login

Changes On Branch use-utf8-in-win-external-editor

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Changes In Branch use-utf8-in-win-external-editor Excluding Merge-Ins

This is equivalent to a diff from 18c310af to c7703868

2012-10-22
17:29
Merge the changes to use various UTF encodings for win32 check-in comment editor into trunk. ... (check-in: cc01ec50 user: drh tags: trunk)
14:56
merge trunk ... (Closed-Leaf check-in: c7703868 user: jan.nijtmans tags: use-utf8-in-win-external-editor)
13:38
Merge in the ability to add submenu buttons on embedded documentation using hyperlinks with the "button" class. ... (check-in: 18c310af user: drh tags: trunk)
13:23
Merge the changes to show unresolved conflicts in "fossil status" and to prevent committing unresolved conflicts. ... (check-in: 7d34d174 user: drh tags: trunk)
2012-10-19
18:35
Add a mention of the ability to do dynamic loading of Tcl to the change log. ... (Closed-Leaf check-in: 5678565b user: drh tags: embedded-doc-buttons)
2012-10-16
01:22
merge trunk ... (check-in: 7f939bd8 user: jan.nijtmans tags: use-utf8-in-win-external-editor)

Changes to src/checkin.c.

475
476
477
478
479
480
481





482
483
484
485
486
487
488
  zEditor = db_get("editor", 0);
  if( zEditor==0 ){
    zEditor = fossil_getenv("VISUAL");
  }
  if( zEditor==0 ){
    zEditor = fossil_getenv("EDITOR");
  }





  if( zEditor==0 ){
    blob_append(pPrompt,
       "#\n"
       "# Since no default text editor is set using EDITOR or VISUAL\n"
       "# environment variables or the \"fossil set editor\" command,\n"
       "# and because no comment was specified using the \"-m\" or \"-M\"\n"
       "# command-line options, you will need to enter the comment below.\n"







>
>
>
>
>







475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
  zEditor = db_get("editor", 0);
  if( zEditor==0 ){
    zEditor = fossil_getenv("VISUAL");
  }
  if( zEditor==0 ){
    zEditor = fossil_getenv("EDITOR");
  }
#ifdef _WIN32
  if( zEditor==0 ){
    zEditor = mprintf("%s\\notepad.exe", fossil_getenv("SystemRoot"));
  }
#endif
  if( zEditor==0 ){
    blob_append(pPrompt,
       "#\n"
       "# Since no default text editor is set using EDITOR or VISUAL\n"
       "# environment variables or the \"fossil set editor\" command,\n"
       "# and because no comment was specified using the \"-m\" or \"-M\"\n"
       "# command-line options, you will need to enter the comment below.\n"
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
    }

    blob_read_from_file(&reply, zFile);
  }else{
    char zIn[300];
    blob_zero(&reply);
    while( fgets(zIn, sizeof(zIn), stdin)!=0 ){
      char *zUtf8 = fossil_mbcs_to_utf8(zIn);
      if( zUtf8[0]=='.' && (zUtf8[1]==0 || zUtf8[1]=='\r' || zUtf8[1]=='\n') ){
        fossil_mbcs_free(zUtf8);
        break;
      }
      blob_append(&reply, zUtf8, -1);
      fossil_mbcs_free(zUtf8);
    }
  }
  blob_remove_cr(&reply);
  file_delete(zFile);
  free(zFile);
  blob_zero(pComment);
  while( blob_line(&reply, &line) ){







<
|
<


|
<







509
510
511
512
513
514
515

516

517
518
519

520
521
522
523
524
525
526
    }

    blob_read_from_file(&reply, zFile);
  }else{
    char zIn[300];
    blob_zero(&reply);
    while( fgets(zIn, sizeof(zIn), stdin)!=0 ){

      if( zIn[0]=='.' && (zIn[1]==0 || zIn[1]=='\r' || zIn[1]=='\n') ){

        break;
      }
      blob_append(&reply, zIn, -1);

    }
  }
  blob_remove_cr(&reply);
  file_delete(zFile);
  free(zFile);
  blob_zero(pComment);
  while( blob_line(&reply, &line) ){
560
561
562
563
564
565
566







567

568
569
570
571
572
573
574
  Blob *pComment,
  char *zInit,
  const char *zBranch,
  int parent_rid,
  const char *zUserOvrd
){
  Blob prompt;







  blob_init(&prompt, zInit, -1);

  blob_append(&prompt,
    "\n"
    "# Enter comments on this check-in.  Lines beginning with # are ignored.\n"
    "# The check-in comment follows wiki formatting rules.\n"
    "#\n", -1
  );
  blob_appendf(&prompt, "# user: %s\n", zUserOvrd ? zUserOvrd : g.zLogin);







>
>
>
>
>
>
>

>







562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
  Blob *pComment,
  char *zInit,
  const char *zBranch,
  int parent_rid,
  const char *zUserOvrd
){
  Blob prompt;
#ifdef _WIN32
  static const unsigned char bom[] = { 0xEF, 0xBB, 0xBF };
  blob_init(&prompt, (const char *) bom, 3);
  if( zInit && zInit[0]) {
    blob_append(&prompt, zInit, -1);
  }
#else
  blob_init(&prompt, zInit, -1);
#endif
  blob_append(&prompt,
    "\n"
    "# Enter comments on this check-in.  Lines beginning with # are ignored.\n"
    "# The check-in comment follows wiki formatting rules.\n"
    "#\n", -1
  );
  blob_appendf(&prompt, "# user: %s\n", zUserOvrd ? zUserOvrd : g.zLogin);
1190
1191
1192
1193
1194
1195
1196



















































1197
1198
1199
1200
1201
1202
1203
    Blob ans;
    blob_zero(&ans);
    prompt_user("empty check-in comment.  continue (y/N)? ", &ans);
    if( blob_str(&ans)[0]!='y' ){
      fossil_exit(1);
    }
  }else{



















































    db_multi_exec("REPLACE INTO vvar VALUES('ci-comment',%B)", &comment);
    db_end_transaction(0);
    db_begin_transaction();
  }

  /* Step 1: Insert records for all modified files into the blob 
  ** table. If there were arguments passed to this command, only







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
    Blob ans;
    blob_zero(&ans);
    prompt_user("empty check-in comment.  continue (y/N)? ", &ans);
    if( blob_str(&ans)[0]!='y' ){
      fossil_exit(1);
    }
  }else{
#ifdef _WIN32
    /* On windows, the check-in comment might come back from the editor
    ** in various encodings.  Try to figure out the encoding and do the
    ** right thing. */
    if( zComment==0 ){
      static const unsigned char bom[] = { 0xEF, 0xBB, 0xBF };
      static const unsigned short ubom = 0xfeff;
      static const unsigned short urbom = 0xfffe;
      if( blob_size(&comment)>2 && memcmp(blob_buffer(&comment), bom, 3)==0 ) {
    	struct Blob temp;
        char *zUtf8 = blob_str(&comment) + 3;
        blob_zero(&temp);
        blob_append(&temp, zUtf8, -1);
        fossil_mbcs_free(zUtf8);
        blob_swap(&temp, &comment);
        blob_reset(&temp);
      }else if( blob_size(&comment)>1 && (blob_size(&comment)&1)==0
          && memcmp(blob_buffer(&comment), &ubom, 2)==0 ) {
        char *zUtf8;
        /* Make sure the blob contains two terminating 0-bytes */
        blob_append(&comment, "", 1);
        zUtf8 = blob_str(&comment) + 2;
        zUtf8 = fossil_unicode_to_utf8(zUtf8);
        blob_zero(&comment);
        blob_append(&comment, zUtf8, -1);
        fossil_mbcs_free(zUtf8);
      }else if( blob_size(&comment)>1 && (blob_size(&comment)&1)==0
          && memcmp(blob_buffer(&comment), &urbom, 2)==0 ) {
        char *zUtf8 = blob_buffer(&comment);
        unsigned int i = blob_size(&comment);
        while( i > 0 ){
            /* swap bytes of unicode representation */
            char temp = zUtf8[--i];
            zUtf8[i] = zUtf8[i-1];
            zUtf8[--i] = temp;
        }
        /* Make sure the blob contains two terminating 0-bytes */
        blob_append(&comment, "", 1);
        zUtf8 = blob_str(&comment) + 2;
        zUtf8 = fossil_unicode_to_utf8(zUtf8);
        blob_zero(&comment);
        blob_append(&comment, zUtf8, -1);
        fossil_mbcs_free(zUtf8);
      }else{
        char *zUtf8 = fossil_mbcs_to_utf8(blob_str(&comment));
        blob_zero(&comment);
        blob_append(&comment, zUtf8, -1);
        fossil_mbcs_free(zUtf8);
      }
    }
#endif /* _WIN32 */
    db_multi_exec("REPLACE INTO vvar VALUES('ci-comment',%B)", &comment);
    db_end_transaction(0);
    db_begin_transaction();
  }

  /* Step 1: Insert records for all modified files into the blob 
  ** table. If there were arguments passed to this command, only