Debian Codegraph @

src/lat1btex.c

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