~ubuntu-branches/ubuntu/maverick/texinfo/maverick

« back to all changes in this revision

Viewing changes to makeinfo/lang.c

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Preining
  • Date: 2005-10-28 15:10:30 UTC
  • mto: (2.1.1 dapper) (3.1.4 hardy)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20051028151030-9nsf2s2k2z3fktjt
Tags: upstream-4.8
ImportĀ upstreamĀ versionĀ 4.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* lang.c -- language-dependent support.
2
 
   $Id: lang.c,v 1.14 2001/09/11 18:04:35 karl Exp $
 
2
   $Id: lang.c,v 1.14 2004/11/22 23:57:33 karl Exp $
3
3
 
4
 
   Copyright (C) 1999, 2000, 01 Free Software Foundation, Inc.
 
4
   Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 Free Software
 
5
   Foundation, Inc.
5
6
 
6
7
   This program is free software; you can redistribute it and/or modify
7
8
   it under the terms of the GNU General Public License as published by
21
22
 
22
23
#include "system.h"
23
24
#include "cmds.h"
 
25
#include "files.h"
24
26
#include "lang.h"
25
27
#include "makeinfo.h"
26
28
#include "xml.h"
31
33
/* Current language code; default is English.  */
32
34
language_code_type language_code = en;
33
35
 
 
36
/* By default, unsupported encoding is an empty string.  */
 
37
char *unknown_encoding = NULL;
 
38
 
 
39
static iso_map_type us_ascii_map [] = {{NULL, 0, 0}}; /* ASCII map is trivial */
 
40
 
34
41
/* Translation table between HTML and ISO Codes.  The last item is
35
42
   hopefully the Unicode. It might be possible that those Unicodes are
36
43
   not correct, cause I didn't check them. kama */
37
 
iso_map_type iso8859_1_map [] = {
 
44
static iso_map_type iso8859_1_map [] = {
38
45
  { "nbsp",   0xA0, 0x00A0 },
39
46
  { "iexcl",  0xA1, 0x00A1 },
40
47
  { "cent",   0xA2, 0x00A2 },
84
91
  { "Iacute", 0xCD, 0x00CD },
85
92
  { "Icirc",  0xCE, 0x00CE },
86
93
  { "Iuml",   0xCF, 0x00CF },
87
 
  { "ETH",    0xD0, 0x00D0 },  /* I don't know ;-( */
88
 
  { "Ntilde", 0xD1, 0x00D1 },
89
 
  { "Ograve", 0xD2, 0x00D2 },
90
 
  { "Oacute", 0xD3, 0x00D3 },
91
 
  { "Ocirc",  0xD4, 0x00D4 },
92
 
  { "Otilde", 0xD5, 0x00D5 },
93
 
  { "Ouml",   0xD6, 0x00D6 },
94
 
  { "times",  0xD7, 0x00D7 },
95
 
  { "Oslash", 0xD8, 0x00D8 },
96
 
  { "Ugrave", 0xD9, 0x00D9 },
97
 
  { "Uacute", 0xDA, 0x00DA },
98
 
  { "Ucirc",  0xDB, 0x00DB },
99
 
  { "Uuml",   0xDC, 0x00DC },
100
 
  { "Yacute", 0xDD, 0x00DD },
101
 
  { "THORN",  0xDE, 0x00DE },
102
 
  { "szlig",  0xDF, 0x00DF },
103
 
  { "agrave", 0xE0, 0x00E0 },
104
 
  { "aacute", 0xE1, 0x00E1 },
105
 
  { "acirc",  0xE2, 0x00E2 },
106
 
  { "atilde", 0xE3, 0x00E3 },
107
 
  { "auml",   0xE4, 0x00E4 },
108
 
  { "aring",  0xE5, 0x00E5 },
109
 
  { "aelig",  0xE6, 0x00E6 },
110
 
  { "ccedil", 0xE7, 0x00E7 },
111
 
  { "egrave", 0xE8, 0x00E8 },
112
 
  { "eacute", 0xE9, 0x00E9 },
113
 
  { "ecirc",  0xEA, 0x00EA },
114
 
  { "euml",   0xEB, 0x00EB },
115
 
  { "igrave", 0xEC, 0x00EC },
116
 
  { "iacute", 0xED, 0x00ED },
117
 
  { "icirc",  0xEE, 0x00EE },
118
 
  { "iuml",   0xEF, 0x00EF },
119
 
  { "eth",    0xF0, 0x00F0 },
120
 
  { "ntilde", 0xF1, 0x00F1 },
121
 
  { "ograve", 0xF2, 0x00F2 },
122
 
  { "oacute", 0xF3, 0x00F3 },
123
 
  { "ocirc",  0xF4, 0x00F4 },
124
 
  { "otilde", 0xF5, 0x00F5 },
125
 
  { "ouml",   0xF6, 0x00F6 },
126
 
  { "divide", 0xF7, 0x00F7 },
127
 
  { "oslash", 0xF8, 0x00F8 },
128
 
  { "ugrave", 0xF9, 0x00F9 },
129
 
  { "uacute", 0xFA, 0x00FA },
130
 
  { "ucirc",  0xFB, 0x00FB },
131
 
  { "uuml",   0xFC, 0x00FC },
132
 
  { "yacute", 0xFD, 0x00FD },
133
 
  { "thorn",  0xFE, 0x00FE },
134
 
  { "yuml",   0xFF, 0x00FF }
135
 
};
136
 
 
137
 
/* This might be put into structure below and NOT coded via define,
138
 
   because some translation tables could contain different numbers of
139
 
   characters, but for now it suffices.  */
140
 
#define ISO_MAP_SIZE (sizeof (iso8859_1_map) / sizeof (iso8859_1_map[0]))
 
94
  { "ETH",    0xD0, 0x00D0 },
 
95
  { "Ntilde", 0xD1, 0x00D1 },
 
96
  { "Ograve", 0xD2, 0x00D2 },
 
97
  { "Oacute", 0xD3, 0x00D3 },
 
98
  { "Ocirc",  0xD4, 0x00D4 },
 
99
  { "Otilde", 0xD5, 0x00D5 },
 
100
  { "Ouml",   0xD6, 0x00D6 },
 
101
  { "times",  0xD7, 0x00D7 },
 
102
  { "Oslash", 0xD8, 0x00D8 },
 
103
  { "Ugrave", 0xD9, 0x00D9 },
 
104
  { "Uacute", 0xDA, 0x00DA },
 
105
  { "Ucirc",  0xDB, 0x00DB },
 
106
  { "Uuml",   0xDC, 0x00DC },
 
107
  { "Yacute", 0xDD, 0x00DD },
 
108
  { "THORN",  0xDE, 0x00DE },
 
109
  { "szlig",  0xDF, 0x00DF },
 
110
  { "agrave", 0xE0, 0x00E0 },
 
111
  { "aacute", 0xE1, 0x00E1 },
 
112
  { "acirc",  0xE2, 0x00E2 },
 
113
  { "atilde", 0xE3, 0x00E3 },
 
114
  { "auml",   0xE4, 0x00E4 },
 
115
  { "aring",  0xE5, 0x00E5 },
 
116
  { "aelig",  0xE6, 0x00E6 },
 
117
  { "ccedil", 0xE7, 0x00E7 },
 
118
  { "egrave", 0xE8, 0x00E8 },
 
119
  { "eacute", 0xE9, 0x00E9 },
 
120
  { "ecirc",  0xEA, 0x00EA },
 
121
  { "euml",   0xEB, 0x00EB },
 
122
  { "igrave", 0xEC, 0x00EC },
 
123
  { "iacute", 0xED, 0x00ED },
 
124
  { "icirc",  0xEE, 0x00EE },
 
125
  { "iuml",   0xEF, 0x00EF },
 
126
  { "eth",    0xF0, 0x00F0 },
 
127
  { "ntilde", 0xF1, 0x00F1 },
 
128
  { "ograve", 0xF2, 0x00F2 },
 
129
  { "oacute", 0xF3, 0x00F3 },
 
130
  { "ocirc",  0xF4, 0x00F4 },
 
131
  { "otilde", 0xF5, 0x00F5 },
 
132
  { "ouml",   0xF6, 0x00F6 },
 
133
  { "divide", 0xF7, 0x00F7 },
 
134
  { "oslash", 0xF8, 0x00F8 },
 
135
  { "ugrave", 0xF9, 0x00F9 },
 
136
  { "uacute", 0xFA, 0x00FA },
 
137
  { "ucirc",  0xFB, 0x00FB },
 
138
  { "uuml",   0xFC, 0x00FC },
 
139
  { "yacute", 0xFD, 0x00FD },
 
140
  { "thorn",  0xFE, 0x00FE },
 
141
  { "yuml",   0xFF, 0x00FF },
 
142
  { NULL, 0, 0 }
 
143
};
 
