Debian Codegraph @

src/lat1ltex.c

raw symbols SCIP
1 /* Conversion of files between different charsets and surfaces.
2 Copyright © 1990-2018 Free Software Foundation, Inc.
3 Contributed by François Pinard <[email protected]>, 1988.
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public License
7 as published by the Free Software Foundation; either version 3 of the
8 License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be
11 useful, but WITHOUT ANY WARRANTY; without even the implied warranty
12 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the Recode Library; see the file `COPYING.LIB'.
17 If not, see <https://www.gnu.org/licenses/>.
18 */
19
20 #include "config.h"
21 #include "common.h"
22 #include "decsteps.h"
23
24 struct translation
25 {
26 unsigned code; /* code being translated */
27 const char *string; /* translation string */
28 };
29
30 static struct translation const diacritic_translations [] =
31 {
32 {192, "\\`A"}, /* capital A with grave accent */
33 {193, "\\'A"}, /* capital A with acute accent */
34 {194, "\\^A"}, /* capital A with circumflex accent */
35 {195, "\\~A"}, /* capital A with tilde */
36 {196, "\\\"A"}, /* capital A diaeresis */
37 {197, "\\AA{}"}, /* capital A with ring above */
38 {198, "\\AE{}"}, /* capital diphthong A with E */
39 {199, "\\c{C}"}, /* capital C with cedilla */
40 {200, "\\`E"}, /* capital E with grave accent */
41 {201, "\\'E"}, /* capital E with acute accent */
42 {202, "\\^E"}, /* capital E with circumflex accent */
43 {203, "\\\"E"}, /* capital E with diaeresis */
44 {204, "\\`I"}, /* capital I with grave accent */
45 {205, "\\'I"}, /* capital I with acute accent */
46 {206, "\\^I"}, /* capital I with circumflex accent */
47 {207, "\\\"I"}, /* capital I with diaeresis */
48 {209, "\\~N"}, /* capital N with tilde */
49 {210, "\\`O"}, /* capital O with grave accent */
50 {211, "\\'O"}, /* capital O with acute accent */
51 {212, "\\^O"}, /* capital O with circumflex accent */
52 {213, "\\~O"}, /* capital O with tilde */
53 {214, "\\\"O"}, /* capital O with diaeresis */
54 {216, "\\O{}"}, /* capital O with oblique stroke */
55 {217, "\\`U"}, /* capital U with grave accent */
56 {218, "\\'U"}, /* capital U with acute accent */
57 {219, "\\^U"}, /* capital U with circumflex accent */
58 {220, "\\\"U"}, /* capital U with diaeresis */
59 {221, "\\'Y"}, /* capital Y with acute accent */
60 {223, "\\ss{}"}, /* small german sharp s */
61 {224, "\\`a"}, /* small a with grave accent */
62 {225, "\\'a"}, /* small a with acute accent */
63 {226, "\\^a"}, /* small a with circumflex accent */
64 {227, "\\~a"}, /* small a with tilde */
65 {228, "\\\"a"}, /* small a with diaeresis */
66 {229, "\\aa{}"}, /* small a with ring above */
67 {230, "\\ae{}"}, /* small diphthong a with e */
68 {231, "\\c{c}"}, /* small c with cedilla */
69 {232, "\\`e"}, /* small e with grave accent */
70 {233, "\\'e"}, /* small e with acute accent */
71 {234, "\\^e"}, /* small e with circumflex accent */
72 {235, "\\\"e"}, /* small e with diaeresis */
73 {236, "\\`{\\i}"}, /* small i with grave accent */
74 {237, "\\'{\\i}"}, /* small i with acute accent */
75 {238, "\\^{\\i}"}, /* small i with circumflex accent */
76 {239, "\\\"{\\i}"}, /* small i with diaeresis */
77 {241, "\\~n"}, /* small n with tilde */
78 {242, "\\`o"}, /* small o with grave accent */
79 {243, "\\'o"}, /* small o with acute accent */
80 {244, "\\^o"}, /* small o with circumflex accent */
81 {245, "\\~o"}, /* small o with tilde */
82 {246, "\\\"o"}, /* small o with diaeresis */
83 {248, "\\o{}"}, /* small o with oblique stroke */
84 {249, "\\`u"}, /* small u with grave accent */
85 {250, "\\'u"}, /* small u with acute accent */
86 {251, "\\^u"}, /* small u with circumflex accent */
87 {252, "\\\"u"}, /* small u with diaeresis */
88 {253, "\\'y"}, /* small y with acute accent */
89 {255, "\\\"y"}, /* small y with diaeresis */
90 {0, NULL}
91 };
92
93 static struct translation const other_translations [] =
94 {
95 { 35, "\\#"},
96 { 36, "\\$"},
97 { 37, "\\%"},
98 { 38, "\\&"},
99 { 60, "$<$"},
100 { 62, "$>$"},
101 { 92, "\\backslash{}"},
102 { 94, "\\textasciicircum{}"},
103 { 95, "\\_"},
104 {123, "\\{"},
105 {125, "\\}"},
106 {160, "~"}, /* no-break space */
107 {161, "!`"}, /* inverted exclamation mark */
108 {163, "\\pound{}"}, /* pound sign */
109 {167, "\\S{}"}, /* paragraph sign, section sign */
110 {168, "\\\"{}"}, /* diaeresis */
111 {169, "\\copyright{}"}, /* copyright sign */
112 {171, "``"}, /* left angle quotation mark */
113 {172, "\\neg{}"}, /* not sign */
114 {173, "\\-"}, /* soft hyphen */
115 {176, "\\mbox{$^\\circ$}"}, /* degree sign */
116 {177, "\\mbox{$\\pm$}"}, /* plus-minus sign */
117 {178, "\\mbox{$^2$}"}, /* superscript two */
118 {179, "\\mbox{$^3$}"}, /* superscript three */
119 {180, "\\'{}"}, /* acute accent */
120 {181, "\\mbox{$\\mu$}"}, /* small greek mu, micro sign */
121 {183, "\\cdotp"}, /* middle dot */
122 {184, "\\,{}"}, /* cedilla */
123 {185, "\\mbox{$^1$}"}, /* superscript one */
124 {187, "''"}, /* right angle quotation mark */
125 {188, "\\frac1/4{}"}, /* vulgar fraction one quarter */
126 {189, "\\frac1/2{}"}, /* vulgar fraction one half */
127 {190, "\\frac3/4{}"}, /* vulgar fraction three quarters */
128 {191, "?`"}, /* inverted question mark */
129 {0, NULL}
130 };
131
132 static bool
133 init_latin1_latex (RECODE_STEP step,
134 RECODE_CONST_REQUEST request,
135 RECODE_CONST_OPTION_LIST before_options,
136 RECODE_CONST_OPTION_LIST after_options)
137 {
138 RECODE_OUTER outer = request->outer;
139 char *pool;
140 const char **table;
141 unsigned counter;
142 struct translation const *cursor;
143
144 if (before_options || after_options)
145 return false;
146
147 if (!ALLOC_SIZE (table, 256 * sizeof (char *) + 256, const char *))
148 return false;
149 pool = (char *) (table + 256);
150
151 for (counter = 0; counter < 128; counter++)
152 {
153 table[counter] = pool;
154 *pool++ = counter;
155 *pool++ = NUL;
156 }
157 for (counter = 128; counter < 256; counter++)
158 table[counter] = NULL;
159 for (cursor = diacritic_translations; cursor->code; cursor++)
160 table[cursor->code] = cursor->string;
161
162 if (!request->diacritics_only)
163 for (cursor = other_translations; cursor->code; cursor++)
164 table[cursor->code] = cursor->string;
165
166 step->step_type = RECODE_BYTE_TO_STRING;
167 step->step_table = table;
168 step->step_table_term_routine = free;
169 return true;
170 }
171
172 bool
173 module_latin1_latex (RECODE_OUTER outer)
174 {
175 return
176 recode_declare_single (outer, "Latin-1", "LaTeX",
177 outer->quality_byte_to_variable,
178 init_latin1_latex, recode_transform_byte_to_variable)
179 && recode_declare_alias (outer, "TeX", "LaTeX")
180 && recode_declare_alias (outer, "ltex", "LaTeX");
181 }
182
183 void
184 delmodule_latin1_latex (_GL_UNUSED RECODE_OUTER outer)
185 {
186 }