chiark / gitweb /
eglibc (2.11.3-4+deb6u3) squeeze-lts; urgency=medium
[eglibc.git] / debian / patches / locale / preprocessor-collate-uli-sucks.diff
1 ---
2  locale/programs/ld-collate.c |  265 -------------------------------------------
3  1 file changed, 265 deletions(-)
4
5 --- a/locale/programs/ld-collate.c
6 +++ b/locale/programs/ld-collate.c
7 @@ -185,14 +185,6 @@
8  #include "3level.h"
9  
10  
11 -/* Simple name list for the preprocessor.  */
12 -struct name_list
13 -{
14 -  struct name_list *next;
15 -  char str[0];
16 -};
17 -
18 -
19  /* The real definition of the struct for the LC_COLLATE locale.  */
20  struct locale_collate_t
21  {
22 @@ -254,15 +246,6 @@
23    /* The arrays with the collation sequence order.  */
24    unsigned char mbseqorder[256];
25    struct collseq_table wcseqorder;
26 -
27 -  /* State of the preprocessor.  */
28 -  enum
29 -    {
30 -      else_none = 0,
31 -      else_ignore,
32 -      else_seen
33 -    }
34 -    else_action;
35  };
36  
37  
38 @@ -270,9 +253,6 @@
39     LC_COLLATE category descriptions in all files.  */
40  static uint32_t nrules;
41  
42 -/* List of defined preprocessor symbols.  */
43 -static struct name_list *defined;
44 -
45  
46  /* We need UTF-8 encoding of numbers.  */
47  static inline int
48 @@ -2511,46 +2491,6 @@
49  }
50  
51  
52 -static enum token_t
53 -skip_to (struct linereader *ldfile, struct locale_collate_t *collate,
54 -        const struct charmap_t *charmap, int to_endif)
55 -{
56 -  while (1)
57 -    {
58 -      struct token *now = lr_token (ldfile, charmap, NULL, NULL, 0);
59 -      enum token_t nowtok = now->tok;
60 -
61 -      if (nowtok == tok_eof || nowtok == tok_end)
62 -       return nowtok;
63 -
64 -      if (nowtok == tok_ifdef || nowtok == tok_ifndef)
65 -       {
66 -         lr_error (ldfile, _("%s: nested conditionals not supported"),
67 -                   "LC_COLLATE");
68 -         nowtok = skip_to (ldfile, collate, charmap, tok_endif);
69 -         if (nowtok == tok_eof || nowtok == tok_end)
70 -           return nowtok;
71 -       }
72 -      else if (nowtok == tok_endif || (!to_endif && nowtok == tok_else))
73 -       {
74 -         lr_ignore_rest (ldfile, 1);
75 -         return nowtok;
76 -       }
77 -      else if (!to_endif && (nowtok == tok_elifdef || nowtok == tok_elifndef))
78 -       {
79 -         /* Do not read the rest of the line.  */
80 -         return nowtok;
81 -       }
82 -      else if (nowtok == tok_else)
83 -       {
84 -         lr_error (ldfile, _("%s: more then one 'else'"), "LC_COLLATE");
85 -       }
86 -
87 -      lr_ignore_rest (ldfile, 0);
88 -    }
89 -}
90 -
91 -
92  void
93  collate_read (struct linereader *ldfile, struct localedef_t *result,
94               const struct charmap_t *charmap, const char *repertoire_name,
95 @@ -2581,8 +2521,6 @@
96    /* The rest of the line containing `LC_COLLATE' must be free.  */
97    lr_ignore_rest (ldfile, 1);
98  
99 -  while (1)
100 -    {
101        do
102         {
103           now = lr_token (ldfile, charmap, result, NULL, verbose);
104 @@ -2590,31 +2528,6 @@
105         }
106        while (nowtok == tok_eol);
107  
108 -      if (nowtok != tok_define)
109 -       break;
110 -
111 -      if (ignore_content)
112 -       lr_ignore_rest (ldfile, 0);
113 -      else
114 -       {
115 -         arg = lr_token (ldfile, charmap, result, NULL, verbose);
116 -         if (arg->tok != tok_ident)
117 -           SYNTAX_ERROR (_("%s: syntax error"), "LC_COLLATE");
118 -         else
119 -           {
120 -             /* Simply add the new symbol.  */
121 -             struct name_list *newsym = xmalloc (sizeof (*newsym)
122 -                                                 + arg->val.str.lenmb + 1);
123 -             memcpy (newsym->str, arg->val.str.startmb, arg->val.str.lenmb);
124 -             newsym->str[arg->val.str.lenmb] = '\0';
125 -             newsym->next = defined;
126 -             defined = newsym;
127 -
128 -             lr_ignore_rest (ldfile, 1);
129 -           }
130 -       }
131 -    }
132 -
133    if (nowtok == tok_copy)
134      {
135        now = lr_token (ldfile, charmap, result, NULL, verbose);
136 @@ -3770,7 +3683,6 @@
137           break;
138  
139         case tok_end:
140 -       seen_end:
141           /* Next we assume `LC_COLLATE'.  */
142           if (!ignore_content)
143             {
144 @@ -3811,182 +3723,6 @@
145           lr_ignore_rest (ldfile, arg->tok == tok_lc_collate);
146           return;
147  
148 -       case tok_define:
149 -         if (ignore_content)
150 -           {
151 -             lr_ignore_rest (ldfile, 0);
152 -             break;
153 -           }
154 -
155 -         arg = lr_token (ldfile, charmap, result, NULL, verbose);
156 -         if (arg->tok != tok_ident)
157 -           goto err_label;
158 -
159 -         /* Simply add the new symbol.  */
160 -         struct name_list *newsym = xmalloc (sizeof (*newsym)
161 -                                             + arg->val.str.lenmb + 1);
162 -         memcpy (newsym->str, arg->val.str.startmb, arg->val.str.lenmb);
163 -         newsym->str[arg->val.str.lenmb] = '\0';
164 -         newsym->next = defined;
165 -         defined = newsym;
166 -
167 -         lr_ignore_rest (ldfile, 1);
168 -         break;
169 -
170 -       case tok_undef:
171 -         if (ignore_content)
172 -           {
173 -             lr_ignore_rest (ldfile, 0);
174 -             break;
175 -           }
176 -
177 -         arg = lr_token (ldfile, charmap, result, NULL, verbose);
178 -         if (arg->tok != tok_ident)
179 -           goto err_label;
180 -
181 -         /* Remove _all_ occurrences of the symbol from the list.  */
182 -         struct name_list *prevdef = NULL;
183 -         struct name_list *curdef = defined;
184 -         while (curdef != NULL)
185 -           if (strncmp (arg->val.str.startmb, curdef->str,
186 -                        arg->val.str.lenmb) == 0
187 -               && curdef->str[arg->val.str.lenmb] == '\0')
188 -             {
189 -               if (prevdef == NULL)
190 -                 defined = curdef->next;
191 -               else
192 -                 prevdef->next = curdef->next;
193 -
194 -               struct name_list *olddef = curdef;
195 -               curdef = curdef->next;
196 -
197 -               free (olddef);
198 -             }
199 -           else
200 -             {
201 -               prevdef = curdef;
202 -               curdef = curdef->next;
203 -             }
204 -
205 -         lr_ignore_rest (ldfile, 1);
206 -         break;
207 -
208 -       case tok_ifdef:
209 -       case tok_ifndef:
210 -         if (ignore_content)
211 -           {
212 -             lr_ignore_rest (ldfile, 0);
213 -             break;
214 -           }
215 -
216 -       found_ifdef:
217 -         arg = lr_token (ldfile, charmap, result, NULL, verbose);
218 -         if (arg->tok != tok_ident)
219 -           goto err_label;
220 -         lr_ignore_rest (ldfile, 1);
221 -
222 -         if (collate->else_action == else_none)
223 -           {
224 -             curdef = defined;
225 -             while (curdef != NULL)
226 -               if (strncmp (arg->val.str.startmb, curdef->str,
227 -                            arg->val.str.lenmb) == 0
228 -                   && curdef->str[arg->val.str.lenmb] == '\0')
229 -                 break;
230 -               else
231 -                 curdef = curdef->next;
232 -
233 -             if ((nowtok == tok_ifdef && curdef != NULL)
234 -                 || (nowtok == tok_ifndef && curdef == NULL))
235 -               {
236 -                 /* We have to use the if-branch.  */
237 -                 collate->else_action = else_ignore;
238 -               }
239 -             else
240 -               {
241 -                 /* We have to use the else-branch, if there is one.  */
242 -                 nowtok = skip_to (ldfile, collate, charmap, 0);
243 -                 if (nowtok == tok_else)
244 -                   collate->else_action = else_seen;
245 -                 else if (nowtok == tok_elifdef)
246 -                   {
247 -                     nowtok = tok_ifdef;
248 -                     goto found_ifdef;
249 -                   }
250 -                 else if (nowtok == tok_elifndef)
251 -                   {
252 -                     nowtok = tok_ifndef;
253 -                     goto found_ifdef;
254 -                   }
255 -                 else if (nowtok == tok_eof)
256 -                   goto seen_eof;
257 -                 else if (nowtok == tok_end)
258 -                   goto seen_end;
259 -               }
260 -           }
261 -         else
262 -           {
263 -             /* XXX Should it really become necessary to support nested
264 -                preprocessor handling we will push the state here.  */
265 -             lr_error (ldfile, _("%s: nested conditionals not supported"),
266 -                       "LC_COLLATE");
267 -             nowtok = skip_to (ldfile, collate, charmap, 1);
268 -             if (nowtok == tok_eof)
269 -               goto seen_eof;
270 -             else if (nowtok == tok_end)
271 -               goto seen_end;
272 -           }
273 -         break;
274 -
275 -       case tok_elifdef:
276 -       case tok_elifndef:
277 -       case tok_else:
278 -         if (ignore_content)
279 -           {
280 -             lr_ignore_rest (ldfile, 0);
281 -             break;
282 -           }
283 -
284 -         lr_ignore_rest (ldfile, 1);
285 -
286 -         if (collate->else_action == else_ignore)
287 -           {
288 -             /* Ignore everything until the endif.  */
289 -             nowtok = skip_to (ldfile, collate, charmap, 1);
290 -             if (nowtok == tok_eof)
291 -               goto seen_eof;
292 -             else if (nowtok == tok_end)
293 -               goto seen_end;
294 -           }
295 -         else
296 -           {
297 -             assert (collate->else_action == else_none);
298 -             lr_error (ldfile, _("\
299 -%s: '%s' without matching 'ifdef' or 'ifndef'"), "LC_COLLATE",
300 -                       nowtok == tok_else ? "else"
301 -                       : nowtok == tok_elifdef ? "elifdef" : "elifndef");
302 -           }
303 -         break;
304 -
305 -       case tok_endif:
306 -         if (ignore_content)
307 -           {
308 -             lr_ignore_rest (ldfile, 0);
309 -             break;
310 -           }
311 -
312 -         lr_ignore_rest (ldfile, 1);
313 -
314 -         if (collate->else_action != else_ignore
315 -             && collate->else_action != else_seen)
316 -           lr_error (ldfile, _("\
317 -%s: 'endif' without matching 'ifdef' or 'ifndef'"), "LC_COLLATE");
318 -
319 -         /* XXX If we support nested preprocessor directives we pop
320 -            the state here.  */
321 -         collate->else_action = else_none;
322 -         break;
323 -
324         default:
325         err_label:
326           SYNTAX_ERROR (_("%s: syntax error"), "LC_COLLATE");
327 @@ -3997,7 +3733,6 @@
328        nowtok = now->tok;
329      }
330  
331 - seen_eof:
332    /* When we come here we reached the end of the file.  */
333    lr_error (ldfile, _("%s: premature end of file"), "LC_COLLATE");
334  }