144
 
 
145
 
 
146
/* ISO 8859-15, also known as Latin 9, differs from Latin 1 in only a
 
147
   few positions.  http://www.cs.tut.fi/~jkorpela/latin9.html has a good
 
148
   explanation and listing, summarized here.  The names are abbreviated
 
149
   from the official Unicode names, to fit in a decent line length.
 
150
 
 
151
  code position
 
152
  dec   oct   hex   latin1 latin1 name        latin9 latin9 name
 
153
 
 
154
  164  0244  0xA4   U+00A4 currency symbol    U+20AC euro sign
 
155
  166  0246  0xA6   U+00A6 broken bar         U+0160 S with caron
 
156
  168  0250  0xA8   U+00A8 diaeresis          U+0161 s with caron
 
157
  180  0264  0xB4   U+00B4 acute accent       U+017D Z with caron
 
158
  184  0270  0xB8   U+00B8 cedilla            U+017E z with caron
 
159
  188  0274  0xBC   U+00BC fraction 1/4       U+0152 ligature OE
 
160
  189  0275  0xBD   U+00BD fraction 1/2       U+0153 ligature oe
 
161
  190  0276  0xBE   U+00BE fraction 3/4       U+0178 Y with diaeresis
 
162
*/
 
163
 
 
164
static iso_map_type iso8859_15_map [] = {
 
165
  { "nbsp",   0xA0, 0x00A0 },
 
166
  { "iexcl",  0xA1, 0x00A1 },
 
167
  { "cent",   0xA2, 0x00A2 },
 
168
  { "pound",  0xA3, 0x00A3 },
 
169
  { "euro",   0xA4, 0x20AC },
 
170
  { "yen",    0xA5, 0x00A5 },
 
171
  { "Scaron", 0xA6, 0x0160 },
 
172
  { "sect",   0xA7, 0x00A7 },
 
173
  { "scaron", 0xA8, 0x0161 },
 
174
  { "copy",   0xA9, 0x00A9 },
 
175
  { "ordf",   0xAA, 0x00AA },
 
176
  { "laquo",  0xAB, 0x00AB },
 
177
  { "not",    0xAC, 0x00AC },
 
178
  { "shy",    0xAD, 0x00AD },
 
179
  { "reg",    0xAE, 0x00AE },
 
180
  { "hibar",  0xAF, 0x00AF },
 
181
  { "deg",    0xB0, 0x00B0 },
 
182
  { "plusmn", 0xB1, 0x00B1 },
 
183
  { "sup2",   0xB2, 0x00B2 },
 
184
  { "sup3",   0xB3, 0x00B3 },
 
185
  { "Zcaron", 0xB4, 0x017D },
 
186
  { "micro",  0xB5, 0x00B5 },
 
187
  { "para",   0xB6, 0x00B6 },
 
188
  { "middot", 0xB7, 0x00B7 },
 
189
  { "zcaron", 0xB8, 0x017E },
 
190
  { "sup1",   0xB9, 0x00B9 },
 
191
  { "ordm",   0xBA, 0x00BA },
 
192
  { "raquo",  0xBB, 0x00BB },
 
193
  { "OElig",  0xBC, 0x0152 },
 
194
  { "oelig",  0xBD, 0x0153 },
 
195
  { "Yuml",   0xBE, 0x0178 },
 
196
  { "iquest", 0xBF, 0x00BF },
 
197
  { "Agrave", 0xC0, 0x00C0 },
 
198
  { "Aacute", 0xC1, 0x00C1 },
 
199
  { "Acirc",  0xC2, 0x00C2 },
 
200
  { "Atilde", 0xC3, 0x00C3 },
 
201
  { "Auml",   0xC4, 0x00C4 },
 
202
  { "Aring",  0xC5, 0x00C5 },
 
203
  { "AElig",  0xC6, 0x00C6 },
 
204
  { "Ccedil", 0xC7, 0x00C7 },
 
205
  { "Ccedil", 0xC7, 0x00C7 },
 
206
  { "Egrave", 0xC8, 0x00C8 },
 
207
  { "Eacute", 0xC9, 0x00C9 },
 
208
  { "Ecirc",  0xCA, 0x00CA },
 
209
  { "Euml",   0xCB, 0x00CB },
 
210
  { "Igrave", 0xCC, 0x00CC },
 
211
  { "Iacute", 0xCD, 0x00CD },
 
212
  { "Icirc",  0xCE, 0x00CE },
 
213
  { "Iuml",   0xCF, 0x00CF },
 
214
  { "ETH",    0xD0, 0x00D0 },
 
215
  { "Ntilde", 0xD1, 0x00D1 },
 
216
  { "Ograve", 0xD2, 0x00D2 },
 
217
  { "Oacute", 0xD3, 0x00D3 },
 
218
  { "Ocirc",  0xD4, 0x00D4 },
 
219
  { "Otilde", 0xD5, 0x00D5 },
 
220
  { "Ouml",   0xD6, 0x00D6 },
 
221
  { "times",  0xD7, 0x00D7 },
 
222
  { "Oslash", 0xD8, 0x00D8 },
 
223
  { "Ugrave", 0xD9, 0x00D9 },
 
224
  { "Uacute", 0xDA, 0x00DA },
 
225
  { "Ucirc",  0xDB, 0x00DB },
 
226
  { "Uuml",   0xDC, 0x00DC },
 
227
  { "Yacute", 0xDD, 0x00DD },
 
228
  { "THORN",  0xDE, 0x00DE },
 
229
  { "szlig",  0xDF, 0x00DF },
 
230
  { "agrave", 0xE0, 0x00E0 },
 
231
  { "aacute", 0xE1, 0x00E1 },
 
232
  { "acirc",  0xE2, 0x00E2 },
 
233
  { "atilde", 0xE3, 0x00E3 },
 
234
  { "auml",   0xE4, 0x00E4 },
 
235
  { "aring",  0xE5, 0x00E5 },
 
236
  { "aelig",  0xE6, 0x00E6 },
 
237
  { "ccedil", 0xE7, 0x00E7 },
 
238
  { "egrave", 0xE8, 0x00E8 },
 
239
  { "eacute", 0xE9, 0x00E9 },
 
240
  { "ecirc",  0xEA, 0x00EA },
 
241
  { "euml",   0xEB, 0x00EB },
 
242
  { "igrave", 0xEC, 0x00EC },
 
243
  { "iacute", 0xED, 0x00ED },
 
244
  { "icirc",  0xEE, 0x00EE },
 
245
  { "iuml",   0xEF, 0x00EF },
 
246
  { "eth",    0xF0, 0x00F0 },
 
247
  { "ntilde", 0xF1, 0x00F1 },
 
248
  { "ograve", 0xF2, 0x00F2 },
 
249
  { "oacute", 0xF3, 0x00F3 },
 
250
  { "ocirc",  0xF4, 0x00F4 },
 
251
  { "otilde", 0xF5, 0x00F5 },
 
252
  { "ouml",   0xF6, 0x00F6 },
 
253
  { "divide", 0xF7, 0x00F7 },
 
254
  { "oslash", 0xF8, 0x00F8 },
 
255
  { "ugrave", 0xF9, 0x00F9 },
 
256
  { "uacute", 0xFA, 0x00FA },
 
257
  { "ucirc",  0xFB, 0x00FB },
 
258
  { "uuml",   0xFC, 0x00FC },
 
259
  { "yacute", 0xFD, 0x00FD },
 
260
  { "thorn",  0xFE, 0x00FE },
 
261
  { "yuml",   0xFF, 0x00FF },
 
262
  { NULL, 0, 0 }
 
263
};
 
