File: lat1txte.c

package info (click to toggle)
recode 3.4.1-10
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 1,560 kB
  • ctags: 623
  • sloc: ansic: 10,572; perl: 339; makefile: 302; lisp: 243; sh: 173; lex: 165; awk: 127; sed: 10
file content (212 lines) | stat: -rw-r--r-- 7,636 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
/* 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"

static const char *const translation_table[128] =
  {
    NULL,			/* 128 */
    NULL,			/* 129 */
    NULL,			/* 130 */
    NULL,			/* 131 */
    NULL,			/* 132 */
    NULL,			/* 133 */
    NULL,			/* 134 */
    NULL,			/* 135 */
    NULL,			/* 136 */
    NULL,			/* 137 */
    NULL,			/* 138 */
    NULL,			/* 139 */
    NULL,			/* 140 */
    NULL,			/* 141 */
    NULL,			/* 142 */
    NULL,			/* 143 */
    NULL,			/* 144 */
    NULL,			/* 145 */
    NULL,			/* 146 */
    NULL,			/* 147 */
    NULL,			/* 148 */
    NULL,			/* 149 */
    NULL,			/* 150 */
    NULL,			/* 151 */
    NULL,			/* 152 */
    NULL,			/* 153 */
    NULL,			/* 154 */
    NULL,			/* 155 */
    NULL,			/* 156 */
    NULL,			/* 157 */
    NULL,			/* 158 */
    NULL,			/* 159 */

    " ",			/* 160 no-break space */
    NULL,			/* 161 inverted exclamation mark */
    NULL,			/* 162 cent sign */
    NULL,			/* 163 pound sign */
    NULL,			/* 164 currency sign */
    NULL,			/* 165 yen sign */
    NULL,			/* 166 broken bar */
    NULL,			/* 167 paragraph sign, section sign */
    NULL,			/* 168 diaeresis */
    NULL,			/* 169 copyright sign */
    NULL,			/* 170 feminine ordinal indicator */
    "``",			/* 171 left angle quotation mark */
    NULL,			/* 172 not sign */
    NULL,			/* 173 soft hyphen */
    NULL,			/* 174 registered trade mark sign */
    NULL,			/* 175 macron */
    NULL,			/* 176 degree sign */
    NULL,			/* 177 plus-minus sign */
    NULL,			/* 178 superscript two */
    NULL,			/* 179 superscript three */
    NULL,			/* 180 acute accent */
    NULL,			/* 181 small greek mu, micro sign */
    NULL,			/* 182 pilcrow sign */
    NULL,			/* 183 middle dot */
    NULL,			/* 184 cedilla */
    NULL,			/* 185 superscript one */
    NULL,			/* 186 masculine ordinal indicator */
    "''",			/* 187 right angle quotation mark */
    NULL,			/* 188 vulgar fraction one quarter */
    NULL,			/* 189 vulgar fraction one half */
    NULL,			/* 190 vulgar fraction three quarters */
    NULL,			/* 191 inverted question mark */
    "A`",			/* 192 capital A with grave accent */
    NULL,			/* 193 capital A with acute accent */
    "A^",			/* 194 capital A with circumflex accent */
    NULL,			/* 195 capital A with tilde */
    "A\"",			/* 196 capital A diaeresis */
    NULL,			/* 197 capital A with ring above */
    NULL,			/* 198 capital diphthong A with E */
    "C,",			/* 199 capital C with cedilla */
    "E`",			/* 200 capital E with grave accent */
    "E\'",			/* 201 capital E with acute accent */
    "E^",			/* 202 capital E with circumflex accent */
    "E\"",			/* 203 capital E with diaeresis */
    NULL,			/* 204 capital I with grave accent */
    NULL,			/* 205 capital I with acute accent */
    "I^",			/* 206 capital I with circumflex accent */
    "I\"",			/* 207 capital I with diaeresis */
    NULL,			/* 208 capital icelandic ETH */
    NULL,			/* 209 capital N with tilde */
    "O`",			/* 210 capital O with grave accent */
    NULL,			/* 211 capital O with acute accent */
    "O^",			/* 212 capital O with circumflex accent */
    NULL,			/* 213 capital O with tilde */
    "O\"",			/* 214 capital O with diaeresis */
    NULL,			/* 215 multiplication sign */
    NULL,			/* 216 capital O with oblique stroke */
    "U`",			/* 217 capital U with grave accent */
    NULL,			/* 218 capital U with acute accent */
    "U^",			/* 219 capital U with circumflex accent */
    "U\"",			/* 220 capital U with diaeresis */
    NULL,			/* 221 capital Y with acute accent */
    NULL,			/* 222 capital icelandic THORN */
    NULL,			/* 223 small german sharp s */
    "a`",			/* 224 small a with grave accent */
    NULL,			/* 225 small a with acute accent */
    "a^",			/* 226 small a with circumflex accent */
    NULL,			/* 227 small a with tilde */
    "a\"",			/* 228 small a with diaeresis */
    NULL,			/* 229 small a with ring above */
    NULL,			/* 230 small diphthong a with e */
    "c,",			/* 231 small c with cedilla */
    "e`",			/* 232 small e with grave accent */
    "e\'",			/* 233 small e with acute accent */
    "e^",			/* 234 small e with circumflex accent */
    "e\"",			/* 235 small e with diaeresis */
    NULL,			/* 236 small i with grave accent */
    NULL,			/* 237 small i with acute accent */
    "i^",			/* 238 small i with circumflex accent */
    "i\"",			/* 239 small i with diaeresis */
    NULL,			/* 240 small icelandic eth */
    NULL,			/* 241 small n with tilde */
    "o`",			/* 242 small o with grave accent */
    NULL,			/* 243 small o with acute accent */
    "o^",			/* 244 small o with circumflex accent */
    NULL,			/* 245 small o with tilde */
    "o\"",			/* 246 small o with diaeresis */
    NULL,			/* 247 division sign */
    NULL,			/* 248 small o with oblique stroke */
    "u`",			/* 249 small u with grave accent */
    NULL,			/* 250 small u with acute accent */
    "u^",			/* 251 small u with circumflex accent */
    "u\"",			/* 252 small u with diaeresis */
    NULL,			/* 253 small y with acute accent */
    NULL,			/* 254 small icelandic thorn */
    NULL,			/* 255 small y with diaeresis */
  };

