diff options
Diffstat (limited to 'lib/unistr')
155 files changed, 495 insertions, 480 deletions
diff --git a/lib/unistr/u-cmp2.h b/lib/unistr/u-cmp2.h index 1b4ca97f..8d5960b4 100644 --- a/lib/unistr/u-cmp2.h +++ b/lib/unistr/u-cmp2.h @@ -1,5 +1,5 @@ /* Compare pieces of UTF-8/UTF-16/UTF-32 strings. - Copyright (C) 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This file is free software. diff --git a/lib/unistr/u-cpy-alloc.h b/lib/unistr/u-cpy-alloc.h index 0f60d1e5..ac225661 100644 --- a/lib/unistr/u-cpy-alloc.h +++ b/lib/unistr/u-cpy-alloc.h @@ -1,5 +1,5 @@ /* Copy piece of UTF-8/UTF-16/UTF-32 string. - Copyright (C) 1999, 2002, 2006-2007, 2009-2022 Free Software Foundation, + Copyright (C) 1999, 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. diff --git a/lib/unistr/u-cpy.h b/lib/unistr/u-cpy.h index f0b3bc85..4848c146 100644 --- a/lib/unistr/u-cpy.h +++ b/lib/unistr/u-cpy.h @@ -1,5 +1,5 @@ /* Copy piece of UTF-8/UTF-16/UTF-32 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software: you can redistribute it and/or modify diff --git a/lib/unistr/u-endswith.h b/lib/unistr/u-endswith.h index d69204b7..0c512ad9 100644 --- a/lib/unistr/u-endswith.h +++ b/lib/unistr/u-endswith.h @@ -1,5 +1,5 @@ /* Substring test for UTF-8/UTF-16/UTF-32 strings. - Copyright (C) 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u-move.h b/lib/unistr/u-move.h index 00ced078..9aa36c41 100644 --- a/lib/unistr/u-move.h +++ b/lib/unistr/u-move.h @@ -1,5 +1,5 @@ /* Copy piece of UTF-8/UTF-16/UTF-32 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u-pcpy.h b/lib/unistr/u-pcpy.h new file mode 100644 index 00000000..81241975 --- /dev/null +++ b/lib/unistr/u-pcpy.h @@ -0,0 +1,22 @@ +/* Copy piece of UTF-8/16/32 string, return pointer after last written unit. + Copyright (C) 2020-2024 Free Software Foundation, Inc. + Written by Bruno Haible <bruno@clisp.org>, 2023. + + This file 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. + + 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. + + 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/>. */ + +UNIT * +FUNC (UNIT *dest, const UNIT *src, size_t n) +{ + return U_CPY (dest, src, n) + n; +} diff --git a/lib/unistr/u-set.h b/lib/unistr/u-set.h index 573da7e9..088cabef 100644 --- a/lib/unistr/u-set.h +++ b/lib/unistr/u-set.h @@ -1,5 +1,5 @@ /* Fill UTF-8/UTF-16/UTF-32 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u-startswith.h b/lib/unistr/u-startswith.h index a6aded59..8346c26c 100644 --- a/lib/unistr/u-startswith.h +++ b/lib/unistr/u-startswith.h @@ -1,5 +1,5 @@ /* Substring test for UTF-8/UTF-16/UTF-32 strings. - Copyright (C) 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u-stpcpy.h b/lib/unistr/u-stpcpy.h index 07008b0a..22099ed7 100644 --- a/lib/unistr/u-stpcpy.h +++ b/lib/unistr/u-stpcpy.h @@ -1,5 +1,5 @@ /* Copy UTF-8/UTF-16/UTF-32 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u-stpncpy.h b/lib/unistr/u-stpncpy.h index 9c4e5829..2e532e07 100644 --- a/lib/unistr/u-stpncpy.h +++ b/lib/unistr/u-stpncpy.h @@ -1,5 +1,5 @@ /* Copy UTF-8/UTF-16/UTF-32 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u-strcat.h b/lib/unistr/u-strcat.h index f742165b..a4a4e931 100644 --- a/lib/unistr/u-strcat.h +++ b/lib/unistr/u-strcat.h @@ -1,27 +1,19 @@ /* Concatenate UTF-8/UTF-16/UTF-32 strings. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. - 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 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. 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 and the GNU General Public License - for more details. + 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 and of the GNU 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 + along with this program. If not, see <https://www.gnu.org/licenses/>. */ UNIT * FUNC (UNIT *dest, const UNIT *src) diff --git a/lib/unistr/u-strcoll.h b/lib/unistr/u-strcoll.h index ee08ab75..e26eac08 100644 --- a/lib/unistr/u-strcoll.h +++ b/lib/unistr/u-strcoll.h @@ -1,6 +1,6 @@ /* Compare UTF-8/UTF-16/UTF-32 strings using the collation rules of the current locale. - Copyright (C) 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This file is free software. diff --git a/lib/unistr/u-strcpy.h b/lib/unistr/u-strcpy.h index 04c1b9d2..4151d1cc 100644 --- a/lib/unistr/u-strcpy.h +++ b/lib/unistr/u-strcpy.h @@ -1,5 +1,5 @@ /* Copy UTF-8/UTF-16/UTF-32 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u-strcspn.h b/lib/unistr/u-strcspn.h index eab30943..3cca61c1 100644 --- a/lib/unistr/u-strcspn.h +++ b/lib/unistr/u-strcspn.h @@ -1,5 +1,5 @@ /* Search for some characters in UTF-8/UTF-16/UTF-32 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u-strdup.h b/lib/unistr/u-strdup.h index 543a5448..978687b6 100644 --- a/lib/unistr/u-strdup.h +++ b/lib/unistr/u-strdup.h @@ -1,5 +1,5 @@ /* Copy UTF-8/UTF-16/UTF-32 string. - Copyright (C) 1999, 2002, 2006-2007, 2009-2022 Free Software Foundation, + Copyright (C) 1999, 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. diff --git a/lib/unistr/u-strlen.h b/lib/unistr/u-strlen.h index 70998fc4..03106a15 100644 --- a/lib/unistr/u-strlen.h +++ b/lib/unistr/u-strlen.h @@ -1,27 +1,19 @@ /* Determine length of UTF-8/UTF-16/UTF-32 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. - 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 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. 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 and the GNU General Public License - for more details. + 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 and of the GNU 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 + along with this program. If not, see <https://www.gnu.org/licenses/>. */ size_t FUNC (const UNIT *s) diff --git a/lib/unistr/u-strncat.h b/lib/unistr/u-strncat.h index 3e85b615..587960da 100644 --- a/lib/unistr/u-strncat.h +++ b/lib/unistr/u-strncat.h @@ -1,5 +1,5 @@ /* Concatenate UTF-8/UTF-16/UTF-32 strings. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u-strncpy.h b/lib/unistr/u-strncpy.h index 89b65dd1..c59db653 100644 --- a/lib/unistr/u-strncpy.h +++ b/lib/unistr/u-strncpy.h @@ -1,5 +1,5 @@ /* Copy UTF-8/UTF-16/UTF-32 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u-strnlen.h b/lib/unistr/u-strnlen.h index b7237ce9..4ec1474f 100644 --- a/lib/unistr/u-strnlen.h +++ b/lib/unistr/u-strnlen.h @@ -1,5 +1,5 @@ /* Determine bounded length of UTF-8/UTF-16/UTF-32 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u-strpbrk.h b/lib/unistr/u-strpbrk.h index 847bd6f9..c5f9d2de 100644 --- a/lib/unistr/u-strpbrk.h +++ b/lib/unistr/u-strpbrk.h @@ -1,5 +1,5 @@ /* Search for some characters in UTF-8/UTF-16/UTF-32 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u-strspn.h b/lib/unistr/u-strspn.h index 13b5df84..021ffcfc 100644 --- a/lib/unistr/u-strspn.h +++ b/lib/unistr/u-strspn.h @@ -1,5 +1,5 @@ /* Search for some characters in UTF-8/UTF-16/UTF-32 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u-strstr.h b/lib/unistr/u-strstr.h deleted file mode 100644 index 98dda4be..00000000 --- a/lib/unistr/u-strstr.h +++ /dev/null @@ -1,139 +0,0 @@ -/* Substring test for UTF-8/UTF-16/UTF-32 strings. -*- coding: utf-8 -*- - Copyright (C) 1999, 2002, 2006, 2010-2022 Free Software Foundation, Inc. - Written by Bruno Haible <bruno@clisp.org>, 2002, 2005. - - 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 and the GNU General Public License - for more details. - - 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/>. */ - -UNIT * -FUNC (const UNIT *haystack, const UNIT *needle) -{ - UNIT first = needle[0]; - - /* Is needle empty? */ - if (first == 0) - return (UNIT *) haystack; - - /* Is needle nearly empty (only one unit)? */ - if (needle[1] == 0) - return U_STRCHR (haystack, first); - -#ifdef U_STRMBTOUC - /* Is needle nearly empty (only one character)? */ - { - ucs4_t first_uc; - int count = U_STRMBTOUC (&first_uc, needle); - if (count > 0 && needle[count] == 0) - return U_STRCHR (haystack, first_uc); - } -#endif - -#if UNIT_IS_UINT8_T - return (uint8_t *) strstr ((const char *) haystack, (const char *) needle); -#else - { - /* Minimizing the worst-case complexity: - Let n = U_STRLEN(haystack), m = U_STRLEN(needle). - The naïve algorithm is O(n*m) worst-case. - The Knuth-Morris-Pratt algorithm is O(n) worst-case but it needs a - memory allocation. - To achieve linear complexity and yet amortize the cost of the - memory allocation, we activate the Knuth-Morris-Pratt algorithm - only once the naïve algorithm has already run for some time; more - precisely, when - - the outer loop count is >= 10, - - the average number of comparisons per outer loop is >= 5, - - the total number of comparisons is >= m. - But we try it only once. If the memory allocation attempt failed, - we don't retry it. */ - bool try_kmp = true; - size_t outer_loop_count = 0; - size_t comparison_count = 0; - size_t last_ccount = 0; /* last comparison count */ - const UNIT *needle_last_ccount = needle; /* = needle + last_ccount */ - - /* Speed up the following searches of needle by caching its first - character. */ - UNIT b = *needle++; - - for (;; haystack++) - { - if (*haystack == 0) - /* No match. */ - return NULL; - - /* See whether it's advisable to use an asymptotically faster - algorithm. */ - if (try_kmp - && outer_loop_count >= 10 - && comparison_count >= 5 * outer_loop_count) - { - /* See if needle + comparison_count now reaches the end of - needle. */ - if (needle_last_ccount != NULL) - { - needle_last_ccount += - U_STRNLEN (needle_last_ccount, - comparison_count - last_ccount); - if (*needle_last_ccount == 0) - needle_last_ccount = NULL; - last_ccount = comparison_count; - } - if (needle_last_ccount == NULL) - { - /* Try the Knuth-Morris-Pratt algorithm. */ - const UNIT *result; - bool success = - knuth_morris_pratt (haystack, - needle - 1, U_STRLEN (needle - 1), - &result); - if (success) - return (UNIT *) result; - try_kmp = false; - } - } - - outer_loop_count++; - comparison_count++; - if (*haystack == b) - /* The first character matches. */ - { - const UNIT *rhaystack = haystack + 1; - const UNIT *rneedle = needle; - - for (;; rhaystack++, rneedle++) - { - if (*rneedle == 0) - /* Found a match. */ - return (UNIT *) haystack; - if (*rhaystack == 0) - /* No match. */ - return NULL; - comparison_count++; - if (*rhaystack != *rneedle) - /* Nothing in this round. */ - break; - } - } - } - } -#endif -} diff --git a/lib/unistr/u-strtok.h b/lib/unistr/u-strtok.h index 088e80ba..823b545d 100644 --- a/lib/unistr/u-strtok.h +++ b/lib/unistr/u-strtok.h @@ -1,5 +1,5 @@ /* Tokenize UTF-8/UTF-16/UTF-32 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u16-check.c b/lib/unistr/u16-check.c index f97327d6..9372236e 100644 --- a/lib/unistr/u16-check.c +++ b/lib/unistr/u16-check.c @@ -1,5 +1,5 @@ /* Check UTF-16 string. - Copyright (C) 2002, 2006-2007, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u16-chr.c b/lib/unistr/u16-chr.c index 97927c2f..fa46cfb1 100644 --- a/lib/unistr/u16-chr.c +++ b/lib/unistr/u16-chr.c @@ -1,5 +1,5 @@ /* Search character in piece of UTF-16 string. - Copyright (C) 1999, 2002, 2006-2007, 2009-2022 Free Software Foundation, + Copyright (C) 1999, 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. diff --git a/lib/unistr/u16-cmp.c b/lib/unistr/u16-cmp.c index 67a69889..1a27f5d3 100644 --- a/lib/unistr/u16-cmp.c +++ b/lib/unistr/u16-cmp.c @@ -1,5 +1,5 @@ /* Compare pieces of UTF-16 strings. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u16-cmp2.c b/lib/unistr/u16-cmp2.c index f6d323eb..bb53fef2 100644 --- a/lib/unistr/u16-cmp2.c +++ b/lib/unistr/u16-cmp2.c @@ -1,5 +1,5 @@ /* Compare pieces of UTF-16 strings. - Copyright (C) 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This file is free software. diff --git a/lib/unistr/u16-cpy-alloc.c b/lib/unistr/u16-cpy-alloc.c index 2da1e64d..a7259d7b 100644 --- a/lib/unistr/u16-cpy-alloc.c +++ b/lib/unistr/u16-cpy-alloc.c @@ -1,5 +1,5 @@ /* Copy piece of UTF-16 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u16-cpy.c b/lib/unistr/u16-cpy.c index 0f0b7d54..0c61d33d 100644 --- a/lib/unistr/u16-cpy.c +++ b/lib/unistr/u16-cpy.c @@ -1,5 +1,5 @@ /* Copy piece of UTF-16 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u16-endswith.c b/lib/unistr/u16-endswith.c index 0dddd2df..b12105d1 100644 --- a/lib/unistr/u16-endswith.c +++ b/lib/unistr/u16-endswith.c @@ -1,5 +1,5 @@ /* Substring test for UTF-16 strings. - Copyright (C) 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u16-mblen.c b/lib/unistr/u16-mblen.c index 2083ee7b..e29d3c07 100644 --- a/lib/unistr/u16-mblen.c +++ b/lib/unistr/u16-mblen.c @@ -1,5 +1,5 @@ /* Look at first character in UTF-16 string. - Copyright (C) 1999-2000, 2002, 2006-2007, 2009-2022 Free Software + Copyright (C) 1999-2000, 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. diff --git a/lib/unistr/u16-mbsnlen.c b/lib/unistr/u16-mbsnlen.c index 05b3330d..3a074507 100644 --- a/lib/unistr/u16-mbsnlen.c +++ b/lib/unistr/u16-mbsnlen.c @@ -1,5 +1,5 @@ /* Count characters in UTF-16 string. - Copyright (C) 2007, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2007. This file is free software. diff --git a/lib/unistr/u16-mbtouc-aux.c b/lib/unistr/u16-mbtouc-aux.c index 99a54aab..f6ca667c 100644 --- a/lib/unistr/u16-mbtouc-aux.c +++ b/lib/unistr/u16-mbtouc-aux.c @@ -1,5 +1,5 @@ /* Conversion UTF-16 to UCS-4. - Copyright (C) 2001-2002, 2006-2007, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2001-2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2001. This file is free software. diff --git a/lib/unistr/u16-mbtouc-unsafe-aux.c b/lib/unistr/u16-mbtouc-unsafe-aux.c index 7199854a..44f68229 100644 --- a/lib/unistr/u16-mbtouc-unsafe-aux.c +++ b/lib/unistr/u16-mbtouc-unsafe-aux.c @@ -1,5 +1,5 @@ /* Conversion UTF-16 to UCS-4. - Copyright (C) 2001-2002, 2006-2007, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2001-2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2001. This file is free software. diff --git a/lib/unistr/u16-mbtouc-unsafe.c b/lib/unistr/u16-mbtouc-unsafe.c index bacacc7d..3d5f8289 100644 --- a/lib/unistr/u16-mbtouc-unsafe.c +++ b/lib/unistr/u16-mbtouc-unsafe.c @@ -1,5 +1,5 @@ /* Look at first character in UTF-16 string. - Copyright (C) 1999-2002, 2006-2007, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999-2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2001. This file is free software. diff --git a/lib/unistr/u16-mbtouc.c b/lib/unistr/u16-mbtouc.c index 20cae8ee..e6fad1c8 100644 --- a/lib/unistr/u16-mbtouc.c +++ b/lib/unistr/u16-mbtouc.c @@ -1,5 +1,5 @@ /* Look at first character in UTF-16 string. - Copyright (C) 1999-2002, 2006-2007, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999-2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2001. This file is free software. diff --git a/lib/unistr/u16-mbtoucr.c b/lib/unistr/u16-mbtoucr.c index 7cb40c1b..7a0ff452 100644 --- a/lib/unistr/u16-mbtoucr.c +++ b/lib/unistr/u16-mbtoucr.c @@ -1,5 +1,5 @@ /* Look at first character in UTF-16 string, returning an error code. - Copyright (C) 1999-2002, 2006-2007, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999-2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2001. This file is free software. diff --git a/lib/unistr/u16-move.c b/lib/unistr/u16-move.c index 9c8ac008..680ac997 100644 --- a/lib/unistr/u16-move.c +++ b/lib/unistr/u16-move.c @@ -1,5 +1,5 @@ /* Copy piece of UTF-16 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u16-next.c b/lib/unistr/u16-next.c index c5bc23ab..c4307681 100644 --- a/lib/unistr/u16-next.c +++ b/lib/unistr/u16-next.c @@ -1,5 +1,5 @@ /* Iterate over next character in UTF-16 string. - Copyright (C) 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u16-pcpy.c b/lib/unistr/u16-pcpy.c new file mode 100644 index 00000000..9ed2c9dc --- /dev/null +++ b/lib/unistr/u16-pcpy.c @@ -0,0 +1,34 @@ +/* Copy piece of UTF-16 string, return pointer after last written unit. + Copyright (C) 2020-2024 Free Software Foundation, Inc. + Written by Bruno Haible <bruno@clisp.org>, 2023. + + 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 and the GNU General Public License + for more details. + + 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> + +/* Specification. */ +#include "unistr.h" + +#define FUNC u16_pcpy +#define UNIT uint16_t +#define U_CPY u16_cpy +#include "u-pcpy.h" diff --git a/lib/unistr/u16-prev.c b/lib/unistr/u16-prev.c index bf5259da..38032708 100644 --- a/lib/unistr/u16-prev.c +++ b/lib/unistr/u16-prev.c @@ -1,5 +1,5 @@ /* Iterate over previous character in UTF-16 string. - Copyright (C) 2002, 2006-2007, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u16-set.c b/lib/unistr/u16-set.c index 0f676bd7..ee4c4d08 100644 --- a/lib/unistr/u16-set.c +++ b/lib/unistr/u16-set.c @@ -1,5 +1,5 @@ /* Fill UTF-16 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u16-startswith.c b/lib/unistr/u16-startswith.c index 2c51c9fe..748ecc51 100644 --- a/lib/unistr/u16-startswith.c +++ b/lib/unistr/u16-startswith.c @@ -1,5 +1,5 @@ /* Substring test for UTF-16 strings. - Copyright (C) 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u16-stpcpy.c b/lib/unistr/u16-stpcpy.c index 9844d501..268d44e7 100644 --- a/lib/unistr/u16-stpcpy.c +++ b/lib/unistr/u16-stpcpy.c @@ -1,5 +1,5 @@ /* Copy UTF-16 string. - Copyright (C) 1999, 2002, 2006-2007, 2009-2022 Free Software Foundation, + Copyright (C) 1999, 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. diff --git a/lib/unistr/u16-stpncpy.c b/lib/unistr/u16-stpncpy.c index da4d90b6..33793a0f 100644 --- a/lib/unistr/u16-stpncpy.c +++ b/lib/unistr/u16-stpncpy.c @@ -1,5 +1,5 @@ /* Copy UTF-16 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u16-strcat.c b/lib/unistr/u16-strcat.c index acc0b008..e3aac729 100644 --- a/lib/unistr/u16-strcat.c +++ b/lib/unistr/u16-strcat.c @@ -1,5 +1,5 @@ /* Concatenate UTF-16 strings. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u16-strchr.c b/lib/unistr/u16-strchr.c index 99ba61cc..fe42999e 100644 --- a/lib/unistr/u16-strchr.c +++ b/lib/unistr/u16-strchr.c @@ -1,5 +1,5 @@ /* Search character in UTF-16 string. - Copyright (C) 1999, 2002, 2006-2007, 2009-2022 Free Software Foundation, + Copyright (C) 1999, 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. diff --git a/lib/unistr/u16-strcmp.c b/lib/unistr/u16-strcmp.c index 4c7f3cc1..449d5d6a 100644 --- a/lib/unistr/u16-strcmp.c +++ b/lib/unistr/u16-strcmp.c @@ -1,5 +1,5 @@ /* Compare UTF-16 strings. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u16-strcoll.c b/lib/unistr/u16-strcoll.c index fd0a3162..ea0b2d03 100644 --- a/lib/unistr/u16-strcoll.c +++ b/lib/unistr/u16-strcoll.c @@ -1,5 +1,5 @@ /* Compare UTF-16 strings using the collation rules of the current locale. - Copyright (C) 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This file is free software. diff --git a/lib/unistr/u16-strcpy.c b/lib/unistr/u16-strcpy.c index 714e8a6f..798cf246 100644 --- a/lib/unistr/u16-strcpy.c +++ b/lib/unistr/u16-strcpy.c @@ -1,5 +1,5 @@ /* Copy UTF-16 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u16-strcspn.c b/lib/unistr/u16-strcspn.c index 686fb89f..c36a84c1 100644 --- a/lib/unistr/u16-strcspn.c +++ b/lib/unistr/u16-strcspn.c @@ -1,5 +1,5 @@ /* Search for some characters in UTF-16 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u16-strdup.c b/lib/unistr/u16-strdup.c index cf6f53bd..bebed128 100644 --- a/lib/unistr/u16-strdup.c +++ b/lib/unistr/u16-strdup.c @@ -1,5 +1,5 @@ /* Copy UTF-16 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u16-strlen.c b/lib/unistr/u16-strlen.c index 95e805cc..d6db9170 100644 --- a/lib/unistr/u16-strlen.c +++ b/lib/unistr/u16-strlen.c @@ -1,5 +1,5 @@ /* Determine length of UTF-16 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u16-strmblen.c b/lib/unistr/u16-strmblen.c index d30f6698..4cbd0204 100644 --- a/lib/unistr/u16-strmblen.c +++ b/lib/unistr/u16-strmblen.c @@ -1,5 +1,5 @@ /* Look at first character in UTF-16 string. - Copyright (C) 1999-2000, 2002, 2006-2007, 2009-2022 Free Software + Copyright (C) 1999-2000, 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. diff --git a/lib/unistr/u16-strmbtouc.c b/lib/unistr/u16-strmbtouc.c index 18853957..c4a9704d 100644 --- a/lib/unistr/u16-strmbtouc.c +++ b/lib/unistr/u16-strmbtouc.c @@ -1,5 +1,5 @@ /* Look at first character in UTF-16 string. - Copyright (C) 1999-2000, 2002, 2006-2007, 2009-2022 Free Software + Copyright (C) 1999-2000, 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. diff --git a/lib/unistr/u16-strncat.c b/lib/unistr/u16-strncat.c index f2a1a2dc..4aa93252 100644 --- a/lib/unistr/u16-strncat.c +++ b/lib/unistr/u16-strncat.c @@ -1,5 +1,5 @@ /* Concatenate UTF-16 strings. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u16-strncmp.c b/lib/unistr/u16-strncmp.c index aad7d68c..0021dbbb 100644 --- a/lib/unistr/u16-strncmp.c +++ b/lib/unistr/u16-strncmp.c @@ -1,5 +1,5 @@ /* Compare UTF-16 strings. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u16-strncpy.c b/lib/unistr/u16-strncpy.c index daa40195..855208b0 100644 --- a/lib/unistr/u16-strncpy.c +++ b/lib/unistr/u16-strncpy.c @@ -1,5 +1,5 @@ /* Copy UTF-16 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u16-strnlen.c b/lib/unistr/u16-strnlen.c index f07a7b57..a4618a6a 100644 --- a/lib/unistr/u16-strnlen.c +++ b/lib/unistr/u16-strnlen.c @@ -1,5 +1,5 @@ /* Determine bounded length of UTF-16 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u16-strpbrk.c b/lib/unistr/u16-strpbrk.c index 8e262fcc..6cb82c9d 100644 --- a/lib/unistr/u16-strpbrk.c +++ b/lib/unistr/u16-strpbrk.c @@ -1,5 +1,5 @@ /* Search for some characters in UTF-16 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u16-strrchr.c b/lib/unistr/u16-strrchr.c index 3cb31b85..822a44bf 100644 --- a/lib/unistr/u16-strrchr.c +++ b/lib/unistr/u16-strrchr.c @@ -1,5 +1,5 @@ /* Search character in UTF-16 string. - Copyright (C) 1999, 2002, 2006-2007, 2009-2022 Free Software Foundation, + Copyright (C) 1999, 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. diff --git a/lib/unistr/u16-strspn.c b/lib/unistr/u16-strspn.c index 36423593..dc575075 100644 --- a/lib/unistr/u16-strspn.c +++ b/lib/unistr/u16-strspn.c @@ -1,5 +1,5 @@ /* Search for some characters in UTF-16 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u16-strstr.c b/lib/unistr/u16-strstr.c index 7ca7625d..8460bb46 100644 --- a/lib/unistr/u16-strstr.c +++ b/lib/unistr/u16-strstr.c @@ -1,5 +1,5 @@ /* Substring test for UTF-16 strings. - Copyright (C) 1999, 2002, 2006, 2010-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2010-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. @@ -28,18 +28,10 @@ /* Specification. */ #include "unistr.h" -#include "malloca.h" - -/* FIXME: Maybe walking the string via u16_mblen is a win? */ - #define UNIT uint16_t - -#define CANON_ELEMENT(c) c -#include "str-kmp.h" - #define FUNC u16_strstr -#define U_STRCHR u16_strchr -#define U_STRMBTOUC u16_strmbtouc -#define U_STRLEN u16_strlen -#define U_STRNLEN u16_strnlen -#include "u-strstr.h" +#define RETURN_TYPE uint16_t * +#define MEMCHR0(s, n) u16_chr (s, n, 0) +#define STRCHR u16_strchr +#define CMP_FUNC u16_cmp +#include "wcsstr-impl.h" diff --git a/lib/unistr/u16-strtok.c b/lib/unistr/u16-strtok.c index dbe6ffb8..2ee3c082 100644 --- a/lib/unistr/u16-strtok.c +++ b/lib/unistr/u16-strtok.c @@ -1,5 +1,5 @@ /* Tokenize UTF-16 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u16-to-u32.c b/lib/unistr/u16-to-u32.c index 8a070fdc..a75770a2 100644 --- a/lib/unistr/u16-to-u32.c +++ b/lib/unistr/u16-to-u32.c @@ -1,5 +1,5 @@ /* Convert UTF-16 string to UTF-32 string. - Copyright (C) 2002, 2006-2007, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u16-to-u8.c b/lib/unistr/u16-to-u8.c index f64f9fb3..dd434b79 100644 --- a/lib/unistr/u16-to-u8.c +++ b/lib/unistr/u16-to-u8.c @@ -1,5 +1,5 @@ /* Convert UTF-16 string to UTF-8 string. - Copyright (C) 2002, 2006-2007, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u16-uctomb-aux.c b/lib/unistr/u16-uctomb-aux.c index 337d34df..f90aad7f 100644 --- a/lib/unistr/u16-uctomb-aux.c +++ b/lib/unistr/u16-uctomb-aux.c @@ -1,5 +1,5 @@ /* Conversion UCS-4 to UTF-16. - Copyright (C) 2002, 2006-2007, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u16-uctomb.c b/lib/unistr/u16-uctomb.c index 56947f48..0cc6c721 100644 --- a/lib/unistr/u16-uctomb.c +++ b/lib/unistr/u16-uctomb.c @@ -1,5 +1,5 @@ /* Store a character in UTF-16 string. - Copyright (C) 2002, 2005-2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2005-2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u32-check.c b/lib/unistr/u32-check.c index 2547812b..813ccd55 100644 --- a/lib/unistr/u32-check.c +++ b/lib/unistr/u32-check.c @@ -1,5 +1,5 @@ /* Check UTF-32 string. - Copyright (C) 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u32-chr.c b/lib/unistr/u32-chr.c index f23b58a1..65500d83 100644 --- a/lib/unistr/u32-chr.c +++ b/lib/unistr/u32-chr.c @@ -1,27 +1,19 @@ /* Search character in piece of UTF-32 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. - 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 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. 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 and the GNU General Public License - for more details. + 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 and of the GNU 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 + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #include <config.h> diff --git a/lib/unistr/u32-cmp.c b/lib/unistr/u32-cmp.c index af875b48..c953c8af 100644 --- a/lib/unistr/u32-cmp.c +++ b/lib/unistr/u32-cmp.c @@ -1,5 +1,5 @@ /* Compare pieces of UTF-32 strings. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u32-cmp2.c b/lib/unistr/u32-cmp2.c index d3d7060f..6cc084f7 100644 --- a/lib/unistr/u32-cmp2.c +++ b/lib/unistr/u32-cmp2.c @@ -1,5 +1,5 @@ /* Compare pieces of UTF-32 strings. - Copyright (C) 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This file is free software. diff --git a/lib/unistr/u32-cpy-alloc.c b/lib/unistr/u32-cpy-alloc.c index 3c7490de..ecdffe52 100644 --- a/lib/unistr/u32-cpy-alloc.c +++ b/lib/unistr/u32-cpy-alloc.c @@ -1,5 +1,5 @@ /* Copy piece of UTF-32 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u32-cpy.c b/lib/unistr/u32-cpy.c index a2664e2e..a1a840f7 100644 --- a/lib/unistr/u32-cpy.c +++ b/lib/unistr/u32-cpy.c @@ -1,5 +1,5 @@ /* Copy piece of UTF-32 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software: you can redistribute it and/or modify diff --git a/lib/unistr/u32-endswith.c b/lib/unistr/u32-endswith.c index 4942f200..7b701e0b 100644 --- a/lib/unistr/u32-endswith.c +++ b/lib/unistr/u32-endswith.c @@ -1,5 +1,5 @@ /* Substring test for UTF-32 strings. - Copyright (C) 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u32-mblen.c b/lib/unistr/u32-mblen.c index e3f9a2a1..0317b3c1 100644 --- a/lib/unistr/u32-mblen.c +++ b/lib/unistr/u32-mblen.c @@ -1,5 +1,5 @@ /* Look at first character in UTF-32 string. - Copyright (C) 2002, 2006-2007, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u32-mbsnlen.c b/lib/unistr/u32-mbsnlen.c index 80c9ba71..c2cb7277 100644 --- a/lib/unistr/u32-mbsnlen.c +++ b/lib/unistr/u32-mbsnlen.c @@ -1,5 +1,5 @@ /* Count characters in UTF-32 string. - Copyright (C) 2007, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2007. This file is free software. diff --git a/lib/unistr/u32-mbtouc-unsafe.c b/lib/unistr/u32-mbtouc-unsafe.c index 38904ea1..0e8eecb7 100644 --- a/lib/unistr/u32-mbtouc-unsafe.c +++ b/lib/unistr/u32-mbtouc-unsafe.c @@ -1,5 +1,5 @@ /* Look at first character in UTF-32 string. - Copyright (C) 2002, 2006-2007, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software: you can redistribute it and/or modify diff --git a/lib/unistr/u32-mbtouc.c b/lib/unistr/u32-mbtouc.c index 70ff857b..96acabd9 100644 --- a/lib/unistr/u32-mbtouc.c +++ b/lib/unistr/u32-mbtouc.c @@ -1,5 +1,5 @@ /* Look at first character in UTF-32 string. - Copyright (C) 2002, 2006-2007, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u32-mbtoucr.c b/lib/unistr/u32-mbtoucr.c index 245f639b..967ade81 100644 --- a/lib/unistr/u32-mbtoucr.c +++ b/lib/unistr/u32-mbtoucr.c @@ -1,5 +1,5 @@ /* Look at first character in UTF-32 string, returning an error code. - Copyright (C) 2002, 2006-2007, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u32-move.c b/lib/unistr/u32-move.c index a5fdd255..3f06b30a 100644 --- a/lib/unistr/u32-move.c +++ b/lib/unistr/u32-move.c @@ -1,5 +1,5 @@ /* Copy piece of UTF-32 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u32-next.c b/lib/unistr/u32-next.c index 348fd987..8668e63b 100644 --- a/lib/unistr/u32-next.c +++ b/lib/unistr/u32-next.c @@ -1,5 +1,5 @@ /* Iterate over next character in UTF-32 string. - Copyright (C) 2002, 2006-2007, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u32-pcpy.c b/lib/unistr/u32-pcpy.c new file mode 100644 index 00000000..922f704c --- /dev/null +++ b/lib/unistr/u32-pcpy.c @@ -0,0 +1,26 @@ +/* Copy piece of UTF-32 string, return pointer after last written unit. + Copyright (C) 2020-2024 Free Software Foundation, Inc. + Written by Bruno Haible <bruno@clisp.org>, 2023. + + This file 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. + + 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. + + 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/>. */ + +#include <config.h> + +/* Specification. */ +#include "unistr.h" + +#define FUNC u32_pcpy +#define UNIT uint32_t +#define U_CPY u32_cpy +#include "u-pcpy.h" diff --git a/lib/unistr/u32-prev.c b/lib/unistr/u32-prev.c index 0289bafe..26eb7dcd 100644 --- a/lib/unistr/u32-prev.c +++ b/lib/unistr/u32-prev.c @@ -1,5 +1,5 @@ /* Iterate over previous character in UTF-32 string. - Copyright (C) 2002, 2006-2007, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u32-set.c b/lib/unistr/u32-set.c index 60f2eaf0..51cf3d63 100644 --- a/lib/unistr/u32-set.c +++ b/lib/unistr/u32-set.c @@ -1,5 +1,5 @@ /* Fill UTF-32 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u32-startswith.c b/lib/unistr/u32-startswith.c index 9d5c53dc..c9c765a7 100644 --- a/lib/unistr/u32-startswith.c +++ b/lib/unistr/u32-startswith.c @@ -1,5 +1,5 @@ /* Substring test for UTF-32 strings. - Copyright (C) 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u32-stpcpy.c b/lib/unistr/u32-stpcpy.c index d95c8551..48cc3e14 100644 --- a/lib/unistr/u32-stpcpy.c +++ b/lib/unistr/u32-stpcpy.c @@ -1,5 +1,5 @@ /* Copy UTF-32 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u32-stpncpy.c b/lib/unistr/u32-stpncpy.c index 1281b649..fc5177d9 100644 --- a/lib/unistr/u32-stpncpy.c +++ b/lib/unistr/u32-stpncpy.c @@ -1,5 +1,5 @@ /* Copy UTF-32 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u32-strcat.c b/lib/unistr/u32-strcat.c index d345487f..2da08b18 100644 --- a/lib/unistr/u32-strcat.c +++ b/lib/unistr/u32-strcat.c @@ -1,27 +1,19 @@ /* Concatenate UTF-32 strings. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. - 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 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. 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 and the GNU General Public License - for more details. + 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 and of the GNU 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 + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #include <config.h> diff --git a/lib/unistr/u32-strchr.c b/lib/unistr/u32-strchr.c index 48d9057d..cf8b0ca1 100644 --- a/lib/unistr/u32-strchr.c +++ b/lib/unistr/u32-strchr.c @@ -1,5 +1,5 @@ /* Search character in UTF-32 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u32-strcmp.c b/lib/unistr/u32-strcmp.c index 6dc801d1..058cf7c4 100644 --- a/lib/unistr/u32-strcmp.c +++ b/lib/unistr/u32-strcmp.c @@ -1,5 +1,5 @@ /* Compare UTF-32 strings. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u32-strcoll.c b/lib/unistr/u32-strcoll.c index 688b8081..c7de5bd6 100644 --- a/lib/unistr/u32-strcoll.c +++ b/lib/unistr/u32-strcoll.c @@ -1,5 +1,5 @@ /* Compare UTF-32 strings using the collation rules of the current locale. - Copyright (C) 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This file is free software. diff --git a/lib/unistr/u32-strcpy.c b/lib/unistr/u32-strcpy.c index b9520741..c23e8763 100644 --- a/lib/unistr/u32-strcpy.c +++ b/lib/unistr/u32-strcpy.c @@ -1,5 +1,5 @@ /* Copy UTF-32 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u32-strcspn.c b/lib/unistr/u32-strcspn.c index 0e7fc00e..ab6c635e 100644 --- a/lib/unistr/u32-strcspn.c +++ b/lib/unistr/u32-strcspn.c @@ -1,5 +1,5 @@ /* Search for some characters in UTF-32 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u32-strdup.c b/lib/unistr/u32-strdup.c index ce1fd612..d4e9ae56 100644 --- a/lib/unistr/u32-strdup.c +++ b/lib/unistr/u32-strdup.c @@ -1,5 +1,5 @@ /* Copy UTF-32 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u32-strlen.c b/lib/unistr/u32-strlen.c index 5f618d8f..1c43a30a 100644 --- a/lib/unistr/u32-strlen.c +++ b/lib/unistr/u32-strlen.c @@ -1,27 +1,19 @@ /* Determine length of UTF-32 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. - 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 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. 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 and the GNU General Public License - for more details. + 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 and of the GNU 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 + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #include <config.h> diff --git a/lib/unistr/u32-strmblen.c b/lib/unistr/u32-strmblen.c index 75e19ee3..294bcf5f 100644 --- a/lib/unistr/u32-strmblen.c +++ b/lib/unistr/u32-strmblen.c @@ -1,5 +1,5 @@ /* Look at first character in UTF-32 string. - Copyright (C) 2002, 2006-2007, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u32-strmbtouc.c b/lib/unistr/u32-strmbtouc.c index 42ab71a1..64879f2a 100644 --- a/lib/unistr/u32-strmbtouc.c +++ b/lib/unistr/u32-strmbtouc.c @@ -1,5 +1,5 @@ /* Look at first character in UTF-32 string. - Copyright (C) 2002, 2006-2007, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u32-strncat.c b/lib/unistr/u32-strncat.c index 3133084a..ab16565d 100644 --- a/lib/unistr/u32-strncat.c +++ b/lib/unistr/u32-strncat.c @@ -1,5 +1,5 @@ /* Concatenate UTF-32 strings. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u32-strncmp.c b/lib/unistr/u32-strncmp.c index a99e1116..0c009ada 100644 --- a/lib/unistr/u32-strncmp.c +++ b/lib/unistr/u32-strncmp.c @@ -1,5 +1,5 @@ /* Compare UTF-32 strings. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u32-strncpy.c b/lib/unistr/u32-strncpy.c index 6f1b40c0..1806238e 100644 --- a/lib/unistr/u32-strncpy.c +++ b/lib/unistr/u32-strncpy.c @@ -1,5 +1,5 @@ /* Copy UTF-32 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u32-strnlen.c b/lib/unistr/u32-strnlen.c index de0b764a..abdf9596 100644 --- a/lib/unistr/u32-strnlen.c +++ b/lib/unistr/u32-strnlen.c @@ -1,5 +1,5 @@ /* Determine bounded length of UTF-32 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u32-strpbrk.c b/lib/unistr/u32-strpbrk.c index a054ef6b..8dc1543a 100644 --- a/lib/unistr/u32-strpbrk.c +++ b/lib/unistr/u32-strpbrk.c @@ -1,5 +1,5 @@ /* Search for some characters in UTF-32 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u32-strrchr.c b/lib/unistr/u32-strrchr.c index ab38bb2c..158c954c 100644 --- a/lib/unistr/u32-strrchr.c +++ b/lib/unistr/u32-strrchr.c @@ -1,5 +1,5 @@ /* Search character in UTF-32 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u32-strspn.c b/lib/unistr/u32-strspn.c index ab089acf..f3625f9c 100644 --- a/lib/unistr/u32-strspn.c +++ b/lib/unistr/u32-strspn.c @@ -1,5 +1,5 @@ /* Search for some characters in UTF-32 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u32-strstr.c b/lib/unistr/u32-strstr.c index f483c32f..573c6580 100644 --- a/lib/unistr/u32-strstr.c +++ b/lib/unistr/u32-strstr.c @@ -1,5 +1,5 @@ /* Substring test for UTF-32 strings. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. @@ -28,15 +28,10 @@ /* Specification. */ #include "unistr.h" -#include "malloca.h" - #define UNIT uint32_t - -#define CANON_ELEMENT(c) c -#include "str-kmp.h" - #define FUNC u32_strstr -#define U_STRCHR u32_strchr -#define U_STRLEN u32_strlen -#define U_STRNLEN u32_strnlen -#include "u-strstr.h" +#define RETURN_TYPE uint32_t * +#define MEMCHR0(s, n) u32_chr (s, n, 0) +#define STRCHR u32_strchr +#define CMP_FUNC u32_cmp +#include "wcsstr-impl.h" diff --git a/lib/unistr/u32-strtok.c b/lib/unistr/u32-strtok.c index 1fd9c10f..2723ef52 100644 --- a/lib/unistr/u32-strtok.c +++ b/lib/unistr/u32-strtok.c @@ -1,5 +1,5 @@ /* Tokenize UTF-32 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u32-to-u16.c b/lib/unistr/u32-to-u16.c index af12bd72..91dcd203 100644 --- a/lib/unistr/u32-to-u16.c +++ b/lib/unistr/u32-to-u16.c @@ -1,5 +1,5 @@ /* Convert UTF-32 string to UTF-16 string. - Copyright (C) 2002, 2006-2007, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u32-to-u8.c b/lib/unistr/u32-to-u8.c index bf462b41..e8095ce8 100644 --- a/lib/unistr/u32-to-u8.c +++ b/lib/unistr/u32-to-u8.c @@ -1,5 +1,5 @@ /* Convert UTF-32 string to UTF-8 string. - Copyright (C) 2002, 2006-2007, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software: you can redistribute it and/or modify diff --git a/lib/unistr/u32-uctomb.c b/lib/unistr/u32-uctomb.c index c6cd7439..552672fa 100644 --- a/lib/unistr/u32-uctomb.c +++ b/lib/unistr/u32-uctomb.c @@ -1,5 +1,5 @@ /* Store a character in UTF-32 string. - Copyright (C) 2002, 2005-2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2005-2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software: you can redistribute it and/or modify diff --git a/lib/unistr/u8-check.c b/lib/unistr/u8-check.c index b6228c1f..556f9927 100644 --- a/lib/unistr/u8-check.c +++ b/lib/unistr/u8-check.c @@ -1,5 +1,5 @@ /* Check UTF-8 string. - Copyright (C) 2002, 2006-2007, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software: you can redistribute it and/or modify @@ -57,13 +57,13 @@ u8_check (const uint8_t *s, size_t n) continue; } } - else if (c < 0xf8) + else if (c <= 0xf4) { if (s + 4 <= s_end && (s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40 && (s[3] ^ 0x80) < 0x40 && (c >= 0xf1 || s[1] >= 0x90) - && (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))) + && (c < 0xf4 || (/* c == 0xf4 && */ s[1] < 0x90))) { s += 4; continue; diff --git a/lib/unistr/u8-chr.c b/lib/unistr/u8-chr.c index d309a82a..550d5756 100644 --- a/lib/unistr/u8-chr.c +++ b/lib/unistr/u8-chr.c @@ -1,5 +1,5 @@ /* Search character in piece of UTF-8 string. - Copyright (C) 1999, 2002, 2006-2007, 2009-2022 Free Software Foundation, + Copyright (C) 1999, 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. diff --git a/lib/unistr/u8-cmp.c b/lib/unistr/u8-cmp.c index effe0dce..064b8206 100644 --- a/lib/unistr/u8-cmp.c +++ b/lib/unistr/u8-cmp.c @@ -1,5 +1,5 @@ /* Compare pieces of UTF-8 strings. - Copyright (C) 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u8-cmp2.c b/lib/unistr/u8-cmp2.c index 1864115f..11d3c364 100644 --- a/lib/unistr/u8-cmp2.c +++ b/lib/unistr/u8-cmp2.c @@ -1,5 +1,5 @@ /* Compare pieces of UTF-8 strings. - Copyright (C) 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This file is free software. diff --git a/lib/unistr/u8-cpy-alloc.c b/lib/unistr/u8-cpy-alloc.c index 550f6777..9e3f6bff 100644 --- a/lib/unistr/u8-cpy-alloc.c +++ b/lib/unistr/u8-cpy-alloc.c @@ -1,5 +1,5 @@ /* Copy piece of UTF-8 string. - Copyright (C) 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u8-cpy.c b/lib/unistr/u8-cpy.c index e25c264c..e2c89c39 100644 --- a/lib/unistr/u8-cpy.c +++ b/lib/unistr/u8-cpy.c @@ -1,5 +1,5 @@ /* Copy piece of UTF-8 string. - Copyright (C) 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u8-endswith.c b/lib/unistr/u8-endswith.c index 8173a884..f9dda573 100644 --- a/lib/unistr/u8-endswith.c +++ b/lib/unistr/u8-endswith.c @@ -1,5 +1,5 @@ /* Substring test for UTF-8 strings. - Copyright (C) 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u8-mblen.c b/lib/unistr/u8-mblen.c index c431c92a..79878f24 100644 --- a/lib/unistr/u8-mblen.c +++ b/lib/unistr/u8-mblen.c @@ -1,5 +1,5 @@ /* Look at first character in UTF-8 string. - Copyright (C) 1999-2000, 2002, 2006-2007, 2009-2022 Free Software + Copyright (C) 1999-2000, 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. @@ -47,13 +47,13 @@ u8_mblen (const uint8_t *s, size_t n) && (c != 0xed || s[1] < 0xa0)) return 3; } - else if (c < 0xf8) + else if (c <= 0xf4) { if (n >= 4 && (s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40 && (s[3] ^ 0x80) < 0x40 && (c >= 0xf1 || s[1] >= 0x90) - && (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))) + && (c < 0xf4 || (/* c == 0xf4 && */ s[1] < 0x90))) return 4; } } diff --git a/lib/unistr/u8-mbsnlen.c b/lib/unistr/u8-mbsnlen.c index 9c2fa4a3..5c9bd43d 100644 --- a/lib/unistr/u8-mbsnlen.c +++ b/lib/unistr/u8-mbsnlen.c @@ -1,5 +1,5 @@ /* Count characters in UTF-8 string. - Copyright (C) 2007, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2007. This file is free software. diff --git a/lib/unistr/u8-mbtouc-aux.c b/lib/unistr/u8-mbtouc-aux.c index 018cf507..22ed807b 100644 --- a/lib/unistr/u8-mbtouc-aux.c +++ b/lib/unistr/u8-mbtouc-aux.c @@ -1,5 +1,5 @@ /* Conversion UTF-8 to UCS-4. - Copyright (C) 2001-2002, 2006-2007, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2001-2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2001. This file is free software: you can redistribute it and/or modify @@ -52,20 +52,15 @@ u8_mbtouc_aux (ucs4_t *puc, const uint8_t *s, size_t n) { if (n >= 3) { - if ((s[1] ^ 0x80) < 0x40) + if ((s[1] ^ 0x80) < 0x40 + && (c >= 0xe1 || s[1] >= 0xa0) + && (c != 0xed || s[1] < 0xa0)) { if ((s[2] ^ 0x80) < 0x40) { - if ((c >= 0xe1 || s[1] >= 0xa0) - && (c != 0xed || s[1] < 0xa0)) - { - *puc = ((unsigned int) (c & 0x0f) << 12) - | ((unsigned int) (s[1] ^ 0x80) << 6) - | (unsigned int) (s[2] ^ 0x80); - return 3; - } - /* invalid multibyte character */ - *puc = 0xfffd; + *puc = ((unsigned int) (c & 0x0f) << 12) + | ((unsigned int) (s[1] ^ 0x80) << 6) + | (unsigned int) (s[2] ^ 0x80); return 3; } /* invalid multibyte character */ @@ -73,38 +68,50 @@ u8_mbtouc_aux (ucs4_t *puc, const uint8_t *s, size_t n) return 2; } /* invalid multibyte character */ + *puc = 0xfffd; + return 1; } else { - /* incomplete multibyte character */ *puc = 0xfffd; - if (n == 1 || (s[1] ^ 0x80) >= 0x40) - return 1; + if (n == 1) + { + /* incomplete multibyte character */ + return 1; + } else - return 2; + { + if ((s[1] ^ 0x80) < 0x40 + && (c >= 0xe1 || s[1] >= 0xa0) + && (c != 0xed || s[1] < 0xa0)) + { + /* incomplete multibyte character */ + return 2; + } + else + { + /* invalid multibyte character */ + return 1; + } + } } } - else if (c < 0xf8) + else if (c <= 0xf4) { if (n >= 4) { - if ((s[1] ^ 0x80) < 0x40) + if ((s[1] ^ 0x80) < 0x40 + && (c >= 0xf1 || s[1] >= 0x90) + && (c < 0xf4 || (/* c == 0xf4 && */ s[1] < 0x90))) { if ((s[2] ^ 0x80) < 0x40) { if ((s[3] ^ 0x80) < 0x40) { - if ((c >= 0xf1 || s[1] >= 0x90) - && (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))) - { - *puc = ((unsigned int) (c & 0x07) << 18) - | ((unsigned int) (s[1] ^ 0x80) << 12) - | ((unsigned int) (s[2] ^ 0x80) << 6) - | (unsigned int) (s[3] ^ 0x80); - return 4; - } - /* invalid multibyte character */ - *puc = 0xfffd; + *puc = ((unsigned int) (c & 0x07) << 18) + | ((unsigned int) (s[1] ^ 0x80) << 12) + | ((unsigned int) (s[2] ^ 0x80) << 6) + | (unsigned int) (s[3] ^ 0x80); return 4; } /* invalid multibyte character */ @@ -116,17 +123,48 @@ u8_mbtouc_aux (ucs4_t *puc, const uint8_t *s, size_t n) return 2; } /* invalid multibyte character */ + *puc = 0xfffd; + return 1; } else { - /* incomplete multibyte character */ *puc = 0xfffd; - if (n == 1 || (s[1] ^ 0x80) >= 0x40) - return 1; - else if (n == 2 || (s[2] ^ 0x80) >= 0x40) - return 2; + if (n == 1) + { + /* incomplete multibyte character */ + return 1; + } else - return 3; + { + if ((s[1] ^ 0x80) < 0x40 + && (c >= 0xf1 || s[1] >= 0x90) + && (c < 0xf4 || (/* c == 0xf4 && */ s[1] < 0x90))) + { + if (n == 2) + { + /* incomplete multibyte character */ + return 2; + } + else + { + if ((s[2] ^ 0x80) < 0x40) + { + /* incomplete multibyte character */ + return 3; + } + else + { + /* invalid multibyte character */ + return 2; + } + } + } + else + { + /* invalid multibyte character */ + return 1; + } + } } } } diff --git a/lib/unistr/u8-mbtouc-unsafe-aux.c b/lib/unistr/u8-mbtouc-unsafe-aux.c index 36e40af8..c763bd44 100644 --- a/lib/unistr/u8-mbtouc-unsafe-aux.c +++ b/lib/unistr/u8-mbtouc-unsafe-aux.c @@ -1,5 +1,5 @@ /* Conversion UTF-8 to UCS-4. - Copyright (C) 2001-2002, 2006-2007, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2001-2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2001. This file is free software: you can redistribute it and/or modify diff --git a/lib/unistr/u8-mbtouc-unsafe.c b/lib/unistr/u8-mbtouc-unsafe.c index 3dd30a12..bfd64941 100644 --- a/lib/unistr/u8-mbtouc-unsafe.c +++ b/lib/unistr/u8-mbtouc-unsafe.c @@ -1,5 +1,5 @@ /* Look at first character in UTF-8 string. - Copyright (C) 1999-2002, 2006-2007, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999-2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2001. This file is free software: you can redistribute it and/or modify diff --git a/lib/unistr/u8-mbtouc.c b/lib/unistr/u8-mbtouc.c index 45250724..6a863a6a 100644 --- a/lib/unistr/u8-mbtouc.c +++ b/lib/unistr/u8-mbtouc.c @@ -1,5 +1,5 @@ /* Look at first character in UTF-8 string. - Copyright (C) 1999-2002, 2006-2007, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999-2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2001. This file is free software: you can redistribute it and/or modify @@ -62,20 +62,15 @@ u8_mbtouc (ucs4_t *puc, const uint8_t *s, size_t n) { if (n >= 3) { - if ((s[1] ^ 0x80) < 0x40) + if ((s[1] ^ 0x80) < 0x40 + && (c >= 0xe1 || s[1] >= 0xa0) + && (c != 0xed || s[1] < 0xa0)) { if ((s[2] ^ 0x80) < 0x40) { - if ((c >= 0xe1 || s[1] >= 0xa0) - && (c != 0xed || s[1] < 0xa0)) - { - *puc = ((unsigned int) (c & 0x0f) << 12) - | ((unsigned int) (s[1] ^ 0x80) << 6) - | (unsigned int) (s[2] ^ 0x80); - return 3; - } - /* invalid multibyte character */ - *puc = 0xfffd; + *puc = ((unsigned int) (c & 0x0f) << 12) + | ((unsigned int) (s[1] ^ 0x80) << 6) + | (unsigned int) (s[2] ^ 0x80); return 3; } /* invalid multibyte character */ @@ -83,38 +78,50 @@ u8_mbtouc (ucs4_t *puc, const uint8_t *s, size_t n) return 2; } /* invalid multibyte character */ + *puc = 0xfffd; + return 1; } else { - /* incomplete multibyte character */ *puc = 0xfffd; - if (n == 1 || (s[1] ^ 0x80) >= 0x40) - return 1; + if (n == 1) + { + /* incomplete multibyte character */ + return 1; + } else - return 2; + { + if ((s[1] ^ 0x80) < 0x40 + && (c >= 0xe1 || s[1] >= 0xa0) + && (c != 0xed || s[1] < 0xa0)) + { + /* incomplete multibyte character */ + return 2; + } + else + { + /* invalid multibyte character */ + return 1; + } + } } } - else if (c < 0xf8) + else if (c <= 0xf4) { if (n >= 4) { - if ((s[1] ^ 0x80) < 0x40) + if ((s[1] ^ 0x80) < 0x40 + && (c >= 0xf1 || s[1] >= 0x90) + && (c < 0xf4 || (/* c == 0xf4 && */ s[1] < 0x90))) { if ((s[2] ^ 0x80) < 0x40) { if ((s[3] ^ 0x80) < 0x40) { - if ((c >= 0xf1 || s[1] >= 0x90) - && (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))) - { - *puc = ((unsigned int) (c & 0x07) << 18) - | ((unsigned int) (s[1] ^ 0x80) << 12) - | ((unsigned int) (s[2] ^ 0x80) << 6) - | (unsigned int) (s[3] ^ 0x80); - return 4; - } - /* invalid multibyte character */ - *puc = 0xfffd; + *puc = ((unsigned int) (c & 0x07) << 18) + | ((unsigned int) (s[1] ^ 0x80) << 12) + | ((unsigned int) (s[2] ^ 0x80) << 6) + | (unsigned int) (s[3] ^ 0x80); return 4; } /* invalid multibyte character */ @@ -126,17 +133,48 @@ u8_mbtouc (ucs4_t *puc, const uint8_t *s, size_t n) return 2; } /* invalid multibyte character */ + *puc = 0xfffd; + return 1; } else { - /* incomplete multibyte character */ *puc = 0xfffd; - if (n == 1 || (s[1] ^ 0x80) >= 0x40) - return 1; - else if (n == 2 || (s[2] ^ 0x80) >= 0x40) - return 2; + if (n == 1) + { + /* incomplete multibyte character */ + return 1; + } else - return 3; + { + if ((s[1] ^ 0x80) < 0x40 + && (c >= 0xf1 || s[1] >= 0x90) + && (c < 0xf4 || (/* c == 0xf4 && */ s[1] < 0x90))) + { + if (n == 2) + { + /* incomplete multibyte character */ + return 2; + } + else + { + if ((s[2] ^ 0x80) < 0x40) + { + /* incomplete multibyte character */ + return 3; + } + else + { + /* invalid multibyte character */ + return 2; + } + } + } + else + { + /* invalid multibyte character */ + return 1; + } + } } } } diff --git a/lib/unistr/u8-mbtoucr.c b/lib/unistr/u8-mbtoucr.c index 6672298a..564e47e9 100644 --- a/lib/unistr/u8-mbtoucr.c +++ b/lib/unistr/u8-mbtoucr.c @@ -1,5 +1,5 @@ /* Look at first character in UTF-8 string, returning an error code. - Copyright (C) 1999-2002, 2006-2007, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999-2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2001. This file is free software: you can redistribute it and/or modify @@ -86,13 +86,13 @@ u8_mbtoucr (ucs4_t *puc, const uint8_t *s, size_t n) return -2; } } - else if (c < 0xf8) + else if (c <= 0xf4) { if (n >= 2) { if ((s[1] ^ 0x80) < 0x40 && (c >= 0xf1 || s[1] >= 0x90) - && (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))) + && (c < 0xf4 || (/* c == 0xf4 && */ s[1] < 0x90))) { if (n >= 3) { diff --git a/lib/unistr/u8-move.c b/lib/unistr/u8-move.c index d7b8225e..f9f37352 100644 --- a/lib/unistr/u8-move.c +++ b/lib/unistr/u8-move.c @@ -1,5 +1,5 @@ /* Copy piece of UTF-8 string. - Copyright (C) 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u8-next.c b/lib/unistr/u8-next.c index 06598555..bba21662 100644 --- a/lib/unistr/u8-next.c +++ b/lib/unistr/u8-next.c @@ -1,5 +1,5 @@ /* Iterate over next character in UTF-8 string. - Copyright (C) 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u8-pcpy.c b/lib/unistr/u8-pcpy.c new file mode 100644 index 00000000..f3caa8b7 --- /dev/null +++ b/lib/unistr/u8-pcpy.c @@ -0,0 +1,34 @@ +/* Copy piece of UTF-8 string, return pointer after last written unit. + Copyright (C) 2020-2024 Free Software Foundation, Inc. + Written by Bruno Haible <bruno@clisp.org>, 2023. + + 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 and the GNU General Public License + for more details. + + 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> + +/* Specification. */ +#include "unistr.h" + +#define FUNC u8_pcpy +#define UNIT uint8_t +#define U_CPY u8_cpy +#include "u-pcpy.h" diff --git a/lib/unistr/u8-prev.c b/lib/unistr/u8-prev.c index d41629ef..d733f758 100644 --- a/lib/unistr/u8-prev.c +++ b/lib/unistr/u8-prev.c @@ -1,5 +1,5 @@ /* Iterate over previous character in UTF-8 string. - Copyright (C) 2002, 2006-2007, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software: you can redistribute it and/or modify @@ -63,9 +63,9 @@ u8_prev (ucs4_t *puc, const uint8_t *s, const uint8_t *start) { uint8_t c_4 = s[-4]; - if (c_4 >= 0xf0 && c_4 < 0xf8 + if (c_4 >= 0xf0 && c_4 <= 0xf4 && (c_4 >= 0xf1 || c_3 >= 0x90) - && (c_4 < 0xf4 || (c_4 == 0xf4 && c_3 < 0x90))) + && (c_4 < 0xf4 || (/* c_4 == 0xf4 && */ c_3 < 0x90))) { *puc = ((unsigned int) (c_4 & 0x07) << 18) | ((unsigned int) (c_3 ^ 0x80) << 12) diff --git a/lib/unistr/u8-set.c b/lib/unistr/u8-set.c index 250c0030..b585fdbc 100644 --- a/lib/unistr/u8-set.c +++ b/lib/unistr/u8-set.c @@ -1,5 +1,5 @@ /* Fill UTF-8 string. - Copyright (C) 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u8-startswith.c b/lib/unistr/u8-startswith.c index b14fdb2f..25ead39c 100644 --- a/lib/unistr/u8-startswith.c +++ b/lib/unistr/u8-startswith.c @@ -1,5 +1,5 @@ /* Substring test for UTF-8 strings. - Copyright (C) 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u8-stpcpy.c b/lib/unistr/u8-stpcpy.c index 30b03bc1..8a34960f 100644 --- a/lib/unistr/u8-stpcpy.c +++ b/lib/unistr/u8-stpcpy.c @@ -1,5 +1,5 @@ /* Copy UTF-8 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u8-stpncpy.c b/lib/unistr/u8-stpncpy.c index d235f463..2c994b9e 100644 --- a/lib/unistr/u8-stpncpy.c +++ b/lib/unistr/u8-stpncpy.c @@ -1,5 +1,5 @@ /* Copy UTF-8 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u8-strcat.c b/lib/unistr/u8-strcat.c index aac92043..10847e61 100644 --- a/lib/unistr/u8-strcat.c +++ b/lib/unistr/u8-strcat.c @@ -1,5 +1,5 @@ /* Concatenate UTF-8 strings. - Copyright (C) 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u8-strchr.c b/lib/unistr/u8-strchr.c index f5c09851..355a12c7 100644 --- a/lib/unistr/u8-strchr.c +++ b/lib/unistr/u8-strchr.c @@ -1,5 +1,5 @@ /* Search character in UTF-8 string. - Copyright (C) 1999, 2002, 2006-2007, 2009-2022 Free Software Foundation, + Copyright (C) 1999, 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. diff --git a/lib/unistr/u8-strcmp.c b/lib/unistr/u8-strcmp.c index 0ff9ac0f..385b0b53 100644 --- a/lib/unistr/u8-strcmp.c +++ b/lib/unistr/u8-strcmp.c @@ -1,5 +1,5 @@ /* Compare UTF-8 strings. - Copyright (C) 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u8-strcoll.c b/lib/unistr/u8-strcoll.c index 56acf3c0..f5ff8c71 100644 --- a/lib/unistr/u8-strcoll.c +++ b/lib/unistr/u8-strcoll.c @@ -1,5 +1,5 @@ /* Compare UTF-8 strings using the collation rules of the current locale. - Copyright (C) 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This file is free software. diff --git a/lib/unistr/u8-strcpy.c b/lib/unistr/u8-strcpy.c index f705234f..60ba3384 100644 --- a/lib/unistr/u8-strcpy.c +++ b/lib/unistr/u8-strcpy.c @@ -1,5 +1,5 @@ /* Copy UTF-8 string. - Copyright (C) 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u8-strcspn.c b/lib/unistr/u8-strcspn.c index 404434ff..f73621c1 100644 --- a/lib/unistr/u8-strcspn.c +++ b/lib/unistr/u8-strcspn.c @@ -1,5 +1,5 @@ /* Search for some characters in UTF-8 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u8-strdup.c b/lib/unistr/u8-strdup.c index f66f46ee..5309690d 100644 --- a/lib/unistr/u8-strdup.c +++ b/lib/unistr/u8-strdup.c @@ -1,5 +1,5 @@ /* Copy UTF-8 string. - Copyright (C) 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u8-strlen.c b/lib/unistr/u8-strlen.c index 6892ec08..7f489e33 100644 --- a/lib/unistr/u8-strlen.c +++ b/lib/unistr/u8-strlen.c @@ -1,5 +1,5 @@ /* Determine length of UTF-8 string. - Copyright (C) 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software: you can redistribute it and/or modify diff --git a/lib/unistr/u8-strmblen.c b/lib/unistr/u8-strmblen.c index 5e15636b..48ea2602 100644 --- a/lib/unistr/u8-strmblen.c +++ b/lib/unistr/u8-strmblen.c @@ -1,5 +1,5 @@ /* Look at first character in UTF-8 string. - Copyright (C) 1999-2000, 2002, 2006-2007, 2009-2022 Free Software + Copyright (C) 1999-2000, 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. @@ -51,12 +51,12 @@ u8_strmblen (const uint8_t *s) && (c != 0xed || s[1] < 0xa0)) return 3; } - else if (c < 0xf8) + else if (c <= 0xf4) { if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40 && (s[3] ^ 0x80) < 0x40 && (c >= 0xf1 || s[1] >= 0x90) - && (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))) + && (c < 0xf4 || (/* c == 0xf4 && */ s[1] < 0x90))) return 4; } } diff --git a/lib/unistr/u8-strmbtouc.c b/lib/unistr/u8-strmbtouc.c index 8af0bb2a..ce6aad9e 100644 --- a/lib/unistr/u8-strmbtouc.c +++ b/lib/unistr/u8-strmbtouc.c @@ -1,5 +1,5 @@ /* Look at first character in UTF-8 string. - Copyright (C) 1999-2000, 2002, 2006-2007, 2009-2022 Free Software + Copyright (C) 1999-2000, 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. @@ -63,12 +63,12 @@ u8_strmbtouc (ucs4_t *puc, const uint8_t *s) return 3; } } - else if (c < 0xf8) + else if (c <= 0xf4) { if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40 && (s[3] ^ 0x80) < 0x40 && (c >= 0xf1 || s[1] >= 0x90) - && (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))) + && (c < 0xf4 || (/* c == 0xf4 && */ s[1] < 0x90))) { *puc = ((unsigned int) (c & 0x07) << 18) | ((unsigned int) (s[1] ^ 0x80) << 12) diff --git a/lib/unistr/u8-strncat.c b/lib/unistr/u8-strncat.c index c5f91df5..a82a7f23 100644 --- a/lib/unistr/u8-strncat.c +++ b/lib/unistr/u8-strncat.c @@ -1,5 +1,5 @@ /* Concatenate UTF-8 strings. - Copyright (C) 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u8-strncmp.c b/lib/unistr/u8-strncmp.c index b534e08f..bc11a21d 100644 --- a/lib/unistr/u8-strncmp.c +++ b/lib/unistr/u8-strncmp.c @@ -1,5 +1,5 @@ /* Compare UTF-8 strings. - Copyright (C) 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u8-strncpy.c b/lib/unistr/u8-strncpy.c index caebbf77..3e40f2f4 100644 --- a/lib/unistr/u8-strncpy.c +++ b/lib/unistr/u8-strncpy.c @@ -1,5 +1,5 @@ /* Copy UTF-8 string. - Copyright (C) 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u8-strnlen.c b/lib/unistr/u8-strnlen.c index 1c601593..88df261f 100644 --- a/lib/unistr/u8-strnlen.c +++ b/lib/unistr/u8-strnlen.c @@ -1,5 +1,5 @@ /* Determine bounded length of UTF-8 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u8-strpbrk.c b/lib/unistr/u8-strpbrk.c index 54d75df5..d7495649 100644 --- a/lib/unistr/u8-strpbrk.c +++ b/lib/unistr/u8-strpbrk.c @@ -1,5 +1,5 @@ /* Search for some characters in UTF-8 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u8-strrchr.c b/lib/unistr/u8-strrchr.c index f9999836..6caae2d7 100644 --- a/lib/unistr/u8-strrchr.c +++ b/lib/unistr/u8-strrchr.c @@ -1,5 +1,5 @@ /* Search character in UTF-8 string. - Copyright (C) 1999, 2002, 2006-2007, 2009-2022 Free Software Foundation, + Copyright (C) 1999, 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. diff --git a/lib/unistr/u8-strspn.c b/lib/unistr/u8-strspn.c index 20a87fea..f4dd9736 100644 --- a/lib/unistr/u8-strspn.c +++ b/lib/unistr/u8-strspn.c @@ -1,5 +1,5 @@ /* Search for some characters in UTF-8 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u8-strstr.c b/lib/unistr/u8-strstr.c index 8b34c0a9..df2dc964 100644 --- a/lib/unistr/u8-strstr.c +++ b/lib/unistr/u8-strstr.c @@ -1,5 +1,5 @@ /* Substring test for UTF-8 strings. - Copyright (C) 1999, 2002, 2006, 2010-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2010-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. @@ -30,11 +30,26 @@ #include <string.h> -/* FIXME: Maybe walking the string via u8_mblen is a win? */ - -#define FUNC u8_strstr -#define UNIT uint8_t -#define U_STRCHR u8_strchr -#define U_STRMBTOUC u8_strmbtouc -#define UNIT_IS_UINT8_T 1 -#include "u-strstr.h" +uint8_t * +u8_strstr (const uint8_t *haystack, const uint8_t *needle) +{ + uint8_t first = needle[0]; + + /* Is needle empty? */ + if (first == 0) + return (uint8_t *) haystack; + + /* Is needle nearly empty (only one unit)? */ + if (needle[1] == 0) + return u8_strchr (haystack, first); + + /* Is needle nearly empty (only one character)? */ + { + ucs4_t first_uc; + int count = u8_strmbtouc (&first_uc, needle); + if (count > 0 && needle[count] == 0) + return u8_strchr (haystack, first_uc); + } + + return (uint8_t *) strstr ((const char *) haystack, (const char *) needle); +} diff --git a/lib/unistr/u8-strtok.c b/lib/unistr/u8-strtok.c index 285df308..5981b747 100644 --- a/lib/unistr/u8-strtok.c +++ b/lib/unistr/u8-strtok.c @@ -1,5 +1,5 @@ /* Tokenize UTF-8 string. - Copyright (C) 1999, 2002, 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u8-to-u16.c b/lib/unistr/u8-to-u16.c index 38d117b4..74b79741 100644 --- a/lib/unistr/u8-to-u16.c +++ b/lib/unistr/u8-to-u16.c @@ -1,5 +1,5 @@ /* Convert UTF-8 string to UTF-16 string. - Copyright (C) 2002, 2006-2007, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software. diff --git a/lib/unistr/u8-to-u32.c b/lib/unistr/u8-to-u32.c index 9f74ede5..a57bb5dc 100644 --- a/lib/unistr/u8-to-u32.c +++ b/lib/unistr/u8-to-u32.c @@ -1,5 +1,5 @@ /* Convert UTF-8 string to UTF-32 string. - Copyright (C) 2002, 2006-2007, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software: you can redistribute it and/or modify diff --git a/lib/unistr/u8-uctomb-aux.c b/lib/unistr/u8-uctomb-aux.c index 5ca21915..ffe567d9 100644 --- a/lib/unistr/u8-uctomb-aux.c +++ b/lib/unistr/u8-uctomb-aux.c @@ -1,5 +1,5 @@ /* Conversion UCS-4 to UTF-8. - Copyright (C) 2002, 2006-2007, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software: you can redistribute it and/or modify diff --git a/lib/unistr/u8-uctomb.c b/lib/unistr/u8-uctomb.c index 2259b1db..0f903fdb 100644 --- a/lib/unistr/u8-uctomb.c +++ b/lib/unistr/u8-uctomb.c @@ -1,5 +1,5 @@ /* Store a character in UTF-8 string. - Copyright (C) 2002, 2005-2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2002, 2005-2006, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This file is free software: you can redistribute it and/or modify |