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

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 18c310afd8 to c7703868b3

2012-10-22
17:29
Merge the changes to use various UTF encodings for win32 check-in comment editor into trunk. check-in: cc01ec5094 user: drh tags: trunk
14:56
merge trunk Closed-Leaf check-in: c7703868b3 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: 18c310afd8 user: drh tags: trunk
13:23
Merge the changes to show unresolved conflicts in "fossil status" and to prevent committing unresolved conflicts. check-in: 7d34d1748a 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: 5678565bec user: drh tags: embedded-doc-buttons
2012-10-16
01:22
merge trunk check-in: 7f939bd8d7 user: jan.nijtmans tags: use-utf8-in-win-external-editor

Changes to src/checkin.c.

   475    475     zEditor = db_get("editor", 0);
   476    476     if( zEditor==0 ){
   477    477       zEditor = fossil_getenv("VISUAL");
   478    478     }
   479    479     if( zEditor==0 ){
   480    480       zEditor = fossil_getenv("EDITOR");
   481    481     }
          482  +#ifdef _WIN32
          483  +  if( zEditor==0 ){
          484  +    zEditor = mprintf("%s\\notepad.exe", fossil_getenv("SystemRoot"));
          485  +  }
          486  +#endif
   482    487     if( zEditor==0 ){
   483    488       blob_append(pPrompt,
   484    489          "#\n"
   485    490          "# Since no default text editor is set using EDITOR or VISUAL\n"
   486    491          "# environment variables or the \"fossil set editor\" command,\n"
   487    492          "# and because no comment was specified using the \"-m\" or \"-M\"\n"
   488    493          "# command-line options, you will need to enter the comment below.\n"
................................................................................
   504    509       }
   505    510   
   506    511       blob_read_from_file(&reply, zFile);
   507    512     }else{
   508    513       char zIn[300];
   509    514       blob_zero(&reply);
   510    515       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') ){
   514    517           break;
   515    518         }
   516         -      blob_append(&reply, zUtf8, -1);
   517         -      fossil_mbcs_free(zUtf8);
          519  +      blob_append(&reply, zIn, -1);
   518    520       }
   519    521     }
   520    522     blob_remove_cr(&reply);
   521    523     file_delete(zFile);
   522    524     free(zFile);
   523    525     blob_zero(pComment);
   524    526     while( blob_line(&reply, &line) ){
................................................................................
   560    562     Blob *pComment,
   561    563     char *zInit,
   562    564     const char *zBranch,
   563    565     int parent_rid,
   564    566     const char *zUserOvrd
   565    567   ){
   566    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
   567    576     blob_init(&prompt, zInit, -1);
          577  +#endif
   568    578     blob_append(&prompt,
   569    579       "\n"
   570    580       "# Enter comments on this check-in.  Lines beginning with # are ignored.\n"
   571    581       "# The check-in comment follows wiki formatting rules.\n"
   572    582       "#\n", -1
   573    583     );
   574    584     blob_appendf(&prompt, "# user: %s\n", zUserOvrd ? zUserOvrd : g.zLogin);
................................................................................
  1190   1200       Blob ans;
  1191   1201       blob_zero(&ans);
  1192   1202       prompt_user("empty check-in comment.  continue (y/N)? ", &ans);
  1193   1203       if( blob_str(&ans)[0]!='y' ){
  1194   1204         fossil_exit(1);
  1195   1205       }
  1196   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 */
  1197   1258       db_multi_exec("REPLACE INTO vvar VALUES('ci-comment',%B)", &comment);
  1198   1259       db_end_transaction(0);
  1199   1260       db_begin_transaction();
  1200   1261     }
  1201   1262   
  1202   1263     /* Step 1: Insert records for all modified files into the blob 
  1203   1264     ** table. If there were arguments passed to this command, only