|
Packit Service |
82fcde |
/* Copyright (C) 2000-2018 Free Software Foundation, Inc.
|
|
Packit Service |
82fcde |
This file is part of the GNU C Library.
|
|
Packit Service |
82fcde |
Contributed by Ulrich Drepper <drepper@gnu.org>, 2000.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit Service |
82fcde |
modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
82fcde |
License as published by the Free Software Foundation; either
|
|
Packit Service |
82fcde |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit Service |
82fcde |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
82fcde |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
82fcde |
Lesser General Public License for more details.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
82fcde |
License along with the GNU C Library; if not, see
|
|
Packit Service |
82fcde |
<http://www.gnu.org/licenses/>. */
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#include <assert.h>
|
|
Packit Service |
82fcde |
#include <langinfo.h>
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Look up the value of the next multibyte character and return its numerical
|
|
Packit Service |
82fcde |
value if it is one of the digits known in the locale. If *DECIDED is
|
|
Packit Service |
82fcde |
-1 this means it is not yet decided which form it is and we have to
|
|
Packit Service |
82fcde |
search through all available digits. Otherwise we know which script
|
|
Packit Service |
82fcde |
the digits are from. */
|
|
Packit Service |
82fcde |
static inline int
|
|
Packit Service |
82fcde |
indigitwc_value (wchar_t wc, int *decided)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
int from_level;
|
|
Packit Service |
82fcde |
int to_level;
|
|
Packit Service |
82fcde |
const wchar_t *wcdigits[10];
|
|
Packit Service |
82fcde |
int n;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
if (*decided != -1)
|
|
Packit Service |
82fcde |
from_level = to_level = *decided;
|
|
Packit Service |
82fcde |
else
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
from_level = 0;
|
|
Packit Service |
82fcde |
to_level = _NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_INDIGITS_WC_LEN) - 1;
|
|
Packit Service |
82fcde |
assert (from_level <= to_level);
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* In this round we get the pointer to the digit strings and also perform
|
|
Packit Service |
82fcde |
the first round of comparisons. */
|
|
Packit Service |
82fcde |
for (n = 0; n < 10; ++n)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
/* Get the string for the digits with value N. */
|
|
Packit Service |
82fcde |
wcdigits[n] = _NL_CURRENT (LC_CTYPE, _NL_CTYPE_INDIGITS0_WC + n);
|
|
Packit Service |
82fcde |
wcdigits[n] += from_level;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
if (wc == *wcdigits[n])
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
/* Found it. */
|
|
Packit Service |
82fcde |
if (*decided == -1)
|
|
Packit Service |
82fcde |
*decided = 0;
|
|
Packit Service |
82fcde |
return n;
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Advance the pointer to the next string. */
|
|
Packit Service |
82fcde |
++wcdigits[n];
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Now perform the remaining tests. */
|
|
Packit Service |
82fcde |
while (++from_level <= to_level)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
/* Search all ten digits of this level. */
|
|
Packit Service |
82fcde |
for (n = 0; n < 10; ++n)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
if (wc == *wcdigits[n])
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
/* Found it. */
|
|
Packit Service |
82fcde |
if (*decided == -1)
|
|
Packit Service |
82fcde |
*decided = from_level;
|
|
Packit Service |
82fcde |
return n;
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Advance the pointer to the next string. */
|
|
Packit Service |
82fcde |
++wcdigits[n];
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* If we reach this point no matching digit was found. */
|
|
Packit Service |
82fcde |
return -1;
|
|
Packit Service |
82fcde |
}
|