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