~ubuntu-branches/ubuntu/trusty/rasmol/trusty

« back to all changes in this revision

Viewing changes to src/languages/genlangsel

  • Committer: Bazaar Package Importer
  • Author(s): Teemu Ikonen
  • Date: 2009-11-24 16:48:04 UTC
  • mfrom: (3.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091124164804-liuvywcs6l45ibl3
Tags: 2.7.5-1
* New upstream release
* Imakefile: Use Debian versions of library dependencies
* control:
  - Add build-deps to libcvector2-dev, libcqrlib2-dev, libneartree3-dev
  - Update to standards-version 3.8.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
 
 
3
################################################################################
 
4
# GENLANGSEL
 
5
#       THE REALLY REALLY BIG VERSION
 
6
################################################################################
 
7
#
 
8
#  Created: 01 July 2008
 
9
#
 
10
#  DESCRIPTION
 
11
#   Converts encoding from UTF8 master files to their proper encodings, and
 
12
#   concatenates them.
 
13
#
 
14
#  ENCODINGS USED
 
15
#   Bulgarian - CP1251 (Windows, Mac, Unix)
 
16
#   Chinese   - GB18030 (Windows, Mac, Unix)
 
17
#   French    - Latin 1 (Windows, Unix)
 
18
#             - MacRoman (Mac)
 
19
#   Italian   - Latin 1 (Windows, Unix)
 
20
#             - MacRoman (Mac)
 
21
#   Japanese  - Shift_JIS (Windows)
 
22
#                         - CP932 (Mac)
 
23
#             - EUC_JP (Unix)
 
24
#   Russian   - GB18030 (Windows, Mac, Unix)
 
25
#   Spanish   - Latin 1 (Windows, Unix)
 
26
#             - MacRoman
 
27
#
 
28
################################################################################
 
29
 
 
30
# No longer being used.
 
31
function clean()
 
32
{
 
33
        LANGS="Bulgarian Chinese English Italian Japanese French Russian Spanish"
 
34
        for LANG in $LANGS
 
35
        do
 
36
                if [ $1 = "mac" ]; then
 
37
                        FILE=langsel.${LANG}.mac.c
 
38
                else
 
39
                        FILE=langsel.${LANG}.c
 
40
                fi
 
41
 
 
42
                if [ ${LANG} = "Japanese" ]; then
 
43
                        if [ $1 = "unix" ]; then
 
44
                                FILE="langsel.Japanese.EUC.c"
 
45
                        fi
 
46
                fi
 
47
                if [ -f ${FILE} ]; then
 
48
                        echo "Deleting temp file $FILE."
 
49
                        rm ${FILE}
 
50
                fi
 
51
        done
 
52
        if [ -f *~ ]; then
 
53
                rm *~
 
54
        fi
 
55
}
 
56
 
 
57
function jp2win ()
 
58
{
 
59
        #convert japanese to windows -- requires some tweaks.
 
60
 
 
61
        #clear temp files.
 
62
        if [ -f tmp_jp ]; then
 
63
                rm tmp_jp
 
64
        fi
 
65
        if [ -f tmp_jp2 ]; then
 
66
                rm tmp_jp2
 
67
        fi
 
68
 
 
69
        tr \\ \\$ < langsel.Japanese.utf.c > tmp_jp
 
70
        iconv -f utf8 -t sjis < tmp_jp > tmp_jp2
 
71
        tr \\$ \\ < tmp_jp2 > conversions/langsel.Japanese.c
 
72
 
 
73
        rm tmp_jp tmp_jp2
 
74
}
 
75
 
 
76
function catunix
 
77
{
 
78
 
 
79
        cat header.c > output/langsel_unix.c
 
80
        cat conversions/langsel.English.c >> output/langsel_unix.c
 
81
        echo "" >> output/langsel_unix.c
 
82
        cat conversions/langsel.Spanish.c >> output/langsel_unix.c
 
83
        echo "" >> output/langsel_unix.c
 
84
        cat conversions/langsel.Italian.c >> output/langsel_unix.c
 
85
        echo "" >> output/langsel_unix.c
 
86
        cat conversions/langsel.French.c >> output/langsel_unix.c
 
87
        echo "" >> output/langsel_unix.c
 
88
        cat conversions/langsel.Russian.c >> output/langsel_unix.c
 
89
        echo "" >> output/langsel_unix.c
 
90
        cat conversions/langsel.Bulgarian.c >> output/langsel_unix.c
 
91
        echo "" >> output/langsel_unix.c
 
92
        cat conversions/langsel.Chinese.c >> output/langsel_unix.c
 
93
        echo "" >> output/langsel_unix.c
 
94
        cat conversions/langsel.Japanese.EUC.c >> output/langsel_unix.c
 
95
        cat footer.c >> output/langsel_unix.c
 
96
}
 
97
 
 
98
function iconvit()
 
99
{
 
100
        #does iconv AND concatenates files.
 
101
        echo "iconv-ing files for mswin..."
 
102
 
 
103
        #latin1 files.
 
104
        iconv -f utf8 -t latin1 < langsel.English.utf.c > conversions/langsel.English.c
 
105
        iconv -f utf8 -t latin1 < langsel.French.utf.c > conversions/langsel.French.c
 
106
        iconv -f utf8 -t latin1 < langsel.Italian.utf.c > conversions/langsel.Italian.c
 
107
        iconv -f utf8 -t latin1 < langsel.Spanish.utf.c > conversions/langsel.Spanish.c
 
108
 
 
109
        iconv -f utf8 -t cp1251 < langsel.Bulgarian.utf.c > conversions/langsel.Bulgarian.c
 
110
        iconv -f utf8 -t gb18030 < langsel.Chinese.utf.c > conversions/langsel.Chinese.c
 
111
        if [ $1 = "unix" ]; then
 
112
                iconv -f utf8 -t eucjp < langsel.Japanese.utf.c > conversions/langsel.Japanese.EUC.c
 
113
        else
 
114
                jp2win
 
115
        fi
 
116
 
 
117
        iconv -f utf8 -t cp1251 < langsel.Russian.utf.c > conversions/langsel.Russian.c 
 
118
        
 
119
        echo "concatenating files..."
 
120
 
 
121
        if [ $1 = "unix" ]; then
 
122
                catunix
 
123
        else
 
124
                cat header.c > output/langsel_mswin.c
 
125
                cat conversions/langsel.English.c >> output/langsel_mswin.c
 
126
                echo "" >> output/langsel_mswin.c
 
127
                cat conversions/langsel.Spanish.c >> output/langsel_mswin.c
 
128
                echo "" >> output/langsel_mswin.c
 
129
                cat conversions/langsel.Italian.c >> output/langsel_mswin.c
 
130
                echo "" >> output/langsel_mswin.c
 
131
                cat conversions/langsel.French.c >> output/langsel_mswin.c
 
132
                echo "" >> output/langsel_mswin.c
 
133
                cat conversions/langsel.Russian.c >> output/langsel_mswin.c
 
134
                echo "" >> output/langsel_mswin.c
 
135
                cat conversions/langsel.Bulgarian.c >> output/langsel_mswin.c
 
136
                echo "" >> output/langsel_mswin.c
 
137
                cat conversions/langsel.Chinese.c >> output/langsel_mswin.c
 
138
                echo "" >> output/langsel_mswin.c
 
139
                cat conversions/langsel.Japanese.c >> output/langsel_mswin.c
 
140
                cat footer.c >> output/langsel_mswin.c
 
141
        fi
 
142
 
 
143
        echo "Done."
 
144
}
 
145
 
 
146
function iconvmac()
 
147
{
 
148
        #does iconv AND concatenates files.
 
149
        echo "iconv-ing files for mac..."
 
150
 
 
151
        #latin1 files.
 
152
        iconv -f utf8 -t latin1 < langsel.English.utf.c > conversions/langsel.English.mac.c
 
153
        iconv -f utf8 -t latin1 < langsel.French.utf.c > conversions/langsel.French.mac.c
 
154
        iconv -f utf8 -t latin1 < langsel.Italian.utf.c > conversions/langsel.Italian.mac.c
 
155
        iconv -f utf8 -t latin1 < langsel.Spanish.utf.c > conversions/langsel.Spanish.mac.c
 
156
 
 
157
        iconv -f utf8 -t cp1251 < langsel.Bulgarian.utf.c > conversions/langsel.Bulgarian.mac.c
 
158
        iconv -f utf8 -t gb18030 < langsel.Chinese.utf.c > conversions/langsel.Chinese.mac.c
 
159
        iconv -f utf8 -t cp932 < langsel.Japanese.utf.c > conversions/langsel.Japanese.mac.c
 
160
        iconv -f utf8 -t cp1251 < langsel.Russian.utf.c > conversions/langsel.Russian.mac.c
 
161
        
 
162
        echo "concatenating files..."
 
163
        cat header.c > output/langsel_mac.c
 
164
        cat conversions/langsel.English.mac.c >> output/langsel_mac.c
 
165
        echo "" >> output/langsel_mac.c
 
166
        cat conversions/langsel.Spanish.mac.c >> output/langsel_mac.c
 
167
        echo "" >> output/langsel_mac.c
 
168
        cat conversions/langsel.Italian.mac.c >> output/langsel_mac.c
 
169
        echo "" >> output/langsel_mac.c
 
170
        cat conversions/langsel.French.mac.c >> output/langsel_mac.c
 
171
        echo "" >> output/langsel_mac.c
 
172
        cat conversions/langsel.Russian.mac.c >> output/langsel_mac.c
 
173
        echo "" >> output/langsel_mac.c
 
174
        cat conversions/langsel.Bulgarian.mac.c >> output/langsel_mac.c
 
175
        echo "" >> output/langsel_mac.c
 
176
        cat conversions/langsel.Chinese.mac.c >> output/langsel_mac.c
 
177
        echo "" >> output/langsel_mac.c
 
178
        cat conversions/langsel.Japanese.mac.c >> output/langsel_mac.c
 
179
        cat footer.c >> output/langsel_mac.c
 
180
 
 
181
}
 
182
 
 
183
if [ ! -d conversions ]; then
 
184
        mkdir conversions
 
185
fi
 
186
if [ ! -d output ]; then
 
187
        mkdir output
 
188
fi
 
189
 
 
190
# Clean up old stuff... if it's still there ;)
 
191
clean mac
 
192
clean win
 
193
clean unix
 
194
 
 
195
case $1 in
 
196
 
 
197
        --help)
 
