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.

stephan 2020-01-24 16:58 mimetypes-setting
Commit baf119337bdc675bab87a0e58d0c473ab44ab423b0796b53a0b375453a407fea
1 file changed +12 -6
+12 -6
--- src/doc.c
+++ src/doc.c
@@ -476,12 +476,13 @@
476476
** Show the built-in table used to guess embedded document mimetypes
477477
** from file suffixes.
478478
*/
479479
void mimetype_list_page(void){
480480
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 */
483484
mimetype_verify();
484485
style_header("Mimetype List");
485486
@ <p>The Fossil <a href="%R/help?cmd=/doc">/doc</a> page uses filename
486487
@ suffixes and the following tables to guess at the appropriate mimetype
487488
@ for each document.</p>
@@ -512,21 +513,26 @@
512513
if( nCustomEntries==0 ){
513514
@ <tr><td colspan="2"><em>none</em></tr>
514515
}
515516
@ </tbody></table>
516517
@ <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
+ }
519522
@ <table class='sortable mimetypetable' border=1 cellpadding=0 \
520523
@ data-column-types='tt' data-init-sort='1'>
521524
@ <thead>
522525
@ <tr><th>Suffix<th>Mimetype
523526
@ </thead>
524527
@ <tbody>
525528
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
+ }
528534
@ <tr><td>%s(zFlag)%h(aMime[i].zSuffix)<td>%h(aMime[i].zMimetype)</tr>
529535
}
530536
@ </tbody></table>
531537
style_table_sorter();
532538
style_footer();
533539
--- 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

Keyboard Shortcuts

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