Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Merge byte-order-mark handling enhancements to trunk. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
9b800ee41c32c4e1941a3bc19798c7b9 |
| User & Date: | mistachkin 2012-11-26 22:51:27.306 |
Context
|
2012-11-27
| ||
| 00:23 | Assume that the NetSurf browser is operated by a human. ... (check-in: 77cd6e0dfb user: drh tags: trunk) | |
|
2012-11-26
| ||
| 23:54 | Changes to support easier debugging on Windows. ... (Closed-Leaf check-in: 642e543c28 user: mistachkin tags: winDebug) | |
| 22:51 | Merge byte-order-mark handling enhancements to trunk. ... (check-in: 9b800ee41c user: mistachkin tags: trunk) | |
| 20:47 | Modify commit error message about unresolved merge conflicts to include the option used to disable the check. ... (check-in: 2ff70a3130 user: mistachkin tags: trunk) | |
|
2012-11-19
| ||
| 20:39 | Allow the get_utf8_bom function to return the size as well. ... (check-in: d857d20bef user: mistachkin tags: convert_before_commit_v2) | |
Changes
Changes to src/attach.c.
| ︙ | ︙ | |||
518 519 520 521 522 523 524 |
@ <div class="section">Content Appended</div>
@ <blockquote>
blob_zero(&attach);
if( zMime==0 || strncmp(zMime,"text/", 5)==0 ){
const char *z;
const char *zLn = P("ln");
content_get(ridSrc, &attach);
| | | 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 |
@ <div class="section">Content Appended</div>
@ <blockquote>
blob_zero(&attach);
if( zMime==0 || strncmp(zMime,"text/", 5)==0 ){
const char *z;
const char *zLn = P("ln");
content_get(ridSrc, &attach);
blob_to_utf8_no_bom(&attach, 0);
z = blob_str(&attach);
if( zLn ){
output_text_with_line_numbers(z, zLn);
}else{
@ <pre>
@ %h(z)
@ </pre>
|
| ︙ | ︙ |
Changes to src/blob.c.
| ︙ | ︙ | |||
1086 1087 1088 1089 1090 1091 1092 |
void blob_swap( Blob *pLeft, Blob *pRight ){
Blob swap = *pLeft;
*pLeft = *pRight;
*pRight = swap;
}
/*
| | | < | | | < < < < < | > | | < > > > > > > > > > < < < < < < < < < < < | | | | | | | | 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 |
void blob_swap( Blob *pLeft, Blob *pRight ){
Blob swap = *pLeft;
*pLeft = *pRight;
*pRight = swap;
}
/*
** Strip a possible byte-order-mark (BOM) from the blob. On Windows, if there
** is either no BOM at all or an (le/be) UTF-16 BOM, a conversion to UTF-8 is
** done. If useMbcs is false and there is no BOM, the input string is assumed
** to be UTF-8 already, so no conversion is done.
*/
void blob_to_utf8_no_bom(Blob *pBlob, int useMbcs){
char *zUtf8;
int bomSize = 0;
if( starts_with_utf8_bom(pBlob, &bomSize) ){
struct Blob temp;
zUtf8 = blob_str(pBlob) + bomSize;
blob_zero(&temp);
blob_append(&temp, zUtf8, -1);
blob_swap(pBlob, &temp);
blob_reset(&temp);
#ifdef _WIN32
}else if( starts_with_utf16be_bom(pBlob, &bomSize) ){
/* Make sure the blob contains two terminating 0-bytes */
blob_append(pBlob, "", 1);
zUtf8 = blob_str(pBlob) + bomSize;
zUtf8 = fossil_unicode_to_utf8(zUtf8);
blob_zero(pBlob);
blob_append(pBlob, zUtf8, -1);
fossil_mbcs_free(zUtf8);
}else if( starts_with_utf16le_bom(pBlob, &bomSize) ){
unsigned int i = blob_size(pBlob);
zUtf8 = blob_buffer(pBlob);
while( i > 0 ){
/* swap bytes of unicode representation */
char zTemp = zUtf8[--i];
zUtf8[i] = zUtf8[i-1];
zUtf8[--i] = zTemp;
}
/* Make sure the blob contains two terminating 0-bytes */
blob_append(pBlob, "", 1);
zUtf8 = blob_str(pBlob) + bomSize;
zUtf8 = fossil_unicode_to_utf8(zUtf8);
blob_zero(pBlob);
blob_append(pBlob, zUtf8, -1);
fossil_mbcs_free(zUtf8);
}else if( useMbcs ){
zUtf8 = fossil_mbcs_to_utf8(blob_str(pBlob));
blob_reset(pBlob);
blob_append(pBlob, zUtf8, -1);
fossil_mbcs_free(zUtf8);
#endif /* _WIN32 */
}
}
|
Changes to src/checkin.c.
| ︙ | ︙ | |||
519 520 521 522 523 524 525 |
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);
}
}
| | | 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 |
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_to_utf8_no_bom(&reply, 1);
blob_remove_cr(&reply);
file_delete(zFile);
free(zFile);
blob_zero(pComment);
while( blob_line(&reply, &line) ){
int i, n;
char *z;
|
| ︙ | ︙ | |||
568 569 570 571 572 573 574 |
char *zInit,
const char *zBranch,
int parent_rid,
const char *zUserOvrd
){
Blob prompt;
#ifdef _WIN32
| > | | | 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 |
char *zInit,
const char *zBranch,
int parent_rid,
const char *zUserOvrd
){
Blob prompt;
#ifdef _WIN32
int bomSize;
const unsigned char *bom = get_utf8_bom(&bomSize);
blob_init(&prompt, (const char *) bom, bomSize);
if( zInit && zInit[0]) {
blob_append(&prompt, zInit, -1);
}
#else
blob_init(&prompt, zInit, -1);
#endif
blob_append(&prompt,
|
| ︙ | ︙ | |||
898 899 900 901 902 903 904 | int eType; /* return value of looks_like_utf8/utf16() */ int fUnicode; /* return value of starts_with_utf16_bom() */ char *zMsg; /* Warning message */ Blob fname; /* Relative pathname of the file */ static int allOk = 0; /* Set to true to disable this routine */ if( allOk ) return; | | | 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 |
int eType; /* return value of looks_like_utf8/utf16() */
int fUnicode; /* return value of starts_with_utf16_bom() */
char *zMsg; /* Warning message */
Blob fname; /* Relative pathname of the file */
static int allOk = 0; /* Set to true to disable this routine */
if( allOk ) return;
fUnicode = starts_with_utf16_bom(p, 0);
eType = fUnicode ? looks_like_utf16(p) : looks_like_utf8(p);
if( eType==0 || eType==-1 || fUnicode ){
const char *zWarning;
Blob ans;
char cReply;
if( eType==-1 && fUnicode ){
|
| ︙ | ︙ | |||
1249 1250 1251 1252 1253 1254 1255 |
if( useCksum ) vfile_aggregate_checksum_disk(vid, &cksum1);
if( zComment ){
blob_zero(&comment);
blob_append(&comment, zComment, -1);
}else if( zComFile ){
blob_zero(&comment);
blob_read_from_file(&comment, zComFile);
| | | 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 |
if( useCksum ) vfile_aggregate_checksum_disk(vid, &cksum1);
if( zComment ){
blob_zero(&comment);
blob_append(&comment, zComment, -1);
}else if( zComFile ){
blob_zero(&comment);
blob_read_from_file(&comment, zComFile);
blob_to_utf8_no_bom(&comment, 1);
}else{
char *zInit = db_text(0, "SELECT value FROM vvar WHERE name='ci-comment'");
prepare_commit_comment(&comment, zInit, zBranch, vid, zUserOvrd);
if( zInit && zInit[0] && fossil_strcmp(zInit, blob_str(&comment))==0 ){
blob_zero(&ans);
prompt_user("unchanged check-in comment. continue (y/N)? ", &ans);
cReply = blob_str(&ans)[0];
|
| ︙ | ︙ |
Changes to src/diff.c.
| ︙ | ︙ | |||
319 320 321 322 323 324 325 326 327 328 329 330 |
}
}
if( j>UTF16_LENGTH_MASK ){
return 0; /* Very long line -> binary */
}
return result; /* No problems seen -> not binary */
}
/*
** This function returns non-zero if the blob starts with a UTF-16le or
** UTF-16be byte-order-mark (BOM).
*/
| > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 |
}
}
if( j>UTF16_LENGTH_MASK ){
return 0; /* Very long line -> binary */
}
return result; /* No problems seen -> not binary */
}
/*
** This function returns an array of bytes representing the byte-order-mark
** for UTF-8.
*/
const unsigned char *get_utf8_bom(int *pnByte){
static const unsigned char bom[] = {
0xEF, 0xBB, 0xBF, 0x00, 0x00, 0x00
};
if( pnByte ) *pnByte = 3;
return bom;
}
/*
** This function returns non-zero if the blob starts with a UTF-8
** byte-order-mark (BOM).
*/
int starts_with_utf8_bom(const Blob *pContent, int *pnByte){
const char *z = blob_buffer(pContent);
int bomSize = 0;
const unsigned char *bom = get_utf8_bom(&bomSize);
if( pnByte ) *pnByte = bomSize;
if( blob_size(pContent)<bomSize ) return 0;
return memcmp(z, bom, bomSize)==0;
}
/*
** This function returns non-zero if the blob starts with a UTF-16le or
** UTF-16be byte-order-mark (BOM).
*/
int starts_with_utf16_bom(const Blob *pContent, int *pnByte){
const char *z = blob_buffer(pContent);
int c1, c2;
if( pnByte ) *pnByte = 2;
if( blob_size(pContent)<2 ) return 0;
c1 = z[0]; c2 = z[1];
if( (c1==(char)0xff) && (c2==(char)0xfe) ){
return 1;
}else if( (c1==(char)0xfe) && (c2==(char)0xff) ){
return 1;
}
return 0;
}
/*
** This function returns non-zero if the blob starts with a UTF-16le
** byte-order-mark (BOM).
*/
int starts_with_utf16le_bom(const Blob *pContent, int *pnByte){
const char *z = blob_buffer(pContent);
int c1, c2;
if( pnByte ) *pnByte = 2;
if( blob_size(pContent)<2 ) return 0;
c1 = z[0]; c2 = z[1];
if( (c1==(char)0xff) && (c2==(char)0xfe) ){
return 1;
}
return 0;
}
/*
** This function returns non-zero if the blob starts with a UTF-16be
** byte-order-mark (BOM).
*/
int starts_with_utf16be_bom(const Blob *pContent, int *pnByte){
const char *z = blob_buffer(pContent);
int c1, c2;
if( pnByte ) *pnByte = 2;
if( blob_size(pContent)<2 ) return 0;
c1 = z[0]; c2 = z[1];
if( (c1==(char)0xfe) && (c2==(char)0xff) ){
return 1;
}
return 0;
}
/*
** Return true if two DLine elements are identical.
*/
static int same_dline(DLine *pA, DLine *pB){
return pA->h==pB->h && memcmp(pA->z,pB->z,pA->h & LENGTH_MASK)==0;
}
|
| ︙ | ︙ |
Changes to src/info.c.
| ︙ | ︙ | |||
1632 1633 1634 1635 1636 1637 1638 |
}
@ <hr />
content_get(rid, &content);
if( renderAsWiki ){
wiki_convert(&content, 0, 0);
}else if( renderAsHtml ){
@ <div>
| | | | 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 |
}
@ <hr />
content_get(rid, &content);
if( renderAsWiki ){
wiki_convert(&content, 0, 0);
}else if( renderAsHtml ){
@ <div>
blob_to_utf8_no_bom(&content, 0);
cgi_append_content(blob_buffer(&content), blob_size(&content));
@ </div>
}else{
style_submenu_element("Hex","Hex", "%s/hexdump?name=%s", g.zTop, zUuid);
zMime = mimetype_from_content(&content);
@ <blockquote>
if( zMime==0 ){
const char *zLn = P("ln");
const char *z;
blob_to_utf8_no_bom(&content, 0);
z = blob_str(&content);
if( zLn ){
output_text_with_line_numbers(z, zLn);
}else{
@ <pre>
@ %h(z)
@ </pre>
|
| ︙ | ︙ |
Changes to src/main.c.
| ︙ | ︙ | |||
517 518 519 520 521 522 523 |
}else{
blob_read_from_channel(&file, zInFile, -1);
if(stdin != zInFile){
fclose(zInFile);
}
zInFile = NULL;
}
| | | 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 |
}else{
blob_read_from_channel(&file, zInFile, -1);
if(stdin != zInFile){
fclose(zInFile);
}
zInFile = NULL;
}
blob_to_utf8_no_bom(&file, 1);
z = blob_str(&file);
for(k=0, nLine=1; z[k]; k++) if( z[k]=='\n' ) nLine++;
newArgv = fossil_malloc( sizeof(char*)*(g.argc + nLine*2) );
for(j=0; j<i; j++) newArgv[j] = g.argv[j];
blob_rewind(&file);
while( (n = blob_line(&file, &line))>0 ){
|
| ︙ | ︙ |
Changes to src/stash.c.
| ︙ | ︙ | |||
157 158 159 160 161 162 163 |
zComment = find_option("comment", "m", 1);
verify_all_options();
if( zComment==0 ){
Blob prompt; /* Prompt for stash comment */
Blob comment; /* User comment reply */
#ifdef _WIN32
| > | | | 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
zComment = find_option("comment", "m", 1);
verify_all_options();
if( zComment==0 ){
Blob prompt; /* Prompt for stash comment */
Blob comment; /* User comment reply */
#ifdef _WIN32
int bomSize;
const unsigned char *bom = get_utf8_bom(&bomSize);
blob_init(&prompt, (const char *) bom, bomSize);
#else
blob_zero(&prompt);
#endif
blob_append(&prompt,
"\n"
"# Enter a description of what is being stashed. Lines beginning\n"
"# with \"#\" are ignored. Stash comments are plain text except.\n"
|
| ︙ | ︙ |
Changes to src/wikiformat.c.
| ︙ | ︙ | |||
1632 1633 1634 1635 1636 1637 1638 |
}
if( pOut ){
renderer.pOut = pOut;
}else{
renderer.pOut = cgi_output_blob();
}
| | | 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 |
}
if( pOut ){
renderer.pOut = pOut;
}else{
renderer.pOut = cgi_output_blob();
}
blob_to_utf8_no_bom(pIn, 0);
wiki_render(&renderer, blob_str(pIn));
endAutoParagraph(&renderer);
while( renderer.nStack ){
popStack(&renderer);
}
blob_append(renderer.pOut, "\n", 1);
free(renderer.aStack);
|
| ︙ | ︙ | |||
1696 1697 1698 1699 1700 1701 1702 |
** of the title and initialize pTail to be the text that follows the
** title.
*/
int wiki_find_title(Blob *pIn, Blob *pTitle, Blob *pTail){
char *z;
int i;
int iStart;
| | | 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 |
** of the title and initialize pTail to be the text that follows the
** title.
*/
int wiki_find_title(Blob *pIn, Blob *pTitle, Blob *pTail){
char *z;
int i;
int iStart;
blob_to_utf8_no_bom(pIn, 0);
z = blob_str(pIn);
for(i=0; fossil_isspace(z[i]); i++){}
if( z[i]!='<' ) return 0;
i++;
if( strncmp(&z[i],"title>", 6)!=0 ) return 0;
iStart = i+6;
for(i=iStart; z[i] && (z[i]!='<' || strncmp(&z[i],"</title>",8)!=0); i++){}
|
| ︙ | ︙ |