264
 
 
265
 
 
266
 
 
267
/* Date: Mon, 31 Mar 2003 00:19:28 +0200
 
268
   From: Wojciech Polak <polak@gnu.org>
 
269
...
 
270
 * Primary Polish site for ogonki is http://www.agh.edu.pl/ogonki/,
 
271
   but it's only in Polish language (it has some interesting links).
 
272
 
 
273
 * A general site about ISO 8859-2 at http://nl.ijs.si/gnusl/cee/iso8859-2.html
 
274
 
 
275
 * ISO 8859-2 Character Set at http://nl.ijs.si/gnusl/cee/charset.html
 
276
   This site provides almost all information about iso-8859-2,
 
277
   including the character table!!! (must see!)
 
278
 
 
279
 * ISO 8859-2 and even HTML entities !!! (must see!)
 
280
   http://people.ssh.fi/mtr/genscript/88592.txt
 
281
 
 
282
 * (minor) http://www.agh.edu.pl/ogonki/plchars.html
 
283
   One more table, this time it includes even information about Polish
 
284
   characters in Unicode.
 
285
*/
 
286
 
 
287
static iso_map_type iso8859_2_map [] = {
 
288
  { "nbsp",     0xA0, 0x00A0 }, /* NO-BREAK SPACE */
 
289
  { "", 0xA1, 0x0104 }, /* LATIN CAPITAL LETTER A WITH OGONEK */
 
290
  { "", 0xA2, 0x02D8 }, /* BREVE */
 
291
  { "", 0xA3, 0x0141 }, /* LATIN CAPITAL LETTER L WITH STROKE */
 
292
  { "curren",   0xA4, 0x00A4 }, /* CURRENCY SIGN */
 
293
  { "", 0xA5, 0x013D }, /* LATIN CAPITAL LETTER L WITH CARON */
 
294
  { "", 0xA6, 0x015A }, /* LATIN CAPITAL LETTER S WITH ACUTE */
 
295
  { "sect",     0xA7, 0x00A7 }, /* SECTION SIGN */
 
296
  { "uml",      0xA8, 0x00A8 }, /* DIAERESIS */
 
297
  { "", 0xA9, 0x0160 }, /* LATIN CAPITAL LETTER S WITH CARON */
 
298
  { "", 0xAA, 0x015E }, /* LATIN CAPITAL LETTER S WITH CEDILLA */
 
299
  { "", 0xAB, 0x0164 }, /* LATIN CAPITAL LETTER T WITH CARON */
 
300
  { "", 0xAC, 0x0179 }, /* LATIN CAPITAL LETTER Z WITH ACUTE */
 
301
  { "shy",      0xAD, 0x00AD }, /* SOFT HYPHEN */
 
302
  { "", 0xAE, 0x017D }, /* LATIN CAPITAL LETTER Z WITH CARON */
 
303
  { "", 0xAF, 0x017B }, /* LATIN CAPITAL LETTER Z WITH DOT ABOVE */
 
304
  { "deg",      0xB0, 0x00B0 }, /* DEGREE SIGN */
 
305
  { "", 0xB1, 0x0105 }, /* LATIN SMALL LETTER A WITH OGONEK */
 
306
  { "", 0xB2, 0x02DB }, /* OGONEK */
 
307
  { "", 0xB3, 0x0142 }, /* LATIN SMALL LETTER L WITH STROKE */
 
308
  { "acute",    0xB4, 0x00B4 }, /* ACUTE ACCENT */
 
309
  { "", 0xB5, 0x013E }, /* LATIN SMALL LETTER L WITH CARON */
 
310
  { "", 0xB6, 0x015B }, /* LATIN SMALL LETTER S WITH ACUTE */
 
311
  { "", 0xB7, 0x02C7 }, /* CARON (Mandarin Chinese third tone) */
 
312
  { "cedil",    0xB8, 0x00B8 }, /* CEDILLA */
 
313
  { "", 0xB9, 0x0161 }, /* LATIN SMALL LETTER S WITH CARON */
 
314
  { "", 0xBA, 0x015F }, /* LATIN SMALL LETTER S WITH CEDILLA */
 
315
  { "", 0xBB, 0x0165 }, /* LATIN SMALL LETTER T WITH CARON */
 
316
  { "", 0xBC, 0x017A }, /* LATIN SMALL LETTER Z WITH ACUTE */
 
317
  { "", 0xBD, 0x02DD }, /* DOUBLE ACUTE ACCENT */
 
318
  { "", 0xBE, 0x017E }, /* LATIN SMALL LETTER Z WITH CARON */
 
319
  { "", 0xBF, 0x017C }, /* LATIN SMALL LETTER Z WITH DOT ABOVE */
 
320
  { "", 0xC0, 0x0154 }, /* LATIN CAPITAL LETTER R WITH ACUTE */
 
321
  { "", 0xC1, 0x00C1 }, /* LATIN CAPITAL LETTER A WITH ACUTE */
 
322
  { "", 0xC2, 0x00C2 }, /* LATIN CAPITAL LETTER A WITH CIRCUMFLEX */
 
323
  { "", 0xC3, 0x0102 }, /* LATIN CAPITAL LETTER A WITH BREVE */
 
324
  { "", 0xC4, 0x00C4 }, /* LATIN CAPITAL LETTER A WITH DIAERESIS */
 
325
  { "", 0xC5, 0x0139 }, /* LATIN CAPITAL LETTER L WITH ACUTE */
 
326
  { "", 0xC6, 0x0106 }, /* LATIN CAPITAL LETTER C WITH ACUTE */
 
327
  { "", 0xC7, 0x00C7 }, /* LATIN CAPITAL LETTER C WITH CEDILLA */
 
328
  { "", 0xC8, 0x010C }, /* LATIN CAPITAL LETTER C WITH CARON */
 
329
  { "", 0xC9, 0x00C9 }, /* LATIN CAPITAL LETTER E WITH ACUTE */
 
330
  { "", 0xCA, 0x0118 }, /* LATIN CAPITAL LETTER E WITH OGONEK */
 
331
  { "", 0xCB, 0x00CB }, /* LATIN CAPITAL LETTER E WITH DIAERESIS */
 
332
  { "", 0xCC, 0x011A }, /* LATIN CAPITAL LETTER E WITH CARON */
 
333
  { "", 0xCD, 0x00CD }, /* LATIN CAPITAL LETTER I WITH ACUTE */
 
334
  { "", 0xCE, 0x00CE }, /* LATIN CAPITAL LETTER I WITH CIRCUMFLEX */
 
335
  { "", 0xCF, 0x010E }, /* LATIN CAPITAL LETTER D WITH CARON */
 
336
  { "", 0xD0, 0x0110 }, /* LATIN CAPITAL LETTER D WITH STROKE */
 
337
  { "", 0xD1, 0x0143 }, /* LATIN CAPITAL LETTER N WITH ACUTE */
 
338
  { "", 0xD2, 0x0147 }, /* LATIN CAPITAL LETTER N WITH CARON */
 
339
  { "", 0xD3, 0x00D3 }, /* LATIN CAPITAL LETTER O WITH ACUTE */
 
340
  { "", 0xD4, 0x00D4 }, /* LATIN CAPITAL LETTER O WITH CIRCUMFLEX */
 
341
  { "", 0xD5, 0x0150 }, /* LATIN CAPITAL LETTER O WITH DOUBLE ACUTE */
 
342
  { "", 0xD6, 0x00D6 }, /* LATIN CAPITAL LETTER O WITH DIAERESIS */
 
343
  { "times",    0xD7, 0x00D7 }, /* MULTIPLICATION SIGN */
 
344
  { "", 0xD8, 0x0158 }, /* LATIN CAPITAL LETTER R WITH CARON */
 
345
  { "", 0xD9, 0x016E }, /* LATIN CAPITAL LETTER U WITH RING ABOVE */
 
346
  { "", 0xDA, 0x00DA }, /* LATIN CAPITAL LETTER U WITH ACUTE */
 
347
  { "", 0xDB, 0x0170 }, /* LATIN CAPITAL LETTER U WITH DOUBLE ACUTE */
 
348
  { "", 0xDC, 0x00DC }, /* LATIN CAPITAL LETTER U WITH DIAERESIS */
 
349
  { "", 0xDD, 0x00DD }, /* LATIN CAPITAL LETTER Y WITH ACUTE */
 
350
  { "", 0xDE, 0x0162 }, /* LATIN CAPITAL LETTER T WITH CEDILLA */
 
351
  { "", 0xDF, 0x00DF }, /* LATIN SMALL LETTER SHARP S (German) */
 
352
  { "", 0xE0, 0x0155 }, /* LATIN SMALL LETTER R WITH ACUTE */
 
353
  { "", 0xE1, 0x00E1 }, /* LATIN SMALL LETTER A WITH ACUTE */
 
354
  { "", 0xE2, 0x00E2 }, /* LATIN SMALL LETTER A WITH CIRCUMFLEX */
 
355
  { "", 0xE3, 0x0103 }, /* LATIN SMALL LETTER A WITH BREVE */
 
356
  { "", 0xE4, 0x00E4 }, /* LATIN SMALL LETTER A WITH DIAERESIS */
 
357
  { "", 0xE5, 0x013A }, /* LATIN SMALL LETTER L WITH ACUTE */
 
358
  { "", 0xE6, 0x0107 }, /* LATIN SMALL LETTER C WITH ACUTE */
 
359
  { "", 0xE7, 0x00E7 }, /* LATIN SMALL LETTER C WITH CEDILLA */
 
360
  { "", 0xE8, 0x010D }, /* LATIN SMALL LETTER C WITH CARON */
 
361
  { "", 0xE9, 0x00E9 }, /* LATIN SMALL LETTER E WITH ACUTE */
 
362
  { "", 0xEA, 0x0119 }, /* LATIN SMALL LETTER E WITH OGONEK */
 
363
  { "", 0xEB, 0x00EB }, /* LATIN SMALL LETTER E WITH DIAERESIS */
 
364
  { "", 0xEC, 0x011B }, /* LATIN SMALL LETTER E WITH CARON */
 
365
  { "", 0xED, 0x00ED }, /* LATIN SMALL LETTER I WITH ACUTE */
 
366
  { "", 0xEE, 0x00EE }, /* LATIN SMALL LETTER I WITH CIRCUMFLEX */
 
367
  { "", 0xEF, 0x010F }, /* LATIN SMALL LETTER D WITH CARON */
 
368
  { "", 0xF0, 0x0111 }, /* LATIN SMALL LETTER D WITH STROKE */
 
369
  { "", 0xF1, 0x0144 }, /* LATIN SMALL LETTER N WITH ACUTE */
 
370
  { "", 0xF2, 0x0148 }, /* LATIN SMALL LETTER N WITH CARON */
 
371
  { "", 0xF3, 0x00F3 }, /* LATIN SMALL LETTER O WITH ACUTE */
 
372
  { "", 0xF4, 0x00F4 }, /* LATIN SMALL LETTER O WITH CIRCUMFLEX */
 
373
  { "", 0xF5, 0x0151 }, /* LATIN SMALL LETTER O WITH DOUBLE ACUTE */
 
374
  { "", 0xF6, 0x00F6 }, /* LATIN SMALL LETTER O WITH DIAERESIS */
 
375
  { "divide",   0xF7, 0x00F7 }, /* DIVISION SIGN */
 
376
  { "", 0xF8, 0x0159 }, /* LATIN SMALL LETTER R WITH CARON */
 
377
  { "", 0xF9, 0x016F }, /* LATIN SMALL LETTER U WITH RING ABOVE */
 
378
  { "", 0xFA, 0x00FA }, /* LATIN SMALL LETTER U WITH ACUTE */
 
379
  { "", 0xFB, 0x0171 }, /* LATIN SMALL LETTER U WITH DOUBLE ACUTE */
 
380
  { "", 0xFC, 0x00FC }, /* LATIN SMALL LETTER U WITH DIAERESIS */
 
381
  { "", 0xFD, 0x00FD }, /* LATIN SMALL LETTER Y WITH ACUTE */
 
382
  { "", 0xFE, 0x0163 }, /* LATIN SMALL LETTER T WITH CEDILLA */
 
383
  { "", 0xFF, 0x02D9 }, /* DOT ABOVE (Mandarin Chinese light tone) */
 
384
  { NULL, 0, 0 }
 
385
};
141
386
 
