Fossil SCM
/mimetype_list: tiny efficiency tweak in the main mimetype loop and only show the 'exclamation point means it's overridden' message if the repo contains at least one custom entry.
Commit
baf119337bdc675bab87a0e58d0c473ab44ab423b0796b53a0b375453a407fea
Parent
9ceec69e9b104f4…
1 file changed
+12
-6
+12
-6
| --- src/doc.c | ||
| +++ src/doc.c | ||
| @@ -476,12 +476,13 @@ | ||
| 476 | 476 | ** Show the built-in table used to guess embedded document mimetypes |
| 477 | 477 | ** from file suffixes. |
| 478 | 478 | */ |
| 479 | 479 | void mimetype_list_page(void){ |
| 480 | 480 | int i; |
| 481 | - char *zCustomList = 0; | |
| 482 | - int nCustomEntries = 0; | |
| 481 | + char *zCustomList = 0; /* value of the mimetypes setting */ | |
| 482 | + int nCustomEntries = 0; /* number of entries in the mimetypes | |
| 483 | + setting */ | |
| 483 | 484 | mimetype_verify(); |
| 484 | 485 | style_header("Mimetype List"); |
| 485 | 486 | @ <p>The Fossil <a href="%R/help?cmd=/doc">/doc</a> page uses filename |
| 486 | 487 | @ suffixes and the following tables to guess at the appropriate mimetype |
| 487 | 488 | @ for each document.</p> |
| @@ -512,21 +513,26 @@ | ||
| 512 | 513 | if( nCustomEntries==0 ){ |
| 513 | 514 | @ <tr><td colspan="2"><em>none</em></tr> |
| 514 | 515 | } |
| 515 | 516 | @ </tbody></table> |
| 516 | 517 | @ <h1>Default built-in mimetypes</h1> |
| 517 | - @ <p>Entries starting with an exclamation mark <em><strong>!</strong></em> | |
| 518 | - @ are overwritten by repository-specific settings.</p> | |
| 518 | + if(nCustomEntries>0){ | |
| 519 | + @ <p>Entries starting with an exclamation mark <em><strong>!</strong></em> | |
| 520 | + @ are overwritten by repository-specific settings.</p> | |
| 521 | + } | |
| 519 | 522 | @ <table class='sortable mimetypetable' border=1 cellpadding=0 \ |
| 520 | 523 | @ data-column-types='tt' data-init-sort='1'> |
| 521 | 524 | @ <thead> |
| 522 | 525 | @ <tr><th>Suffix<th>Mimetype |
| 523 | 526 | @ </thead> |
| 524 | 527 | @ <tbody> |
| 525 | 528 | for(i=0; i<count(aMime); i++){ |
| 526 | - const char *zFlag = mimetype_from_name_custom(aMime[i].zSuffix)==0 | |
| 527 | - ? "" : "<em><strong>!</strong></em> "; | |
| 529 | + const char *zFlag = ""; | |
| 530 | + if(nCustomEntries>0 && | |
| 531 | + mimetype_from_name_custom(aMime[i].zSuffix)!=0){ | |
| 532 | + zFlag = "<em><strong>!</strong></em> "; | |
| 533 | + } | |
| 528 | 534 | @ <tr><td>%s(zFlag)%h(aMime[i].zSuffix)<td>%h(aMime[i].zMimetype)</tr> |
| 529 | 535 | } |
| 530 | 536 | @ </tbody></table> |
| 531 | 537 | style_table_sorter(); |
| 532 | 538 | style_footer(); |
| 533 | 539 |
| --- src/doc.c | |
| +++ src/doc.c | |
| @@ -476,12 +476,13 @@ | |
| 476 | ** Show the built-in table used to guess embedded document mimetypes |
| 477 | ** from file suffixes. |
| 478 | */ |
| 479 | void mimetype_list_page(void){ |
| 480 | int i; |
| 481 | char *zCustomList = 0; |
| 482 | int nCustomEntries = 0; |
| 483 | mimetype_verify(); |
| 484 | style_header("Mimetype List"); |
| 485 | @ <p>The Fossil <a href="%R/help?cmd=/doc">/doc</a> page uses filename |
| 486 | @ suffixes and the following tables to guess at the appropriate mimetype |
| 487 | @ for each document.</p> |
| @@ -512,21 +513,26 @@ | |
| 512 | if( nCustomEntries==0 ){ |
| 513 | @ <tr><td colspan="2"><em>none</em></tr> |
| 514 | } |
| 515 | @ </tbody></table> |
| 516 | @ <h1>Default built-in mimetypes</h1> |
| 517 | @ <p>Entries starting with an exclamation mark <em><strong>!</strong></em> |
| 518 | @ are overwritten by repository-specific settings.</p> |
| 519 | @ <table class='sortable mimetypetable' border=1 cellpadding=0 \ |
| 520 | @ data-column-types='tt' data-init-sort='1'> |
| 521 | @ <thead> |
| 522 | @ <tr><th>Suffix<th>Mimetype |
| 523 | @ </thead> |
| 524 | @ <tbody> |
| 525 | for(i=0; i<count(aMime); i++){ |
| 526 | const char *zFlag = mimetype_from_name_custom(aMime[i].zSuffix)==0 |
| 527 | ? "" : "<em><strong>!</strong></em> "; |
| 528 | @ <tr><td>%s(zFlag)%h(aMime[i].zSuffix)<td>%h(aMime[i].zMimetype)</tr> |
| 529 | } |
| 530 | @ </tbody></table> |
| 531 | style_table_sorter(); |
| 532 | style_footer(); |
| 533 |
| --- src/doc.c | |
| +++ src/doc.c | |
| @@ -476,12 +476,13 @@ | |
| 476 | ** Show the built-in table used to guess embedded document mimetypes |
| 477 | ** from file suffixes. |
| 478 | */ |
| 479 | void mimetype_list_page(void){ |
| 480 | int i; |
| 481 | char *zCustomList = 0; /* value of the mimetypes setting */ |
| 482 | int nCustomEntries = 0; /* number of entries in the mimetypes |
| 483 | setting */ |
| 484 | mimetype_verify(); |
| 485 | style_header("Mimetype List"); |
| 486 | @ <p>The Fossil <a href="%R/help?cmd=/doc">/doc</a> page uses filename |
| 487 | @ suffixes and the following tables to guess at the appropriate mimetype |
| 488 | @ for each document.</p> |
| @@ -512,21 +513,26 @@ | |
| 513 | if( nCustomEntries==0 ){ |
| 514 | @ <tr><td colspan="2"><em>none</em></tr> |
| 515 | } |
| 516 | @ </tbody></table> |
| 517 | @ <h1>Default built-in mimetypes</h1> |
| 518 | if(nCustomEntries>0){ |
| 519 | @ <p>Entries starting with an exclamation mark <em><strong>!</strong></em> |
| 520 | @ are overwritten by repository-specific settings.</p> |
| 521 | } |
| 522 | @ <table class='sortable mimetypetable' border=1 cellpadding=0 \ |
| 523 | @ data-column-types='tt' data-init-sort='1'> |
| 524 | @ <thead> |
| 525 | @ <tr><th>Suffix<th>Mimetype |
| 526 | @ </thead> |
| 527 | @ <tbody> |
| 528 | for(i=0; i<count(aMime); i++){ |
| 529 | const char *zFlag = ""; |
| 530 | if(nCustomEntries>0 && |
| 531 | mimetype_from_name_custom(aMime[i].zSuffix)!=0){ |
| 532 | zFlag = "<em><strong>!</strong></em> "; |
| 533 | } |
| 534 | @ <tr><td>%s(zFlag)%h(aMime[i].zSuffix)<td>%h(aMime[i].zMimetype)</tr> |
| 535 | } |
| 536 | @ </tbody></table> |
| 537 | style_table_sorter(); |
| 538 | style_footer(); |
| 539 |