Fossil SCM

Add text/csv to the mimetype table. Add additional code to verify that the mimetype table is well-ordered.

drh 2015-02-11 20:24 trunk
Commit e4c420b4373cc7f7d37fdf1bdc2512320aba4edb
1 file changed +18 -6
+18 -6
--- src/doc.c
+++ src/doc.c
@@ -106,10 +106,11 @@
106106
{ "com", 3, "application/x-msdos-program" },
107107
{ "cpio", 4, "application/x-cpio" },
108108
{ "cpt", 3, "application/mac-compactpro" },
109109
{ "csh", 3, "application/x-csh" },
110110
{ "css", 3, "text/css" },
111
+ { "csv", 3, "text/csv" },
111112
{ "dcr", 3, "application/x-director" },
112113
{ "deb", 3, "application/x-debian-package" },
113114
{ "dir", 3, "application/x-director" },
114115
{ "dl", 2, "video/dl" },
115116
{ "dms", 3, "application/octet-stream" },
@@ -291,10 +292,24 @@
291292
{ "xpm", 3, "image/x-xpixmap" },
292293
{ "xwd", 3, "image/x-xwindowdump" },
293294
{ "xyz", 3, "chemical/x-pdb" },
294295
{ "zip", 3, "application/zip" },
295296
};
297
+
298
+/*
299
+** Verify that all entries in the aMime[] table are in sorted order.
300
+** Abort with a fatal error if any is out-of-order.
301
+*/
302
+static void mimetype_verify(void){
303
+ int i;
304
+ for(i=1; i<ArraySize(aMime); i++){
305
+ if( fossil_strcmp(aMime[i-1].zSuffix,aMime[i].zSuffix)>=0 ){
306
+ fossil_fatal("mimetypes out of sequence: %s before %s",
307
+ aMime[i-1].zSuffix, aMime[i].zSuffix);
308
+ }
309
+ }
310
+}
296311
297312
/*
298313
** Guess the mime-type of a document based on its name.
299314
*/
300315
const char *mimetype_from_name(const char *zName){
@@ -308,16 +323,11 @@
308323
#ifdef FOSSIL_DEBUG
309324
/* This is test code to make sure the table above is in the correct
310325
** order
311326
*/
312327
if( fossil_strcmp(zName, "mimetype-test")==0 ){
313
- for(i=1; i<ArraySize(aMime); i++){
314
- if( fossil_strcmp(aMime[i-1].zSuffix,aMime[i].zSuffix)>=0 ){
315
- fossil_fatal("mimetypes out of sequence: %s before %s",
316
- aMime[i-1].zSuffix, aMime[i].zSuffix);
317
- }
318
- }
328
+ mimetype_verify();
319329
return "ok";
320330
}
321331
#endif
322332
323333
z = zName;
@@ -356,10 +366,11 @@
356366
** filename is special and verifies the integrity of the mimetype table.
357367
** It should return "ok".
358368
*/
359369
void mimetype_test_cmd(void){
360370
int i;
371
+ mimetype_verify();
361372
for(i=2; i<g.argc; i++){
362373
fossil_print("%-20s -> %s\n", g.argv[i], mimetype_from_name(g.argv[i]));
363374
}
364375
}
365376
@@ -369,10 +380,11 @@
369380
** Show the built-in table used to guess embedded document mimetypes
370381
** from file suffixes.
371382
*/
372383
void mimetype_list_page(void){
373384
int i;
385
+ mimetype_verify();
374386
style_header("Mimetype List");
375387
@ <p>The Fossil <a href="%R/help?cmd=/doc">/doc</a> page uses filename
376388
@ suffixes and the following table to guess at the appropriate mimetype
377389
@ for each document.</p>
378390
@ <table id='mimeTable' border=1 cellpadding=0 class='mimetypetable'>
379391
--- src/doc.c
+++ src/doc.c
@@ -106,10 +106,11 @@
106 { "com", 3, "application/x-msdos-program" },
107 { "cpio", 4, "application/x-cpio" },
108 { "cpt", 3, "application/mac-compactpro" },
109 { "csh", 3, "application/x-csh" },
110 { "css", 3, "text/css" },
 
111 { "dcr", 3, "application/x-director" },
112 { "deb", 3, "application/x-debian-package" },
113 { "dir", 3, "application/x-director" },
114 { "dl", 2, "video/dl" },
115 { "dms", 3, "application/octet-stream" },
@@ -291,10 +292,24 @@
291 { "xpm", 3, "image/x-xpixmap" },
292 { "xwd", 3, "image/x-xwindowdump" },
293 { "xyz", 3, "chemical/x-pdb" },
294 { "zip", 3, "application/zip" },
295 };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
296
297 /*
298 ** Guess the mime-type of a document based on its name.
299 */
300 const char *mimetype_from_name(const char *zName){
@@ -308,16 +323,11 @@
308 #ifdef FOSSIL_DEBUG
309 /* This is test code to make sure the table above is in the correct
310 ** order
311 */
312 if( fossil_strcmp(zName, "mimetype-test")==0 ){
313 for(i=1; i<ArraySize(aMime); i++){
314 if( fossil_strcmp(aMime[i-1].zSuffix,aMime[i].zSuffix)>=0 ){
315 fossil_fatal("mimetypes out of sequence: %s before %s",
316 aMime[i-1].zSuffix, aMime[i].zSuffix);
317 }
318 }
319 return "ok";
320 }
321 #endif
322
323 z = zName;
@@ -356,10 +366,11 @@
356 ** filename is special and verifies the integrity of the mimetype table.
357 ** It should return "ok".
358 */
359 void mimetype_test_cmd(void){
360 int i;
 
361 for(i=2; i<g.argc; i++){
362 fossil_print("%-20s -> %s\n", g.argv[i], mimetype_from_name(g.argv[i]));
363 }
364 }
365
@@ -369,10 +380,11 @@
369 ** Show the built-in table used to guess embedded document mimetypes
370 ** from file suffixes.
371 */
372 void mimetype_list_page(void){
373 int i;
 
374 style_header("Mimetype List");
375 @ <p>The Fossil <a href="%R/help?cmd=/doc">/doc</a> page uses filename
376 @ suffixes and the following table to guess at the appropriate mimetype
377 @ for each document.</p>
378 @ <table id='mimeTable' border=1 cellpadding=0 class='mimetypetable'>
379
--- src/doc.c
+++ src/doc.c
@@ -106,10 +106,11 @@
106 { "com", 3, "application/x-msdos-program" },
107 { "cpio", 4, "application/x-cpio" },
108 { "cpt", 3, "application/mac-compactpro" },
109 { "csh", 3, "application/x-csh" },
110 { "css", 3, "text/css" },
111 { "csv", 3, "text/csv" },
112 { "dcr", 3, "application/x-director" },
113 { "deb", 3, "application/x-debian-package" },
114 { "dir", 3, "application/x-director" },
115 { "dl", 2, "video/dl" },
116 { "dms", 3, "application/octet-stream" },
@@ -291,10 +292,24 @@
292 { "xpm", 3, "image/x-xpixmap" },
293 { "xwd", 3, "image/x-xwindowdump" },
294 { "xyz", 3, "chemical/x-pdb" },
295 { "zip", 3, "application/zip" },
296 };
297
298 /*
299 ** Verify that all entries in the aMime[] table are in sorted order.
300 ** Abort with a fatal error if any is out-of-order.
301 */
302 static void mimetype_verify(void){
303 int i;
304 for(i=1; i<ArraySize(aMime); i++){
305 if( fossil_strcmp(aMime[i-1].zSuffix,aMime[i].zSuffix)>=0 ){
306 fossil_fatal("mimetypes out of sequence: %s before %s",
307 aMime[i-1].zSuffix, aMime[i].zSuffix);
308 }
309 }
310 }
311
312 /*
313 ** Guess the mime-type of a document based on its name.
314 */
315 const char *mimetype_from_name(const char *zName){
@@ -308,16 +323,11 @@
323 #ifdef FOSSIL_DEBUG
324 /* This is test code to make sure the table above is in the correct
325 ** order
326 */
327 if( fossil_strcmp(zName, "mimetype-test")==0 ){
328 mimetype_verify();
 
 
 
 
 
329 return "ok";
330 }
331 #endif
332
333 z = zName;
@@ -356,10 +366,11 @@
366 ** filename is special and verifies the integrity of the mimetype table.
367 ** It should return "ok".
368 */
369 void mimetype_test_cmd(void){
370 int i;
371 mimetype_verify();
372 for(i=2; i<g.argc; i++){
373 fossil_print("%-20s -> %s\n", g.argv[i], mimetype_from_name(g.argv[i]));
374 }
375 }
376
@@ -369,10 +380,11 @@
380 ** Show the built-in table used to guess embedded document mimetypes
381 ** from file suffixes.
382 */
383 void mimetype_list_page(void){
384 int i;
385 mimetype_verify();
386 style_header("Mimetype List");
387 @ <p>The Fossil <a href="%R/help?cmd=/doc">/doc</a> page uses filename
388 @ suffixes and the following table to guess at the appropriate mimetype
389 @ for each document.</p>
390 @ <table id='mimeTable' border=1 cellpadding=0 class='mimetypetable'>
391

Keyboard Shortcuts

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