diff options
author | Jörg Frings-Fürst <debian@jff.email> | 2022-01-08 11:51:07 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff.email> | 2022-01-08 11:51:07 +0100 |
commit | be8efac78d067c138ad8dda03df4336e73f94887 (patch) | |
tree | 5f5254a628ba0ef72065b93d949d1c985742ea8e /lib/uniname/uniname.c | |
parent | 7b65dbd4ebade81d504cfe5e681292a58ad1fdf0 (diff) |
New upstream version 1.0upstream/1.0
Diffstat (limited to 'lib/uniname/uniname.c')
-rw-r--r-- | lib/uniname/uniname.c | 67 |
1 files changed, 35 insertions, 32 deletions
diff --git a/lib/uniname/uniname.c b/lib/uniname/uniname.c index 85c4676e..479cb83c 100644 --- a/lib/uniname/uniname.c +++ b/lib/uniname/uniname.c @@ -1,27 +1,26 @@ /* Association between Unicode characters and their names. - Copyright (C) 2000-2002, 2005-2007, 2009-2018 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or - modify it under the terms of either: - - * the GNU Lesser General Public License as published by the Free - Software Foundation; either version 3 of the License, or (at your - option) any later version. - - or - - * the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your - option) any later version. - - or both in parallel, as here. - This program is distributed in the hope that it will be useful, + Copyright (C) 2000-2002, 2005-2007, 2009-2022 Free Software Foundation, Inc. + + This file is free software. + It is dual-licensed under "the GNU LGPLv3+ or the GNU GPLv2+". + You can redistribute it and/or modify it under either + - the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 3, or (at your + option) any later version, or + - the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) + any later version, or + - the same dual license "the GNU LGPLv3+ or the GNU GPLv2+". + + This file 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. + Lesser General Public License and the GNU General Public License + for more details. - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see <https://www.gnu.org/licenses/>. */ + You should have received a copy of the GNU Lesser General Public + License and of the GNU General Public License along with this + program. If not, see <https://www.gnu.org/licenses/>. */ #include <config.h> @@ -34,6 +33,8 @@ #include <stdio.h> #include <string.h> +#include "attribute.h" + #define SIZEOF(a) (sizeof(a) / sizeof(a[0])) @@ -67,7 +68,6 @@ unicode_name_word (unsigned int index, unsigned int *lengthp) { unsigned int i1; unsigned int i2; - unsigned int i; assert (index < UNICODE_CHARNAME_NUM_WORDS); @@ -87,7 +87,7 @@ unicode_name_word (unsigned int index, unsigned int *lengthp) else i2 = i; } - i = i1; + unsigned int i = i1; assert (unicode_name_by_length[i].ind_offset <= index && index < unicode_name_by_length[i+1].ind_offset); *lengthp = i; @@ -97,7 +97,7 @@ unicode_name_word (unsigned int index, unsigned int *lengthp) /* Looks up the index of a word. */ static int -unicode_name_word_lookup (const char *word, unsigned int length) +unicode_name_word_lookup (const char *word, size_t length) { if (length > 0 && length < SIZEOF (unicode_name_by_length) - 1) { @@ -366,7 +366,7 @@ unicode_character_name (ucs4_t c, char *buf) ucs4_t unicode_name_character (const char *name) { - unsigned int len = strlen (name); + size_t len = strlen (name); if (len > 1 && len <= UNICODE_CHARNAME_MAX_LENGTH) { /* Test for "word1 word2 ..." syntax. */ @@ -476,9 +476,9 @@ unicode_name_character (const char *name) p4++; if (p4 == ptr) { - unsigned int n1 = p2 - p1; - unsigned int n2 = p3 - p2; - unsigned int n3 = p4 - p3; + size_t n1 = p2 - p1; + size_t n2 = p3 - p2; + size_t n3 = p4 - p3; if (n1 <= 2 && (n2 >= 1 && n2 <= 3) && n3 <= 2) { @@ -585,12 +585,15 @@ unicode_name_character (const char *name) filled_words: { /* Multiply by 2, to simplify later comparisons. */ - unsigned int words_length = wordptr - words; + size_t words_length = wordptr - words; { - int i = words_length - 1; + size_t i = words_length - 1; words[i] = 2 * words[i]; - for (; --i >= 0; ) - words[i] = 2 * words[i] + 1; + for (; i > 0; ) + { + --i; + words[i] = 2 * words[i] + 1; + } } /* Binary search in unicode_name_to_index. */ { @@ -601,7 +604,7 @@ unicode_name_character (const char *name) unsigned int i = (i1 + i2) >> 1; const uint16_t *w = words; const uint16_t *p = &unicode_names[unicode_name_to_index[i].name]; - unsigned int n = words_length; + size_t n = words_length; for (;;) { if (*p < *w) |