| 1 |
|
| 2 |
. |
| 3 |
. |
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
#include "config.h" |
| 21 |
#include "common.h" |
| 22 |
#include "decsteps.h" |
| 23 |
|
| 24 |
struct translation |
| 25 |
{ |
| 26 |
unsigned code; |
| 27 |
const char *string; |
| 28 |
}; |
| 29 |
|
| 30 |
static struct translation const diacritic_translations [] = |
| 31 |
{ |
| 32 |
{192, "\\`A"}, |
| 33 |
{193, "\\'A"}, |
| 34 |
{194, "\\^A"}, |
| 35 |
{195, "\\~A"}, |
| 36 |
{196, "\\\"A"}, |
| 37 |
{197, "\\AA{}"}, |
| 38 |
{198, "\\AE{}"}, |
| 39 |
{199, "\\c{C}"}, |
| 40 |
{200, "\\`E"}, |
| 41 |
{201, "\\'E"}, |
| 42 |
{202, "\\^E"}, |
| 43 |
{203, "\\\"E"}, |
| 44 |
{204, "\\`I"}, |
| 45 |
{205, "\\'I"}, |
| 46 |
{206, "\\^I"}, |
| 47 |
{207, "\\\"I"}, |
| 48 |
{209, "\\~N"}, |
| 49 |
{210, "\\`O"}, |
| 50 |
{211, "\\'O"}, |
| 51 |
{212, "\\^O"}, |
| 52 |
{213, "\\~O"}, |
| 53 |
{214, "\\\"O"}, |
| 54 |
{216, "\\O{}"}, |
| 55 |
{217, "\\`U"}, |
| 56 |
{218, "\\'U"}, |
| 57 |
{219, "\\^U"}, |
| 58 |
{220, "\\\"U"}, |
| 59 |
{221, "\\'Y"}, |
| 60 |
{223, "\\ss{}"}, |
| 61 |
{224, "\\`a"}, |
| 62 |
{225, "\\'a"}, |
| 63 |
{226, "\\^a"}, |
| 64 |
{227, "\\~a"}, |
| 65 |
{228, "\\\"a"}, |
| 66 |
{229, "\\aa{}"}, |
| 67 |
{230, "\\ae{}"}, |
| 68 |
{231, "\\c{c}"}, |
| 69 |
{232, "\\`e"}, |
| 70 |
{233, "\\'e"}, |
| 71 |
{234, "\\^e"}, |
| 72 |
{235, "\\\"e"}, |
| 73 |
{236, "\\`{\\i}"}, |
| 74 |
{237, "\\'{\\i}"}, |
| 75 |
{238, "\\^{\\i}"}, |
| 76 |
{239, "\\\"{\\i}"}, |
| 77 |
{241, "\\~n"}, |
| 78 |
{242, "\\`o"}, |
| 79 |
{243, "\\'o"}, |
| 80 |
{244, "\\^o"}, |
| 81 |
{245, "\\~o"}, |
| 82 |
{246, "\\\"o"}, |
| 83 |
{248, "\\o{}"}, |
| 84 |
{249, "\\`u"}, |
| 85 |
{250, "\\'u"}, |
| 86 |
{251, "\\^u"}, |
| 87 |
{252, "\\\"u"}, |
| 88 |
{253, "\\'y"}, |
| 89 |
{255, "\\\"y"}, |
| 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, "~"}, |
| 107 |
{161, "!`"}, |
| 108 |
{163, "\\pound{}"}, |
| 109 |
{167, "\\S{}"}, |
| 110 |
{168, "\\\"{}"}, |
| 111 |
{169, "\\copyright{}"}, |
| 112 |
{171, "``"}, |
| 113 |
{172, "\\neg{}"}, |
| 114 |
{173, "\\-"}, |
| 115 |
{176, "\\mbox{$^\\circ$}"}, |
| 116 |
{177, "\\mbox{$\\pm$}"}, |
| 117 |
{178, "\\mbox{$^2$}"}, |
| 118 |
{179, "\\mbox{$^3$}"}, |
| 119 |
{180, "\\'{}"}, |
| 120 |
{181, "\\mbox{$\\mu$}"}, |
| 121 |
{183, "\\cdotp"}, |
| 122 |
{184, "\\,{}"}, |
| 123 |
{185, "\\mbox{$^1$}"}, |
| 124 |
{187, "''"}, |
| 125 |
{188, "\\frac1/4{}"}, |
| 126 |
{189, "\\frac1/2{}"}, |
| 127 |
{190, "\\frac3/4{}"}, |
| 128 |
{191, "?`"}, |
| 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 |
} |