static void
init_latin1_texte (STEP *step)
{
  int rewritten;		/* number of rewritten translations */
  const char **table;		/* allocated structure, including pool */
  char *pool;			/* cursor in character pool */
  int counter;			/* general purpose counter */

  /* The algorithm for proper processing of -c option depends on the fact
     that quotes to be changed in colons are exactly those, in strings
     from translation_table, which are in second position while the
     string is two characters in length.  This is sufficient for now.  */

  rewritten = 0;
  if (diaeresis_char != '"')
    for (counter = 128; counter < 256; counter++)
      if (translation_table[counter - 128]
	  && translation_table[counter - 128][1] == '"'
	  && translation_table[counter - 128][2] == '\0')
	rewritten++;

  table = (const char **) xmalloc (sizeof (char *) * 256
				   + 2 * 128
				   + 3 * rewritten);
  pool = (char *) (table + 256);

  for (counter = 0; counter < 128; counter++)
    {
      table[counter] = pool;
      *pool++ = counter;
      *pool++ = '\0';
    }

  for (; counter < 256; counter++)
    if (diaeresis_char != '"'
	&& translation_table[counter - 128]
	&& translation_table[counter - 128][1] == '"'
	&& translation_table[counter - 128][2] == '\0')
      {
	table[counter] = pool;
	*pool++ = translation_table[counter - 128][0];
	*pool++ = diaeresis_char;
	*pool++ = '\0';
      }
    else
      table[counter] = translation_table[counter - 128];

  step->one_to_many = table;
}

void
module_latin1_texte (void)
{
  declare_step ("Latin-1", "Texte", ONE_TO_MANY, init_latin1_texte,
		file_one_to_many);

  declare_alias ("txte", "Texte");
}