1 /* Copyright (C) 1995 Free Software Foundation, Inc.
3 The GNU C Library is free software; you can redistribute it and/or
4 modify it under the terms of the GNU Library General Public License as
5 published by the Free Software Foundation; either version 2 of the
6 License, or (at your option) any later version.
8 The GNU C Library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
13 You should have received a copy of the GNU Library General Public
14 License along with the GNU C Library; see the file COPYING.LIB. If
15 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
16 Cambridge, MA 02139, USA. */
21 #include "localedef.h"
25 /* defined in locfile-lex.c: flag to indicate that unknown element names
27 extern int reject_new_char
;
30 #define SYNTAX_ERROR \
31 error (0, 0, gettext ("%s:%Zd: syntax error in locale definition file"), \
32 locfile_data.filename, locfile_data.line_no);
35 collate_input (int token
)
37 int read_order_start
= 0;
45 /* This is the end of the category. */
47 token
= xlocfile_lex (&ptr
, &len
);
49 if (token
!= _NL_NUM_LC_COLLATE
)
51 error (0, 0, gettext ("%s:%Zd: category `%s' does not end "
52 "with `END %s'"), locfile_data
.filename
,
53 locfile_data
.line_no
, "LC_COLLATE", "LC_COLLATE");
59 /* Start next category. */
65 if (read_order_start
== 0)
66 /* We're still in the preambel. */
70 case TOK_COLLATING_ELEMENT
:
72 token
= xlocfile_lex (&ptr
, &len
);
74 if (token
== TOK_CHAR
)
76 error (0, 0, gettext ("%s:%Zd: symbolic name must not be "
77 "duplicate name in charmap"),
78 locfile_data
.filename
, locfile_data
.line_no
);
82 else if (token
!= TOK_ILL_CHAR
)
90 char elem_name
[len
+ 1];
91 memcpy (elem_name
, ptr
, len
);
92 elem_name
[len
] = '\0';
94 /* Test whether defined in symbol table. */
96 token
= xlocfile_lex (&ptr
, &len
);
97 if (token
!= TOK_FROM
)
100 ignore_to_eol (0, 0);
104 token
= xlocfile_lex (&ptr
, &len
);
105 if (token
!= TOK_STRING
)
108 ignore_to_eol (0, 0);
112 /* Insert collating element into table. */
114 /* Rest of the line should be empty. */
115 ignore_to_eol (0, 1);
118 case TOK_COLLATING_SYMBOL
:
120 token
= xlocfile_lex (&ptr
, &len
);
122 if (token
== TOK_CHAR
)
124 error (0, 0, gettext ("%s:%Zd: symbolic name must not "
125 "duplicate name in charmap"),
126 locfile_data
.filename
, locfile_data
.line_no
);
127 ignore_to_eol (0, 0);
130 else if (token
!= TOK_ILL_CHAR
)
133 ignore_to_eol (0, 0);
138 /* Test whether defined in element table. */
140 /* Insert collating symbol into table. */
142 ignore_to_eol (0, 1);
144 case TOK_ORDER_START
:
149 token
= xlocfile_lex (&ptr
, &len
);
151 if (nsort_rules
== 0 && token
== ENDOFLINE
)
154 if (token
!= TOK_BACKWARD
&& token
!= TOK_FORWARD
155 && token
!= TOK_POSITION
)
164 if ((sort_rule
[nsort_rules
] & FORWARD_BIT
) != 0)
165 error (0, 0, gettext ("%s:%Zd: directives `forward' "
166 "and `backward' are mutually "
168 locfile_data
.filename
, locfile_data
.lineno
);
170 sort_rule
[nsort_rules
] |= BACKWARD_BIT
;
173 if ((sort_rule
[nsort_rules
] & BACKWARD_BIT
) != 0)
174 error (0, 0, gettext ("%s:%Zd: directives `forward' "
175 "and `backward' are mutually "
177 locfile_data
.filename
, locfile_data
.lineno
);
179 sort_rule
[nsort_rules
] |= FORWARD_BIT
;
182 sort_rule
[nsort_rules
] |= POSITION_BIT
;
193 ignore_to_eol (token
, 0);
201 ignore_to_eol(token
,0);
202 /* Get next token. */
203 token
= xlocfile_lex (&ptr
, &len
);