142
387
encoding_type encoding_table[] = {
143
388
  { no_encoding, "(no encoding)", NULL },
144
 
  { ISO_8859_1,  "ISO-8859-1",  (iso_map_type *) iso8859_1_map },
145
 
  { ISO_8859_2,  "ISO-8859-2",  NULL },
146
 
  { ISO_8859_3,  "ISO-8859-3",  NULL },
147
 
  { ISO_8859_4,  "ISO-8859-4",  NULL },
148
 
  { ISO_8859_5,  "ISO-8859-5",  NULL },
149
 
  { ISO_8859_6,  "ISO-8859-6",  NULL },
150
 
  { ISO_8859_7,  "ISO-8859-7",  NULL },
151
 
  { ISO_8859_8,  "ISO-8859-8",  NULL },
152
 
  { ISO_8859_9,  "ISO-8859-9",  NULL },
153
 
  { ISO_8859_10, "ISO-8859-10", NULL },
154
 
  { ISO_8859_11, "ISO-8859-11", NULL },
155
 
  { ISO_8859_12, "ISO-8859-12", NULL },
156
 
  { ISO_8859_13, "ISO-8859-13", NULL },
157
 
  { ISO_8859_14, "ISO-8859-14", NULL },
158
 
  { ISO_8859_15, "ISO-8859-15", NULL },
 
389
  { US_ASCII,    "US-ASCII",    us_ascii_map },
 
390
  { ISO_8859_1,  "iso-8859-1",  (iso_map_type *) iso8859_1_map },
 
391
  { ISO_8859_2,  "iso-8859-2",  (iso_map_type *) iso8859_2_map },
 
392
  { ISO_8859_3,  "iso-8859-3",  NULL },
 
393
  { ISO_8859_4,  "iso-8859-4",  NULL },
 
394
  { ISO_8859_5,  "iso-8859-5",  NULL },
 
395
  { ISO_8859_6,  "iso-8859-6",  NULL },
 
396
  { ISO_8859_7,  "iso-8859-7",  NULL },
 
397
  { ISO_8859_8,  "iso-8859-8",  NULL },
 
398
  { ISO_8859_9,  "iso-8859-9",  NULL },
 
399
  { ISO_8859_10, "iso-8859-10", NULL },
 
400
  { ISO_8859_11, "iso-8859-11", NULL },
 
401
  { ISO_8859_12, "iso-8859-12", NULL },
 
402
  { ISO_8859_13, "iso-8859-13", NULL },
 
403
  { ISO_8859_14, "iso-8859-14", NULL },
 
404
  { ISO_8859_15, "iso-8859-15", (iso_map_type *) iso8859_15_map },
159
405
  { last_encoding_code, NULL, NULL }
160
406
};
161
407
 
