Fossil SCM
Add the test-mimetype command and use it to verify the correct order of entries in the mimetype table. Fix the errors found.
Commit
ea2698e9c7de2222f285034e0c4ceb2f307568eb
Parent
32ad9a1584a16f0…
1 file changed
+40
-10
+40
-10
| --- src/doc.c | ||
| +++ src/doc.c | ||
| @@ -139,14 +139,14 @@ | ||
| 139 | 139 | { "flv", 3, "video/flv" }, |
| 140 | 140 | { "gif", 3, "image/gif" }, |
| 141 | 141 | { "gl", 2, "video/gl" }, |
| 142 | 142 | { "gtar", 4, "application/x-gtar" }, |
| 143 | 143 | { "gz", 2, "application/x-gzip" }, |
| 144 | + { "h", 1, "text/plain" }, | |
| 144 | 145 | { "hdf", 3, "application/x-hdf" }, |
| 145 | 146 | { "hh", 2, "text/plain" }, |
| 146 | 147 | { "hqx", 3, "application/mac-binhex40" }, |
| 147 | - { "h", 1, "text/plain" }, | |
| 148 | 148 | { "htm", 3, "text/html" }, |
| 149 | 149 | { "html", 4, "text/html" }, |
| 150 | 150 | { "ice", 3, "x-conference/x-cooltalk" }, |
| 151 | 151 | { "ief", 3, "image/ief" }, |
| 152 | 152 | { "iges", 4, "model/iges" }, |
| @@ -153,12 +153,12 @@ | ||
| 153 | 153 | { "igs", 3, "model/iges" }, |
| 154 | 154 | { "ips", 3, "application/x-ipscript" }, |
| 155 | 155 | { "ipx", 3, "application/x-ipix" }, |
| 156 | 156 | { "jad", 3, "text/vnd.sun.j2me.app-descriptor" }, |
| 157 | 157 | { "jar", 3, "application/java-archive" }, |
| 158 | - { "jpeg", 4, "image/jpeg" }, | |
| 159 | 158 | { "jpe", 3, "image/jpeg" }, |
| 159 | + { "jpeg", 4, "image/jpeg" }, | |
| 160 | 160 | { "jpg", 3, "image/jpeg" }, |
| 161 | 161 | { "js", 2, "application/x-javascript" }, |
| 162 | 162 | { "kar", 3, "audio/midi" }, |
| 163 | 163 | { "latex", 5, "application/x-latex" }, |
| 164 | 164 | { "lha", 3, "application/octet-stream" }, |
| @@ -171,19 +171,18 @@ | ||
| 171 | 171 | { "mesh", 4, "model/mesh" }, |
| 172 | 172 | { "mid", 3, "audio/midi" }, |
| 173 | 173 | { "midi", 4, "audio/midi" }, |
| 174 | 174 | { "mif", 3, "application/x-mif" }, |
| 175 | 175 | { "mime", 4, "www/mime" }, |
| 176 | - { "movie", 5, "video/x-sgi-movie" }, | |
| 177 | 176 | { "mov", 3, "video/quicktime" }, |
| 177 | + { "movie", 5, "video/x-sgi-movie" }, | |
| 178 | 178 | { "mp2", 3, "audio/mpeg" }, |
| 179 | - { "mp2", 3, "video/mpeg" }, | |
| 180 | 179 | { "mp3", 3, "audio/mpeg" }, |
| 181 | - { "mpeg", 4, "video/mpeg" }, | |
| 182 | 180 | { "mpe", 3, "video/mpeg" }, |
| 183 | - { "mpga", 4, "audio/mpeg" }, | |
| 181 | + { "mpeg", 4, "video/mpeg" }, | |
| 184 | 182 | { "mpg", 3, "video/mpeg" }, |
| 183 | + { "mpga", 4, "audio/mpeg" }, | |
| 185 | 184 | { "ms", 2, "application/x-troff-ms" }, |
| 186 | 185 | { "msh", 3, "model/mesh" }, |
| 187 | 186 | { "nc", 2, "application/x-netcdf" }, |
| 188 | 187 | { "oda", 3, "application/oda" }, |
| 189 | 188 | { "ogg", 3, "application/ogg" }, |
| @@ -209,22 +208,20 @@ | ||
| 209 | 208 | { "qt", 2, "video/quicktime" }, |
| 210 | 209 | { "ra", 2, "audio/x-realaudio" }, |
| 211 | 210 | { "ram", 3, "audio/x-pn-realaudio" }, |
| 212 | 211 | { "rar", 3, "application/x-rar-compressed" }, |
| 213 | 212 | { "ras", 3, "image/cmu-raster" }, |
| 214 | - { "ras", 3, "image/x-cmu-raster" }, | |
| 215 | 213 | { "rgb", 3, "image/x-rgb" }, |
| 216 | 214 | { "rm", 2, "audio/x-pn-realaudio" }, |
| 217 | 215 | { "roff", 4, "application/x-troff" }, |
| 218 | 216 | { "rpm", 3, "audio/x-pn-realaudio-plugin" }, |
| 219 | - { "rtf", 3, "application/rtf" }, | |
| 220 | 217 | { "rtf", 3, "text/rtf" }, |
| 221 | 218 | { "rtx", 3, "text/richtext" }, |
| 222 | 219 | { "scm", 3, "application/x-lotusscreencam" }, |
| 223 | 220 | { "set", 3, "application/set" }, |
| 224 | - { "sgml", 4, "text/sgml" }, | |
| 225 | 221 | { "sgm", 3, "text/sgml" }, |
| 222 | + { "sgml", 4, "text/sgml" }, | |
| 226 | 223 | { "sh", 2, "application/x-sh" }, |
| 227 | 224 | { "shar", 4, "application/x-shar" }, |
| 228 | 225 | { "silo", 4, "model/mesh" }, |
| 229 | 226 | { "sit", 3, "application/x-stuffit" }, |
| 230 | 227 | { "skd", 3, "application/x-koan" }, |
| @@ -249,12 +246,12 @@ | ||
| 249 | 246 | { "tcl", 3, "application/x-tcl" }, |
| 250 | 247 | { "tex", 3, "application/x-tex" }, |
| 251 | 248 | { "texi", 4, "application/x-texinfo" }, |
| 252 | 249 | { "texinfo", 7, "application/x-texinfo" }, |
| 253 | 250 | { "tgz", 3, "application/x-tar-gz" }, |
| 254 | - { "tiff", 4, "image/tiff" }, | |
| 255 | 251 | { "tif", 3, "image/tiff" }, |
| 252 | + { "tiff", 4, "image/tiff" }, | |
| 256 | 253 | { "tr", 2, "application/x-troff" }, |
| 257 | 254 | { "tsi", 3, "audio/TSP-audio" }, |
| 258 | 255 | { "tsp", 3, "application/dsptype" }, |
| 259 | 256 | { "tsv", 3, "text/tab-separated-values" }, |
| 260 | 257 | { "txt", 3, "text/plain" }, |
| @@ -283,10 +280,25 @@ | ||
| 283 | 280 | { "xpm", 3, "image/x-xpixmap" }, |
| 284 | 281 | { "xwd", 3, "image/x-xwindowdump" }, |
| 285 | 282 | { "xyz", 3, "chemical/x-pdb" }, |
| 286 | 283 | { "zip", 3, "application/zip" }, |
| 287 | 284 | }; |
| 285 | + | |
| 286 | +#ifdef FOSSIL_DEBUG | |
| 287 | + /* This is test code to make sure the table above is in the correct | |
| 288 | + ** order | |
| 289 | + */ | |
| 290 | + if( fossil_strcmp(zName, "mimetype-test")==0 ){ | |
| 291 | + for(i=1; i<sizeof(aMime)/sizeof(aMime[0]); i++){ | |
| 292 | + if( fossil_strcmp(aMime[i-1].zSuffix,aMime[i].zSuffix)>=0 ){ | |
| 293 | + fossil_fatal("mimetypes out of sequence: %s before %s", | |
| 294 | + aMime[i-1].zSuffix, aMime[i].zSuffix); | |
| 295 | + } | |
| 296 | + } | |
| 297 | + return "ok"; | |
| 298 | + } | |
| 299 | +#endif | |
| 288 | 300 | |
| 289 | 301 | z = zName; |
| 290 | 302 | for(i=0; zName[i]; i++){ |
| 291 | 303 | if( zName[i]=='.' ) z = &zName[i+1]; |
| 292 | 304 | } |
| @@ -308,10 +320,28 @@ | ||
| 308 | 320 | } |
| 309 | 321 | } |
| 310 | 322 | } |
| 311 | 323 | return "application/x-fossil-artifact"; |
| 312 | 324 | } |
| 325 | + | |
| 326 | +/* | |
| 327 | +** COMMAND: test-mimetype | |
| 328 | +** | |
| 329 | +** Usage: %fossil test-mimetype FILENAME... | |
| 330 | +** | |
| 331 | +** Return the deduced mimetype for each file listed. | |
| 332 | +** | |
| 333 | +** If Fossil is compiled with -DFOSSIL_DEBUG then the "mimetype-test" | |
| 334 | +** filename is special and verifies the integrity of the mimetype table. | |
| 335 | +** It should return "ok". | |
| 336 | +*/ | |
| 337 | +void mimetype_test_cmd(void){ | |
| 338 | + int i; | |
| 339 | + for(i=2; i<g.argc; i++){ | |
| 340 | + fossil_print("%-20s -> %s\n", g.argv[i], mimetype_from_name(g.argv[i])); | |
| 341 | + } | |
| 342 | +} | |
| 313 | 343 | |
| 314 | 344 | /* |
| 315 | 345 | ** WEBPAGE: doc |
| 316 | 346 | ** URL: /doc?name=BASELINE/PATH |
| 317 | 347 | ** URL: /doc/BASELINE/PATH |
| 318 | 348 |
| --- src/doc.c | |
| +++ src/doc.c | |
| @@ -139,14 +139,14 @@ | |
| 139 | { "flv", 3, "video/flv" }, |
| 140 | { "gif", 3, "image/gif" }, |
| 141 | { "gl", 2, "video/gl" }, |
| 142 | { "gtar", 4, "application/x-gtar" }, |
| 143 | { "gz", 2, "application/x-gzip" }, |
| 144 | { "hdf", 3, "application/x-hdf" }, |
| 145 | { "hh", 2, "text/plain" }, |
| 146 | { "hqx", 3, "application/mac-binhex40" }, |
| 147 | { "h", 1, "text/plain" }, |
| 148 | { "htm", 3, "text/html" }, |
| 149 | { "html", 4, "text/html" }, |
| 150 | { "ice", 3, "x-conference/x-cooltalk" }, |
| 151 | { "ief", 3, "image/ief" }, |
| 152 | { "iges", 4, "model/iges" }, |
| @@ -153,12 +153,12 @@ | |
| 153 | { "igs", 3, "model/iges" }, |
| 154 | { "ips", 3, "application/x-ipscript" }, |
| 155 | { "ipx", 3, "application/x-ipix" }, |
| 156 | { "jad", 3, "text/vnd.sun.j2me.app-descriptor" }, |
| 157 | { "jar", 3, "application/java-archive" }, |
| 158 | { "jpeg", 4, "image/jpeg" }, |
| 159 | { "jpe", 3, "image/jpeg" }, |
| 160 | { "jpg", 3, "image/jpeg" }, |
| 161 | { "js", 2, "application/x-javascript" }, |
| 162 | { "kar", 3, "audio/midi" }, |
| 163 | { "latex", 5, "application/x-latex" }, |
| 164 | { "lha", 3, "application/octet-stream" }, |
| @@ -171,19 +171,18 @@ | |
| 171 | { "mesh", 4, "model/mesh" }, |
| 172 | { "mid", 3, "audio/midi" }, |
| 173 | { "midi", 4, "audio/midi" }, |
| 174 | { "mif", 3, "application/x-mif" }, |
| 175 | { "mime", 4, "www/mime" }, |
| 176 | { "movie", 5, "video/x-sgi-movie" }, |
| 177 | { "mov", 3, "video/quicktime" }, |
| 178 | { "mp2", 3, "audio/mpeg" }, |
| 179 | { "mp2", 3, "video/mpeg" }, |
| 180 | { "mp3", 3, "audio/mpeg" }, |
| 181 | { "mpeg", 4, "video/mpeg" }, |
| 182 | { "mpe", 3, "video/mpeg" }, |
| 183 | { "mpga", 4, "audio/mpeg" }, |
| 184 | { "mpg", 3, "video/mpeg" }, |
| 185 | { "ms", 2, "application/x-troff-ms" }, |
| 186 | { "msh", 3, "model/mesh" }, |
| 187 | { "nc", 2, "application/x-netcdf" }, |
| 188 | { "oda", 3, "application/oda" }, |
| 189 | { "ogg", 3, "application/ogg" }, |
| @@ -209,22 +208,20 @@ | |
| 209 | { "qt", 2, "video/quicktime" }, |
| 210 | { "ra", 2, "audio/x-realaudio" }, |
| 211 | { "ram", 3, "audio/x-pn-realaudio" }, |
| 212 | { "rar", 3, "application/x-rar-compressed" }, |
| 213 | { "ras", 3, "image/cmu-raster" }, |
| 214 | { "ras", 3, "image/x-cmu-raster" }, |
| 215 | { "rgb", 3, "image/x-rgb" }, |
| 216 | { "rm", 2, "audio/x-pn-realaudio" }, |
| 217 | { "roff", 4, "application/x-troff" }, |
| 218 | { "rpm", 3, "audio/x-pn-realaudio-plugin" }, |
| 219 | { "rtf", 3, "application/rtf" }, |
| 220 | { "rtf", 3, "text/rtf" }, |
| 221 | { "rtx", 3, "text/richtext" }, |
| 222 | { "scm", 3, "application/x-lotusscreencam" }, |
| 223 | { "set", 3, "application/set" }, |
| 224 | { "sgml", 4, "text/sgml" }, |
| 225 | { "sgm", 3, "text/sgml" }, |
| 226 | { "sh", 2, "application/x-sh" }, |
| 227 | { "shar", 4, "application/x-shar" }, |
| 228 | { "silo", 4, "model/mesh" }, |
| 229 | { "sit", 3, "application/x-stuffit" }, |
| 230 | { "skd", 3, "application/x-koan" }, |
| @@ -249,12 +246,12 @@ | |
| 249 | { "tcl", 3, "application/x-tcl" }, |
| 250 | { "tex", 3, "application/x-tex" }, |
| 251 | { "texi", 4, "application/x-texinfo" }, |
| 252 | { "texinfo", 7, "application/x-texinfo" }, |
| 253 | { "tgz", 3, "application/x-tar-gz" }, |
| 254 | { "tiff", 4, "image/tiff" }, |
| 255 | { "tif", 3, "image/tiff" }, |
| 256 | { "tr", 2, "application/x-troff" }, |
| 257 | { "tsi", 3, "audio/TSP-audio" }, |
| 258 | { "tsp", 3, "application/dsptype" }, |
| 259 | { "tsv", 3, "text/tab-separated-values" }, |
| 260 | { "txt", 3, "text/plain" }, |
| @@ -283,10 +280,25 @@ | |
| 283 | { "xpm", 3, "image/x-xpixmap" }, |
| 284 | { "xwd", 3, "image/x-xwindowdump" }, |
| 285 | { "xyz", 3, "chemical/x-pdb" }, |
| 286 | { "zip", 3, "application/zip" }, |
| 287 | }; |
| 288 | |
| 289 | z = zName; |
| 290 | for(i=0; zName[i]; i++){ |
| 291 | if( zName[i]=='.' ) z = &zName[i+1]; |
| 292 | } |
| @@ -308,10 +320,28 @@ | |
| 308 | } |
| 309 | } |
| 310 | } |
| 311 | return "application/x-fossil-artifact"; |
| 312 | } |
| 313 | |
| 314 | /* |
| 315 | ** WEBPAGE: doc |
| 316 | ** URL: /doc?name=BASELINE/PATH |
| 317 | ** URL: /doc/BASELINE/PATH |
| 318 |
| --- src/doc.c | |
| +++ src/doc.c | |
| @@ -139,14 +139,14 @@ | |
| 139 | { "flv", 3, "video/flv" }, |
| 140 | { "gif", 3, "image/gif" }, |
| 141 | { "gl", 2, "video/gl" }, |
| 142 | { "gtar", 4, "application/x-gtar" }, |
| 143 | { "gz", 2, "application/x-gzip" }, |
| 144 | { "h", 1, "text/plain" }, |
| 145 | { "hdf", 3, "application/x-hdf" }, |
| 146 | { "hh", 2, "text/plain" }, |
| 147 | { "hqx", 3, "application/mac-binhex40" }, |
| 148 | { "htm", 3, "text/html" }, |
| 149 | { "html", 4, "text/html" }, |
| 150 | { "ice", 3, "x-conference/x-cooltalk" }, |
| 151 | { "ief", 3, "image/ief" }, |
| 152 | { "iges", 4, "model/iges" }, |
| @@ -153,12 +153,12 @@ | |
| 153 | { "igs", 3, "model/iges" }, |
| 154 | { "ips", 3, "application/x-ipscript" }, |
| 155 | { "ipx", 3, "application/x-ipix" }, |
| 156 | { "jad", 3, "text/vnd.sun.j2me.app-descriptor" }, |
| 157 | { "jar", 3, "application/java-archive" }, |
| 158 | { "jpe", 3, "image/jpeg" }, |
| 159 | { "jpeg", 4, "image/jpeg" }, |
| 160 | { "jpg", 3, "image/jpeg" }, |
| 161 | { "js", 2, "application/x-javascript" }, |
| 162 | { "kar", 3, "audio/midi" }, |
| 163 | { "latex", 5, "application/x-latex" }, |
| 164 | { "lha", 3, "application/octet-stream" }, |
| @@ -171,19 +171,18 @@ | |
| 171 | { "mesh", 4, "model/mesh" }, |
| 172 | { "mid", 3, "audio/midi" }, |
| 173 | { "midi", 4, "audio/midi" }, |
| 174 | { "mif", 3, "application/x-mif" }, |
| 175 | { "mime", 4, "www/mime" }, |
| 176 | { "mov", 3, "video/quicktime" }, |
| 177 | { "movie", 5, "video/x-sgi-movie" }, |
| 178 | { "mp2", 3, "audio/mpeg" }, |
| 179 | { "mp3", 3, "audio/mpeg" }, |
| 180 | { "mpe", 3, "video/mpeg" }, |
| 181 | { "mpeg", 4, "video/mpeg" }, |
| 182 | { "mpg", 3, "video/mpeg" }, |
| 183 | { "mpga", 4, "audio/mpeg" }, |
| 184 | { "ms", 2, "application/x-troff-ms" }, |
| 185 | { "msh", 3, "model/mesh" }, |
| 186 | { "nc", 2, "application/x-netcdf" }, |
| 187 | { "oda", 3, "application/oda" }, |
| 188 | { "ogg", 3, "application/ogg" }, |
| @@ -209,22 +208,20 @@ | |
| 208 | { "qt", 2, "video/quicktime" }, |
| 209 | { "ra", 2, "audio/x-realaudio" }, |
| 210 | { "ram", 3, "audio/x-pn-realaudio" }, |
| 211 | { "rar", 3, "application/x-rar-compressed" }, |
| 212 | { "ras", 3, "image/cmu-raster" }, |
| 213 | { "rgb", 3, "image/x-rgb" }, |
| 214 | { "rm", 2, "audio/x-pn-realaudio" }, |
| 215 | { "roff", 4, "application/x-troff" }, |
| 216 | { "rpm", 3, "audio/x-pn-realaudio-plugin" }, |
| 217 | { "rtf", 3, "text/rtf" }, |
| 218 | { "rtx", 3, "text/richtext" }, |
| 219 | { "scm", 3, "application/x-lotusscreencam" }, |
| 220 | { "set", 3, "application/set" }, |
| 221 | { "sgm", 3, "text/sgml" }, |
| 222 | { "sgml", 4, "text/sgml" }, |
| 223 | { "sh", 2, "application/x-sh" }, |
| 224 | { "shar", 4, "application/x-shar" }, |
| 225 | { "silo", 4, "model/mesh" }, |
| 226 | { "sit", 3, "application/x-stuffit" }, |
| 227 | { "skd", 3, "application/x-koan" }, |
| @@ -249,12 +246,12 @@ | |
| 246 | { "tcl", 3, "application/x-tcl" }, |
| 247 | { "tex", 3, "application/x-tex" }, |
| 248 | { "texi", 4, "application/x-texinfo" }, |
| 249 | { "texinfo", 7, "application/x-texinfo" }, |
| 250 | { "tgz", 3, "application/x-tar-gz" }, |
| 251 | { "tif", 3, "image/tiff" }, |
| 252 | { "tiff", 4, "image/tiff" }, |
| 253 | { "tr", 2, "application/x-troff" }, |
| 254 | { "tsi", 3, "audio/TSP-audio" }, |
| 255 | { "tsp", 3, "application/dsptype" }, |
| 256 | { "tsv", 3, "text/tab-separated-values" }, |
| 257 | { "txt", 3, "text/plain" }, |
| @@ -283,10 +280,25 @@ | |
| 280 | { "xpm", 3, "image/x-xpixmap" }, |
| 281 | { "xwd", 3, "image/x-xwindowdump" }, |
| 282 | { "xyz", 3, "chemical/x-pdb" }, |
| 283 | { "zip", 3, "application/zip" }, |
| 284 | }; |
| 285 | |
| 286 | #ifdef FOSSIL_DEBUG |
| 287 | /* This is test code to make sure the table above is in the correct |
| 288 | ** order |
| 289 | */ |
| 290 | if( fossil_strcmp(zName, "mimetype-test")==0 ){ |
| 291 | for(i=1; i<sizeof(aMime)/sizeof(aMime[0]); i++){ |
| 292 | if( fossil_strcmp(aMime[i-1].zSuffix,aMime[i].zSuffix)>=0 ){ |
| 293 | fossil_fatal("mimetypes out of sequence: %s before %s", |
| 294 | aMime[i-1].zSuffix, aMime[i].zSuffix); |
| 295 | } |
| 296 | } |
| 297 | return "ok"; |
| 298 | } |
| 299 | #endif |
| 300 | |
| 301 | z = zName; |
| 302 | for(i=0; zName[i]; i++){ |
| 303 | if( zName[i]=='.' ) z = &zName[i+1]; |
| 304 | } |
| @@ -308,10 +320,28 @@ | |
| 320 | } |
| 321 | } |
| 322 | } |
| 323 | return "application/x-fossil-artifact"; |
| 324 | } |
| 325 | |
| 326 | /* |
| 327 | ** COMMAND: test-mimetype |
| 328 | ** |
| 329 | ** Usage: %fossil test-mimetype FILENAME... |
| 330 | ** |
| 331 | ** Return the deduced mimetype for each file listed. |
| 332 | ** |
| 333 | ** If Fossil is compiled with -DFOSSIL_DEBUG then the "mimetype-test" |
| 334 | ** filename is special and verifies the integrity of the mimetype table. |
| 335 | ** It should return "ok". |
| 336 | */ |
| 337 | void mimetype_test_cmd(void){ |
| 338 | int i; |
| 339 | for(i=2; i<g.argc; i++){ |
| 340 | fossil_print("%-20s -> %s\n", g.argv[i], mimetype_from_name(g.argv[i])); |
| 341 | } |
| 342 | } |
| 343 | |
| 344 | /* |
| 345 | ** WEBPAGE: doc |
| 346 | ** URL: /doc?name=BASELINE/PATH |
| 347 | ** URL: /doc/BASELINE/PATH |
| 348 |