198
                echo "genlangsel v1.0."
 
199
                echo "DESCRIPTION"
 
200
                echo -e "\tGenerates langsel.c files using proper encodings."
 
201
                echo
 
202
                echo "USAGE"
 
203
                echo -e "\tgenlangsel [platform]"
 
204
                echo
 
205
                echo -e "\tIf no platform is specified, ALL platform langsel files"
 
206
                echo -e "\twill be generated"
 
207
                echo
 
208
                echo "PLATFORMS"
 
209
                echo "Acceptable arguments for 'platform' are:"
 
210
                echo -e "\tmswin - generate windows langsel.c"
 
211
                echo -e "\tunix - generate unix langsel_unix.c"
 
212
                echo -e "\tmac - generate mac langsel_mac.c"
 
213
                echo -e "\tall - generate all langsel files."
 
214
                echo -e "\tIf no platform is specified the script defaults to 'all'"
 
215
                echo
 
216
                echo "Using: genlangsel --help will bring up this message."
 
217
                echo
 
218
                echo "NOTES"
 
219
                echo -e "\tIf this script is not in \$PATH, run with the ./ prefix:"
 
220
                echo -e "\t./genlangsel all"
 
221
                echo -e "\tAll temporary converted files are located in conversions/ path."
 
222
                echo -e "\tThe final output is stored in output/ and should be moved up to the rasmol/src directory after compiling."
 
223
 
 
224
                exit 0;
 
225
 
 
226
                ;;
 
227
 
 
228
        mac)
 
229
                iconvmac
 
230
                ;;
 
231
 
 
232
        mswin)
 
233
                iconvit mswin
 
234
                ;;
 
235
 
 
236
        unix)
 
237
                iconvit unix
 
238
                ;;
 
239
 
 
240
        all)
 
241
                iconvit mswin
 
242
                iconvit unix
 
243
                iconvmac
 
244
                ;;
 
245
 
 
246
        *)
 
247
                iconvit mswin
 
248
                iconvit unix
 
249
                iconvmac
 
250
                ;;
 
251
esac