302
548
  { zu, "zu", "Zulu" },
303
549
  { last_language_code, NULL, NULL }
304
550
};
305
 
 
306
 
 
307
551
 
308
552
/* @documentlanguage.  Maybe we'll do something useful with this in the
309
553
   future.  For now, we just recognize it.  */
 
554
 
 
555
/* XML documents can make use of this data.  Unfortunately, it clashes with
 
556
   the structure currently used.  So instead of enclosing content into
 
557
   a language block, we just output an empty element.  Anyways, a stream based
 
558
   parser can make good use of it.  */
310
559
void
311
 
cm_documentlanguage ()
 
560
cm_documentlanguage (void)
312
561
{
313
562
  language_code_type c;
314
 
  char *lang_arg;  
 
563
  char *lang_arg;
315
564
 
316
565
  /* Read the line with the language code on it.  */
317
566
  get_rest_of_line (0, &lang_arg);
330
579
  if (c == last_language_code)
331
580
    warning (_("%s is not a valid ISO 639 language code"), lang_arg);
332
581
 
 
582
  if (xml && !docbook)
 
583
    {
 
584
      xml_insert_element_with_attribute (DOCUMENTLANGUAGE, START, "xml:lang=\"%s\"", lang_arg);
 
585
      xml_insert_element (DOCUMENTLANGUAGE, END);
 
586
    }
 
587
 
333
588
  free (lang_arg);
334
589
}
335
590
 
