_collate.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  1. /*
  2. * Copyright (C) 2002 Manuel Novoa III
  3. * Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
  4. *
  5. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  6. */
  7. /* Dec 20, 2002
  8. * Initial test implementation of strcoll, strxfrm, wcscoll, and wcsxfrm.
  9. * The code needs to be cleaned up a good bit, but I'd like to see people
  10. * test it out.
  11. *
  12. */
  13. #include "_string.h"
  14. #include <ctype.h>
  15. #include <locale.h>
  16. #include <stdlib.h>
  17. #include <errno.h>
  18. #include <assert.h>
  19. #ifdef __UCLIBC_HAS_LOCALE__
  20. #if defined(L_strxfrm) || defined(L_strxfrm_l) || defined(L_wcsxfrm) || defined(L_wcsxfrm_l)
  21. #ifdef L_strxfrm
  22. #ifndef WANT_WIDE
  23. #error WANT_WIDE should be defined for L_strxfrm
  24. #endif
  25. #ifdef L_wcsxfrm
  26. #error L_wcsxfrm already defined for L_strxfrm
  27. #endif
  28. #endif /* L_strxfrm */
  29. #if defined(L_strxfrm) || defined(L_strxfrm_l)
  30. #define wcscoll strcoll
  31. #define wcscoll_l strcoll_l
  32. #define wcsxfrm strxfrm
  33. #define wcsxfrm_l strxfrm_l
  34. #undef WANT_WIDE
  35. #undef Wvoid
  36. #undef Wchar
  37. #undef Wuchar
  38. #undef Wint
  39. #define Wchar char
  40. #endif /* defined(L_strxfrm) || defined(L_strxfrm_l) */
  41. #if defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE)
  42. int wcscoll (const Wchar *s0, const Wchar *s1)
  43. {
  44. return wcscoll_l(s0, s1, __UCLIBC_CURLOCALE );
  45. }
  46. libc_hidden_def(wcscoll)
  47. size_t wcsxfrm(Wchar *__restrict ws1, const Wchar *__restrict ws2, size_t n)
  48. {
  49. return wcsxfrm_l(ws1, ws2, n, __UCLIBC_CURLOCALE );
  50. }
  51. #else /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
  52. #if 0
  53. #define CUR_COLLATE (&__UCLIBC_CURLOCALE->collate)
  54. #else
  55. #define CUR_COLLATE (& __LOCALE_PTR->collate)
  56. #endif
  57. #define MAX_PENDING 8
  58. typedef struct {
  59. const Wchar *s;
  60. const Wchar *eob; /* end of backward */
  61. __uwchar_t weight;
  62. __uwchar_t ui_weight; /* undefined or invalid */
  63. int colitem;
  64. int weightidx;
  65. int rule;
  66. size_t position;
  67. /* should be wchar_t. if wchar < 0 do EILSEQ? */
  68. __uwchar_t *cip;
  69. __uwchar_t ci_pending[MAX_PENDING]; /* nul-terminated */
  70. char *back_buf;
  71. char *bbe; /* end of back_buf (actual last... not 1 past end) */
  72. char *bp; /* ptr into backbuf, NULL if not in backward mode */
  73. char ibb[128];
  74. size_t bb_size;
  75. int ru_pushed;
  76. } col_state_t;
  77. #define WEIGHT_MASK 0x3fffU
  78. #define RULE_MASK 0xc000U
  79. #define RULE_FORWARD (1 << 14)
  80. #define RULE_POSITION (1 << 15)
  81. #define UI_IDX (WEIGHT_MASK-6)
  82. #define POSIT_IDX (WEIGHT_MASK-5)
  83. #define RANGE_IDX (WEIGHT_MASK-4)
  84. #define UNDEF_IDX (WEIGHT_MASK-3)
  85. #define INVAL_IDX (WEIGHT_MASK-2)
  86. #define DITTO_IDX (WEIGHT_MASK-1)
  87. #undef TRACE
  88. #if 0
  89. #define TRACE(X) printf X
  90. #else
  91. #define TRACE(X) ((void)0)
  92. #endif
  93. static int lookup(wchar_t wc __LOCALE_PARAM )
  94. {
  95. unsigned int sc, n, i0, i1;
  96. if (((__uwchar_t) wc) > 0xffffU) {
  97. return 0;
  98. }
  99. sc = wc & CUR_COLLATE->ti_mask;
  100. wc >>= CUR_COLLATE->ti_shift;
  101. n = wc & CUR_COLLATE->ii_mask;
  102. wc >>= CUR_COLLATE->ii_shift;
  103. i0 = CUR_COLLATE->wcs2colidt_tbl[wc];
  104. i0 <<= CUR_COLLATE->ii_shift;
  105. i1 = CUR_COLLATE->wcs2colidt_tbl[CUR_COLLATE->ii_len + i0 + n];
  106. i1 <<= CUR_COLLATE->ti_shift;
  107. return CUR_COLLATE->wcs2colidt_tbl[CUR_COLLATE->ii_len + CUR_COLLATE->ti_len + i1 + sc];
  108. }
  109. static void init_col_state(col_state_t *cs, const Wchar *wcs)
  110. {
  111. memset(cs, 0, sizeof(col_state_t));
  112. cs->s = wcs;
  113. cs->bp = cs->back_buf = cs->ibb;
  114. cs->bb_size = 128;
  115. cs->bbe = cs->back_buf + (cs->bb_size -1);
  116. }
  117. static void next_weight(col_state_t *cs, int pass __LOCALE_PARAM )
  118. {
  119. int r, w, ru, ri, popping_backup_stack;
  120. ssize_t n;
  121. const uint16_t *p;
  122. #ifdef WANT_WIDE
  123. #define WC (*cs->s)
  124. #define N (1)
  125. #else /* WANT_WIDE */
  126. wchar_t WC;
  127. size_t n0, nx = 0;
  128. #define N n0
  129. #endif /* WANT_WIDE */
  130. do {
  131. if (cs->ru_pushed) {
  132. ru = cs->ru_pushed;
  133. TRACE(("ru_pushed = %d\n", ru));
  134. cs->ru_pushed = 0;
  135. goto POSITION_SKIP;
  136. }
  137. if (cs->cip) { /* possible pending weight */
  138. if ((r = *(cs->cip++)) == 0) {
  139. cs->cip = NULL;
  140. continue;
  141. }
  142. cs->weightidx = r & WEIGHT_MASK;
  143. assert(cs->weightidx);
  144. /* assert(cs->weightidx != WEIGHT_MASK); */
  145. } else { /* get the next collation item from the string */
  146. TRACE(("clearing popping flag\n"));
  147. popping_backup_stack = 0;
  148. IGNORE_LOOP:
  149. /* keep first pos as 0 for a sentinal */
  150. if (*cs->bp) { /* pending backward chars */
  151. POP_BACKUP:
  152. popping_backup_stack = 1;
  153. TRACE(("setting popping flag\n"));
  154. n = 0;
  155. if (*cs->bp > 0) { /* singles pending */
  156. cs->s -= 1;
  157. if ((*cs->bp -= 1) == 0) {
  158. cs->bp -= 1;
  159. }
  160. } else { /* last was a multi */
  161. cs->s += *cs->bp;
  162. cs->bp -= 1;
  163. }
  164. } else if (!*cs->s) { /* not in backward mode and end of string */
  165. cs->weight = 0;
  166. return;
  167. } else {
  168. cs->position += 1;
  169. }
  170. BACK_LOOP:
  171. #ifdef WANT_WIDE
  172. n = 1;
  173. cs->colitem = r = lookup(*cs->s __LOCALE_ARG );
  174. #else /* WANT_WIDE */
  175. n = n0 = __locale_mbrtowc_l(&WC, cs->s, __LOCALE_PTR);
  176. if (n < 0) {
  177. __set_errno(EILSEQ);
  178. cs->weight = 0;
  179. return;
  180. }
  181. cs->colitem = r = lookup(WC __LOCALE_ARG );
  182. #endif /* WANT_WIDE */
  183. TRACE((" r=%d WC=%#lx\n", r, (unsigned long)(WC)));
  184. if (r > CUR_COLLATE->max_col_index) { /* starting char for one or more sequences */
  185. p = CUR_COLLATE->multistart_tbl;
  186. p += p[r-CUR_COLLATE->max_col_index -1];
  187. do {
  188. n = N;
  189. r = *p++;
  190. do {
  191. if (!*p) { /* found it */
  192. cs->colitem = r;
  193. TRACE((" found multi %d\n", n));
  194. goto FOUND;
  195. }
  196. #ifdef WANT_WIDE
  197. /* the lookup check here is safe since we're assured that *p is a valid colidx */
  198. if (!cs->s[n] || (lookup(cs->s[n] __LOCALE_ARG ) != *p)) {
  199. do {} while (*p++);
  200. break;
  201. }
  202. ++p;
  203. ++n;
  204. #else /* WANT_WIDE */
  205. if (cs->s[n]) {
  206. nx = __locale_mbrtowc_l(&WC, cs->s + n, __LOCALE_PTR);
  207. if (nx < 0) {
  208. __set_errno(EILSEQ);
  209. cs->weight = 0;
  210. return;
  211. }
  212. }
  213. if (!cs->s[n] || (lookup(WC __LOCALE_ARG ) != *p)) {
  214. do {} while (*p++);
  215. break;
  216. }
  217. ++p;
  218. n += nx; /* Only gets here if cs->s[n] != 0, so nx is set. */
  219. #endif /* WANT_WIDE */
  220. } while (1);
  221. } while (1);
  222. } else if (r == 0) { /* illegal, undefined, or part of a range */
  223. if ((CUR_COLLATE->range_count)
  224. && (((__uwchar_t)(WC - CUR_COLLATE->range_low)) <= CUR_COLLATE->range_count)
  225. ) { /* part of a range */
  226. /* Note: cs->colitem = 0 already. */
  227. TRACE((" found range\n"));
  228. ru = CUR_COLLATE->ruletable[CUR_COLLATE->range_rule_offset*CUR_COLLATE->MAX_WEIGHTS + pass];
  229. assert((ru & WEIGHT_MASK) != DITTO_IDX);
  230. if ((ru & WEIGHT_MASK) == WEIGHT_MASK) {
  231. ru = (ru & RULE_MASK) | RANGE_IDX;
  232. cs->weight = CUR_COLLATE->range_base_weight + (WC - CUR_COLLATE->range_low);
  233. }
  234. goto RANGE_SKIP_TO;
  235. } else if (((__uwchar_t)(WC)) <= 0x7fffffffUL) { /* legal but undefined */
  236. UNDEFINED:
  237. /* Note: cs->colitem = 0 already. */
  238. ri = CUR_COLLATE->undefined_idx;
  239. assert(ri != 0); /* implicit undefined isn't supported */
  240. TRACE((" found explicit UNDEFINED\n"));
  241. if (CUR_COLLATE->num_weights == 1) {
  242. TRACE((" single weight UNDEFINED\n"));
  243. cs->weightidx = RANGE_IDX;
  244. cs->weight = ri;
  245. cs->s += n;
  246. goto PROCESS_WEIGHT;
  247. }
  248. ri = CUR_COLLATE->index2ruleidx[ri - 1];
  249. ru = CUR_COLLATE->ruletable[ri * CUR_COLLATE->MAX_WEIGHTS + pass];
  250. assert((ru & WEIGHT_MASK) != WEIGHT_MASK); /* TODO: handle ".." */
  251. if ((ru & WEIGHT_MASK) == DITTO_IDX) {
  252. cs->colitem = CUR_COLLATE->undefined_idx;
  253. }
  254. goto RANGE_SKIP_TO;
  255. } else { /* illegal */
  256. TRACE((" found illegal\n"));
  257. __set_errno(EINVAL);
  258. /* We put all illegals in the same equiv class with maximal weight,
  259. * and ignore them after the first pass. */
  260. if (pass > 0) {
  261. cs->s += n;
  262. goto IGNORE_LOOP;
  263. }
  264. ru = (RULE_FORWARD | RANGE_IDX);
  265. cs->weight = 0xffffU;
  266. goto RANGE_SKIP_TO;
  267. }
  268. } else if (CUR_COLLATE->num_weights == 1) {
  269. TRACE((" single weight\n"));
  270. cs->weightidx = RANGE_IDX;
  271. cs->weight = cs->colitem;
  272. cs->s += n;
  273. goto PROCESS_WEIGHT;
  274. } else {
  275. TRACE((" normal\n"));
  276. }
  277. /* if we get here, it is a normal char either singlely weighted, undefined, or in a range */
  278. FOUND:
  279. ri = CUR_COLLATE->index2ruleidx[cs->colitem - 1];
  280. TRACE((" ri=%d ", ri));
  281. if (!ri) {
  282. TRACE(("NOT IN THIS LOCALE\n"));
  283. goto UNDEFINED;
  284. }
  285. ru = CUR_COLLATE->ruletable[ri * CUR_COLLATE->MAX_WEIGHTS + pass];
  286. RANGE_SKIP_TO:
  287. /* if (!(ru & WEIGHT_MASK)) { */
  288. /* TRACE(("IGNORE\n")); */
  289. /* cs->s += n; */
  290. /* continue; */
  291. /* } */
  292. TRACE((" rule = %#x weight = %#x popping = %d s = %p eob = %p\n",
  293. ru & RULE_MASK, ru & WEIGHT_MASK, popping_backup_stack,
  294. cs->s, cs->eob));
  295. /* now we need to check if we're going backwards... */
  296. if (!popping_backup_stack) {
  297. if (!(ru & RULE_MASK)) { /* backward */
  298. TRACE(("backwards\n"));
  299. assert(cs->bp <= cs->bbe);
  300. if (cs->bp == cs->bbe) {
  301. if (cs->back_buf == cs->ibb) { /* was using internal buffer */
  302. cs->bp = malloc(cs->bb_size + 128);
  303. if (!cs->bp) {
  304. /* __set_errno(ENOMEM); */
  305. cs->weight = 0;
  306. return;
  307. }
  308. memcpy(cs->bp, cs->back_buf, cs->bb_size);
  309. } else {
  310. cs->bp = realloc(cs->back_buf, cs->bb_size + 128);
  311. if (!cs->bp) {
  312. /* __set_errno(ENOMEM); */
  313. cs->weight = 0;
  314. return;
  315. }
  316. }
  317. cs->bb_size += 128;
  318. cs->bbe = cs->bp + (cs->bbe - cs->back_buf);
  319. cs->back_buf = cs->bp;
  320. cs->bp = cs->bbe;
  321. }
  322. if (n==1) { /* single char */
  323. if (*cs->bp && (((unsigned char)(*cs->bp)) < CHAR_MAX)) {
  324. *cs->bp += 1; /* increment last single's count */
  325. } else { /* last was a multi, or just starting */
  326. if (!cs->bp) {
  327. cs->bp = cs->back_buf;
  328. } else {
  329. assert(cs->bp < cs->bbe);
  330. ++cs->bp;
  331. }
  332. *cs->bp = 1;
  333. }
  334. } else { /* multichar */
  335. assert(n>1);
  336. assert(cs->bp < cs->bbe);
  337. *++cs->bp = -n;
  338. }
  339. cs->s += n;
  340. if (*cs->s) {
  341. goto BACK_LOOP;
  342. }
  343. /* end-of-string so start popping */
  344. cs->eob = cs->s;
  345. TRACE(("popping\n"));
  346. goto POP_BACKUP;
  347. } else if (*cs->bp) { /* was going backward but this element isn't */
  348. /* discard current and use previous backward element */
  349. assert(!cs->cip);
  350. cs->eob = cs->s;
  351. TRACE(("popping\n"));
  352. goto POP_BACKUP;
  353. } else { /* was and still going forward */
  354. TRACE(("forwards\n"));
  355. if ((ru & (RULE_POSITION|WEIGHT_MASK)) > RULE_POSITION) {
  356. assert(ru & WEIGHT_MASK);
  357. cs->ru_pushed = ru;
  358. cs->weight = cs->position;
  359. cs->position = 0; /* reset to reduce size for strcoll? */
  360. cs->s += n;
  361. cs->weightidx = RANGE_IDX;
  362. goto PROCESS_WEIGHT;
  363. }
  364. }
  365. } else { /* popping backwards stack */
  366. TRACE(("popping (continued)\n"));
  367. if (!*cs->bp) {
  368. cs->s = cs->eob;
  369. }
  370. cs->s -= n;
  371. }
  372. cs->s += n;
  373. POSITION_SKIP:
  374. cs->weightidx = ru & WEIGHT_MASK;
  375. cs->rule = ru & RULE_MASK;
  376. }
  377. if (!cs->weightidx) { /* ignore */
  378. continue;
  379. }
  380. PROCESS_WEIGHT:
  381. assert(cs->weightidx);
  382. if (((unsigned int)(cs->weightidx - UI_IDX)) <= (INVAL_IDX-UI_IDX)) {
  383. if (cs->weightidx == UI_IDX) {
  384. cs->weight = cs->ui_weight;
  385. }
  386. return;
  387. }
  388. assert(cs->weightidx != WEIGHT_MASK);
  389. if (cs->weightidx == DITTO_IDX) { /* want the weight of the current collating item */
  390. TRACE(("doing ditto\n"));
  391. w = CUR_COLLATE->index2weight[cs->colitem -1];
  392. } else if (cs->weightidx <= CUR_COLLATE->max_col_index) { /* normal */
  393. TRACE(("doing normal\n"));
  394. w = CUR_COLLATE->index2weight[cs->weightidx -1];
  395. } else { /* a string */
  396. TRACE(("doing string\n"));
  397. assert(!(cs->weightidx & RULE_MASK));
  398. /* note: iso14561 allows null string here */
  399. p = CUR_COLLATE->weightstr + (cs->weightidx - (CUR_COLLATE->max_col_index + 2));
  400. if (*p & WEIGHT_MASK) {
  401. r = 0;
  402. do {
  403. assert(r < MAX_PENDING);
  404. cs->ci_pending[r++] = *p++;
  405. } while (*p & WEIGHT_MASK);
  406. cs->cip = cs->ci_pending;
  407. }
  408. continue;
  409. }
  410. cs->weight = w;
  411. return;
  412. } while (1);
  413. }
  414. int __XL_NPP(wcscoll) (const Wchar *s0, const Wchar *s1 __LOCALE_PARAM )
  415. {
  416. col_state_t ws[2];
  417. int pass;
  418. if (!CUR_COLLATE->num_weights) { /* C locale */
  419. #ifdef WANT_WIDE
  420. return wcscmp(s0, s1);
  421. #else
  422. return strcmp(s0, s1);
  423. #endif
  424. }
  425. pass = 0;
  426. do { /* loop through the weights levels */
  427. init_col_state(ws, s0);
  428. init_col_state(ws+1, s1);
  429. do { /* loop through the strings */
  430. /* for each string, get the next weight */
  431. next_weight(ws, pass __LOCALE_ARG );
  432. next_weight(ws+1, pass __LOCALE_ARG );
  433. TRACE(("w0=%lu w1=%lu\n",
  434. (unsigned long) ws[0].weight,
  435. (unsigned long) ws[1].weight));
  436. if (ws[0].weight != ws[1].weight) {
  437. return ws[0].weight - ws[1].weight;
  438. }
  439. } while (ws[0].weight);
  440. } while (++pass < CUR_COLLATE->num_weights);
  441. return 0;
  442. }
  443. libc_hidden_def(__XL_NPP(wcscoll))
  444. #ifdef WANT_WIDE
  445. size_t __XL_NPP(wcsxfrm)(wchar_t *__restrict ws1, const wchar_t *__restrict ws2,
  446. size_t n __LOCALE_PARAM )
  447. {
  448. col_state_t cs;
  449. size_t count;
  450. int pass;
  451. if (!CUR_COLLATE->num_weights) { /* C locale */
  452. return __wcslcpy(ws1, ws2, n);
  453. }
  454. count = pass = 0;
  455. do { /* loop through the weights levels */
  456. init_col_state(&cs, ws2);
  457. do { /* loop through the string */
  458. next_weight(&cs, pass __LOCALE_ARG );
  459. TRACE(("weight=%lu (%#lx)\n", (unsigned long) cs.weight, (unsigned long) cs.weight));
  460. if (count < n) {
  461. ws1[count] = cs.weight +1;
  462. }
  463. ++count;
  464. TRACE(("--------------------------------------------\n"));
  465. } while (cs.weight);
  466. if (count <= n) { /* overwrite the trailing 0 end-of-pass marker */
  467. ws1[count-1] = 1;
  468. }
  469. TRACE(("-------------------- pass %d --------------------\n", pass));
  470. } while (++pass < CUR_COLLATE->num_weights);
  471. if (count <= n) { /* oops... change it back */
  472. ws1[count-1] = 0;
  473. }
  474. return count-1;
  475. }
  476. #if defined L_strxfrm_l || defined L_wcsxfrm_l
  477. libc_hidden_def(__XL_NPP(wcsxfrm))
  478. #endif
  479. #else /* WANT_WIDE */
  480. static const unsigned long bound[] = {
  481. 1UL << 7,
  482. 1UL << 11,
  483. 1UL << 16,
  484. 1UL << 21,
  485. 1UL << 26,
  486. };
  487. static unsigned char first[] = {
  488. 0x0, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc
  489. };
  490. /* Use an extension of UTF-8 to store a 32 bit val in max 6 bytes. */
  491. static size_t store(unsigned char *s, size_t count, size_t n, __uwchar_t weight)
  492. {
  493. int i, r;
  494. i = 0;
  495. do {
  496. if (weight < bound[i]) {
  497. break;
  498. }
  499. } while (++i < sizeof(bound)/sizeof(bound[0]));
  500. r = i+1;
  501. if (i + count < n) {
  502. s += count;
  503. s[0] = first[i];
  504. while (i) {
  505. s[i] = 0x80 | (weight & 0x3f);
  506. weight >>= 6;
  507. --i;
  508. }
  509. s[0] |= weight;
  510. }
  511. return r;
  512. }
  513. size_t __XL_NPP(strxfrm)(char *__restrict ws1, const char *__restrict ws2, size_t n
  514. __LOCALE_PARAM )
  515. {
  516. col_state_t cs;
  517. size_t count, inc;
  518. int pass;
  519. if (!CUR_COLLATE->num_weights) { /* C locale */
  520. return strlcpy(ws1, ws2, n);
  521. }
  522. inc = count = pass = 0;
  523. do { /* loop through the weights levels */
  524. init_col_state(&cs, ws2);
  525. do { /* loop through the string */
  526. next_weight(&cs, pass __LOCALE_ARG );
  527. TRACE(("weight=%lu (%#lx)\n", (unsigned long) cs.weight, (unsigned long) cs.weight));
  528. inc = store((unsigned char *)ws1, count, n, cs.weight + 1);
  529. count += inc;
  530. TRACE(("--------------------------------------------\n"));
  531. } while (cs.weight);
  532. /* overwrite the trailing 0 end-of-pass marker */
  533. assert(inc == 1);
  534. if (count <= n) {
  535. ws1[count-1] = 1;
  536. }
  537. TRACE(("-------------------- pass %d --------------------\n", pass));
  538. } while (++pass < CUR_COLLATE->num_weights);
  539. if (count <= n) { /* oops... change it back */
  540. ws1[count-1] = 0;
  541. }
  542. return count-1;
  543. }
  544. #ifdef L_strxfrm_l
  545. libc_hidden_def(__XL_NPP(strxfrm))
  546. #endif
  547. #endif /* WANT_WIDE */
  548. #endif /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
  549. #endif /* defined(L_strxfrm) || defined(L_strxfrm_l) || defined(L_wcsxfrm) || defined(L_wcsxfrm_l) */
  550. #endif /* __UCLIBC_HAS_LOCALE__ */
  551. /**********************************************************************/