pmt: revert 7f8090b
This commit is contained in:
@@ -1,35 +0,0 @@
|
||||
/* Compare pieces of UTF-8/UTF-16/UTF-32 strings.
|
||||
Copyright (C) 2009-2024 Free Software Foundation, Inc.
|
||||
Written by Bruno Haible <bruno@clisp.org>, 2009.
|
||||
|
||||
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/>. */
|
||||
|
||||
int
|
||||
FUNC (const UNIT *s1, size_t n1, const UNIT *s2, size_t n2)
|
||||
{
|
||||
int cmp = U_CMP (s1, s2, MIN (n1, n2));
|
||||
|
||||
if (cmp == 0)
|
||||
cmp = _GL_CMP (n1, n2);
|
||||
|
||||
return cmp;
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
/* Copy piece of UTF-8/UTF-16/UTF-32 string.
|
||||
Copyright (C) 1999, 2002, 2006-2007, 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 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 <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
UNIT *
|
||||
FUNC (const UNIT *s, size_t n)
|
||||
{
|
||||
UNIT *dest;
|
||||
|
||||
dest = (UNIT *) malloc (n > 0 ? n * sizeof (UNIT) : 1);
|
||||
if (dest != NULL)
|
||||
{
|
||||
#if 0
|
||||
UNIT *destptr = dest;
|
||||
|
||||
for (; n > 0; n--)
|
||||
*destptr++ = *s++;
|
||||
#else
|
||||
if (n > 0)
|
||||
memcpy ((char *) dest, (const char *) s, n * sizeof (UNIT));
|
||||
#endif
|
||||
}
|
||||
return dest;
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/* Copy piece of UTF-8/UTF-16/UTF-32 string.
|
||||
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
|
||||
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 <string.h>
|
||||
|
||||
UNIT *
|
||||
FUNC (UNIT *dest, const UNIT *src, size_t n)
|
||||
{
|
||||
#if 0
|
||||
UNIT *destptr = dest;
|
||||
|
||||
for (; n > 0; n--)
|
||||
*destptr++ = *src++;
|
||||
#else
|
||||
if (n > 0)
|
||||
memcpy ((char *) dest, (const char *) src, n * sizeof (UNIT));
|
||||
#endif
|
||||
return dest;
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/* Substring test for UTF-8/UTF-16/UTF-32 strings.
|
||||
Copyright (C) 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 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/>. */
|
||||
|
||||
bool
|
||||
FUNC (const UNIT *str, const UNIT *suffix)
|
||||
{
|
||||
size_t len = U_STRLEN (str);
|
||||
size_t suffixlen = U_STRLEN (suffix);
|
||||
|
||||
if (len >= suffixlen)
|
||||
return (U_CMP (str + (len - suffixlen), suffix, suffixlen) == 0);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
/* Copy piece of UTF-8/UTF-16/UTF-32 string.
|
||||
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 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 <string.h>
|
||||
|
||||
UNIT *
|
||||
FUNC (UNIT *dest, const UNIT *src, size_t n)
|
||||
{
|
||||
#if 0
|
||||
if (dest < src)
|
||||
{
|
||||
UNIT *destptr = dest;
|
||||
const UNIT *srcptr = src;
|
||||
|
||||
for (; n > 0; n--)
|
||||
*destptr++ = *srcptr++;
|
||||
}
|
||||
else if (dest > src)
|
||||
{
|
||||
UNIT *destptr = dest + n - 1;
|
||||
const UNIT *srcptr = src + n - 1;
|
||||
|
||||
for (; n > 0; n--)
|
||||
*destptr-- = *srcptr--;
|
||||
}
|
||||
#else
|
||||
memmove ((char *) dest, (const char *) src, n * sizeof (UNIT));
|
||||
#endif
|
||||
return dest;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
/* 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;
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
/* Fill UTF-8/UTF-16/UTF-32 string.
|
||||
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 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 <errno.h>
|
||||
|
||||
UNIT *
|
||||
FUNC (UNIT *s, ucs4_t uc, size_t n)
|
||||
{
|
||||
if (n > 0)
|
||||
{
|
||||
if (IS_SINGLE_UNIT (uc))
|
||||
{
|
||||
UNIT *ptr = s;
|
||||
|
||||
for (; n > 0; n--)
|
||||
*ptr++ = uc;
|
||||
}
|
||||
else
|
||||
{
|
||||
errno = EILSEQ;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/* Substring test for UTF-8/UTF-16/UTF-32 strings.
|
||||
Copyright (C) 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 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/>. */
|
||||
|
||||
bool
|
||||
FUNC (const UNIT *str, const UNIT *prefix)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
UNIT uc1 = *str++;
|
||||
UNIT uc2 = *prefix++;
|
||||
if (uc2 == 0)
|
||||
return true;
|
||||
if (uc1 != uc2)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/* Copy UTF-8/UTF-16/UTF-32 string.
|
||||
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 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 (UNIT *dest, const UNIT *src)
|
||||
{
|
||||
for (; (*dest = *src) != 0; src++, dest++)
|
||||
;
|
||||
return dest;
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
/* Copy UTF-8/UTF-16/UTF-32 string.
|
||||
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 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 (UNIT *dest, const UNIT *src, size_t n)
|
||||
{
|
||||
for (; n > 0 && (*dest = *src) != 0; src++, dest++, n--)
|
||||
;
|
||||
|
||||
/* This behavior is rarely useful, but it is here for consistency with
|
||||
strncpy and wcsncpy. */
|
||||
{
|
||||
UNIT *destptr = dest;
|
||||
|
||||
for (; n > 0; n--)
|
||||
*destptr++ = 0;
|
||||
}
|
||||
|
||||
return dest;
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
/* Concatenate UTF-8/UTF-16/UTF-32 strings.
|
||||
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
|
||||
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)
|
||||
{
|
||||
UNIT *destptr = dest + U_STRLEN (dest);
|
||||
|
||||
for (; (*destptr = *src) != 0; src++, destptr++)
|
||||
;
|
||||
return dest;
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
/* Compare UTF-8/UTF-16/UTF-32 strings using the collation rules of the current
|
||||
locale.
|
||||
Copyright (C) 2009-2024 Free Software Foundation, Inc.
|
||||
Written by Bruno Haible <bruno@clisp.org>, 2009.
|
||||
|
||||
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/>. */
|
||||
|
||||
int
|
||||
FUNC (const UNIT *s1, const UNIT *s2)
|
||||
{
|
||||
/* When this function succeeds, it sets errno back to its original value.
|
||||
When it fails, it sets errno, but also returns a meaningful return value,
|
||||
for the sake of callers which ignore errno. */
|
||||
int final_errno = errno;
|
||||
const char *encoding = locale_charset ();
|
||||
char *sl1;
|
||||
char *sl2;
|
||||
int result;
|
||||
|
||||
/* Pass iconveh_error here, not iconveh_question_mark. Otherwise the
|
||||
conversion to locale encoding can do transliteration or map some
|
||||
characters to question marks, leading to results that depend on the
|
||||
iconv() implementation and are not obvious. */
|
||||
sl1 = U_STRCONV_TO_ENCODING (s1, encoding, iconveh_error);
|
||||
if (sl1 != NULL)
|
||||
{
|
||||
sl2 = U_STRCONV_TO_ENCODING (s2, encoding, iconveh_error);
|
||||
if (sl2 != NULL)
|
||||
{
|
||||
/* Compare sl1 and sl2. */
|
||||
errno = 0;
|
||||
result = strcoll (sl1, sl2);
|
||||
if (errno == 0)
|
||||
{
|
||||
/* strcoll succeeded. */
|
||||
free (sl1);
|
||||
free (sl2);
|
||||
/* The conversion to locale encoding can drop Unicode TAG
|
||||
characters. Therefore sl1 and sl2 may be equal when s1
|
||||
and s2 were in fact different. Return a nonzero result
|
||||
in this case. */
|
||||
if (result == 0)
|
||||
result = U_STRCMP (s1, s2);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* strcoll failed. */
|
||||
final_errno = errno;
|
||||
free (sl1);
|
||||
free (sl2);
|
||||
result = U_STRCMP (s1, s2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* s1 could be converted to locale encoding, s2 not. */
|
||||
final_errno = errno;
|
||||
free (sl1);
|
||||
result = -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
final_errno = errno;
|
||||
sl2 = U_STRCONV_TO_ENCODING (s2, encoding, iconveh_error);
|
||||
if (sl2 != NULL)
|
||||
{
|
||||
/* s2 could be converted to locale encoding, s1 not. */
|
||||
free (sl2);
|
||||
result = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Neither s1 nor s2 could be converted to locale encoding. */
|
||||
result = U_STRCMP (s1, s2);
|
||||
}
|
||||
}
|
||||
|
||||
errno = final_errno;
|
||||
return result;
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/* Copy UTF-8/UTF-16/UTF-32 string.
|
||||
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 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 (UNIT *dest, const UNIT *src)
|
||||
{
|
||||
UNIT *destptr = dest;
|
||||
|
||||
for (; (*destptr = *src) != 0; src++, destptr++)
|
||||
;
|
||||
return dest;
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
/* Search for some characters in UTF-8/UTF-16/UTF-32 string.
|
||||
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 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/>. */
|
||||
|
||||
size_t
|
||||
FUNC (const UNIT *str, const UNIT *reject)
|
||||
{
|
||||
/* Optimize two cases. */
|
||||
if (reject[0] == 0)
|
||||
return U_STRLEN (str);
|
||||
{
|
||||
ucs4_t uc;
|
||||
int count = U_STRMBTOUC (&uc, reject);
|
||||
if (count >= 0 && reject[count] == 0)
|
||||
{
|
||||
const UNIT *found = U_STRCHR (str, uc);
|
||||
if (found != NULL)
|
||||
return found - str;
|
||||
else
|
||||
return U_STRLEN (str);
|
||||
}
|
||||
}
|
||||
/* General case. */
|
||||
{
|
||||
const UNIT *ptr = str;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
ucs4_t uc;
|
||||
int count = U_STRMBTOUC (&uc, ptr);
|
||||
if (count == 0)
|
||||
return ptr - str;
|
||||
if (count < 0)
|
||||
break;
|
||||
if (U_STRCHR (reject, uc))
|
||||
return ptr - str;
|
||||
ptr += count;
|
||||
}
|
||||
return U_STRLEN (str);
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
/* Copy UTF-8/UTF-16/UTF-32 string.
|
||||
Copyright (C) 1999, 2002, 2006-2007, 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 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 <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
UNIT *
|
||||
FUNC (const UNIT *s)
|
||||
{
|
||||
size_t n = U_STRLEN (s) + 1;
|
||||
UNIT *dest;
|
||||
|
||||
dest = (UNIT *) malloc (n * sizeof (UNIT));
|
||||
if (dest != NULL)
|
||||
{
|
||||
#if 0
|
||||
UNIT *destptr = dest;
|
||||
|
||||
for (; n > 0; n--)
|
||||
*destptr++ = *s++;
|
||||
#else
|
||||
memcpy ((char *) dest, (const char *) s, n * sizeof (UNIT));
|
||||
#endif
|
||||
}
|
||||
return dest;
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
/* Determine length of UTF-8/UTF-16/UTF-32 string.
|
||||
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
|
||||
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/>. */
|
||||
|
||||
size_t
|
||||
FUNC (const UNIT *s)
|
||||
{
|
||||
const UNIT *ptr;
|
||||
|
||||
for (ptr = s; *ptr != 0; ptr++)
|
||||
;
|
||||
return ptr - s;
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/* Concatenate UTF-8/UTF-16/UTF-32 strings.
|
||||
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 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 (UNIT *dest, const UNIT *src, size_t n)
|
||||
{
|
||||
UNIT *destptr = dest + U_STRLEN (dest);
|
||||
|
||||
for (; n > 0 && (*destptr = *src) != 0; src++, destptr++, n--)
|
||||
;
|
||||
if (n == 0)
|
||||
*destptr = 0;
|
||||
return dest;
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
/* Copy UTF-8/UTF-16/UTF-32 string.
|
||||
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 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 (UNIT *dest, const UNIT *src, size_t n)
|
||||
{
|
||||
UNIT *destptr = dest;
|
||||
|
||||
for (; n > 0 && (*destptr = *src) != 0; src++, destptr++, n--)
|
||||
;
|
||||
|
||||
/* This behavior is rarely useful, but it is here for consistency with
|
||||
strncpy and wcsncpy. */
|
||||
for (; n > 0; n--)
|
||||
*destptr++ = 0;
|
||||
|
||||
return dest;
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/* Determine bounded length of UTF-8/UTF-16/UTF-32 string.
|
||||
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 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/>. */
|
||||
|
||||
size_t
|
||||
FUNC (const UNIT *s, size_t maxlen)
|
||||
{
|
||||
const UNIT *ptr;
|
||||
|
||||
for (ptr = s; maxlen > 0 && *ptr != 0; ptr++, maxlen--)
|
||||
;
|
||||
return ptr - s;
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
/* Search for some characters in UTF-8/UTF-16/UTF-32 string.
|
||||
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 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 *str, const UNIT *accept)
|
||||
{
|
||||
/* Optimize two cases. */
|
||||
if (accept[0] == 0)
|
||||
return NULL;
|
||||
{
|
||||
ucs4_t uc;
|
||||
int count = U_STRMBTOUC (&uc, accept);
|
||||
if (count >= 0 && accept[count] == 0)
|
||||
return U_STRCHR (str, uc);
|
||||
}
|
||||
/* General case. */
|
||||
{
|
||||
const UNIT *ptr = str;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
ucs4_t uc;
|
||||
int count = U_STRMBTOUC (&uc, ptr);
|
||||
if (count <= 0)
|
||||
break;
|
||||
if (U_STRCHR (accept, uc))
|
||||
return (UNIT *) ptr;
|
||||
ptr += count;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
/* Search for some characters in UTF-8/UTF-16/UTF-32 string.
|
||||
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 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/>. */
|
||||
|
||||
size_t
|
||||
FUNC (const UNIT *str, const UNIT *accept)
|
||||
{
|
||||
/* Optimize two cases. */
|
||||
if (accept[0] == 0)
|
||||
return 0;
|
||||
{
|
||||
ucs4_t uc;
|
||||
int count = U_STRMBTOUC (&uc, accept);
|
||||
if (count >= 0 && accept[count] == 0)
|
||||
{
|
||||
const UNIT *ptr = str;
|
||||
for (; *ptr != 0; ptr += count)
|
||||
if (U_CMP (ptr, accept, count) != 0)
|
||||
break;
|
||||
return ptr - str;
|
||||
}
|
||||
}
|
||||
/* General case. */
|
||||
{
|
||||
const UNIT *ptr = str;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
ucs4_t uc;
|
||||
int count = U_STRMBTOUC (&uc, ptr);
|
||||
if (count == 0)
|
||||
return ptr - str;
|
||||
if (count < 0)
|
||||
break;
|
||||
if (!U_STRCHR (accept, uc))
|
||||
return ptr - str;
|
||||
ptr += count;
|
||||
}
|
||||
return U_STRLEN (str);
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
/* Tokenize UTF-8/UTF-16/UTF-32 string.
|
||||
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 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 (UNIT *str, const UNIT *delim, UNIT **ptr)
|
||||
{
|
||||
if (str == NULL)
|
||||
{
|
||||
str = *ptr;
|
||||
if (str == NULL)
|
||||
return NULL; /* reminder that end of token sequence has been reached */
|
||||
}
|
||||
|
||||
/* Skip leading delimiters. */
|
||||
str += U_STRSPN (str, delim);
|
||||
|
||||
/* Found a token? */
|
||||
if (*str == 0)
|
||||
{
|
||||
*ptr = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Move past the token. */
|
||||
{
|
||||
UNIT *token_end = U_STRPBRK (str, delim);
|
||||
if (token_end)
|
||||
{
|
||||
*ptr = token_end + U_STRMBLEN (token_end);
|
||||
/* NUL-terminate the token. */
|
||||
*token_end = 0;
|
||||
}
|
||||
else
|
||||
*ptr = NULL;
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
Reference in New Issue
Block a user