mirror of
https://sourceware.org/git/glibc.git
synced 2025-01-03 00:10:10 +00:00
Update.
1999-12-30 Ulrich Drepper <drepper@cygnus.com> * wcsmbs/wcscoll.c: Use multibyte character version. * wcsmbs/wcsxfrm.c: Likewise. * string/strcoll.c: Prepare to be used for the wide character version. * string/strxfrm.c: Likewise. * locale/weightwc.h: New file.
This commit is contained in:
parent
9eb157c875
commit
83d660c76f
@ -1,3 +1,11 @@
|
|||||||
|
1999-12-30 Ulrich Drepper <drepper@cygnus.com>
|
||||||
|
|
||||||
|
* wcsmbs/wcscoll.c: Use multibyte character version.
|
||||||
|
* wcsmbs/wcsxfrm.c: Likewise.
|
||||||
|
* string/strcoll.c: Prepare to be used for the wide character version.
|
||||||
|
* string/strxfrm.c: Likewise.
|
||||||
|
* locale/weightwc.h: New file.
|
||||||
|
|
||||||
1999-12-30 Geoff Keating <geoffk@cygnus.com>
|
1999-12-30 Geoff Keating <geoffk@cygnus.com>
|
||||||
|
|
||||||
* sysdeps/powerpc/fpu/bits/fenvinline.h (feraiseexcept): Remove
|
* sysdeps/powerpc/fpu/bits/fenvinline.h (feraiseexcept): Remove
|
||||||
|
101
string/strcoll.c
101
string/strcoll.c
@ -24,24 +24,36 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "../locale/localeinfo.h"
|
#ifndef STRING_TYPE
|
||||||
|
# define STRING_TYPE char
|
||||||
#ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
# define USTRING_TYPE unsigned char
|
||||||
# define STRCOLL __strcoll_l
|
# ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
||||||
#else
|
# define STRCOLL __strcoll_l
|
||||||
# define STRCOLL strcoll
|
# 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
|
#endif
|
||||||
|
|
||||||
|
#define CONCAT(a,b) CONCAT1(a,b)
|
||||||
|
#define CONCAT1(a,b) a##b
|
||||||
|
|
||||||
|
#include "../locale/localeinfo.h"
|
||||||
|
|
||||||
#ifndef USE_IN_EXTENDED_LOCALE_MODEL
|
#ifndef USE_IN_EXTENDED_LOCALE_MODEL
|
||||||
int
|
int
|
||||||
STRCOLL (s1, s2)
|
STRCOLL (s1, s2)
|
||||||
const char *s1;
|
const STRING_TYPE *s1;
|
||||||
const char *s2;
|
const STRING_TYPE *s2;
|
||||||
#else
|
#else
|
||||||
int
|
int
|
||||||
STRCOLL (s1, s2, l)
|
STRCOLL (s1, s2, l)
|
||||||
const char *s1;
|
const STRING_TYPE *s1;
|
||||||
const char *s2;
|
const STRING_TYPE *s2;
|
||||||
__locale_t l;
|
__locale_t l;
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
@ -49,19 +61,19 @@ STRCOLL (s1, s2, l)
|
|||||||
struct locale_data *current = l->__locales[LC_COLLATE];
|
struct locale_data *current = l->__locales[LC_COLLATE];
|
||||||
uint_fast32_t nrules = *((uint32_t *) current->values[_NL_ITEM_INDEX (_NL_COLLATE_NRULES)].string);
|
uint_fast32_t nrules = *((uint32_t *) current->values[_NL_ITEM_INDEX (_NL_COLLATE_NRULES)].string);
|
||||||
#else
|
#else
|
||||||
uint32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
|
uint_fast32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
|
||||||
#endif
|
#endif
|
||||||
/* We don't assign the following values right away since it might be
|
/* We don't assign the following values right away since it might be
|
||||||
unnecessary in case there are no rules. */
|
unnecessary in case there are no rules. */
|
||||||
const unsigned char *rulesets;
|
const unsigned char *rulesets;
|
||||||
const int32_t *table;
|
const int32_t *table;
|
||||||
const unsigned char *weights;
|
const USTRING_TYPE *weights;
|
||||||
const unsigned char *extra;
|
const USTRING_TYPE *extra;
|
||||||
const int32_t *indirect;
|
const int32_t *indirect;
|
||||||
uint_fast32_t pass;
|
uint_fast32_t pass;
|
||||||
int result = 0;
|
int result = 0;
|
||||||
const unsigned char *us1;
|
const USTRING_TYPE *us1;
|
||||||
const unsigned char *us2;
|
const USTRING_TYPE *us2;
|
||||||
size_t s1len;
|
size_t s1len;
|
||||||
size_t s2len;
|
size_t s2len;
|
||||||
int32_t *idx1arr;
|
int32_t *idx1arr;
|
||||||
@ -83,45 +95,62 @@ STRCOLL (s1, s2, l)
|
|||||||
int position;
|
int position;
|
||||||
int seq1len;
|
int seq1len;
|
||||||
int seq2len;
|
int seq2len;
|
||||||
int use_malloc = 0;
|
int use_malloc;
|
||||||
|
#ifdef WIDE_CHAR_VERSION
|
||||||
|
size_t size;
|
||||||
|
size_t layers;
|
||||||
|
const wint_t *names;
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "../locale/weight.h"
|
#include WEIGHT_H
|
||||||
|
|
||||||
if (nrules == 0)
|
if (nrules == 0)
|
||||||
return strcmp (s1, s2);
|
return STRCMP (s1, s2);
|
||||||
|
|
||||||
#ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
#ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
||||||
rulesets = (const unsigned char *)
|
rulesets = (const unsigned char *)
|
||||||
current->values[_NL_ITEM_INDEX (_NL_COLLATE_RULESETS)].string;
|
current->values[_NL_ITEM_INDEX (_NL_COLLATE_RULESETS)].string;
|
||||||
table = (const int32_t *)
|
table = (const int32_t *)
|
||||||
current->values[_NL_ITEM_INDEX (_NL_COLLATE_TABLEMB)].string;
|
current->values[_NL_ITEM_INDEX (CONCAT(_NL_COLLATE_TABLE,SUFFIX))].string;
|
||||||
weights = (const unsigned char *)
|
weights = (const USTRING_TYPE *)
|
||||||
current->values[_NL_ITEM_INDEX (_NL_COLLATE_WEIGHTMB)].string;
|
current->values[_NL_ITEM_INDEX (CONCAT(_NL_COLLATE_WEIGHT,SUFFIX))].string;
|
||||||
extra = (const unsigned char *)
|
extra = (const USTRING_TYPE *)
|
||||||
current->values[_NL_ITEM_INDEX (_NL_COLLATE_EXTRAMB)].string;
|
current->values[_NL_ITEM_INDEX (CONCAT(_NL_COLLATE_EXTRA,SUFFIX))].string;
|
||||||
indirect = (const int32_t *)
|
indirect = (const int32_t *)
|
||||||
current->values[_NL_ITEM_INDEX (_NL_COLLATE_INDIRECTMB)].string;
|
current->values[_NL_ITEM_INDEX (CONCAT(_NL_COLLATE_INDIRECT,SUFFIX))].string;
|
||||||
|
# ifdef WIDE_CHAR_VERSION
|
||||||
|
names = (const wint_t *)
|
||||||
|
current->values[_NL_ITEM_INDEX (_NL_COLLATE_NAMES)].string;
|
||||||
|
size = current->values[_NL_ITEM_INDEX (_NL_COLLATE_HASH_SIZE)].word;
|
||||||
|
layers = current->values[_NL_ITEM_INDEX (_NL_COLLATE_HASH_LAYERS)].word;
|
||||||
|
# endif
|
||||||
#else
|
#else
|
||||||
rulesets = (const unsigned char *)
|
rulesets = (const unsigned char *)
|
||||||
_NL_CURRENT (LC_COLLATE, _NL_COLLATE_RULESETS);
|
_NL_CURRENT (LC_COLLATE, _NL_COLLATE_RULESETS);
|
||||||
table = (const int32_t *)
|
table = (const int32_t *)
|
||||||
_NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB);
|
_NL_CURRENT (LC_COLLATE, CONCAT(_NL_COLLATE_TABLE,SUFFIX));
|
||||||
weights = (const unsigned char *)
|
weights = (const USTRING_TYPE *)
|
||||||
_NL_CURRENT (LC_COLLATE, _NL_COLLATE_WEIGHTMB);
|
_NL_CURRENT (LC_COLLATE, CONCAT(_NL_COLLATE_WEIGHT,SUFFIX));
|
||||||
extra = (const unsigned char *)
|
extra = (const USTRING_TYPE *)
|
||||||
_NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB);
|
_NL_CURRENT (LC_COLLATE, CONCAT(_NL_COLLATE_EXTRA,SUFFIX));
|
||||||
indirect = (const int32_t *)
|
indirect = (const int32_t *)
|
||||||
_NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTMB);
|
_NL_CURRENT (LC_COLLATE, CONCAT(_NL_COLLATE_INDIRECT,SUFFIX));
|
||||||
|
# ifdef WIDE_CHAR_VERSION
|
||||||
|
names = (const wint_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_NAMES);
|
||||||
|
size = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_HASH_SIZE);
|
||||||
|
layers = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_HASH_LAYERS);
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
use_malloc = 0;
|
||||||
|
|
||||||
/* We need this a few times. */
|
/* We need this a few times. */
|
||||||
s1len = strlen (s1);
|
s1len = STRLEN (s1);
|
||||||
s2len = strlen (s2);
|
s2len = STRLEN (s2);
|
||||||
|
|
||||||
/* We need the elements of the strings as unsigned values since they
|
/* We need the elements of the strings as unsigned values since they
|
||||||
are used as indeces. */
|
are used as indeces. */
|
||||||
us1 = (const unsigned char *) s1;
|
us1 = (const USTRING_TYPE *) s1;
|
||||||
us2 = (const unsigned char *) s2;
|
us2 = (const USTRING_TYPE *) s2;
|
||||||
|
|
||||||
/* Perform the first pass over the string and while doing this find
|
/* Perform the first pass over the string and while doing this find
|
||||||
and store the weights for each character. Since we want this to
|
and store the weights for each character. Since we want this to
|
||||||
@ -204,7 +233,7 @@ STRCOLL (s1, s2, l)
|
|||||||
{
|
{
|
||||||
backw1_stop = idx1max;
|
backw1_stop = idx1max;
|
||||||
|
|
||||||
while (*us1 != '\0')
|
while (*us1 != L('\0'))
|
||||||
{
|
{
|
||||||
int32_t tmp = findidx (&us1);
|
int32_t tmp = findidx (&us1);
|
||||||
rule1arr[idx1max] = tmp >> 24;
|
rule1arr[idx1max] = tmp >> 24;
|
||||||
@ -263,7 +292,7 @@ STRCOLL (s1, s2, l)
|
|||||||
{
|
{
|
||||||
backw2_stop = idx2max;
|
backw2_stop = idx2max;
|
||||||
|
|
||||||
while (*us2 != '\0')
|
while (*us2 != L('\0'))
|
||||||
{
|
{
|
||||||
int32_t tmp = findidx (&us2);
|
int32_t tmp = findidx (&us2);
|
||||||
rule2arr[idx2max] = tmp >> 24;
|
rule2arr[idx2max] = tmp >> 24;
|
||||||
|
141
string/strxfrm.c
141
string/strxfrm.c
@ -1,6 +1,6 @@
|
|||||||
/* Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
|
/* Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
|
Written by Ulrich Drepper <drepper@cygnus.com>, 1995.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU Library General Public License as
|
modify it under the terms of the GNU Library General Public License as
|
||||||
@ -23,15 +23,29 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "../locale/localeinfo.h"
|
#ifndef STRING_TYPE
|
||||||
|
# define STRING_TYPE char
|
||||||
#ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
# define USTRING_TYPE unsigned char
|
||||||
# define STRXFRM __strxfrm_l
|
# ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
||||||
#else
|
# define STRXFRM __strxfrm_l
|
||||||
# define STRXFRM strxfrm
|
# 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
|
#endif
|
||||||
|
|
||||||
|
#define CONCAT(a,b) CONCAT1(a,b)
|
||||||
|
#define CONCAT1(a,b) a##b
|
||||||
|
|
||||||
|
#include "../locale/localeinfo.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef WIDE_CHAR_VERSION
|
||||||
/* These are definitions used by some of the functions for handling
|
/* These are definitions used by some of the functions for handling
|
||||||
UTF-8 encoding below. */
|
UTF-8 encoding below. */
|
||||||
static const uint32_t encoding_mask[] =
|
static const uint32_t encoding_mask[] =
|
||||||
@ -79,14 +93,15 @@ utf8_encode (char *buf, int val)
|
|||||||
|
|
||||||
return buf - startp;
|
return buf - startp;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifndef USE_IN_EXTENDED_LOCALE_MODEL
|
#ifndef USE_IN_EXTENDED_LOCALE_MODEL
|
||||||
size_t
|
size_t
|
||||||
STRXFRM (char *dest, const char *src, size_t n)
|
STRXFRM (STRING_TYPE *dest, const STRING_TYPE *src, size_t n)
|
||||||
#else
|
#else
|
||||||
size_t
|
size_t
|
||||||
STRXFRM (char *dest, const char *src, size_t n, __locale_t l)
|
STRXFRM (STRING_TYPE *dest, const STRING_TYPE *src, size_t n, __locale_t l)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
#ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
||||||
@ -99,25 +114,30 @@ STRXFRM (char *dest, const char *src, size_t n, __locale_t l)
|
|||||||
unnecessary in case there are no rules. */
|
unnecessary in case there are no rules. */
|
||||||
const unsigned char *rulesets;
|
const unsigned char *rulesets;
|
||||||
const int32_t *table;
|
const int32_t *table;
|
||||||
const unsigned char *weights;
|
const USTRING_TYPE *weights;
|
||||||
const unsigned char *extra;
|
const USTRING_TYPE *extra;
|
||||||
const int32_t *indirect;
|
const int32_t *indirect;
|
||||||
uint_fast32_t pass;
|
uint_fast32_t pass;
|
||||||
size_t needed;
|
size_t needed;
|
||||||
const unsigned char *usrc;
|
const USTRING_TYPE *usrc;
|
||||||
size_t srclen = strlen (src);
|
size_t srclen = STRLEN (src);
|
||||||
int32_t *idxarr;
|
int32_t *idxarr;
|
||||||
unsigned char *rulearr;
|
unsigned char *rulearr;
|
||||||
size_t idxmax;
|
size_t idxmax;
|
||||||
size_t idxcnt;
|
size_t idxcnt;
|
||||||
int use_malloc = 0;
|
int use_malloc;
|
||||||
|
#ifdef WIDE_CHAR_VERSION
|
||||||
|
size_t size;
|
||||||
|
size_t layers;
|
||||||
|
const wint_t *names;
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "../locale/weight.h"
|
#include WEIGHT_H
|
||||||
|
|
||||||
if (nrules == 0)
|
if (nrules == 0)
|
||||||
{
|
{
|
||||||
if (n != 0)
|
if (n != 0)
|
||||||
__stpncpy (dest, src, n);
|
STPNCPY (dest, src, n);
|
||||||
|
|
||||||
return srclen;
|
return srclen;
|
||||||
}
|
}
|
||||||
@ -126,37 +146,49 @@ STRXFRM (char *dest, const char *src, size_t n, __locale_t l)
|
|||||||
rulesets = (const unsigned char *)
|
rulesets = (const unsigned char *)
|
||||||
current->values[_NL_ITEM_INDEX (_NL_COLLATE_RULESETS)].string;
|
current->values[_NL_ITEM_INDEX (_NL_COLLATE_RULESETS)].string;
|
||||||
table = (const int32_t *)
|
table = (const int32_t *)
|
||||||
current->values[_NL_ITEM_INDEX (_NL_COLLATE_TABLEMB)].string;
|
current->values[_NL_ITEM_INDEX (CONCAT(_NL_COLLATE_TABLE,SUFFIX))].string;
|
||||||
weights = (const unsigned char *)
|
weights = (const USTRING_TYPE *)
|
||||||
current->values[_NL_ITEM_INDEX (_NL_COLLATE_WEIGHTMB)].string;
|
current->values[_NL_ITEM_INDEX (CONCAT(_NL_COLLATE_WEIGHT,SUFFIX))].string;
|
||||||
extra = (const unsigned char *)
|
extra = (const USTRING_TYPE *)
|
||||||
current->values[_NL_ITEM_INDEX (_NL_COLLATE_EXTRAMB)].string;
|
current->values[_NL_ITEM_INDEX (CONCAT(_NL_COLLATE_EXTRA,SUFFIX))].string;
|
||||||
indirect = (const int32_t *)
|
indirect = (const int32_t *)
|
||||||
current->values[_NL_ITEM_INDEX (_NL_COLLATE_INDIRECTMB)].string;
|
current->values[_NL_ITEM_INDEX (CONCAT(_NL_COLLATE_INDIRECT,SUFFIX))].string;
|
||||||
|
# ifdef WIDE_CHAR_VERSION
|
||||||
|
names = (const wint_t *)
|
||||||
|
current->values[_NL_ITEM_INDEX (_NL_COLLATE_NAMES)].string;
|
||||||
|
size = current->values[_NL_ITEM_INDEX (_NL_COLLATE_HASH_SIZE)].word;
|
||||||
|
layers = current->values[_NL_ITEM_INDEX (_NL_COLLATE_HASH_LAYERS)].word;
|
||||||
|
# endif
|
||||||
#else
|
#else
|
||||||
rulesets = (const unsigned char *)
|
rulesets = (const unsigned char *)
|
||||||
_NL_CURRENT (LC_COLLATE, _NL_COLLATE_RULESETS);
|
_NL_CURRENT (LC_COLLATE, _NL_COLLATE_RULESETS);
|
||||||
table = (const int32_t *)
|
table = (const int32_t *)
|
||||||
_NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB);
|
_NL_CURRENT (LC_COLLATE, CONCAT(_NL_COLLATE_TABLE,SUFFIX));
|
||||||
weights = (const unsigned char *)
|
weights = (const USTRING_TYPE *)
|
||||||
_NL_CURRENT (LC_COLLATE, _NL_COLLATE_WEIGHTMB);
|
_NL_CURRENT (LC_COLLATE, CONCAT(_NL_COLLATE_WEIGHT,SUFFIX));
|
||||||
extra = (const unsigned char *)
|
extra = (const USTRING_TYPE *)
|
||||||
_NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB);
|
_NL_CURRENT (LC_COLLATE, CONCAT(_NL_COLLATE_EXTRA,SUFFIX));
|
||||||
indirect = (const int32_t *)
|
indirect = (const int32_t *)
|
||||||
_NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTMB);
|
_NL_CURRENT (LC_COLLATE, CONCAT(_NL_COLLATE_INDIRECT,SUFFIX));
|
||||||
|
# ifdef WIDE_CHAR_VERSION
|
||||||
|
names = (const wint_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_NAMES);
|
||||||
|
size = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_HASH_SIZE);
|
||||||
|
layers = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_HASH_LAYERS);
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
use_malloc = 0;
|
||||||
|
|
||||||
/* Handle an empty string as a special case. */
|
/* Handle an empty string as a special case. */
|
||||||
if (srclen == 0)
|
if (srclen == 0)
|
||||||
{
|
{
|
||||||
if (n != 0)
|
if (n != 0)
|
||||||
*dest = '\0';
|
*dest = L('\0');
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We need the elements of the string as unsigned values since they
|
/* We need the elements of the string as unsigned values since they
|
||||||
are used as indeces. */
|
are used as indeces. */
|
||||||
usrc = (const unsigned char *) src;
|
usrc = (const USTRING_TYPE *) src;
|
||||||
|
|
||||||
/* Perform the first pass over the string and while doing this find
|
/* Perform the first pass over the string and while doing this find
|
||||||
and store the weights for each character. Since we want this to
|
and store the weights for each character. Since we want this to
|
||||||
@ -195,7 +227,7 @@ STRXFRM (char *dest, const char *src, size_t n, __locale_t l)
|
|||||||
|
|
||||||
++idxmax;
|
++idxmax;
|
||||||
}
|
}
|
||||||
while (*usrc != '\0');
|
while (*usrc != L('\0'));
|
||||||
|
|
||||||
/* Now the passes over the weights. We now use the indeces we found
|
/* Now the passes over the weights. We now use the indeces we found
|
||||||
before. */
|
before. */
|
||||||
@ -287,8 +319,10 @@ STRXFRM (char *dest, const char *src, size_t n, __locale_t l)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
int val = 1;
|
int val = 1;
|
||||||
|
#ifndef WIDE_CHAR_VERSION
|
||||||
char buf[7];
|
char buf[7];
|
||||||
size_t buflen;
|
size_t buflen;
|
||||||
|
#endif
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
for (idxcnt = 0; idxcnt < idxmax; ++idxcnt)
|
for (idxcnt = 0; idxcnt < idxmax; ++idxcnt)
|
||||||
@ -307,6 +341,16 @@ STRXFRM (char *dest, const char *src, size_t n, __locale_t l)
|
|||||||
len = weights[idxarr[backw]++];
|
len = weights[idxarr[backw]++];
|
||||||
if (len != 0)
|
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);
|
buflen = utf8_encode (buf, val);
|
||||||
if (needed + buflen + len < n)
|
if (needed + buflen + len < n)
|
||||||
{
|
{
|
||||||
@ -316,8 +360,9 @@ STRXFRM (char *dest, const char *src, size_t n, __locale_t l)
|
|||||||
dest[needed + buflen + i] =
|
dest[needed + buflen + i] =
|
||||||
weights[idxarr[backw] + i];
|
weights[idxarr[backw] + i];
|
||||||
}
|
}
|
||||||
idxarr[backw] += len;
|
|
||||||
needed += buflen + len;
|
needed += buflen + len;
|
||||||
|
#endif
|
||||||
|
idxarr[backw] += len;
|
||||||
val = 1;
|
val = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -331,6 +376,16 @@ STRXFRM (char *dest, const char *src, size_t n, __locale_t l)
|
|||||||
len = weights[idxarr[idxcnt]++];
|
len = weights[idxarr[idxcnt]++];
|
||||||
if (len != 0)
|
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);
|
buflen = utf8_encode (buf, val);
|
||||||
if (needed + buflen + len < n)
|
if (needed + buflen + len < n)
|
||||||
{
|
{
|
||||||
@ -340,8 +395,9 @@ STRXFRM (char *dest, const char *src, size_t n, __locale_t l)
|
|||||||
dest[needed + buflen + i] =
|
dest[needed + buflen + i] =
|
||||||
weights[idxarr[idxcnt] + i];
|
weights[idxarr[idxcnt] + i];
|
||||||
}
|
}
|
||||||
idxarr[idxcnt] += len;
|
|
||||||
needed += buflen + len;
|
needed += buflen + len;
|
||||||
|
#endif
|
||||||
|
idxarr[idxcnt] += len;
|
||||||
val = 1;
|
val = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -370,6 +426,16 @@ STRXFRM (char *dest, const char *src, size_t n, __locale_t l)
|
|||||||
size_t len = weights[idxarr[--backw]++];
|
size_t len = weights[idxarr[--backw]++];
|
||||||
if (len != 0)
|
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);
|
buflen = utf8_encode (buf, val);
|
||||||
if (needed + buflen + len < n)
|
if (needed + buflen + len < n)
|
||||||
{
|
{
|
||||||
@ -379,8 +445,9 @@ STRXFRM (char *dest, const char *src, size_t n, __locale_t l)
|
|||||||
dest[needed + buflen + i] =
|
dest[needed + buflen + i] =
|
||||||
weights[idxarr[backw] + i];
|
weights[idxarr[backw] + i];
|
||||||
}
|
}
|
||||||
idxarr[backw] += len;
|
|
||||||
needed += buflen + len;
|
needed += buflen + len;
|
||||||
|
#endif
|
||||||
|
idxarr[backw] += len;
|
||||||
val = 1;
|
val = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -392,7 +459,7 @@ STRXFRM (char *dest, const char *src, size_t n, __locale_t l)
|
|||||||
/* Finally store the byte to separate the passes or terminate
|
/* Finally store the byte to separate the passes or terminate
|
||||||
the string. */
|
the string. */
|
||||||
if (needed < n)
|
if (needed < n)
|
||||||
dest[needed] = pass + 1 < nrules ? '\1' : '\0';
|
dest[needed] = pass + 1 < nrules ? L('\1') : L('\0');
|
||||||
++needed;
|
++needed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -400,11 +467,11 @@ STRXFRM (char *dest, const char *src, size_t n, __locale_t l)
|
|||||||
a `position' rule at the end and if no non-ignored character
|
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
|
is found the last \1 byte is immediately followed by a \0 byte
|
||||||
signalling this. We can avoid the \1 byte(s). */
|
signalling this. We can avoid the \1 byte(s). */
|
||||||
if (needed <= n && needed > 2 && dest[needed - 2] == '\1')
|
if (needed <= n && needed > 2 && dest[needed - 2] == L('\1'))
|
||||||
{
|
{
|
||||||
/* Remove the \1 byte. */
|
/* Remove the \1 byte. */
|
||||||
--needed;
|
--needed;
|
||||||
dest[needed - 1] = '\0';
|
dest[needed - 1] = L('\0');
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free the memory if needed. */
|
/* Free the memory if needed. */
|
||||||
|
@ -19,26 +19,18 @@
|
|||||||
|
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
|
||||||
|
#define STRING_TYPE wchar_t
|
||||||
|
#define USTRING_TYPE wint_t
|
||||||
#ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
#ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
||||||
# define STRCOLL __wcscoll_l
|
# define STRCOLL __wcscoll_l
|
||||||
#else
|
#else
|
||||||
# define STRCOLL wcscoll
|
# define STRCOLL wcscoll
|
||||||
#endif
|
#endif
|
||||||
#define STRCMP wcscmp
|
#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
|
|
||||||
int
|
|
||||||
STRCOLL (s1, s2)
|
|
||||||
const wchar_t *s1;
|
|
||||||
const wchar_t *s2;
|
|
||||||
#else
|
|
||||||
int
|
|
||||||
STRCOLL (s1, s2, l)
|
|
||||||
const wchar_t *s1;
|
|
||||||
const wchar_t *s2;
|
|
||||||
__locale_t l;
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
return STRCMP (s1, s2);
|
|
||||||
}
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
|
/* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
|
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU Library General Public License as
|
modify it under the terms of the GNU Library General Public License as
|
||||||
@ -19,23 +19,19 @@
|
|||||||
|
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
|
||||||
|
#define STRING_TYPE wchar_t
|
||||||
|
#define USTRING_TYPE wint_t
|
||||||
#ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
#ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
||||||
# define STRXFRM __wcsxfrm_l
|
# define STRXFRM __wcsxfrm_l
|
||||||
#else
|
#else
|
||||||
# define STRXFRM wcsxfrm
|
# define STRXFRM wcsxfrm
|
||||||
#endif
|
#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"
|
||||||
#ifndef USE_IN_EXTENDED_LOCALE_MODEL
|
|
||||||
size_t
|
|
||||||
STRXFRM (wchar_t *dest, const wchar_t *src, size_t n)
|
|
||||||
#else
|
|
||||||
size_t
|
|
||||||
STRXFRM (wchar_t *dest, const wchar_t *src, size_t n, __locale_t l)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
if (n != 0)
|
|
||||||
__wcpncpy (dest, src, n);
|
|
||||||
|
|
||||||
return __wcslen (src);
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user