File: lat1ltex.c

package info (click to toggle)
recode 3.4.1-11
  • links: PTS
  • area: main
  • in suites: slink
  • size: 1,560 kB
  • ctags: 622
  • sloc: ansic: 10,572; perl: 339; makefile: 317; lisp: 243; sh: 173; lex: 165; awk: 127; sed: 10
file content (164 lines) | stat: -rw-r--r-- 6,396 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/* Conversion of files between different charsets and usages.
   Copyright (C) 1990, 1993 Free Software Foundation, Inc.
   Francois Pinard <pinard@iro.umontreal.ca>, 1988.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2, or (at your option)
   any later version.

   This program is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include "recode.h"

struct translation
  {
    int code;			/* code being translated */
    const char *string;		/* translation string */
  };

static struct translation const diacritic_translations [] =
  {
    {192, "\\`A"},		/* capital A with grave accent */
    {193, "\\'A"},		/* capital A with acute accent */
    {194, "\\^A"},		/* capital A with circumflex accent */
    {195, "\\~A"},		/* capital A with tilde */
    {196, "\\\"A"},		/* capital A diaeresis */
    {197, "\\AA{}"},		/* capital A with ring above */
    {198, "\\AE{}"},		/* capital diphthong A with E */
    {199, "\\c{C}"},		/* capital C with cedilla */
    {200, "\\`E"},		/* capital E with grave accent */
    {201, "\\'E"},		/* capital E with acute accent */
    {202, "\\^E"},		/* capital E with circumflex accent */
    {203, "\\\"E"},		/* capital E with diaeresis */
    {204, "\\`I"},		/* capital I with grave accent */
    {205, "\\'I"},		/* capital I with acute accent */
    {206, "\\^I"},		/* capital I with circumflex accent */
    {207, "\\\"I"},		/* capital I with diaeresis */
    {209, "\\~N"},		/* capital N with tilde */
    {210, "\\`O"},		/* capital O with grave accent */
    {211, "\\'O"},		/* capital O with acute accent */
    {212, "\\^O"},		/* capital O with circumflex accent */
    {213, "\\~O"},		/* capital O with tilde */
    {214, "\\\"O"},		/* capital O with diaeresis */
    {216, "\\O{}"},		/* capital O with oblique stroke */
    {217, "\\`U"},		/* capital U with grave accent */
    {218, "\\'U"},		/* capital U with acute accent */
    {219, "\\^U"},		/* capital U with circumflex accent */
    {220, "\\\"U"},		/* capital U with diaeresis */
    {221, "\\'Y"},		/* capital Y with acute accent */
    {223, "\\ss{}"},		/* small german sharp s */
    {224, "\\`a"},		/* small a with grave accent */
    {225, "\\'a"},		/* small a with acute accent */
    {226, "\\^a"},		/* small a with circumflex accent */
    {227, "\\~a"},		/* small a with tilde */
    {228, "\\\"a"},		/* small a with diaeresis */
    {229, "\\aa{}"},		/* small a with ring above */
    {230, "\\ae{}"},		/* small diphthong a with e */
    {231, "\\c{c}"},		/* small c with cedilla */
    {232, "\\`e"},		/* small e with grave accent */
    {233, "\\'e"},		/* small e with acute accent */
    {234, "\\^e"},		/* small e with circumflex accent */
    {235, "\\\"e"},		/* small e with diaeresis */
    {236, "\\`{\\i}"},		/* small i with grave accent */
    {237, "\\'{\\i}"},		/* small i with acute accent */
    {238, "\\^{\\i}"},		/* small i with circumflex accent */
    {239, "\\\"{\\i}"},		/* small i with diaeresis */
    {241, "\\~n"},		/* small n with tilde */
    {242, "\\`o"},		/* small o with grave accent */
    {243, "\\'o"},		/* small o with acute accent */
    {244, "\\^o"},		/* small o with circumflex accent */
    {245, "\\~o"},		/* small o with tilde */
    {246, "\\\"o"},		/* small o with diaeresis */
    {248, "\\o{}"},		/* small o with oblique stroke */
    {249, "\\`u"},		/* small u with grave accent */
    {250, "\\'u"},		/* small u with acute accent */
    {251, "\\^u"},		/* small u with circumflex accent */
    {252, "\\\"u"},		/* small u with diaeresis */
    {253, "\\'y"},		/* small y with acute accent */
    {255, "\\\"y"},		/* small y with diaeresis */
    {0, NULL}
  };

static struct translation const other_translations [] =
  {
    { 35, "\\#"},
    { 36, "\\$"},
    { 37, "\\%"},
    { 38, "\\&"},
    { 92, "\\backslash{}"},
    { 95, "\\_"},
    {123, "\\{"},
    {125, "\\}"},
    {160, "~"},			/* no-break space */
    {161, "!`"},		/* inverted exclamation mark */
    {163, "\\pound{}"},		/* pound sign */
    {167, "\\S{}"},		/* paragraph sign, section sign */
    {168, "\\\"{}"},		/* diaeresis */
    {169, "\\copyright{}"},	/* copyright sign */
    {171, "``"},		/* left angle quotation mark */
    {172, "\\neg{}"},		/* not sign */
    {173, "\\-"},		/* soft hyphen */
    {176, "\\mbox{$^\\circ$}"}, /* degree sign */
    {177, "\\mbox{$\\pm$}"},	/* plus-minus sign */
    {178, "\\mbox{$^2$}"},	/* superscript two */
    {179, "\\mbox{$^3$}"},	/* superscript three */
    {180, "\\'{}"},		/* acute accent */
    {181, "\\mbox{$\\mu$}"},	/* small greek mu, micro sign */
    {183, "\\cdotp"},		/* middle dot */
    {184, "\\,{}"},		/* cedilla */
    {185, "\\mbox{$^1$}"},	/* superscript one */
    {187, "''"},		/* right angle quotation mark */
    {188, "\\frac1/4{}"},	/* vulgar fraction one quarter */
    {189, "\\frac1/2{}"},	/* vulgar fraction one half */
    {190, "\\frac3/4{}"},	/* vulgar fraction three quarters */
    {191, "?`"},		/* inverted question mark */
    {0, NULL}
  };

static void
init_latin1_latex (STEP *step)
{
  char *pool;
  const char **table;
  int counter;
  struct translation const *cursor;

  table = (const char **) xmalloc (256 * sizeof (char *) + 256);
  pool = (char *) (table + 256);

  for (counter = 0; counter < 128; counter++)
    {
      table[counter] = pool;
      *pool++ = counter;
      *pool++ = '\0';
    }
  for (counter = 128; counter < 256; counter++)
    table[counter] = NULL;
  for (cursor = diacritic_translations; cursor->code; cursor++)
    table[cursor->code] = cursor->string;

  if (!diacritics_only)
    for (cursor = other_translations; cursor->code; cursor++)
      table[cursor->code] = cursor->string;

  step->one_to_many = table;
}

void
module_latin1_latex (void)
{
  declare_step ("Latin-1", "LaTeX", ONE_TO_MANY, init_latin1_latex,
		file_one_to_many);

  declare_alias ("TeX", "LaTeX");
  declare_alias ("ltex", "LaTeX");
}