c_addrcodec(): CID 1549184 (not on [next])
[s-mailx.git] / mk / make-mime-types.sh
blobe1a14e3ce45c75abd6ddc205ee3a95df723f396f
1 #!/bin/sh -
2 #@ Generate builtin mime.types (configuration sourced in environment).
4 # Public Domain
6 LC_ALL=C
8 < "$1" > "$2" exec ${awk} '
9 function add(mt, ln){
10 gsub(/[ ]]+/, " ", ln)
11 i = split(ln, i_a)
12 e = ""
13 for(j = 1; j <= i; ++j){
14 k = i_a[j]
15 e = (e ? e " " : "") k
17 if(e){
18 if(e_a[mt])
19 e_a[mt] = e_a[mt] " "
20 e_a[mt] = e_a[mt] e
23 /^[ ]*#/{next}
24 /^[ ]*$/{ltype = ""; next}
25 /^[ ]/{
26 if(!ltype)
27 print "FAULTY CONTINUATION: " $0 >> "/dev/stderr"
28 add(ltype, $0)
29 next
31 /^(\?([thHq])? )?[a-zA-Z]/{
32 if($1 ~ /^\?([thHq])?$/){
33 pa = $1
34 $1 = $2
35 $2 = ""
36 }else
37 pa = ""
38 if($1 !~ /^([0-9a-zA-Z]+)\/([0-9a-zA-Z_+-]+)$/)
39 print "FAULTY MIME TYPE: <" $1 ">" >> "/dev/stderr"
40 ltype = $1; $1 = ""
41 if(pa)
42 p_a[ltype] = pa
43 if(!nt_a[ltype])
44 no_a[++no_ai] = nt_a[ltype] = ltype
45 add(ltype, $0)
47 END{
48 for(z = 1; z <= no_ai; ++z){
49 t = no_a[z]
50 j = index(t, "/")
51 mt = toupper(substr(t, 1, j - 1))
52 j = substr(t, j + 1)
53 l = length(j)
54 if(!p_a[t])
55 mt = "a_MIMETYPE_" mt
56 else{
57 tm = p_a[t]
58 if(tm ~ /^\?t?$/)
59 mt = "a_MIMETYPE_" mt " | a_MIMETYPE_TM_PLAIN"
60 else if(tm ~ /^\?h$/)
61 mt = "a_MIMETYPE_" mt " | a_MIMETYPE_TM_SOUP_h"
62 else if(tm ~ /^\?H$/)
63 mt = "a_MIMETYPE_" mt " | a_MIMETYPE_TM_SOUP_H"
64 else if(tm ~ /^\?q$/)
65 mt = "a_MIMETYPE_" mt " | a_MIMETYPE_TM_QUIET"
67 print " {" mt ", " l ", \"" j e_a[t] "\"},"
72 # s-sh-mode