1 *** glibc-2.5/./locale/programs/ld-collate.c- 2006-09-21 05:57:30.000000000 +0200
2 --- glibc-2.5/./locale/programs/ld-collate.c 2010-06-01 10:00:50.000000000 +0200
5 return retval | ((elem->section->ruleidx & 0x7f) << 24);
10 collate_output (struct localedef_t *locale, const struct charmap_t *charmap,
11 const char *output_path)
13 - struct locale_collate_t *collate = locale->categories[LC_COLLATE].collate;
14 const size_t nelems = _NL_ITEM_INDEX (_NL_NUM_LC_COLLATE);
15 struct iovec iov[2 + nelems];
16 struct locale_file data;
18 return retval | ((elem->section->ruleidx & 0x7f) << 24);
21 + /* If localedef is every threaded, these would need to be __thread var. */
22 + struct obstack weightpool;
23 + struct obstack extrapool;
24 + struct obstack indirectpool;
25 + struct collidx_table tablewc;
26 + struct locale_collate_t *collate;
29 + add_to_tablewc (uint32_t ch, struct element_t *runp)
31 + if (runp->wcnext == NULL && runp->nwcs == 1)
33 + int32_t weigthidx = output_weightwc (&weightpool, collate, runp);
34 + collidx_table_add (&tablewc, ch, weigthidx);
38 + /* As for the singlebyte table, we recognize sequences and
40 + struct element_t *lastp;
42 + collidx_table_add (&tablewc, ch,
43 + -(obstack_object_size (&extrapool) / sizeof (uint32_t)));
47 + /* Store the current index in the weight table. We know that
48 + the current position in the `extrapool' is aligned on a
53 + /* Find out wether this is a single entry or we have more than
54 + one consecutive entry. */
55 + if (runp->wcnext != NULL
56 + && runp->nwcs == runp->wcnext->nwcs
57 + && wmemcmp ((wchar_t *) runp->wcs,
58 + (wchar_t *)runp->wcnext->wcs,
59 + runp->nwcs - 1) == 0
60 + && (runp->wcs[runp->nwcs - 1]
61 + == runp->wcnext->wcs[runp->nwcs - 1] + 1))
64 + struct element_t *series_startp = runp;
65 + struct element_t *curp;
67 + /* Now add first the initial byte sequence. */
68 + added = (1 + 1 + 2 * (runp->nwcs - 1)) * sizeof (int32_t);
69 + if (sizeof (int32_t) == sizeof (int))
70 + obstack_make_room (&extrapool, added);
72 + /* More than one consecutive entry. We mark this by having
73 + a negative index into the indirect table. */
74 + obstack_int32_grow_fast (&extrapool,
75 + -(obstack_object_size (&indirectpool)
76 + / sizeof (int32_t)));
77 + obstack_int32_grow_fast (&extrapool, runp->nwcs - 1);
80 + runp = runp->wcnext;
81 + while (runp->wcnext != NULL
82 + && runp->nwcs == runp->wcnext->nwcs
83 + && wmemcmp ((wchar_t *) runp->wcs,
84 + (wchar_t *)runp->wcnext->wcs,
85 + runp->nwcs - 1) == 0
86 + && (runp->wcs[runp->nwcs - 1]
87 + == runp->wcnext->wcs[runp->nwcs - 1] + 1));
89 + /* Now walk backward from here to the beginning. */
92 + for (i = 1; i < runp->nwcs; ++i)
93 + obstack_int32_grow_fast (&extrapool, curp->wcs[i]);
95 + /* Now find the end of the consecutive sequence and
96 + add all the indeces in the indirect pool. */
99 + weightidx = output_weightwc (&weightpool, collate,
101 + obstack_int32_grow (&indirectpool, weightidx);
103 + curp = curp->wclast;
105 + while (curp != series_startp);
107 + /* Add the final weight. */
108 + weightidx = output_weightwc (&weightpool, collate, curp);
109 + obstack_int32_grow (&indirectpool, weightidx);
111 + /* And add the end byte sequence. Without length this
113 + for (i = 1; i < curp->nwcs; ++i)
114 + obstack_int32_grow (&extrapool, curp->wcs[i]);
118 + /* A single entry. Simply add the index and the length and
119 + string (except for the first character which is already
123 + /* Output the weight info. */
124 + weightidx = output_weightwc (&weightpool, collate, runp);
126 + added = (1 + 1 + runp->nwcs - 1) * sizeof (int32_t);
127 + if (sizeof (int) == sizeof (int32_t))
128 + obstack_make_room (&extrapool, added);
130 + obstack_int32_grow_fast (&extrapool, weightidx);
131 + obstack_int32_grow_fast (&extrapool, runp->nwcs - 1);
132 + for (i = 1; i < runp->nwcs; ++i)
133 + obstack_int32_grow_fast (&extrapool, runp->wcs[i]);
138 + runp = runp->wcnext;
140 + while (runp != NULL);
145 collate_output (struct localedef_t *locale, const struct charmap_t *charmap,
146 const char *output_path)
148 const size_t nelems = _NL_ITEM_INDEX (_NL_NUM_LC_COLLATE);
149 struct iovec iov[2 + nelems];
150 struct locale_file data;
155 int32_t tablemb[256];
156 - struct obstack weightpool;
157 - struct obstack extrapool;
158 - struct obstack indirectpool;
159 struct section_list *sect;
160 - struct collidx_table tablewc;
162 uint32_t *elem_table;
164 struct element_t *runp;
166 data.magic = LIMAGIC (LC_COLLATE);
168 iov[0].iov_base = (void *) &data;
172 int32_t tablemb[256];
173 struct section_list *sect;
175 uint32_t *elem_table;
177 struct element_t *runp;
179 + collate = locale->categories[LC_COLLATE].collate;
180 data.magic = LIMAGIC (LC_COLLATE);
182 iov[0].iov_base = (void *) &data;
185 the table. In case we have more than one sequence starting with
186 the same byte we have to use extra indirection. */
188 - auto void add_to_tablewc (uint32_t ch, struct element_t *runp);
190 - void add_to_tablewc (uint32_t ch, struct element_t *runp)
192 - if (runp->wcnext == NULL && runp->nwcs == 1)
194 - int32_t weigthidx = output_weightwc (&weightpool, collate, runp);
195 - collidx_table_add (&tablewc, ch, weigthidx);
199 - /* As for the singlebyte table, we recognize sequences and
201 - struct element_t *lastp;
203 - collidx_table_add (&tablewc, ch,
204 - -(obstack_object_size (&extrapool) / sizeof (uint32_t)));
208 - /* Store the current index in the weight table. We know that
209 - the current position in the `extrapool' is aligned on a
214 - /* Find out wether this is a single entry or we have more than
215 - one consecutive entry. */
216 - if (runp->wcnext != NULL
217 - && runp->nwcs == runp->wcnext->nwcs
218 - && wmemcmp ((wchar_t *) runp->wcs,
219 - (wchar_t *)runp->wcnext->wcs,
220 - runp->nwcs - 1) == 0
221 - && (runp->wcs[runp->nwcs - 1]
222 - == runp->wcnext->wcs[runp->nwcs - 1] + 1))
225 - struct element_t *series_startp = runp;
226 - struct element_t *curp;
228 - /* Now add first the initial byte sequence. */
229 - added = (1 + 1 + 2 * (runp->nwcs - 1)) * sizeof (int32_t);
230 - if (sizeof (int32_t) == sizeof (int))
231 - obstack_make_room (&extrapool, added);
233 - /* More than one consecutive entry. We mark this by having
234 - a negative index into the indirect table. */
235 - obstack_int32_grow_fast (&extrapool,
236 - -(obstack_object_size (&indirectpool)
237 - / sizeof (int32_t)));
238 - obstack_int32_grow_fast (&extrapool, runp->nwcs - 1);
241 - runp = runp->wcnext;
242 - while (runp->wcnext != NULL
243 - && runp->nwcs == runp->wcnext->nwcs
244 - && wmemcmp ((wchar_t *) runp->wcs,
245 - (wchar_t *)runp->wcnext->wcs,
246 - runp->nwcs - 1) == 0
247 - && (runp->wcs[runp->nwcs - 1]
248 - == runp->wcnext->wcs[runp->nwcs - 1] + 1));
250 - /* Now walk backward from here to the beginning. */
253 - for (i = 1; i < runp->nwcs; ++i)
254 - obstack_int32_grow_fast (&extrapool, curp->wcs[i]);
256 - /* Now find the end of the consecutive sequence and
257 - add all the indeces in the indirect pool. */
260 - weightidx = output_weightwc (&weightpool, collate,
262 - obstack_int32_grow (&indirectpool, weightidx);
264 - curp = curp->wclast;
266 - while (curp != series_startp);
268 - /* Add the final weight. */
269 - weightidx = output_weightwc (&weightpool, collate, curp);
270 - obstack_int32_grow (&indirectpool, weightidx);
272 - /* And add the end byte sequence. Without length this
274 - for (i = 1; i < curp->nwcs; ++i)
275 - obstack_int32_grow (&extrapool, curp->wcs[i]);
279 - /* A single entry. Simply add the index and the length and
280 - string (except for the first character which is already
284 - /* Output the weight info. */
285 - weightidx = output_weightwc (&weightpool, collate, runp);
287 - added = (1 + 1 + runp->nwcs - 1) * sizeof (int32_t);
288 - if (sizeof (int) == sizeof (int32_t))
289 - obstack_make_room (&extrapool, added);
291 - obstack_int32_grow_fast (&extrapool, weightidx);
292 - obstack_int32_grow_fast (&extrapool, runp->nwcs - 1);
293 - for (i = 1; i < runp->nwcs; ++i)
294 - obstack_int32_grow_fast (&extrapool, runp->wcs[i]);
299 - runp = runp->wcnext;
301 - while (runp != NULL);
307 collidx_table_init (&tablewc);