339
594
   its equivalent.  */
340
595
 
341
596
static int
342
 
cm_search_iso_map (html)
343
 
      char *html;
 
597
cm_search_iso_map (char *html)
344
598
{
345
599
  int i;
346
600
  iso_map_type *iso = encoding_table[document_encoding_code].isotab;
349
603
  if (!iso)
350
604
    return -1;
351
605
 
352
 
  for (i = 0; i < ISO_MAP_SIZE; i++)
 
606
  for (i = 0; iso[i].html; i++)
353
607
    {
354
608
      if (strcmp (html, iso[i].html) == 0)
355
609
        return i;
362
616
/* @documentencoding.  Set the translation table.  */
363
617
 
364
618
void
365
 
cm_documentencoding ()
366
 
{
367
 
  encoding_code_type enc;
368
 
  char *enc_arg;
369
 
  
370
 
  get_rest_of_line (1, &enc_arg);
371
 
 
372
 
  /* See if we have this encoding.  */
373
 
  for (enc = ISO_8859_1; enc != last_encoding_code; enc++)
374
 
    {
375
 
      if (strcasecmp (enc_arg, encoding_table[enc].ecname) == 0)
376
 
        {
377
 
          document_encoding_code = enc;
378
 
          break;
379
 
        }
380
 
    }
381
 
 
382
 
  /* If we didn't find this code, complain.  */
383
 
  if (enc == last_encoding_code)
384
 
    warning (_("unrecogized encoding name `%s'"), enc_arg);
385
 
 
386
 
  else if (encoding_table[document_encoding_code].isotab == NULL)
387
 
    warning (_("sorry, encoding `%s' not supported"), enc_arg);
388
 
 
389
 
  free (enc_arg);
390
 
}
391
 
 
392
 
 
393
 
/* If html or xml output, add HTML_STR to the output.  If not html and
 
619
cm_documentencoding (void)
 
620
{
 
621
  if (!handling_delayed_writes)
 
622
    {
 
623
      encoding_code_type enc;
 
624
      char *enc_arg;
 
625
 
 
626
      /* This is ugly and probably needs to apply to other commands'
 
627
         argument parsing as well.  When we're doing @documentencoding,
 
628
         we're generally in the frontmatter of the document, and so the.
 
629
         expansion in html/xml/docbook would generally be the empty string.
 
630
         (Because those modes wait until the first normal text of the
 
631
         document to start outputting.)  The result would thus be a warning
 
632
         "unrecognized encoding name `'".  Sigh.  */
 
633
      int save_html = html;
 
634
      int save_xml = xml;
 
635
 
 
636
      html = 0;
 
637
      xml = 0;
 
638
      get_rest_of_line (1, &enc_arg);
 
639
      html = save_html;
 
640
      xml = save_xml;
 
641
 
 
642
      /* See if we have this encoding.  */
 
643
      for (enc = no_encoding+1; enc != last_encoding_code; enc++)
 
644
        {
 
645
          if (strcasecmp (enc_arg, encoding_table[enc].encname) == 0)
 
646
            {
 
647
              document_encoding_code = enc;
 
648
              break;
 
649
            }
 
650
        }
 
651
 
 
652
      /* If we didn't find this code, complain.  */
 
653
      if (enc == last_encoding_code)
 
654
        {
 
655
          warning (_("unrecognized encoding name `%s'"), enc_arg);
 
656
          /* Let the previous one go.  */
 
657
          if (unknown_encoding && *unknown_encoding)
 
658
            free (unknown_encoding);
 
659
          unknown_encoding = xstrdup (enc_arg);
 
660
        }
 
661
 
 
662
      else if (encoding_table[document_encoding_code].isotab == NULL)
 
663
        warning (_("sorry, encoding `%s' not supported"), enc_arg);
 
664
 
 
665
      free (enc_arg);
 
666
    }
 
667
  else if (xml)
 
668
    {
 
669
      char *encoding = current_document_encoding ();
 
670
 
 
671
      if (encoding && *encoding)
 
672
        {
 
673
          insert_string (" encoding=\"");
 
674
          insert_string (encoding);
 
675
          insert_string ("\"");
 
676
        }
 
677
 
 
678
      free (encoding);
 
679
    }
 
680
}
 
