Drop now unneeded glibc wchar-files (plus others).
This commit is contained in:
parent
b7417fbec1
commit
174676503b
|
@ -1,556 +0,0 @@
|
||||||
/* Copyright (C) 1995,96,97,98,99,2000,2001,2002 Free Software Foundation, Inc.
|
|
||||||
This file is part of the GNU C Library.
|
|
||||||
Written by Ulrich Drepper <drepper@cygnus.com>, 1995.
|
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
The GNU C Library 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
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with the GNU C Library; if not, write to the Free
|
|
||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
||||||
02111-1307 USA. */
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <langinfo.h>
|
|
||||||
#include <locale.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#ifndef STRING_TYPE
|
|
||||||
# define STRING_TYPE char
|
|
||||||
# define USTRING_TYPE unsigned char
|
|
||||||
# ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
|
||||||
# define STRCOLL __strcoll_l
|
|
||||||
# else
|
|
||||||
# define STRCOLL strcoll
|
|
||||||
# endif
|
|
||||||
# define STRCMP strcmp
|
|
||||||
# define STRLEN strlen
|
|
||||||
# define WEIGHT_H "../locale/weight.h"
|
|
||||||
# define SUFFIX MB
|
|
||||||
# define L(arg) arg
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define CONCAT(a,b) CONCAT1(a,b)
|
|
||||||
#define CONCAT1(a,b) a##b
|
|
||||||
|
|
||||||
#include "../locale/localeinfo.h"
|
|
||||||
|
|
||||||
#ifndef USE_IN_EXTENDED_LOCALE_MODEL
|
|
||||||
int
|
|
||||||
STRCOLL (s1, s2)
|
|
||||||
const STRING_TYPE *s1;
|
|
||||||
const STRING_TYPE *s2;
|
|
||||||
#else
|
|
||||||
int
|
|
||||||
STRCOLL (s1, s2, l)
|
|
||||||
const STRING_TYPE *s1;
|
|
||||||
const STRING_TYPE *s2;
|
|
||||||
__locale_t l;
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
#ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
|
||||||
struct locale_data *current = l->__locales[LC_COLLATE];
|
|
||||||
uint_fast32_t nrules = current->values[_NL_ITEM_INDEX (_NL_COLLATE_NRULES)].word;
|
|
||||||
#else
|
|
||||||
uint_fast32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
|
|
||||||
#endif
|
|
||||||
/* We don't assign the following values right away since it might be
|
|
||||||
unnecessary in case there are no rules. */
|
|
||||||
const unsigned char *rulesets;
|
|
||||||
const int32_t *table;
|
|
||||||
const USTRING_TYPE *weights;
|
|
||||||
const USTRING_TYPE *extra;
|
|
||||||
const int32_t *indirect;
|
|
||||||
uint_fast32_t pass;
|
|
||||||
int result = 0;
|
|
||||||
const USTRING_TYPE *us1;
|
|
||||||
const USTRING_TYPE *us2;
|
|
||||||
size_t s1len;
|
|
||||||
size_t s2len;
|
|
||||||
int32_t *idx1arr;
|
|
||||||
int32_t *idx2arr;
|
|
||||||
unsigned char *rule1arr;
|
|
||||||
unsigned char *rule2arr;
|
|
||||||
size_t idx1max;
|
|
||||||
size_t idx2max;
|
|
||||||
size_t idx1cnt;
|
|
||||||
size_t idx2cnt;
|
|
||||||
size_t idx1now;
|
|
||||||
size_t idx2now;
|
|
||||||
size_t backw1_stop;
|
|
||||||
size_t backw2_stop;
|
|
||||||
size_t backw1;
|
|
||||||
size_t backw2;
|
|
||||||
int val1;
|
|
||||||
int val2;
|
|
||||||
int position;
|
|
||||||
int seq1len;
|
|
||||||
int seq2len;
|
|
||||||
int use_malloc;
|
|
||||||
|
|
||||||
#include WEIGHT_H
|
|
||||||
|
|
||||||
if (nrules == 0)
|
|
||||||
return STRCMP (s1, s2);
|
|
||||||
|
|
||||||
#ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
|
||||||
rulesets = (const unsigned char *)
|
|
||||||
current->values[_NL_ITEM_INDEX (_NL_COLLATE_RULESETS)].string;
|
|
||||||
table = (const int32_t *)
|
|
||||||
current->values[_NL_ITEM_INDEX (CONCAT(_NL_COLLATE_TABLE,SUFFIX))].string;
|
|
||||||
weights = (const USTRING_TYPE *)
|
|
||||||
current->values[_NL_ITEM_INDEX (CONCAT(_NL_COLLATE_WEIGHT,SUFFIX))].string;
|
|
||||||
extra = (const USTRING_TYPE *)
|
|
||||||
current->values[_NL_ITEM_INDEX (CONCAT(_NL_COLLATE_EXTRA,SUFFIX))].string;
|
|
||||||
indirect = (const int32_t *)
|
|
||||||
current->values[_NL_ITEM_INDEX (CONCAT(_NL_COLLATE_INDIRECT,SUFFIX))].string;
|
|
||||||
#else
|
|
||||||
rulesets = (const unsigned char *)
|
|
||||||
_NL_CURRENT (LC_COLLATE, _NL_COLLATE_RULESETS);
|
|
||||||
table = (const int32_t *)
|
|
||||||
_NL_CURRENT (LC_COLLATE, CONCAT(_NL_COLLATE_TABLE,SUFFIX));
|
|
||||||
weights = (const USTRING_TYPE *)
|
|
||||||
_NL_CURRENT (LC_COLLATE, CONCAT(_NL_COLLATE_WEIGHT,SUFFIX));
|
|
||||||
extra = (const USTRING_TYPE *)
|
|
||||||
_NL_CURRENT (LC_COLLATE, CONCAT(_NL_COLLATE_EXTRA,SUFFIX));
|
|
||||||
indirect = (const int32_t *)
|
|
||||||
_NL_CURRENT (LC_COLLATE, CONCAT(_NL_COLLATE_INDIRECT,SUFFIX));
|
|
||||||
#endif
|
|
||||||
use_malloc = 0;
|
|
||||||
|
|
||||||
assert (((uintptr_t) table) % __alignof__ (table[0]) == 0);
|
|
||||||
assert (((uintptr_t) weights) % __alignof__ (weights[0]) == 0);
|
|
||||||
assert (((uintptr_t) extra) % __alignof__ (extra[0]) == 0);
|
|
||||||
assert (((uintptr_t) indirect) % __alignof__ (indirect[0]) == 0);
|
|
||||||
|
|
||||||
/* We need this a few times. */
|
|
||||||
s1len = STRLEN (s1);
|
|
||||||
s2len = STRLEN (s2);
|
|
||||||
|
|
||||||
/* Catch empty strings. */
|
|
||||||
if (__builtin_expect (s1len == 0, 0) || __builtin_expect (s2len == 0, 0))
|
|
||||||
return (s1len != 0) - (s2len != 0);
|
|
||||||
|
|
||||||
/* We need the elements of the strings as unsigned values since they
|
|
||||||
are used as indeces. */
|
|
||||||
us1 = (const USTRING_TYPE *) s1;
|
|
||||||
us2 = (const USTRING_TYPE *) s2;
|
|
||||||
|
|
||||||
/* Perform the first pass over the string and while doing this find
|
|
||||||
and store the weights for each character. Since we want this to
|
|
||||||
be as fast as possible we are using `alloca' to store the temporary
|
|
||||||
values. But since there is no limit on the length of the string
|
|
||||||
we have to use `malloc' if the string is too long. We should be
|
|
||||||
very conservative here.
|
|
||||||
|
|
||||||
Please note that the localedef programs makes sure that `position'
|
|
||||||
is not used at the first level. */
|
|
||||||
if (! __libc_use_alloca (s1len + s2len))
|
|
||||||
{
|
|
||||||
idx1arr = (int32_t *) malloc ((s1len + s2len) * (sizeof (int32_t) + 1));
|
|
||||||
idx2arr = &idx1arr[s1len];
|
|
||||||
rule1arr = (unsigned char *) &idx2arr[s2len];
|
|
||||||
rule2arr = &rule1arr[s1len];
|
|
||||||
|
|
||||||
if (idx1arr == NULL)
|
|
||||||
/* No memory. Well, go with the stack then.
|
|
||||||
|
|
||||||
XXX Once this implementation is stable we will handle this
|
|
||||||
differently. Instead of precomputing the indeces we will
|
|
||||||
do this in time. This means, though, that this happens for
|
|
||||||
every pass again. */
|
|
||||||
goto try_stack;
|
|
||||||
use_malloc = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
try_stack:
|
|
||||||
idx1arr = (int32_t *) alloca (s1len * sizeof (int32_t));
|
|
||||||
idx2arr = (int32_t *) alloca (s2len * sizeof (int32_t));
|
|
||||||
rule1arr = (unsigned char *) alloca (s1len);
|
|
||||||
rule2arr = (unsigned char *) alloca (s2len);
|
|
||||||
}
|
|
||||||
|
|
||||||
idx1cnt = 0;
|
|
||||||
idx2cnt = 0;
|
|
||||||
idx1max = 0;
|
|
||||||
idx2max = 0;
|
|
||||||
idx1now = 0;
|
|
||||||
idx2now = 0;
|
|
||||||
backw1_stop = ~0ul;
|
|
||||||
backw2_stop = ~0ul;
|
|
||||||
backw1 = ~0ul;
|
|
||||||
backw2 = ~0ul;
|
|
||||||
seq1len = 0;
|
|
||||||
seq2len = 0;
|
|
||||||
position = rulesets[0] & sort_position;
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
val1 = 0;
|
|
||||||
val2 = 0;
|
|
||||||
|
|
||||||
/* Get the next non-IGNOREd element for string `s1'. */
|
|
||||||
if (seq1len == 0)
|
|
||||||
do
|
|
||||||
{
|
|
||||||
++val1;
|
|
||||||
|
|
||||||
if (backw1_stop != ~0ul)
|
|
||||||
{
|
|
||||||
/* The is something pushed. */
|
|
||||||
if (backw1 == backw1_stop)
|
|
||||||
{
|
|
||||||
/* The last pushed character was handled. Continue
|
|
||||||
with forward characters. */
|
|
||||||
if (idx1cnt < idx1max)
|
|
||||||
idx1now = idx1cnt;
|
|
||||||
else
|
|
||||||
/* Nothing anymore. The backward sequence ended with
|
|
||||||
the last sequence in the string. Note that seq1len
|
|
||||||
is still zero. */
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
idx1now = --backw1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
backw1_stop = idx1max;
|
|
||||||
|
|
||||||
while (*us1 != L('\0'))
|
|
||||||
{
|
|
||||||
int32_t tmp = findidx (&us1);
|
|
||||||
rule1arr[idx1max] = tmp >> 24;
|
|
||||||
idx1arr[idx1max] = tmp & 0xffffff;
|
|
||||||
idx1cnt = idx1max++;
|
|
||||||
|
|
||||||
if ((rulesets[rule1arr[idx1cnt] * nrules]
|
|
||||||
& sort_backward) == 0)
|
|
||||||
/* No more backward characters to push. */
|
|
||||||
break;
|
|
||||||
++idx1cnt;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (backw1_stop >= idx1cnt)
|
|
||||||
{
|
|
||||||
/* No sequence at all or just one. */
|
|
||||||
if (idx1cnt == idx1max || backw1_stop > idx1cnt)
|
|
||||||
/* Note that seq1len is still zero. */
|
|
||||||
break;
|
|
||||||
|
|
||||||
backw1_stop = ~0ul;
|
|
||||||
idx1now = idx1cnt;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
/* We pushed backward sequences. */
|
|
||||||
idx1now = backw1 = idx1cnt - 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while ((seq1len = weights[idx1arr[idx1now]++]) == 0);
|
|
||||||
|
|
||||||
/* And the same for string `s2'. */
|
|
||||||
if (seq2len == 0)
|
|
||||||
do
|
|
||||||
{
|
|
||||||
++val2;
|
|
||||||
|
|
||||||
if (backw2_stop != ~0ul)
|
|
||||||
{
|
|
||||||
/* The is something pushed. */
|
|
||||||
if (backw2 == backw2_stop)
|
|
||||||
{
|
|
||||||
/* The last pushed character was handled. Continue
|
|
||||||
with forward characters. */
|
|
||||||
if (idx2cnt < idx2max)
|
|
||||||
idx2now = idx2cnt;
|
|
||||||
else
|
|
||||||
/* Nothing anymore. The backward sequence ended with
|
|
||||||
the last sequence in the string. Note that seq2len
|
|
||||||
is still zero. */
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
idx2now = --backw2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
backw2_stop = idx2max;
|
|
||||||
|
|
||||||
while (*us2 != L('\0'))
|
|
||||||
{
|
|
||||||
int32_t tmp = findidx (&us2);
|
|
||||||
rule2arr[idx2max] = tmp >> 24;
|
|
||||||
idx2arr[idx2max] = tmp & 0xffffff;
|
|
||||||
idx2cnt = idx2max++;
|
|
||||||
|
|
||||||
if ((rulesets[rule2arr[idx2cnt] * nrules]
|
|
||||||
& sort_backward) == 0)
|
|
||||||
/* No more backward characters to push. */
|
|
||||||
break;
|
|
||||||
++idx2cnt;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (backw2_stop >= idx2cnt)
|
|
||||||
{
|
|
||||||
/* No sequence at all or just one. */
|
|
||||||
if (idx2cnt == idx2max || backw2_stop > idx2cnt)
|
|
||||||
/* Note that seq1len is still zero. */
|
|
||||||
break;
|
|
||||||
|
|
||||||
backw2_stop = ~0ul;
|
|
||||||
idx2now = idx2cnt;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
/* We pushed backward sequences. */
|
|
||||||
idx2now = backw2 = idx2cnt - 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while ((seq2len = weights[idx2arr[idx2now]++]) == 0);
|
|
||||||
|
|
||||||
/* See whether any or both strings are empty. */
|
|
||||||
if (seq1len == 0 || seq2len == 0)
|
|
||||||
{
|
|
||||||
if (seq1len == seq2len)
|
|
||||||
/* Both ended. So far so good, both strings are equal at the
|
|
||||||
first level. */
|
|
||||||
break;
|
|
||||||
|
|
||||||
/* This means one string is shorter than the other. Find out
|
|
||||||
which one and return an appropriate value. */
|
|
||||||
result = seq1len == 0 ? -1 : 1;
|
|
||||||
goto free_and_return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Test for position if necessary. */
|
|
||||||
if (position && val1 != val2)
|
|
||||||
{
|
|
||||||
result = val1 - val2;
|
|
||||||
goto free_and_return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Compare the two sequences. */
|
|
||||||
do
|
|
||||||
{
|
|
||||||
if (weights[idx1arr[idx1now]] != weights[idx2arr[idx2now]])
|
|
||||||
{
|
|
||||||
/* The sequences differ. */
|
|
||||||
result = weights[idx1arr[idx1now]] - weights[idx2arr[idx2now]];
|
|
||||||
goto free_and_return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Increment the offsets. */
|
|
||||||
++idx1arr[idx1now];
|
|
||||||
++idx2arr[idx2now];
|
|
||||||
|
|
||||||
--seq1len;
|
|
||||||
--seq2len;
|
|
||||||
}
|
|
||||||
while (seq1len > 0 && seq2len > 0);
|
|
||||||
|
|
||||||
if (position && seq1len != seq2len)
|
|
||||||
{
|
|
||||||
result = seq1len - seq2len;
|
|
||||||
goto free_and_return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Now the remaining passes over the weights. We now use the
|
|
||||||
indeces we found before. */
|
|
||||||
for (pass = 1; pass < nrules; ++pass)
|
|
||||||
{
|
|
||||||
/* We assume that if a rule has defined `position' in one section
|
|
||||||
this is true for all of them. */
|
|
||||||
idx1cnt = 0;
|
|
||||||
idx2cnt = 0;
|
|
||||||
backw1_stop = ~0ul;
|
|
||||||
backw2_stop = ~0ul;
|
|
||||||
backw1 = ~0ul;
|
|
||||||
backw2 = ~0ul;
|
|
||||||
position = rulesets[rule1arr[0] * nrules + pass] & sort_position;
|
|
||||||
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
val1 = 0;
|
|
||||||
val2 = 0;
|
|
||||||
|
|
||||||
/* Get the next non-IGNOREd element for string `s1'. */
|
|
||||||
if (seq1len == 0)
|
|
||||||
do
|
|
||||||
{
|
|
||||||
++val1;
|
|
||||||
|
|
||||||
if (backw1_stop != ~0ul)
|
|
||||||
{
|
|
||||||
/* The is something pushed. */
|
|
||||||
if (backw1 == backw1_stop)
|
|
||||||
{
|
|
||||||
/* The last pushed character was handled. Continue
|
|
||||||
with forward characters. */
|
|
||||||
if (idx1cnt < idx1max)
|
|
||||||
idx1now = idx1cnt;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Nothing anymore. The backward sequence
|
|
||||||
ended with the last sequence in the string. */
|
|
||||||
idx1now = ~0ul;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
idx1now = --backw1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
backw1_stop = idx1cnt;
|
|
||||||
|
|
||||||
while (idx1cnt < idx1max)
|
|
||||||
{
|
|
||||||
if ((rulesets[rule1arr[idx1cnt] * nrules + pass]
|
|
||||||
& sort_backward) == 0)
|
|
||||||
/* No more backward characters to push. */
|
|
||||||
break;
|
|
||||||
++idx1cnt;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (backw1_stop == idx1cnt)
|
|
||||||
{
|
|
||||||
/* No sequence at all or just one. */
|
|
||||||
if (idx1cnt == idx1max)
|
|
||||||
/* Note that seq1len is still zero. */
|
|
||||||
break;
|
|
||||||
|
|
||||||
backw1_stop = ~0ul;
|
|
||||||
idx1now = idx1cnt++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
/* We pushed backward sequences. */
|
|
||||||
idx1now = backw1 = idx1cnt - 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while ((seq1len = weights[idx1arr[idx1now]++]) == 0);
|
|
||||||
|
|
||||||
/* And the same for string `s2'. */
|
|
||||||
if (seq2len == 0)
|
|
||||||
do
|
|
||||||
{
|
|
||||||
++val2;
|
|
||||||
|
|
||||||
if (backw2_stop != ~0ul)
|
|
||||||
{
|
|
||||||
/* The is something pushed. */
|
|
||||||
if (backw2 == backw2_stop)
|
|
||||||
{
|
|
||||||
/* The last pushed character was handled. Continue
|
|
||||||
with forward characters. */
|
|
||||||
if (idx2cnt < idx2max)
|
|
||||||
idx2now = idx2cnt;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Nothing anymore. The backward sequence
|
|
||||||
ended with the last sequence in the string. */
|
|
||||||
idx2now = ~0ul;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
idx2now = --backw2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
backw2_stop = idx2cnt;
|
|
||||||
|
|
||||||
while (idx2cnt < idx2max)
|
|
||||||
{
|
|
||||||
if ((rulesets[rule2arr[idx2cnt] * nrules + pass]
|
|
||||||
& sort_backward) == 0)
|
|
||||||
/* No more backward characters to push. */
|
|
||||||
break;
|
|
||||||
++idx2cnt;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (backw2_stop == idx2cnt)
|
|
||||||
{
|
|
||||||
/* No sequence at all or just one. */
|
|
||||||
if (idx2cnt == idx2max)
|
|
||||||
/* Note that seq2len is still zero. */
|
|
||||||
break;
|
|
||||||
|
|
||||||
backw2_stop = ~0ul;
|
|
||||||
idx2now = idx2cnt++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
/* We pushed backward sequences. */
|
|
||||||
idx2now = backw2 = idx2cnt - 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while ((seq2len = weights[idx2arr[idx2now]++]) == 0);
|
|
||||||
|
|
||||||
/* See whether any or both strings are empty. */
|
|
||||||
if (seq1len == 0 || seq2len == 0)
|
|
||||||
{
|
|
||||||
if (seq1len == seq2len)
|
|
||||||
/* Both ended. So far so good, both strings are equal
|
|
||||||
at this level. */
|
|
||||||
break;
|
|
||||||
|
|
||||||
/* This means one string is shorter than the other. Find out
|
|
||||||
which one and return an appropriate value. */
|
|
||||||
result = seq1len == 0 ? -1 : 1;
|
|
||||||
goto free_and_return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Test for position if necessary. */
|
|
||||||
if (position && val1 != val2)
|
|
||||||
{
|
|
||||||
result = val1 - val2;
|
|
||||||
goto free_and_return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Compare the two sequences. */
|
|
||||||
do
|
|
||||||
{
|
|
||||||
if (weights[idx1arr[idx1now]] != weights[idx2arr[idx2now]])
|
|
||||||
{
|
|
||||||
/* The sequences differ. */
|
|
||||||
result = (weights[idx1arr[idx1now]]
|
|
||||||
- weights[idx2arr[idx2now]]);
|
|
||||||
goto free_and_return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Increment the offsets. */
|
|
||||||
++idx1arr[idx1now];
|
|
||||||
++idx2arr[idx2now];
|
|
||||||
|
|
||||||
--seq1len;
|
|
||||||
--seq2len;
|
|
||||||
}
|
|
||||||
while (seq1len > 0 && seq2len > 0);
|
|
||||||
|
|
||||||
if (position && seq1len != seq2len)
|
|
||||||
{
|
|
||||||
result = seq1len - seq2len;
|
|
||||||
goto free_and_return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Free the memory if needed. */
|
|
||||||
free_and_return:
|
|
||||||
if (use_malloc)
|
|
||||||
free (idx1arr);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
#if !defined WIDE_CHAR_VERSION && !defined USE_IN_EXTENDED_LOCALE_MODEL
|
|
||||||
libc_hidden_def (strcoll)
|
|
||||||
#endif
|
|
|
@ -1,466 +0,0 @@
|
||||||
/* Copyright (C) 1995-1999,2000,2001,2002 Free Software Foundation, Inc.
|
|
||||||
This file is part of the GNU C Library.
|
|
||||||
Written by Ulrich Drepper <drepper@cygnus.com>, 1995.
|
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
The GNU C Library 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
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with the GNU C Library; if not, write to the Free
|
|
||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
||||||
02111-1307 USA. */
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <langinfo.h>
|
|
||||||
#include <locale.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <sys/param.h>
|
|
||||||
|
|
||||||
#ifndef STRING_TYPE
|
|
||||||
# define STRING_TYPE char
|
|
||||||
# define USTRING_TYPE unsigned char
|
|
||||||
# ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
|
||||||
# define STRXFRM __strxfrm_l
|
|
||||||
# else
|
|
||||||
# define STRXFRM strxfrm
|
|
||||||
# endif
|
|
||||||
# define STRCMP strcmp
|
|
||||||
# define STRLEN strlen
|
|
||||||
# define STPNCPY __stpncpy
|
|
||||||
# define WEIGHT_H "../locale/weight.h"
|
|
||||||
# define SUFFIX MB
|
|
||||||
# define L(arg) arg
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define CONCAT(a,b) CONCAT1(a,b)
|
|
||||||
#define CONCAT1(a,b) a##b
|
|
||||||
|
|
||||||
#include "../locale/localeinfo.h"
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef WIDE_CHAR_VERSION
|
|
||||||
|
|
||||||
/* We need UTF-8 encoding of numbers. */
|
|
||||||
static inline int
|
|
||||||
utf8_encode (char *buf, int val)
|
|
||||||
{
|
|
||||||
int retval;
|
|
||||||
|
|
||||||
if (val < 0x80)
|
|
||||||
{
|
|
||||||
*buf++ = (char) val;
|
|
||||||
retval = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int step;
|
|
||||||
|
|
||||||
for (step = 2; step < 6; ++step)
|
|
||||||
if ((val & (~(uint32_t)0 << (5 * step + 1))) == 0)
|
|
||||||
break;
|
|
||||||
retval = step;
|
|
||||||
|
|
||||||
*buf = (unsigned char) (~0xff >> step);
|
|
||||||
--step;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
buf[step] = 0x80 | (val & 0x3f);
|
|
||||||
val >>= 6;
|
|
||||||
}
|
|
||||||
while (--step > 0);
|
|
||||||
*buf |= val;
|
|
||||||
}
|
|
||||||
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef USE_IN_EXTENDED_LOCALE_MODEL
|
|
||||||
size_t
|
|
||||||
STRXFRM (STRING_TYPE *dest, const STRING_TYPE *src, size_t n)
|
|
||||||
#else
|
|
||||||
size_t
|
|
||||||
STRXFRM (STRING_TYPE *dest, const STRING_TYPE *src, size_t n, __locale_t l)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
#ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
|
||||||
struct locale_data *current = l->__locales[LC_COLLATE];
|
|
||||||
uint_fast32_t nrules = current->values[_NL_ITEM_INDEX (_NL_COLLATE_NRULES)].word;
|
|
||||||
#else
|
|
||||||
uint32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
|
|
||||||
#endif
|
|
||||||
/* We don't assign the following values right away since it might be
|
|
||||||
unnecessary in case there are no rules. */
|
|
||||||
const unsigned char *rulesets;
|
|
||||||
const int32_t *table;
|
|
||||||
const USTRING_TYPE *weights;
|
|
||||||
const USTRING_TYPE *extra;
|
|
||||||
const int32_t *indirect;
|
|
||||||
uint_fast32_t pass;
|
|
||||||
size_t needed;
|
|
||||||
const USTRING_TYPE *usrc;
|
|
||||||
size_t srclen = STRLEN (src);
|
|
||||||
int32_t *idxarr;
|
|
||||||
unsigned char *rulearr;
|
|
||||||
size_t idxmax;
|
|
||||||
size_t idxcnt;
|
|
||||||
int use_malloc;
|
|
||||||
|
|
||||||
#include WEIGHT_H
|
|
||||||
|
|
||||||
if (nrules == 0)
|
|
||||||
{
|
|
||||||
if (n != 0)
|
|
||||||
STPNCPY (dest, src, MIN (srclen + 1, n));
|
|
||||||
|
|
||||||
return srclen;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
|
||||||
rulesets = (const unsigned char *)
|
|
||||||
current->values[_NL_ITEM_INDEX (_NL_COLLATE_RULESETS)].string;
|
|
||||||
table = (const int32_t *)
|
|
||||||
current->values[_NL_ITEM_INDEX (CONCAT(_NL_COLLATE_TABLE,SUFFIX))].string;
|
|
||||||
weights = (const USTRING_TYPE *)
|
|
||||||
current->values[_NL_ITEM_INDEX (CONCAT(_NL_COLLATE_WEIGHT,SUFFIX))].string;
|
|
||||||
extra = (const USTRING_TYPE *)
|
|
||||||
current->values[_NL_ITEM_INDEX (CONCAT(_NL_COLLATE_EXTRA,SUFFIX))].string;
|
|
||||||
indirect = (const int32_t *)
|
|
||||||
current->values[_NL_ITEM_INDEX (CONCAT(_NL_COLLATE_INDIRECT,SUFFIX))].string;
|
|
||||||
#else
|
|
||||||
rulesets = (const unsigned char *)
|
|
||||||
_NL_CURRENT (LC_COLLATE, _NL_COLLATE_RULESETS);
|
|
||||||
table = (const int32_t *)
|
|
||||||
_NL_CURRENT (LC_COLLATE, CONCAT(_NL_COLLATE_TABLE,SUFFIX));
|
|
||||||
weights = (const USTRING_TYPE *)
|
|
||||||
_NL_CURRENT (LC_COLLATE, CONCAT(_NL_COLLATE_WEIGHT,SUFFIX));
|
|
||||||
extra = (const USTRING_TYPE *)
|
|
||||||
_NL_CURRENT (LC_COLLATE, CONCAT(_NL_COLLATE_EXTRA,SUFFIX));
|
|
||||||
indirect = (const int32_t *)
|
|
||||||
_NL_CURRENT (LC_COLLATE, CONCAT(_NL_COLLATE_INDIRECT,SUFFIX));
|
|
||||||
#endif
|
|
||||||
use_malloc = 0;
|
|
||||||
|
|
||||||
assert (((uintptr_t) table) % __alignof__ (table[0]) == 0);
|
|
||||||
assert (((uintptr_t) weights) % __alignof__ (weights[0]) == 0);
|
|
||||||
assert (((uintptr_t) extra) % __alignof__ (extra[0]) == 0);
|
|
||||||
assert (((uintptr_t) indirect) % __alignof__ (indirect[0]) == 0);
|
|
||||||
|
|
||||||
/* Handle an empty string as a special case. */
|
|
||||||
if (srclen == 0)
|
|
||||||
{
|
|
||||||
if (n != 0)
|
|
||||||
*dest = L('\0');
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* We need the elements of the string as unsigned values since they
|
|
||||||
are used as indeces. */
|
|
||||||
usrc = (const USTRING_TYPE *) src;
|
|
||||||
|
|
||||||
/* Perform the first pass over the string and while doing this find
|
|
||||||
and store the weights for each character. Since we want this to
|
|
||||||
be as fast as possible we are using `alloca' to store the temporary
|
|
||||||
values. But since there is no limit on the length of the string
|
|
||||||
we have to use `malloc' if the string is too long. We should be
|
|
||||||
very conservative here. */
|
|
||||||
if (! __libc_use_alloca (srclen))
|
|
||||||
{
|
|
||||||
idxarr = (int32_t *) malloc ((srclen + 1) * (sizeof (int32_t) + 1));
|
|
||||||
rulearr = (unsigned char *) &idxarr[srclen];
|
|
||||||
|
|
||||||
if (idxarr == NULL)
|
|
||||||
/* No memory. Well, go with the stack then.
|
|
||||||
|
|
||||||
XXX Once this implementation is stable we will handle this
|
|
||||||
differently. Instead of precomputing the indeces we will
|
|
||||||
do this in time. This means, though, that this happens for
|
|
||||||
every pass again. */
|
|
||||||
goto try_stack;
|
|
||||||
use_malloc = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
try_stack:
|
|
||||||
idxarr = (int32_t *) alloca (srclen * sizeof (int32_t));
|
|
||||||
rulearr = (unsigned char *) alloca (srclen + 1);
|
|
||||||
}
|
|
||||||
/* This element is only read, the value never used but to determine
|
|
||||||
another value which then is ignored. */
|
|
||||||
rulearr[srclen] = '\0';
|
|
||||||
|
|
||||||
idxmax = 0;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
int32_t tmp = findidx (&usrc);
|
|
||||||
rulearr[idxmax] = tmp >> 24;
|
|
||||||
idxarr[idxmax] = tmp & 0xffffff;
|
|
||||||
|
|
||||||
++idxmax;
|
|
||||||
}
|
|
||||||
while (*usrc != L('\0'));
|
|
||||||
|
|
||||||
/* Now the passes over the weights. We now use the indeces we found
|
|
||||||
before. */
|
|
||||||
needed = 0;
|
|
||||||
for (pass = 0; pass < nrules; ++pass)
|
|
||||||
{
|
|
||||||
size_t backw_stop = ~0ul;
|
|
||||||
int rule = rulesets[rulearr[0] * nrules + pass];
|
|
||||||
/* We assume that if a rule has defined `position' in one section
|
|
||||||
this is true for all of them. */
|
|
||||||
int position = rule & sort_position;
|
|
||||||
|
|
||||||
if (position == 0)
|
|
||||||
{
|
|
||||||
for (idxcnt = 0; idxcnt < idxmax; ++idxcnt)
|
|
||||||
{
|
|
||||||
if ((rule & sort_forward) != 0)
|
|
||||||
{
|
|
||||||
size_t len;
|
|
||||||
|
|
||||||
if (backw_stop != ~0ul)
|
|
||||||
{
|
|
||||||
/* Handle the pushed elements now. */
|
|
||||||
size_t backw;
|
|
||||||
|
|
||||||
for (backw = idxcnt - 1; backw >= backw_stop; --backw)
|
|
||||||
{
|
|
||||||
len = weights[idxarr[backw]++];
|
|
||||||
|
|
||||||
if (needed + len < n)
|
|
||||||
while (len-- > 0)
|
|
||||||
dest[needed++] = weights[idxarr[backw]++];
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* No more characters fit into the buffer. */
|
|
||||||
needed += len;
|
|
||||||
idxarr[backw] += len;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
backw_stop = ~0ul;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Now handle the forward element. */
|
|
||||||
len = weights[idxarr[idxcnt]++];
|
|
||||||
if (needed + len < n)
|
|
||||||
while (len-- > 0)
|
|
||||||
dest[needed++] = weights[idxarr[idxcnt]++];
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* No more characters fit into the buffer. */
|
|
||||||
needed += len;
|
|
||||||
idxarr[idxcnt] += len;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Remember where the backwards series started. */
|
|
||||||
if (backw_stop == ~0ul)
|
|
||||||
backw_stop = idxcnt;
|
|
||||||
}
|
|
||||||
|
|
||||||
rule = rulesets[rulearr[idxcnt + 1] * nrules + pass];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (backw_stop != ~0ul)
|
|
||||||
{
|
|
||||||
/* Handle the pushed elements now. */
|
|
||||||
size_t backw;
|
|
||||||
|
|
||||||
backw = idxcnt;
|
|
||||||
while (backw > backw_stop)
|
|
||||||
{
|
|
||||||
size_t len = weights[idxarr[--backw]++];
|
|
||||||
|
|
||||||
if (needed + len < n)
|
|
||||||
while (len-- > 0)
|
|
||||||
dest[needed++] = weights[idxarr[backw]++];
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* No more characters fit into the buffer. */
|
|
||||||
needed += len;
|
|
||||||
idxarr[backw] += len;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int val = 1;
|
|
||||||
#ifndef WIDE_CHAR_VERSION
|
|
||||||
char buf[7];
|
|
||||||
size_t buflen;
|
|
||||||
#endif
|
|
||||||
size_t i;
|
|
||||||
|
|
||||||
for (idxcnt = 0; idxcnt < idxmax; ++idxcnt)
|
|
||||||
{
|
|
||||||
if ((rule & sort_forward) != 0)
|
|
||||||
{
|
|
||||||
size_t len;
|
|
||||||
|
|
||||||
if (backw_stop != ~0ul)
|
|
||||||
{
|
|
||||||
/* Handle the pushed elements now. */
|
|
||||||
size_t backw;
|
|
||||||
|
|
||||||
for (backw = idxcnt - 1; backw >= backw_stop; --backw)
|
|
||||||
{
|
|
||||||
len = weights[idxarr[backw]++];
|
|
||||||
if (len != 0)
|
|
||||||
{
|
|
||||||
#ifdef WIDE_CHAR_VERSION
|
|
||||||
if (needed + 1 + len < n)
|
|
||||||
{
|
|
||||||
dest[needed] = val;
|
|
||||||
for (i = 0; i < len; ++i)
|
|
||||||
dest[needed + 1 + i] =
|
|
||||||
weights[idxarr[backw] + i];
|
|
||||||
}
|
|
||||||
needed += 1 + len;
|
|
||||||
#else
|
|
||||||
buflen = utf8_encode (buf, val);
|
|
||||||
if (needed + buflen + len < n)
|
|
||||||
{
|
|
||||||
for (i = 0; i < buflen; ++i)
|
|
||||||
dest[needed + i] = buf[i];
|
|
||||||
for (i = 0; i < len; ++i)
|
|
||||||
dest[needed + buflen + i] =
|
|
||||||
weights[idxarr[backw] + i];
|
|
||||||
}
|
|
||||||
needed += buflen + len;
|
|
||||||
#endif
|
|
||||||
idxarr[backw] += len;
|
|
||||||
val = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
++val;
|
|
||||||
}
|
|
||||||
|
|
||||||
backw_stop = ~0ul;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Now handle the forward element. */
|
|
||||||
len = weights[idxarr[idxcnt]++];
|
|
||||||
if (len != 0)
|
|
||||||
{
|
|
||||||
#ifdef WIDE_CHAR_VERSION
|
|
||||||
if (needed + 1+ len < n)
|
|
||||||
{
|
|
||||||
dest[needed] = val;
|
|
||||||
for (i = 0; i < len; ++i)
|
|
||||||
dest[needed + 1 + i] =
|
|
||||||
weights[idxarr[idxcnt] + i];
|
|
||||||
}
|
|
||||||
needed += 1 + len;
|
|
||||||
#else
|
|
||||||
buflen = utf8_encode (buf, val);
|
|
||||||
if (needed + buflen + len < n)
|
|
||||||
{
|
|
||||||
for (i = 0; i < buflen; ++i)
|
|
||||||
dest[needed + i] = buf[i];
|
|
||||||
for (i = 0; i < len; ++i)
|
|
||||||
dest[needed + buflen + i] =
|
|
||||||
weights[idxarr[idxcnt] + i];
|
|
||||||
}
|
|
||||||
needed += buflen + len;
|
|
||||||
#endif
|
|
||||||
idxarr[idxcnt] += len;
|
|
||||||
val = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
/* Note that we don't have to increment `idxarr[idxcnt]'
|
|
||||||
since the length is zero. */
|
|
||||||
++val;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Remember where the backwards series started. */
|
|
||||||
if (backw_stop == ~0ul)
|
|
||||||
backw_stop = idxcnt;
|
|
||||||
}
|
|
||||||
|
|
||||||
rule = rulesets[rulearr[idxcnt + 1] * nrules + pass];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (backw_stop != ~0ul)
|
|
||||||
{
|
|
||||||
/* Handle the pushed elements now. */
|
|
||||||
size_t backw;
|
|
||||||
|
|
||||||
backw = idxmax - 1;
|
|
||||||
while (backw > backw_stop)
|
|
||||||
{
|
|
||||||
size_t len = weights[idxarr[--backw]++];
|
|
||||||
if (len != 0)
|
|
||||||
{
|
|
||||||
#ifdef WIDE_CHAR_VERSION
|
|
||||||
if (needed + 1 + len < n)
|
|
||||||
{
|
|
||||||
dest[needed] = val;
|
|
||||||
for (i = 0; i < len; ++i)
|
|
||||||
dest[needed + 1 + i] =
|
|
||||||
weights[idxarr[backw] + i];
|
|
||||||
}
|
|
||||||
needed += 1 + len;
|
|
||||||
#else
|
|
||||||
buflen = utf8_encode (buf, val);
|
|
||||||
if (needed + buflen + len < n)
|
|
||||||
{
|
|
||||||
for (i = 0; i < buflen; ++i)
|
|
||||||
dest[needed + i] = buf[i];
|
|
||||||
for (i = 0; i < len; ++i)
|
|
||||||
dest[needed + buflen + i] =
|
|
||||||
weights[idxarr[backw] + i];
|
|
||||||
}
|
|
||||||
needed += buflen + len;
|
|
||||||
#endif
|
|
||||||
idxarr[backw] += len;
|
|
||||||
val = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
++val;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Finally store the byte to separate the passes or terminate
|
|
||||||
the string. */
|
|
||||||
if (needed < n)
|
|
||||||
dest[needed] = pass + 1 < nrules ? L('\1') : L('\0');
|
|
||||||
++needed;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* This is a little optimization: many collation specifications have
|
|
||||||
a `position' rule at the end and if no non-ignored character
|
|
||||||
is found the last \1 byte is immediately followed by a \0 byte
|
|
||||||
signalling this. We can avoid the \1 byte(s). */
|
|
||||||
if (needed <= n && needed > 2 && dest[needed - 2] == L('\1'))
|
|
||||||
{
|
|
||||||
/* Remove the \1 byte. */
|
|
||||||
--needed;
|
|
||||||
dest[needed - 1] = L('\0');
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Free the memory if needed. */
|
|
||||||
if (use_malloc)
|
|
||||||
free (idxarr);
|
|
||||||
|
|
||||||
/* Return the number of bytes/words we need, but don't count the NUL
|
|
||||||
byte/word at the end. */
|
|
||||||
return needed - 1;
|
|
||||||
}
|
|
|
@ -1,68 +0,0 @@
|
||||||
# Copyright (C) 1995-2000, 2002 Free Software Foundation, Inc.
|
|
||||||
# This file is part of the GNU C Library.
|
|
||||||
|
|
||||||
# The GNU C Library is free software; you can redistribute it and/or
|
|
||||||
# modify it under the terms of the GNU Lesser General Public
|
|
||||||
# License as published by the Free Software Foundation; either
|
|
||||||
# version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
# The GNU C Library 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
|
|
||||||
# Lesser General Public License for more details.
|
|
||||||
|
|
||||||
# You should have received a copy of the GNU Lesser General Public
|
|
||||||
# License along with the GNU C Library; if not, write to the Free
|
|
||||||
# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
||||||
# 02111-1307 USA.
|
|
||||||
|
|
||||||
#
|
|
||||||
# Sub-makefile for wcsmbs portion of the library.
|
|
||||||
#
|
|
||||||
subdir := wcsmbs
|
|
||||||
|
|
||||||
headers := wchar.h
|
|
||||||
distribute := wcwidth.h wcsmbsload.h
|
|
||||||
|
|
||||||
routines := wcscat wcschr wcscmp wcscpy wcscspn wcsdup wcslen wcsncat \
|
|
||||||
wcsncmp wcsncpy wcspbrk wcsrchr wcsspn wcstok wcsstr wmemchr \
|
|
||||||
wmemcmp wmemcpy wmemmove wmemset wcpcpy wcpncpy wmempcpy \
|
|
||||||
btowc wctob mbsinit \
|
|
||||||
mbrlen mbrtowc wcrtomb mbsrtowcs wcsrtombs \
|
|
||||||
mbsnrtowcs wcsnrtombs wcsnlen wcschrnul \
|
|
||||||
wcstol wcstoul wcstoll wcstoull wcstod wcstold wcstof \
|
|
||||||
wcstol_l wcstoul_l wcstoll_l wcstoull_l \
|
|
||||||
wcstod_l wcstold_l wcstof_l \
|
|
||||||
wcscoll wcsxfrm \
|
|
||||||
wcwidth wcswidth \
|
|
||||||
wcscoll_l wcsxfrm_l \
|
|
||||||
wcscasecmp wcsncase wcscasecmp_l wcsncase_l \
|
|
||||||
wcsmbsload mbsrtowcs_l
|
|
||||||
|
|
||||||
tests := tst-wcstof wcsmbs-tst1 tst-wcsnlen tst-btowc tst-mbrtowc \
|
|
||||||
tst-wcrtomb
|
|
||||||
|
|
||||||
include ../Rules
|
|
||||||
|
|
||||||
CFLAGS-wcwidth.c = -I../wctype
|
|
||||||
CFLAGS-wcswidth.c = -I../wctype
|
|
||||||
|
|
||||||
strtox-CFLAGS = -I../include -I../stdlib
|
|
||||||
CFLAGS-wcstol.c = $(strtox-CFLAGS)
|
|
||||||
CFLAGS-wcstoul.c = $(strtox-CFLAGS)
|
|
||||||
CFLAGS-wcstoll.c = $(strtox-CFLAGS)
|
|
||||||
CFLAGS-wcstoull.c = $(strtox-CFLAGS)
|
|
||||||
CFLAGS-wcstod.c = $(strtox-CFLAGS)
|
|
||||||
CFLAGS-wcstold.c = $(strtox-CFLAGS)
|
|
||||||
CFLAGS-wcstof.c = $(strtox-CFLAGS)
|
|
||||||
CFLAGS-wcstol_l.c = $(strtox-CFLAGS)
|
|
||||||
CFLAGS-wcstoul_l.c = $(strtox-CFLAGS)
|
|
||||||
CFLAGS-wcstoll_l.c = $(strtox-CFLAGS)
|
|
||||||
CFLAGS-wcstoull_l.c = $(strtox-CFLAGS)
|
|
||||||
CFLAGS-wcstod_l.c = $(strtox-CFLAGS)
|
|
||||||
CFLAGS-wcstold_l.c = $(strtox-CFLAGS)
|
|
||||||
CFLAGS-wcstof_l.c = $(strtox-CFLAGS)
|
|
||||||
|
|
||||||
tst-btowc-ENV = LOCPATH=$(common-objpfx)localedata
|
|
||||||
tst-mbrtowc-ENV = LOCPATH=$(common-objpfx)localedata
|
|
||||||
tst-wcrtomb-ENV = LOCPATH=$(common-objpfx)localedata
|
|
|
@ -1,47 +0,0 @@
|
||||||
/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
|
|
||||||
This file is part of the GNU C Library.
|
|
||||||
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
|
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
The GNU C Library 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
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with the GNU C Library; if not, write to the Free
|
|
||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
||||||
02111-1307 USA. */
|
|
||||||
|
|
||||||
#include <wchar.h>
|
|
||||||
|
|
||||||
#define __need_ptrdiff_t
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
|
|
||||||
/* Copy SRC to DEST, returning the address of the terminating L'\0' in
|
|
||||||
DEST. */
|
|
||||||
wchar_t *
|
|
||||||
__wcpcpy (dest, src)
|
|
||||||
wchar_t *dest;
|
|
||||||
const wchar_t *src;
|
|
||||||
{
|
|
||||||
wchar_t *wcp = (wchar_t *) dest - 1;
|
|
||||||
wint_t c;
|
|
||||||
const ptrdiff_t off = src - dest + 1;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
c = wcp[off];
|
|
||||||
*++wcp = c;
|
|
||||||
}
|
|
||||||
while (c != L'\0');
|
|
||||||
|
|
||||||
return wcp;
|
|
||||||
}
|
|
||||||
|
|
||||||
weak_alias (__wcpcpy, wcpcpy)
|
|
|
@ -1,89 +0,0 @@
|
||||||
/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
|
|
||||||
This file is part of the GNU C Library.
|
|
||||||
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
|
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
The GNU C Library 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
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with the GNU C Library; if not, write to the Free
|
|
||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
||||||
02111-1307 USA. */
|
|
||||||
|
|
||||||
#include <wchar.h>
|
|
||||||
|
|
||||||
|
|
||||||
/* Copy no more than N wide-characters of SRC to DEST, returning the
|
|
||||||
address of the last character written into DEST. */
|
|
||||||
wchar_t *
|
|
||||||
__wcpncpy (dest, src, n)
|
|
||||||
wchar_t *dest;
|
|
||||||
const wchar_t *src;
|
|
||||||
size_t n;
|
|
||||||
{
|
|
||||||
wint_t c;
|
|
||||||
wchar_t *const s = dest;
|
|
||||||
|
|
||||||
--dest;
|
|
||||||
|
|
||||||
if (n >= 4)
|
|
||||||
{
|
|
||||||
size_t n4 = n >> 2;
|
|
||||||
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
c = *src++;
|
|
||||||
*++dest = c;
|
|
||||||
if (c == L'\0')
|
|
||||||
break;
|
|
||||||
c = *src++;
|
|
||||||
*++dest = c;
|
|
||||||
if (c == L'\0')
|
|
||||||
break;
|
|
||||||
c = *src++;
|
|
||||||
*++dest = c;
|
|
||||||
if (c == L'\0')
|
|
||||||
break;
|
|
||||||
c = *src++;
|
|
||||||
*++dest = c;
|
|
||||||
if (c == L'\0')
|
|
||||||
break;
|
|
||||||
if (--n4 == 0)
|
|
||||||
goto last_chars;
|
|
||||||
}
|
|
||||||
n = n - (dest - s) - 1;
|
|
||||||
if (n == 0)
|
|
||||||
return dest;
|
|
||||||
goto zero_fill;
|
|
||||||
}
|
|
||||||
|
|
||||||
last_chars:
|
|
||||||
n &= 3;
|
|
||||||
if (n == 0)
|
|
||||||
return dest;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
c = *src++;
|
|
||||||
*++dest = c;
|
|
||||||
if (--n == 0)
|
|
||||||
return dest;
|
|
||||||
}
|
|
||||||
while (c != L'\0');
|
|
||||||
|
|
||||||
zero_fill:
|
|
||||||
do
|
|
||||||
*++dest = L'\0';
|
|
||||||
while (--n > 0);
|
|
||||||
|
|
||||||
return dest;
|
|
||||||
}
|
|
||||||
|
|
||||||
weak_alias (__wcpncpy, wcpncpy)
|
|
|
@ -1,73 +0,0 @@
|
||||||
/* Copyright (C) 1991, 1992, 1995, 1996, 1997 Free Software Foundation, Inc.
|
|
||||||
This file is part of the GNU C Library.
|
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
The GNU C Library 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
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with the GNU C Library; if not, write to the Free
|
|
||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
||||||
02111-1307 USA. */
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
# include <config.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <wctype.h>
|
|
||||||
#include <wchar.h>
|
|
||||||
|
|
||||||
#ifndef weak_alias
|
|
||||||
# define __wcscasecmp wcscasecmp
|
|
||||||
# define TOLOWER(Ch) towlower (Ch)
|
|
||||||
#else
|
|
||||||
# ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
|
||||||
# define __wcscasecmp __wcscasecmp_l
|
|
||||||
# define TOLOWER(Ch) __towlower_l ((Ch), loc)
|
|
||||||
# else
|
|
||||||
# define TOLOWER(Ch) towlower (Ch)
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
|
||||||
# define LOCALE_PARAM , loc
|
|
||||||
# define LOCALE_PARAM_DECL __locale_t loc;
|
|
||||||
#else
|
|
||||||
# define LOCALE_PARAM
|
|
||||||
# define LOCALE_PARAM_DECL
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Compare S1 and S2, ignoring case, returning less than, equal to or
|
|
||||||
greater than zero if S1 is lexicographically less than,
|
|
||||||
equal to or greater than S2. */
|
|
||||||
int
|
|
||||||
__wcscasecmp (s1, s2 LOCALE_PARAM)
|
|
||||||
const wchar_t *s1;
|
|
||||||
const wchar_t *s2;
|
|
||||||
LOCALE_PARAM_DECL
|
|
||||||
{
|
|
||||||
wint_t c1, c2;
|
|
||||||
|
|
||||||
if (s1 == s2)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
c1 = TOLOWER (*s1++);
|
|
||||||
c2 = TOLOWER (*s2++);
|
|
||||||
if (c1 == L'\0')
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
while (c1 == c2);
|
|
||||||
|
|
||||||
return c1 - c2;
|
|
||||||
}
|
|
||||||
#ifndef __wcscasecmp
|
|
||||||
weak_alias (__wcscasecmp, wcscasecmp)
|
|
||||||
#endif
|
|
|
@ -1,24 +0,0 @@
|
||||||
/* Copyright (C) 1997,2002 Free Software Foundation, Inc.
|
|
||||||
This file is part of the GNU C Library.
|
|
||||||
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
|
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
The GNU C Library 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
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with the GNU C Library; if not, write to the Free
|
|
||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
||||||
02111-1307 USA. */
|
|
||||||
|
|
||||||
#define USE_IN_EXTENDED_LOCALE_MODEL 1
|
|
||||||
#include <wcscasecmp.c>
|
|
||||||
|
|
||||||
libc_hidden_def (__wcscasecmp_l)
|
|
||||||
weak_alias (__wcscasecmp_l, wcscasecmp_l)
|
|
|
@ -1,51 +0,0 @@
|
||||||
/* Copyright (C) 1995, 1996, 1997, 2001 Free Software Foundation, Inc.
|
|
||||||
This file is part of the GNU C Library.
|
|
||||||
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
|
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
The GNU C Library 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
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with the GNU C Library; if not, write to the Free
|
|
||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
||||||
02111-1307 USA. */
|
|
||||||
|
|
||||||
#include <wchar.h>
|
|
||||||
|
|
||||||
|
|
||||||
/* Append SRC on the end of DEST. */
|
|
||||||
wchar_t *
|
|
||||||
__wcscat (dest, src)
|
|
||||||
wchar_t *dest;
|
|
||||||
const wchar_t *src;
|
|
||||||
{
|
|
||||||
register wchar_t *s1 = dest;
|
|
||||||
register const wchar_t *s2 = src;
|
|
||||||
wchar_t c;
|
|
||||||
|
|
||||||
/* Find the end of the string. */
|
|
||||||
do
|
|
||||||
c = *s1++;
|
|
||||||
while (c != L'\0');
|
|
||||||
|
|
||||||
/* Make S1 point before the next character, so we can increment
|
|
||||||
it while memory is read (wins on pipelined cpus). */
|
|
||||||
s1 -= 2;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
c = *s2++;
|
|
||||||
*++s1 = c;
|
|
||||||
}
|
|
||||||
while (c != L'\0');
|
|
||||||
|
|
||||||
return dest;
|
|
||||||
}
|
|
||||||
weak_alias (__wcscat, wcscat)
|
|
|
@ -1,35 +0,0 @@
|
||||||
/* Copyright (C) 1995, 1996, 1999 Free Software Foundation, Inc.
|
|
||||||
This file is part of the GNU C Library.
|
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
The GNU C Library 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
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with the GNU C Library; if not, write to the Free
|
|
||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
||||||
02111-1307 USA. */
|
|
||||||
|
|
||||||
#include <wchar.h>
|
|
||||||
|
|
||||||
|
|
||||||
/* Find the first occurrence of WC in WCS. */
|
|
||||||
wchar_t *
|
|
||||||
wcschr (wcs, wc)
|
|
||||||
register const wchar_t *wcs;
|
|
||||||
register const wchar_t wc;
|
|
||||||
{
|
|
||||||
do
|
|
||||||
if (*wcs == wc)
|
|
||||||
return (wchar_t *) wcs;
|
|
||||||
while (*wcs++ != L'\0');
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
libc_hidden_def (wcschr)
|
|
|
@ -1,36 +0,0 @@
|
||||||
/* Copyright (C) 1995, 1996, 1999 Free Software Foundation, Inc.
|
|
||||||
This file is part of the GNU C Library.
|
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
The GNU C Library 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
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with the GNU C Library; if not, write to the Free
|
|
||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
||||||
02111-1307 USA. */
|
|
||||||
|
|
||||||
#include <wchar.h>
|
|
||||||
|
|
||||||
|
|
||||||
/* Find the first occurrence of WC in WCS. */
|
|
||||||
wchar_t *
|
|
||||||
__wcschrnul (wcs, wc)
|
|
||||||
register const wchar_t *wcs;
|
|
||||||
register const wchar_t wc;
|
|
||||||
{
|
|
||||||
while (*wcs != L'\0')
|
|
||||||
if (*wcs == wc)
|
|
||||||
break;
|
|
||||||
else
|
|
||||||
++wcs;
|
|
||||||
|
|
||||||
return (wchar_t *) wcs;
|
|
||||||
}
|
|
||||||
weak_alias (__wcschrnul, wcschrnul)
|
|
|
@ -1,44 +0,0 @@
|
||||||
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
|
||||||
This file is part of the GNU C Library.
|
|
||||||
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
|
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
The GNU C Library 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
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with the GNU C Library; if not, write to the Free
|
|
||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
||||||
02111-1307 USA. */
|
|
||||||
|
|
||||||
#include <wchar.h>
|
|
||||||
|
|
||||||
|
|
||||||
/* Compare S1 and S2, returning less than, equal to or
|
|
||||||
greater than zero if S1 is lexicographically less than,
|
|
||||||
equal to or greater than S2. */
|
|
||||||
int
|
|
||||||
wcscmp (s1, s2)
|
|
||||||
const wchar_t *s1;
|
|
||||||
const wchar_t *s2;
|
|
||||||
{
|
|
||||||
wint_t c1, c2;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
c1 = (wint_t) *s1++;
|
|
||||||
c2 = (wint_t) *s2++;
|
|
||||||
if (c1 == L'\0')
|
|
||||||
return c1 - c2;
|
|
||||||
}
|
|
||||||
while (c1 == c2);
|
|
||||||
|
|
||||||
return c1 - c2;
|
|
||||||
}
|
|
||||||
libc_hidden_def (wcscmp)
|
|
|
@ -1,41 +0,0 @@
|
||||||
/* Copyright (C) 1996, 1997, 1999, 2000, 2001 Free Software Foundation, Inc.
|
|
||||||
This file is part of the GNU C Library.
|
|
||||||
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
|
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
The GNU C Library 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
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with the GNU C Library; if not, write to the Free
|
|
||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
||||||
02111-1307 USA. */
|
|
||||||
|
|
||||||
#include <wchar.h>
|
|
||||||
#include "../locale/coll-lookup.h"
|
|
||||||
|
|
||||||
#define STRING_TYPE wchar_t
|
|
||||||
#define USTRING_TYPE wint_t
|
|
||||||
#ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
|
||||||
# define STRCOLL __wcscoll_l
|
|
||||||
#else
|
|
||||||
# define STRCOLL __wcscoll
|
|
||||||
#endif
|
|
||||||
#define STRCMP wcscmp
|
|
||||||
#define STRLEN __wcslen
|
|
||||||
#define WEIGHT_H "../locale/weightwc.h"
|
|
||||||
#define SUFFIX WC
|
|
||||||
#define L(arg) L##arg
|
|
||||||
#define WIDE_CHAR_VERSION 1
|
|
||||||
|
|
||||||
#include "../string/strcoll.c"
|
|
||||||
|
|
||||||
#ifndef USE_IN_EXTENDED_LOCALE_MODEL
|
|
||||||
weak_alias (__wcscoll, wcscoll)
|
|
||||||
#endif
|
|
|
@ -1,23 +0,0 @@
|
||||||
/* Copyright (C) 1996, 1997, 2002 Free Software Foundation, Inc.
|
|
||||||
This file is part of the GNU C Library.
|
|
||||||
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
|
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
The GNU C Library 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
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with the GNU C Library; if not, write to the Free
|
|
||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
||||||
02111-1307 USA. */
|
|
||||||
|
|
||||||
#define USE_IN_EXTENDED_LOCALE_MODEL 1
|
|
||||||
#include <wcscoll.c>
|
|
||||||
|
|
||||||
weak_alias (__wcscoll_l, wcscoll_l)
|
|
|
@ -1,59 +0,0 @@
|
||||||
/* Copyright (C) 1995, 1996, 1997, 2003 Free Software Foundation, Inc.
|
|
||||||
This file is part of the GNU C Library.
|
|
||||||
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
|
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
The GNU C Library 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
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with the GNU C Library; if not, write to the Free
|
|
||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
||||||
02111-1307 USA. */
|
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <wchar.h>
|
|
||||||
|
|
||||||
|
|
||||||
/* Copy SRC to DEST. */
|
|
||||||
wchar_t *
|
|
||||||
wcscpy (dest, src)
|
|
||||||
wchar_t *dest;
|
|
||||||
const wchar_t *src;
|
|
||||||
{
|
|
||||||
wint_t c;
|
|
||||||
wchar_t *wcp;
|
|
||||||
|
|
||||||
if (__alignof__ (wchar_t) >= sizeof (wchar_t))
|
|
||||||
{
|
|
||||||
const ptrdiff_t off = dest - src - 1;
|
|
||||||
|
|
||||||
wcp = (wchar_t *) src;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
c = *wcp++;
|
|
||||||
wcp[off] = c;
|
|
||||||
}
|
|
||||||
while (c != L'\0');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
wcp = dest;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
c = *src++;
|
|
||||||
*wcp++ = c;
|
|
||||||
}
|
|
||||||
while (c != L'\0');
|
|
||||||
}
|
|
||||||
|
|
||||||
return dest;
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
|
||||||
This file is part of the GNU C Library.
|
|
||||||
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
|
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
The GNU C Library 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
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with the GNU C Library; if not, write to the Free
|
|
||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
||||||
02111-1307 USA. */
|
|
||||||
|
|
||||||
#include <wchar.h>
|
|
||||||
|
|
||||||
|
|
||||||
/* Return the length of the maximum initial segment
|
|
||||||
of WCS which contains only wide-characters not in REJECT. */
|
|
||||||
size_t
|
|
||||||
wcscspn (wcs, reject)
|
|
||||||
const wchar_t *wcs;
|
|
||||||
const wchar_t *reject;
|
|
||||||
{
|
|
||||||
register size_t count = 0;
|
|
||||||
|
|
||||||
while (*wcs != L'\0')
|
|
||||||
if (wcschr (reject, *wcs++) == NULL)
|
|
||||||
++count;
|
|
||||||
else
|
|
||||||
return count;
|
|
||||||
|
|
||||||
return count;
|
|
||||||
}
|
|
|
@ -1,37 +0,0 @@
|
||||||
/* Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
|
|
||||||
This file is part of the GNU C Library.
|
|
||||||
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
|
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
The GNU C Library 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
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with the GNU C Library; if not, write to the Free
|
|
||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
||||||
02111-1307 USA. */
|
|
||||||
|
|
||||||
#include <wchar.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
|
|
||||||
/* Duplicate S, returning an identical malloc'd string. */
|
|
||||||
wchar_t *
|
|
||||||
wcsdup (s)
|
|
||||||
const wchar_t *s;
|
|
||||||
{
|
|
||||||
size_t len = (__wcslen (s) + 1) * sizeof (wchar_t);
|
|
||||||
void *new = malloc (len);
|
|
||||||
|
|
||||||
if (new == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return (wchar_t *) memcpy (new, (void *) s, len);
|
|
||||||
}
|
|
|
@ -1,43 +0,0 @@
|
||||||
/* Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
|
|
||||||
This file is part of the GNU C Library.
|
|
||||||
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
|
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
The GNU C Library 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
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with the GNU C Library; if not, write to the Free
|
|
||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
||||||
02111-1307 USA. */
|
|
||||||
|
|
||||||
#include <wchar.h>
|
|
||||||
|
|
||||||
|
|
||||||
/* Return length of string S. */
|
|
||||||
size_t
|
|
||||||
__wcslen (s)
|
|
||||||
const wchar_t *s;
|
|
||||||
{
|
|
||||||
size_t len = 0;
|
|
||||||
|
|
||||||
while (s[len] != L'\0')
|
|
||||||
{
|
|
||||||
if (s[++len] == L'\0')
|
|
||||||
return len;
|
|
||||||
if (s[++len] == L'\0')
|
|
||||||
return len;
|
|
||||||
if (s[++len] == L'\0')
|
|
||||||
return len;
|
|
||||||
++len;
|
|
||||||
}
|
|
||||||
|
|
||||||
return len;
|
|
||||||
}
|
|
||||||
weak_alias (__wcslen, wcslen)
|
|
|
@ -1,59 +0,0 @@
|
||||||
/* Based on a test program by Won Kyu Park <wkpark@chem.skku.ac.kr>. */
|
|
||||||
|
|
||||||
#include <wchar.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <wctype.h>
|
|
||||||
#include <locale.h>
|
|
||||||
|
|
||||||
int
|
|
||||||
main (void)
|
|
||||||
{
|
|
||||||
int test = 0;
|
|
||||||
int idx = 0;
|
|
||||||
char buf[100], *pchar;
|
|
||||||
wchar_t tmp[10];
|
|
||||||
wchar_t tmp1[] = { L'W', L'o', L'r', L'l', L'd', L'\0' };
|
|
||||||
char str[] = "Hello";
|
|
||||||
int result = 0;
|
|
||||||
|
|
||||||
pchar = setlocale (LC_ALL, "");
|
|
||||||
printf ("locale : %s\n",pchar);
|
|
||||||
printf ("MB_CUR_MAX %Zd\n", MB_CUR_MAX);
|
|
||||||
|
|
||||||
puts ("---- test 1 ------");
|
|
||||||
test = mbstowcs (tmp, str, (strlen (str) + 1) * sizeof (char));
|
|
||||||
printf ("size of string by mbstowcs %d\n", test);
|
|
||||||
if (test != strlen (str))
|
|
||||||
result = 1;
|
|
||||||
idx += wctomb (&buf[0], tmp[0]);
|
|
||||||
idx += wctomb (&buf[idx], tmp[1]);
|
|
||||||
buf[idx] = 0;
|
|
||||||
printf ("orig string %s\n", str);
|
|
||||||
printf ("string by wctomb %s\n", buf);
|
|
||||||
printf ("string by %%C %C", tmp[0]);
|
|
||||||
if (tmp[0] != L'H')
|
|
||||||
result = 1;
|
|
||||||
printf ("%C\n", tmp[1]);
|
|
||||||
if (tmp[1] != L'e')
|
|
||||||
result = 1;
|
|
||||||
printf ("string by %%S %S\n", tmp);
|
|
||||||
if (wcscmp (tmp, L"Hello") != 0)
|
|
||||||
result = 1;
|
|
||||||
puts ("---- test 2 ------");
|
|
||||||
printf ("wchar string %S\n", tmp1);
|
|
||||||
printf ("wchar %C\n", tmp1[0]);
|
|
||||||
test = wcstombs (buf, tmp1, (wcslen (tmp1) + 1) * sizeof (wchar_t));
|
|
||||||
printf ("size of string by wcstombs %d\n", test);
|
|
||||||
if (test != wcslen (tmp1))
|
|
||||||
result = 1;
|
|
||||||
test = wcslen (tmp1);
|
|
||||||
printf ("size of string by wcslen %d\n", test);
|
|
||||||
printf ("char %s\n", buf);
|
|
||||||
if (strcmp (buf, "World") != 0)
|
|
||||||
result = 1;
|
|
||||||
puts ("------------------");
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
|
@ -1,76 +0,0 @@
|
||||||
/* Compare at most N wide characters of two strings without taking care
|
|
||||||
for the case.
|
|
||||||
Copyright (C) 1992, 1996, 1997 Free Software Foundation, Inc.
|
|
||||||
This file is part of the GNU C Library.
|
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
The GNU C Library 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
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with the GNU C Library; if not, write to the Free
|
|
||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
||||||
02111-1307 USA. */
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
# include <config.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <wchar.h>
|
|
||||||
#include <wctype.h>
|
|
||||||
|
|
||||||
#ifndef weak_alias
|
|
||||||
# define __wcsncasecmp wcsncasecmp
|
|
||||||
# define TOLOWER(Ch) towlower (Ch)
|
|
||||||
#else
|
|
||||||
# ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
|
||||||
# define __wcsncasecmp __wcsncasecmp_l
|
|
||||||
# define TOLOWER(Ch) __towlower_l ((Ch), loc)
|
|
||||||
# else
|
|
||||||
# define TOLOWER(Ch) towlower (Ch)
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
|
||||||
# define LOCALE_PARAM , loc
|
|
||||||
# define LOCALE_PARAM_DECL __locale_t loc;
|
|
||||||
#else
|
|
||||||
# define LOCALE_PARAM
|
|
||||||
# define LOCALE_PARAM_DECL
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Compare no more than N wide characters of S1 and S2,
|
|
||||||
ignoring case, returning less than, equal to or
|
|
||||||
greater than zero if S1 is lexicographically less
|
|
||||||
than, equal to or greater than S2. */
|
|
||||||
int
|
|
||||||
__wcsncasecmp (s1, s2, n LOCALE_PARAM)
|
|
||||||
const wchar_t *s1;
|
|
||||||
const wchar_t *s2;
|
|
||||||
size_t n;
|
|
||||||
LOCALE_PARAM_DECL
|
|
||||||
{
|
|
||||||
wint_t c1, c2;
|
|
||||||
|
|
||||||
if (s1 == s2 || n == 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
c1 = (wint_t) TOLOWER (*s1++);
|
|
||||||
c2 = (wint_t) TOLOWER (*s2++);
|
|
||||||
if (c1 == L'\0' || c1 != c2)
|
|
||||||
return c1 - c2;
|
|
||||||
} while (--n > 0);
|
|
||||||
|
|
||||||
return c1 - c2;
|
|
||||||
}
|
|
||||||
#ifndef __wcsncasecmp
|
|
||||||
weak_alias (__wcsncasecmp, wcsncasecmp)
|
|
||||||
#endif
|
|
|
@ -1,24 +0,0 @@
|
||||||
/* Copyright (C) 1997, 2002 Free Software Foundation, Inc.
|
|
||||||
This file is part of the GNU C Library.
|
|
||||||
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
|
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
The GNU C Library 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
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with the GNU C Library; if not, write to the Free
|
|
||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
||||||
02111-1307 USA. */
|
|
||||||
|
|
||||||
#define USE_IN_EXTENDED_LOCALE_MODEL 1
|
|
||||||
#include <wcsncase.c>
|
|
||||||
|
|
||||||
libc_hidden_def (__wcsncasecmp_l)
|
|
||||||
weak_alias (__wcsncasecmp_l, wcsncasecmp_l)
|
|
|
@ -1,80 +0,0 @@
|
||||||
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
|
||||||
This file is part of the GNU C Library.
|
|
||||||
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
|
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
The GNU C Library 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
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with the GNU C Library; if not, write to the Free
|
|
||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
||||||
02111-1307 USA. */
|
|
||||||
|
|
||||||
#include <wchar.h>
|
|
||||||
|
|
||||||
|
|
||||||
/* Append no more than N wide-character of SRC onto DEST. */
|
|
||||||
wchar_t *
|
|
||||||
wcsncat (dest, src, n)
|
|
||||||
wchar_t *dest;
|
|
||||||
const wchar_t *src;
|
|
||||||
size_t n;
|
|
||||||
{
|
|
||||||
wchar_t c;
|
|
||||||
wchar_t * const s = dest;
|
|
||||||
|
|
||||||
/* Find the end of DEST. */
|
|
||||||
do
|
|
||||||
c = *dest++;
|
|
||||||
while (c != L'\0');
|
|
||||||
|
|
||||||
/* Make DEST point before next character, so we can increment
|
|
||||||
it while memory is read (wins on pipelined cpus). */
|
|
||||||
dest -= 2;
|
|
||||||
|
|
||||||
if (n >= 4)
|
|
||||||
{
|
|
||||||
size_t n4 = n >> 2;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
c = *src++;
|
|
||||||
*++dest = c;
|
|
||||||
if (c == L'\0')
|
|
||||||
return s;
|
|
||||||
c = *src++;
|
|
||||||
*++dest = c;
|
|
||||||
if (c == L'\0')
|
|
||||||
return s;
|
|
||||||
c = *src++;
|
|
||||||
*++dest = c;
|
|
||||||
if (c == L'\0')
|
|
||||||
return s;
|
|
||||||
c = *src++;
|
|
||||||
*++dest = c;
|
|
||||||
if (c == L'\0')
|
|
||||||
return s;
|
|
||||||
} while (--n4 > 0);
|
|
||||||
n &= 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (n > 0)
|
|
||||||
{
|
|
||||||
c = *src++;
|
|
||||||
*++dest = c;
|
|
||||||
if (c == L'\0')
|
|
||||||
return s;
|
|
||||||
n--;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (c != L'\0')
|
|
||||||
*++dest = L'\0';
|
|
||||||
|
|
||||||
return s;
|
|
||||||
}
|
|
|
@ -1,71 +0,0 @@
|
||||||
/* Copyright (C) 1995, 1996 Free Software Foundation, Inc.
|
|
||||||
This file is part of the GNU C Library.
|
|
||||||
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
|
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
The GNU C Library 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
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with the GNU C Library; if not, write to the Free
|
|
||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
||||||
02111-1307 USA. */
|
|
||||||
|
|
||||||
#include <wchar.h>
|
|
||||||
|
|
||||||
|
|
||||||
/* Compare no more than N characters of S1 and S2,
|
|
||||||
returning less than, equal to or greater than zero
|
|
||||||
if S1 is lexicographically less than, equal to or
|
|
||||||
greater than S2. */
|
|
||||||
int
|
|
||||||
wcsncmp (s1, s2, n)
|
|
||||||
const wchar_t *s1;
|
|
||||||
const wchar_t *s2;
|
|
||||||
size_t n;
|
|
||||||
{
|
|
||||||
wint_t c1 = L'\0';
|
|
||||||
wint_t c2 = L'\0';
|
|
||||||
|
|
||||||
if (n >= 4)
|
|
||||||
{
|
|
||||||
size_t n4 = n >> 2;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
c1 = (wint_t) *s1++;
|
|
||||||
c2 = (wint_t) *s2++;
|
|
||||||
if (c1 == L'\0' || c1 != c2)
|
|
||||||
return c1 - c2;
|
|
||||||
c1 = (wint_t) *s1++;
|
|
||||||
c2 = (wint_t) *s2++;
|
|
||||||
if (c1 == L'\0' || c1 != c2)
|
|
||||||
return c1 - c2;
|
|
||||||
c1 = (wint_t) *s1++;
|
|
||||||
c2 = (wint_t) *s2++;
|
|
||||||
if (c1 == L'\0' || c1 != c2)
|
|
||||||
return c1 - c2;
|
|
||||||
c1 = (wint_t) *s1++;
|
|
||||||
c2 = (wint_t) *s2++;
|
|
||||||
if (c1 == L'\0' || c1 != c2)
|
|
||||||
return c1 - c2;
|
|
||||||
} while (--n4 > 0);
|
|
||||||
n &= 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (n > 0)
|
|
||||||
{
|
|
||||||
c1 = (wint_t) *s1++;
|
|
||||||
c2 = (wint_t) *s2++;
|
|
||||||
if (c1 == L'\0' || c1 != c2)
|
|
||||||
return c1 - c2;
|
|
||||||
n--;
|
|
||||||
}
|
|
||||||
|
|
||||||
return c1 - c2;
|
|
||||||
}
|
|
|
@ -1,86 +0,0 @@
|
||||||
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
|
||||||
This file is part of the GNU C Library.
|
|
||||||
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
|
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
The GNU C Library 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
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with the GNU C Library; if not, write to the Free
|
|
||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
||||||
02111-1307 USA. */
|
|
||||||
|
|
||||||
#include <wchar.h>
|
|
||||||
|
|
||||||
|
|
||||||
/* Copy no more than N wide-characters of SRC to DEST. */
|
|
||||||
wchar_t *
|
|
||||||
wcsncpy (dest, src, n)
|
|
||||||
wchar_t *dest;
|
|
||||||
const wchar_t *src;
|
|
||||||
size_t n;
|
|
||||||
{
|
|
||||||
wint_t c;
|
|
||||||
wchar_t *const s = dest;
|
|
||||||
|
|
||||||
--dest;
|
|
||||||
|
|
||||||
if (n >= 4)
|
|
||||||
{
|
|
||||||
size_t n4 = n >> 2;
|
|
||||||
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
c = *src++;
|
|
||||||
*++dest = c;
|
|
||||||
if (c == L'\0')
|
|
||||||
break;
|
|
||||||
c = *src++;
|
|
||||||
*++dest = c;
|
|
||||||
if (c == L'\0')
|
|
||||||
break;
|
|
||||||
c = *src++;
|
|
||||||
*++dest = c;
|
|
||||||
if (c == L'\0')
|
|
||||||
break;
|
|
||||||
c = *src++;
|
|
||||||
*++dest = c;
|
|
||||||
if (c == L'\0')
|
|
||||||
break;
|
|
||||||
if (--n4 == 0)
|
|
||||||
goto last_chars;
|
|
||||||
}
|
|
||||||
n = n - (dest - s) - 1;
|
|
||||||
if (n == 0)
|
|
||||||
return s;
|
|
||||||
goto zero_fill;
|
|
||||||
}
|
|
||||||
|
|
||||||
last_chars:
|
|
||||||
n &= 3;
|
|
||||||
if (n == 0)
|
|
||||||
return s;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
c = *src++;
|
|
||||||
*++dest = c;
|
|
||||||
if (--n == 0)
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
while (c != L'\0');
|
|
||||||
|
|
||||||
zero_fill:
|
|
||||||
do
|
|
||||||
*++dest = L'\0';
|
|
||||||
while (--n > 0);
|
|
||||||
|
|
||||||
return s;
|
|
||||||
}
|
|
|
@ -1,45 +0,0 @@
|
||||||
/* Copyright (C) 1998, 1999 Free Software Foundation, Inc.
|
|
||||||
This file is part of the GNU C Library.
|
|
||||||
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
|
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
The GNU C Library 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
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with the GNU C Library; if not, write to the Free
|
|
||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
||||||
02111-1307 USA. */
|
|
||||||
|
|
||||||
#include <wchar.h>
|
|
||||||
|
|
||||||
|
|
||||||
/* Copy SRC to DEST. */
|
|
||||||
size_t
|
|
||||||
__wcsnlen (s, maxlen)
|
|
||||||
const wchar_t *s;
|
|
||||||
size_t maxlen;
|
|
||||||
{
|
|
||||||
size_t len = 0;
|
|
||||||
|
|
||||||
while (s[len] != L'\0' && maxlen > 0)
|
|
||||||
{
|
|
||||||
if (s[++len] == L'\0' || --maxlen == 0)
|
|
||||||
return len;
|
|
||||||
if (s[++len] == L'\0' || --maxlen == 0)
|
|
||||||
return len;
|
|
||||||
if (s[++len] == L'\0' || --maxlen == 0)
|
|
||||||
return len;
|
|
||||||
++len;
|
|
||||||
--maxlen;
|
|
||||||
}
|
|
||||||
|
|
||||||
return len;
|
|
||||||
}
|
|
||||||
weak_alias (__wcsnlen, wcsnlen)
|
|
|
@ -1,37 +0,0 @@
|
||||||
/* Copyright (C) 1995, 1996 Free Software Foundation, Inc.
|
|
||||||
This file is part of the GNU C Library.
|
|
||||||
Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>
|
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
The GNU C Library 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
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with the GNU C Library; if not, write to the Free
|
|
||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
||||||
02111-1307 USA. */
|
|
||||||
|
|
||||||
#include <wchar.h>
|
|
||||||
|
|
||||||
|
|
||||||
/* Find the first occurrence in WCS of any wide-character in ACCEPT. */
|
|
||||||
wchar_t *
|
|
||||||
wcspbrk (wcs, accept)
|
|
||||||
register const wchar_t *wcs;
|
|
||||||
register const wchar_t *accept;
|
|
||||||
{
|
|
||||||
while (*wcs != L'\0')
|
|
||||||
if (wcschr (accept, *wcs) == NULL)
|
|
||||||
++wcs;
|
|
||||||
else
|
|
||||||
return (wchar_t *) wcs;
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
libc_hidden_def (wcspbrk)
|
|
|
@ -1,37 +0,0 @@
|
||||||
/* Copyright (C) 1995, 1996, 1999 Free Software Foundation, Inc.
|
|
||||||
This file is part of the GNU C Library.
|
|
||||||
Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>
|
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
The GNU C Library 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
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with the GNU C Library; if not, write to the Free
|
|
||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
||||||
02111-1307 USA. */
|
|
||||||
|
|
||||||
#include <wchar.h>
|
|
||||||
|
|
||||||
|
|
||||||
/* Find the last occurrence of WC in WCS. */
|
|
||||||
wchar_t *
|
|
||||||
wcsrchr (wcs, wc)
|
|
||||||
register const wchar_t *wcs;
|
|
||||||
register const wchar_t wc;
|
|
||||||
{
|
|
||||||
const wchar_t *retval = NULL;
|
|
||||||
|
|
||||||
do
|
|
||||||
if (*wcs == wc)
|
|
||||||
retval = wcs;
|
|
||||||
while (*wcs++ != L'\0');
|
|
||||||
|
|
||||||
return (wchar_t *) retval;
|
|
||||||
}
|
|
|
@ -1,47 +0,0 @@
|
||||||
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
|
||||||
This file is part of the GNU C Library.
|
|
||||||
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
|
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
The GNU C Library 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
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with the GNU C Library; if not, write to the Free
|
|
||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
||||||
02111-1307 USA. */
|
|
||||||
|
|
||||||
#include <wchar.h>
|
|
||||||
|
|
||||||
|
|
||||||
/* Return the length of the maximum initial segment
|
|
||||||
of WCS which contains only wide-characters in ACCEPT. */
|
|
||||||
size_t
|
|
||||||
wcsspn (wcs, accept)
|
|
||||||
const wchar_t *wcs;
|
|
||||||
const wchar_t *accept;
|
|
||||||
{
|
|
||||||
register const wchar_t *p;
|
|
||||||
register const wchar_t *a;
|
|
||||||
register size_t count = 0;
|
|
||||||
|
|
||||||
for (p = wcs; *p != L'\0'; ++p)
|
|
||||||
{
|
|
||||||
for (a = accept; *a != L'\0'; ++a)
|
|
||||||
if (*p == *a)
|
|
||||||
break;
|
|
||||||
if (*a == L'\0')
|
|
||||||
return count;
|
|
||||||
else
|
|
||||||
++count;
|
|
||||||
}
|
|
||||||
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
libc_hidden_def (wcsspn)
|
|
|
@ -1,100 +0,0 @@
|
||||||
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
|
||||||
This file is part of the GNU C Library.
|
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
The GNU C Library 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
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with the GNU C Library; if not, write to the Free
|
|
||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
||||||
02111-1307 USA. */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The original strstr() file contains the following comment:
|
|
||||||
*
|
|
||||||
* My personal strstr() implementation that beats most other algorithms.
|
|
||||||
* Until someone tells me otherwise, I assume that this is the
|
|
||||||
* fastest implementation of strstr() in C.
|
|
||||||
* I deliberately chose not to comment it. You should have at least
|
|
||||||
* as much fun trying to understand it, as I had to write it :-).
|
|
||||||
*
|
|
||||||
* Stephen R. van den Berg, berg@pool.informatik.rwth-aachen.de */
|
|
||||||
|
|
||||||
#include <wchar.h>
|
|
||||||
|
|
||||||
wchar_t *
|
|
||||||
wcsstr (haystack, needle)
|
|
||||||
const wchar_t *haystack;
|
|
||||||
const wchar_t *needle;
|
|
||||||
{
|
|
||||||
register wchar_t b, c;
|
|
||||||
|
|
||||||
if ((b = *needle) != L'\0')
|
|
||||||
{
|
|
||||||
haystack--; /* possible ANSI violation */
|
|
||||||
do
|
|
||||||
if ((c = *++haystack) == L'\0')
|
|
||||||
goto ret0;
|
|
||||||
while (c != b);
|
|
||||||
|
|
||||||
if (!(c = *++needle))
|
|
||||||
goto foundneedle;
|
|
||||||
++needle;
|
|
||||||
goto jin;
|
|
||||||
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
register wchar_t a;
|
|
||||||
register const wchar_t *rhaystack, *rneedle;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
if (!(a = *++haystack))
|
|
||||||
goto ret0;
|
|
||||||
if (a == b)
|
|
||||||
break;
|
|
||||||
if ((a = *++haystack) == L'\0')
|
|
||||||
goto ret0;
|
|
||||||
shloop: ;
|
|
||||||
}
|
|
||||||
while (a != b);
|
|
||||||
|
|
||||||
jin: if (!(a = *++haystack))
|
|
||||||
goto ret0;
|
|
||||||
|
|
||||||
if (a != c)
|
|
||||||
goto shloop;
|
|
||||||
|
|
||||||
if (*(rhaystack = haystack-- + 1) == (a = *(rneedle = needle)))
|
|
||||||
do
|
|
||||||
{
|
|
||||||
if (a == L'\0')
|
|
||||||
goto foundneedle;
|
|
||||||
if (*++rhaystack != (a = *++needle))
|
|
||||||
break;
|
|
||||||
if (a == L'\0')
|
|
||||||
goto foundneedle;
|
|
||||||
}
|
|
||||||
while (*++rhaystack == (a = *++needle));
|
|
||||||
|
|
||||||
needle = rneedle; /* took the register-poor approach */
|
|
||||||
|
|
||||||
if (a == L'\0')
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foundneedle:
|
|
||||||
return (wchar_t*) haystack;
|
|
||||||
ret0:
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
/* This alias is for backward compatibility with drafts of the ISO C
|
|
||||||
standard. Unfortunately the Unix(TM) standard requires this name. */
|
|
||||||
weak_alias (wcsstr, wcswcs)
|
|
|
@ -1,35 +0,0 @@
|
||||||
/* Convert string representing a number to integer value, using given locale.
|
|
||||||
Copyright (C) 1997, 1998, 2002 Free Software Foundation, Inc.
|
|
||||||
This file is part of the GNU C Library.
|
|
||||||
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
|
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
The GNU C Library 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
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with the GNU C Library; if not, write to the Free
|
|
||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
||||||
02111-1307 USA. */
|
|
||||||
|
|
||||||
#define __need_wchar_t
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <locale.h>
|
|
||||||
|
|
||||||
#define USE_IN_EXTENDED_LOCALE_MODEL 1
|
|
||||||
|
|
||||||
extern double ____wcstod_l_internal (const wchar_t *, wchar_t **, int,
|
|
||||||
__locale_t);
|
|
||||||
extern unsigned long long int ____wcstoull_l_internal (const wchar_t *,
|
|
||||||
wchar_t **, int, int,
|
|
||||||
__locale_t);
|
|
||||||
|
|
||||||
#include <wcstod.c>
|
|
||||||
|
|
||||||
weak_alias (__wcstod_l, wcstod_l)
|
|
|
@ -1,35 +0,0 @@
|
||||||
/* Convert string representing a number to integer value, using given locale.
|
|
||||||
Copyright (C) 1997,98,2002 Free Software Foundation, Inc.
|
|
||||||
This file is part of the GNU C Library.
|
|
||||||
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
|
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
The GNU C Library 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
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with the GNU C Library; if not, write to the Free
|
|
||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
||||||
02111-1307 USA. */
|
|
||||||
|
|
||||||
#define __need_wchar_t
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <locale.h>
|
|
||||||
|
|
||||||
#define USE_IN_EXTENDED_LOCALE_MODEL 1
|
|
||||||
|
|
||||||
extern float ____wcstof_l_internal (const wchar_t *, wchar_t **, int,
|
|
||||||
__locale_t);
|
|
||||||
extern unsigned long long int ____wcstoull_l_internal (const wchar_t *,
|
|
||||||
wchar_t **, int, int,
|
|
||||||
__locale_t);
|
|
||||||
|
|
||||||
#include <wcstof.c>
|
|
||||||
|
|
||||||
weak_alias (__wcstof_l, wcstof_l)
|
|
|
@ -1,66 +0,0 @@
|
||||||
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
|
||||||
This file is part of the GNU C Library.
|
|
||||||
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
|
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
The GNU C Library 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
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with the GNU C Library; if not, write to the Free
|
|
||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
||||||
02111-1307 USA. */
|
|
||||||
|
|
||||||
#include <wchar.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
|
|
||||||
/* Parse WCS into tokens separated by characters in DELIM. If WCS is
|
|
||||||
NULL, the last string wcstok() was called with is used. */
|
|
||||||
wchar_t *
|
|
||||||
wcstok (wcs, delim, save_ptr)
|
|
||||||
wchar_t *wcs;
|
|
||||||
const wchar_t *delim;
|
|
||||||
wchar_t **save_ptr;
|
|
||||||
{
|
|
||||||
wchar_t *result;
|
|
||||||
|
|
||||||
if (wcs == NULL)
|
|
||||||
{
|
|
||||||
if (*save_ptr == NULL)
|
|
||||||
{
|
|
||||||
__set_errno (EINVAL);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
wcs = *save_ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Scan leading delimiters. */
|
|
||||||
wcs += wcsspn (wcs, delim);
|
|
||||||
if (*wcs == L'\0')
|
|
||||||
{
|
|
||||||
*save_ptr = NULL;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Find the end of the token. */
|
|
||||||
result = wcs;
|
|
||||||
wcs = wcspbrk (result, delim);
|
|
||||||
if (wcs == NULL)
|
|
||||||
/* This token finishes the string. */
|
|
||||||
*save_ptr = NULL;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Terminate the token and make *SAVE_PTR point past it. */
|
|
||||||
*wcs = L'\0';
|
|
||||||
*save_ptr = wcs + 1;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
|
@ -1,56 +0,0 @@
|
||||||
/* Convert string representing a number to integer value, using given locale.
|
|
||||||
Copyright (C) 1997,98,99,2002 Free Software Foundation, Inc.
|
|
||||||
This file is part of the GNU C Library.
|
|
||||||
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
|
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
The GNU C Library 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
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with the GNU C Library; if not, write to the Free
|
|
||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
||||||
02111-1307 USA. */
|
|
||||||
|
|
||||||
#define __need_wchar_t
|
|
||||||
#include <math.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <locale.h>
|
|
||||||
#include <wchar.h>
|
|
||||||
|
|
||||||
#define USE_IN_EXTENDED_LOCALE_MODEL 1
|
|
||||||
|
|
||||||
#ifndef __NO_LONG_DOUBLE_MATH
|
|
||||||
|
|
||||||
extern long double ____wcstold_l_internal (const wchar_t *, wchar_t **, int,
|
|
||||||
__locale_t);
|
|
||||||
extern unsigned long long int ____wcstoull_l_internal (const wchar_t *,
|
|
||||||
wchar_t **, int, int,
|
|
||||||
__locale_t);
|
|
||||||
|
|
||||||
# include <wcstold.c>
|
|
||||||
#else
|
|
||||||
/* There is no `long double' type, use the `double' implementations. */
|
|
||||||
extern double ____wcstod_l_internal (const wchar_t *, wchar_t **, int,
|
|
||||||
__locale_t);
|
|
||||||
long double
|
|
||||||
____wcstold_l_internal (const wchar_t *nptr, wchar_t **endptr, int group,
|
|
||||||
__locale_t loc)
|
|
||||||
{
|
|
||||||
return ____wcstod_l_internal (nptr, endptr, group, loc);
|
|
||||||
}
|
|
||||||
|
|
||||||
long double
|
|
||||||
__wcstold_l (const wchar_t *nptr, wchar_t **endptr, __locale_t loc)
|
|
||||||
{
|
|
||||||
return ____wcstod_l_internal (nptr, endptr, 0, loc);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
weak_alias (__wcstold_l, wcstold_l)
|
|
|
@ -1,38 +0,0 @@
|
||||||
/* Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
|
|
||||||
This file is part of the GNU C Library.
|
|
||||||
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
|
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
The GNU C Library 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
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with the GNU C Library; if not, write to the Free
|
|
||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
||||||
02111-1307 USA. */
|
|
||||||
|
|
||||||
#include <wchar.h>
|
|
||||||
#include "../locale/coll-lookup.h"
|
|
||||||
|
|
||||||
#define STRING_TYPE wchar_t
|
|
||||||
#define USTRING_TYPE wint_t
|
|
||||||
#ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
|
||||||
# define STRXFRM __wcsxfrm_l
|
|
||||||
#else
|
|
||||||
# define STRXFRM wcsxfrm
|
|
||||||
#endif
|
|
||||||
#define STRCMP wcscmp
|
|
||||||
#define STRLEN __wcslen
|
|
||||||
#define STPNCPY __wcpncpy
|
|
||||||
#define WEIGHT_H "../locale/weightwc.h"
|
|
||||||
#define SUFFIX WC
|
|
||||||
#define L(arg) L##arg
|
|
||||||
#define WIDE_CHAR_VERSION 1
|
|
||||||
|
|
||||||
#include "../string/strxfrm.c"
|
|
|
@ -1,23 +0,0 @@
|
||||||
/* Copyright (C) 1996,97,2002 Free Software Foundation, Inc.
|
|
||||||
This file is part of the GNU C Library.
|
|
||||||
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
|
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
The GNU C Library 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
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with the GNU C Library; if not, write to the Free
|
|
||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
||||||
02111-1307 USA. */
|
|
||||||
|
|
||||||
#define USE_IN_EXTENDED_LOCALE_MODEL 1
|
|
||||||
#include <wcsxfrm.c>
|
|
||||||
|
|
||||||
weak_alias (__wcsxfrm_l, wcsxfrm_l)
|
|
|
@ -1,63 +0,0 @@
|
||||||
/* Copyright (C) 1996,97,2002 Free Software Foundation, Inc.
|
|
||||||
This file is part of the GNU C Library.
|
|
||||||
Contributed by Ulrich Drepper <drepper@gnu.org>, 1996.
|
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
The GNU C Library 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
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with the GNU C Library; if not, write to the Free
|
|
||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
||||||
02111-1307 USA. */
|
|
||||||
|
|
||||||
#include <wchar.h>
|
|
||||||
|
|
||||||
wchar_t *
|
|
||||||
wmemchr (s, c, n)
|
|
||||||
register const wchar_t *s;
|
|
||||||
register wchar_t c;
|
|
||||||
register size_t n;
|
|
||||||
{
|
|
||||||
/* For performance reasons unfold the loop four times. */
|
|
||||||
while (n >= 4)
|
|
||||||
{
|
|
||||||
if (s[0] == c)
|
|
||||||
return (wchar_t *) s;
|
|
||||||
if (s[1] == c)
|
|
||||||
return (wchar_t *) &s[1];
|
|
||||||
if (s[2] == c)
|
|
||||||
return (wchar_t *) &s[2];
|
|
||||||
if (s[3] == c)
|
|
||||||
return (wchar_t *) &s[3];
|
|
||||||
s += 4;
|
|
||||||
n -= 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (n > 0)
|
|
||||||
{
|
|
||||||
if (*s == c)
|
|
||||||
return (wchar_t *) s;
|
|
||||||
++s;
|
|
||||||
--n;
|
|
||||||
}
|
|
||||||
if (n > 0)
|
|
||||||
{
|
|
||||||
if (*s == c)
|
|
||||||
return (wchar_t *) s;
|
|
||||||
++s;
|
|
||||||
--n;
|
|
||||||
}
|
|
||||||
if (n > 0)
|
|
||||||
if (*s == c)
|
|
||||||
return (wchar_t *) s;
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
libc_hidden_def (wmemchr)
|
|
|
@ -1,84 +0,0 @@
|
||||||
/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
|
|
||||||
This file is part of the GNU C Library.
|
|
||||||
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
|
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
The GNU C Library 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
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with the GNU C Library; if not, write to the Free
|
|
||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
||||||
02111-1307 USA. */
|
|
||||||
|
|
||||||
#include <wchar.h>
|
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
wmemcmp (s1, s2, n)
|
|
||||||
const wchar_t *s1;
|
|
||||||
const wchar_t *s2;
|
|
||||||
size_t n;
|
|
||||||
{
|
|
||||||
register wint_t c1;
|
|
||||||
register wint_t c2;
|
|
||||||
|
|
||||||
while (n >= 4)
|
|
||||||
{
|
|
||||||
c1 = (wint_t) s1[0];
|
|
||||||
c2 = (wint_t) s2[0];
|
|
||||||
if (c1 - c2 != 0)
|
|
||||||
return c1 - c2;
|
|
||||||
c1 = (wint_t) s1[1];
|
|
||||||
c2 = (wint_t) s2[1];
|
|
||||||
if (c1 - c2 != 0)
|
|
||||||
return c1 - c2;
|
|
||||||
c1 = (wint_t) s1[2];
|
|
||||||
c2 = (wint_t) s2[2];
|
|
||||||
if (c1 - c2 != 0)
|
|
||||||
return c1 - c2;
|
|
||||||
c1 = (wint_t) s1[3];
|
|
||||||
c2 = (wint_t) s2[3];
|
|
||||||
if (c1 - c2 != 0)
|
|
||||||
return c1 - c2;
|
|
||||||
s1 += 4;
|
|
||||||
s2 += 4;
|
|
||||||
n -= 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (n > 0)
|
|
||||||
{
|
|
||||||
c1 = (wint_t) s1[0];
|
|
||||||
c2 = (wint_t) s2[0];
|
|
||||||
if (c1 - c2 != 0)
|
|
||||||
return c1 - c2;
|
|
||||||
++s1;
|
|
||||||
++s2;
|
|
||||||
--n;
|
|
||||||
}
|
|
||||||
if (n > 0)
|
|
||||||
{
|
|
||||||
c1 = (wint_t) s1[0];
|
|
||||||
c2 = (wint_t) s2[0];
|
|
||||||
if (c1 - c2 != 0)
|
|
||||||
return c1 - c2;
|
|
||||||
++s1;
|
|
||||||
++s2;
|
|
||||||
--n;
|
|
||||||
}
|
|
||||||
if (n > 0)
|
|
||||||
{
|
|
||||||
c1 = (wint_t) s1[0];
|
|
||||||
c2 = (wint_t) s2[0];
|
|
||||||
if (c1 - c2 != 0)
|
|
||||||
return c1 - c2;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
/* Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc.
|
|
||||||
This file is part of the GNU C Library.
|
|
||||||
Contributed by Ulrich Drepper <drepper@gnu.org>, 1996.
|
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
The GNU C Library 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
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with the GNU C Library; if not, write to the Free
|
|
||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
||||||
02111-1307 USA. */
|
|
||||||
|
|
||||||
#include <wchar.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
|
|
||||||
wchar_t *
|
|
||||||
__wmemcpy (s1, s2, n)
|
|
||||||
wchar_t *s1;
|
|
||||||
const wchar_t *s2;
|
|
||||||
size_t n;
|
|
||||||
{
|
|
||||||
return (wchar_t *) memcpy ((char *) s1, (char *) s2, n * sizeof (wchar_t));
|
|
||||||
}
|
|
||||||
weak_alias (__wmemcpy, wmemcpy)
|
|
|
@ -1,32 +0,0 @@
|
||||||
/* Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc.
|
|
||||||
This file is part of the GNU C Library.
|
|
||||||
Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>
|
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
The GNU C Library 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
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with the GNU C Library; if not, write to the Free
|
|
||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
||||||
02111-1307 USA. */
|
|
||||||
|
|
||||||
#include <wchar.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
|
|
||||||
wchar_t *
|
|
||||||
__wmemmove (s1, s2, n)
|
|
||||||
wchar_t *s1;
|
|
||||||
const wchar_t *s2;
|
|
||||||
size_t n;
|
|
||||||
{
|
|
||||||
return (wchar_t *) memmove ((char *) s1, (char *) s2, n * sizeof (wchar_t));
|
|
||||||
}
|
|
||||||
weak_alias (__wmemmove, wmemmove)
|
|
|
@ -1,33 +0,0 @@
|
||||||
/* Copyright (C) 1999 Free Software Foundation, Inc.
|
|
||||||
This file is part of the GNU C Library.
|
|
||||||
Contributed by Ulrich Drepper <drepper@gnu.org>, 1999.
|
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
The GNU C Library 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
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with the GNU C Library; if not, write to the Free
|
|
||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
||||||
02111-1307 USA. */
|
|
||||||
|
|
||||||
#include <wchar.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
|
|
||||||
wchar_t *
|
|
||||||
__wmempcpy (s1, s2, n)
|
|
||||||
wchar_t *s1;
|
|
||||||
const wchar_t *s2;
|
|
||||||
size_t n;
|
|
||||||
{
|
|
||||||
return (wchar_t *) __mempcpy ((char *) s1, (char *) s2,
|
|
||||||
n * sizeof (wchar_t));
|
|
||||||
}
|
|
||||||
weak_alias (__wmempcpy, wmempcpy)
|
|
|
@ -1,56 +0,0 @@
|
||||||
/* Copyright (C) 1996,97,99,2002 Free Software Foundation, Inc.
|
|
||||||
This file is part of the GNU C Library.
|
|
||||||
Contributed by Ulrich Drepper <drepper@gnu.org>, 1996.
|
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
The GNU C Library 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
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with the GNU C Library; if not, write to the Free
|
|
||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
||||||
02111-1307 USA. */
|
|
||||||
|
|
||||||
#include <wchar.h>
|
|
||||||
|
|
||||||
|
|
||||||
wchar_t *
|
|
||||||
wmemset (s, c, n)
|
|
||||||
wchar_t *s;
|
|
||||||
wchar_t c;
|
|
||||||
size_t n;
|
|
||||||
{
|
|
||||||
register wchar_t *wp = s;
|
|
||||||
|
|
||||||
while (n >= 4)
|
|
||||||
{
|
|
||||||
wp[0] = c;
|
|
||||||
wp[1] = c;
|
|
||||||
wp[2] = c;
|
|
||||||
wp[3] = c;
|
|
||||||
wp += 4;
|
|
||||||
n -= 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (n > 0)
|
|
||||||
{
|
|
||||||
wp[0] = c;
|
|
||||||
|
|
||||||
if (n > 1)
|
|
||||||
{
|
|
||||||
wp[1] = c;
|
|
||||||
|
|
||||||
if (n > 2)
|
|
||||||
wp[2] = c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
libc_hidden_def (wmemset)
|
|
Loading…
Reference in New Issue