681
 
 
682
char *
 
683
current_document_encoding (void)
 
684
{
 
685
  if (document_encoding_code != no_encoding)
 
686
    return xstrdup (encoding_table[document_encoding_code].encname);
 
687
  else if (unknown_encoding && *unknown_encoding)
 
688
    return xstrdup (unknown_encoding);
 
689
  else
 
690
    return xstrdup ("");
 
691
}
 
692
 
 
693
 
 
694
/* If html or xml output, add &HTML_STR; to the output.  If not html and
394
695
   the user requested encoded output, add the real 8-bit character
395
696
   corresponding to HTML_STR from the translation tables.  Otherwise,
396
697
   add INFO_STR.  */
397
698
 
398
 
void
399
 
add_encoded_char (html_str, info_str)
400
 
      char *html_str;
401
 
      char *info_str;
 
699
static void
 
700
add_encoded_char (char *html_str, char *info_str)
402
701
{
403
 
  if (html || xml)
 
702
  if (html)
404
703
    add_word_args ("&%s;", html_str);
 
704
  else if (xml)
 
705
    xml_insert_entity (html_str);
405
706
  else if (enable_encoding)
406
707
    {
407
708
      /* Look for HTML_STR in the current translation table.  */
424
725
/* Output an accent for HTML or XML. */
425
726
 
426
727
static void
427
 
cm_accent_generic_html (arg, start, end, html_supported, single,
428
 
                        html_solo_standalone, html_solo)
429
 
     int arg, start, end;
430
 
     char *html_supported;
431
 
     int single;
432
 
     int html_solo_standalone;
433
 
     char *html_solo;
 
728
cm_accent_generic_html (int arg, int start, int end, char *html_supported,
 
729
    int single, int html_solo_standalone, char *html_solo)
434
730
{
435
731
  static int valid_html_accent; /* yikes */
436
 
  
 
732
 
437
733
  if (arg == START)
438
734
    { /* If HTML has good support for this character, use it.  */
439
735
      if (strchr (html_supported, curchar ()))
440
736
        { /* Yes; start with an ampersand.  The character itself
441
737
             will be added later in read_command (makeinfo.c).  */
 
738
          int saved_escape_html = escape_html;
 
739
          escape_html = 0;
442
740
          valid_html_accent = 1;
443
741
          add_char ('&');
 
742
          escape_html = saved_escape_html;
444
743
        }
445
744
      else
446
 
        { 
447
 
          valid_html_accent = 0;
448
 
          if (html_solo_standalone)
449
 
            { /* No special HTML support, so produce standalone char.  */
450
 
              add_word_args ("&%s;", html_solo);
451
 
            }
452
 
          else
453
 
            /* If the html_solo does not exist as standalone character
454
 
               (namely &circ; &grave; &tilde;), then we use
455
 
               the single character version instead.  */
456
 
            add_char (single);
 
745
        { /* @dotless{i} is not listed in html_supported but HTML entities
 
746
             starting with `i' can be used, such as &icirc;.  */
 
747
          int save_input_text_offset = input_text_offset;
 
748
          char *accent_contents;
 
749
 
 
750
          get_until_in_braces ("\n", &accent_contents);
 
751
          canon_white (accent_contents);
 
752
 
 
753
          if (strstr (accent_contents, "@dotless{i"))
 
754
            {
 
755
              add_word_args ("&%c", accent_contents[9]);
 
756
              valid_html_accent = 1;
 
757
            }
 
758
          else
 
759
            {
 
760
              /* Search for @dotless{} wasn't successful, so rewind.  */
 
761
              input_text_offset = save_input_text_offset;
 
762
              valid_html_accent = 0;
 
763
              if (html_solo_standalone)
 
764
                { /* No special HTML support, so produce standalone char.  */
 
765
                  if (xml)
 
766
                    xml_insert_entity (html_solo);
 
767
                  else
 
768
                    add_word_args ("&%s;", html_solo);
 
769
                }
 
770
              else
 
771
                /* If the html_solo does not exist as standalone character
 
772
                   (namely &circ; &grave; &tilde;), then we use
 
773
                   the single character version instead.  */
 
774
                add_char (single);
 
775
            }
 
776
 
 
777
          free (accent_contents);
457
778
        }
458
779
    }
459
780
  else if (arg == END)
469
790
 
470
791
 
471
792
static void
472
 
cm_accent_generic_no_headers (arg, start, end, single, html_solo)
473
 
     int arg, start, end;
474
 
     int single;
475
 
     char *html_solo;
 
793
cm_accent_generic_no_headers (int arg, int start, int end, int single,
 
794
    char *html_solo)
476
795
{
477
796
  if (arg == END)
478
797
    {
485
804
          buffer[0] = output_paragraph[end - 1];
486
805
          buffer[1] = 0;
487
806
          strcat (buffer, html_solo);
488
 
          
 
807
 
489
808
          rc = cm_search_iso_map (buffer);
490
809
          if (rc >= 0)
491
810
            /* A little bit tricky ;-)
498
817
          else
499
818
            { /* If we didn't find a translation for this character,
500
819
                 put the single instead. E.g., &Xuml; does not exist so X&uml;
501
 
                 should be produced. */ 
502
 
              warning (_("%s is an invalid ISO code, using %c"),
503
 
                       buffer, single);
 
820
                 should be produced. */
 
821
              /* When the below warning is issued, an author has nothing
 
822
                 wrong in their document, let alone anything ``fixable''
 
823
                 on their side.  So it is commented out for now.  */
 
824
              /* warning (_("%s is an invalid ISO code, using %c"),
 
825
                       buffer, single); */
504
826
              add_char (single);
505
827
            }
506
 
          
 
828
 
507
829
          free (buffer);
508
830
        }
509
831
    }
515
837
   special HTML support.  */
516
838
 
517
839
void
518
 
cm_accent (arg)
519
 
    int arg;
 
840
cm_accent (int arg)
520
841
{
521
842
  int old_escape_html = escape_html;
522
843
  escape_html = 0;
558
879
   exists as valid standalone character in HTML, e.g., &uml;.  */
559
880
 
560
881
static void
561
 
cm_accent_generic (arg, start, end, html_supported, single,
562
 
                   html_solo_standalone, html_solo)
563
 
     int arg, start, end;
564
 
     char *html_supported;
565
 
     int single;
566
 
     int html_solo_standalone;
567
 
     char *html_solo;
 
882
cm_accent_generic (int arg, int start, int end, char *html_supported,
 
883
    int single, int html_solo_standalone, char *html_solo)
568
884
{
 
885
  /* Accentuating space characters makes no sense, so issue a warning.  */
 
886
  if (arg == START && isspace (input_text[input_text_offset]))
 
887
    warning ("Accent command `@%s' must not be followed by whitespace",
 
888
        command);
 
889
 
569
890
  if (html || xml)
570
891
    cm_accent_generic_html (arg, start, end, html_supported,
571
892
                            single, html_solo_standalone, html_solo);
572
893
  else if (no_headers)
573
894
    cm_accent_generic_no_headers (arg, start, end, single, html_solo);
574
895
  else if (arg == END)
575
 
    { 
 
896
    {
576
897
      if (enable_encoding)
577
898
        /* use 8-bit if available */
578
899
        cm_accent_generic_no_headers (arg, start, end, single, html_solo);
583
904
}
584
905
 
585
906
void
586
 
cm_accent_umlaut (arg, start, end)
587
 
     int arg, start, end;
 
907
cm_accent_umlaut (int arg, int start, int end)
588
908
{
589
909
  cm_accent_generic (arg, start, end, "aouAOUEeIiy", '"', 1, "uml");
590
910
}
591
911
 
592
912
void
593
 
cm_accent_acute (arg, start, end)
594
 
     int arg, start, end;
 
913
cm_accent_acute (int arg, int start, int end)
595
914
{
596
915
  cm_accent_generic (arg, start, end, "AEIOUYaeiouy", '\'', 1, "acute");
597
916
}
598
917
 
599
918
void
600
 
cm_accent_cedilla (arg, start, end)
601
 
     int arg, start, end;
 
919
cm_accent_cedilla (int arg, int start, int end)
602
920
{
603
921
  cm_accent_generic (arg, start, end, "Cc", ',', 1, "cedil");
604
922
}
605
923
 
606
924
void
607
 
cm_accent_hat (arg, start, end)
608
 
     int arg, start, end;
 
925
cm_accent_hat (int arg, int start, int end)
609
926
{
610
927
  cm_accent_generic (arg, start, end, "AEIOUaeiou", '^', 0, "circ");
611
928
}
612
929
 
613
930
void
614
 
cm_accent_grave (arg, start, end)
615
 
     int arg, start, end;
 
931
cm_accent_grave (int arg, int start, int end)
616
932
{
617
933
  cm_accent_generic (arg, start, end, "AEIOUaeiou", '`', 0, "grave");
618
934
}
619
935
 
620
936
void
621
 
cm_accent_tilde (arg, start, end)
622
 
     int arg, start, end;
 
937
cm_accent_tilde (int arg, int start, int end)
623
938
{
624
939
  cm_accent_generic (arg, start, end, "ANOano", '~', 0, "tilde");
625
940
}
628
943
 
629
944
/* Non-English letters/characters that don't insert themselves.  */
630
945
void
631
 
cm_special_char (arg)
 
946
cm_special_char (int arg)
632
947
{
633
948
  int old_escape_html = escape_html;
634
949
  escape_html = 0;
640
955
          && command[1] == 0)
641
956
        { /* Lslash lslash Oslash oslash.
642
957
             Lslash and lslash aren't supported in HTML.  */
643
 
          if ((html || xml) && command[0] == 'O')
 
958
          if (command[0] == 'O')
644
959
            add_encoded_char ("Oslash", "/O");
645
 
          else if ((html || xml) && command[0] == 'o')
 
960
          else if (command[0] == 'o')
646
961
            add_encoded_char ("oslash", "/o");
647
962
          else
648
963
            add_word_args ("/%c", command[0]);
649
964
        }
650
965
      else if (strcmp (command, "exclamdown") == 0)
651
966
        add_encoded_char ("iexcl", "!");
 
967
      else if (strcmp (command, "questiondown") == 0)
 
968
        add_encoded_char ("iquest", "?");
 
969
      else if (strcmp (command, "euro") == 0)
 
970
        /* http://www.cs.tut.fi/~jkorpela/html/euro.html suggests that
 
971
           &euro; degrades best in old browsers.  */
 
972
        add_encoded_char ("euro", "Euro ");
652
973
      else if (strcmp (command, "pounds") == 0)
653
974
        add_encoded_char ("pound" , "#");
654
 
      else if (strcmp (command, "questiondown") == 0)
655
 
        add_encoded_char ("iquest", "?");
 
975
      else if (strcmp (command, "ordf") == 0)
 
976
        add_encoded_char ("ordf" , "a");
 
977
      else if (strcmp (command, "ordm") == 0)
 
978
        add_encoded_char ("ordm" , "o");
656
979
      else if (strcmp (command, "AE") == 0)
657
980
        add_encoded_char ("AElig", command);
658
981
      else if (strcmp (command, "ae") == 0)
659
982
        add_encoded_char ("aelig",  command);
660
983
      else if (strcmp (command, "OE") == 0)
661
 
        add_word ("&#140;", command);
 
984
        add_encoded_char ("OElig", command);
662
985
      else if (strcmp (command, "oe") == 0)
663
 
        add_word ("&#156;", command);
 
986
        add_encoded_char ("oelig", command);
664
987
      else if (strcmp (command, "AA") == 0)
665
988
        add_encoded_char ("Aring", command);
666
989
      else if (strcmp (command, "aa") == 0)
675
998
 
676
999
/* Dotless i or j.  */
677
1000
void
678
 
cm_dotless (arg, start, end)
679
 
    int arg, start, end;
 
1001
cm_dotless (int arg, int start, int end)
680
1002
{
681
1003
  if (arg == END)
682
1004
    {