pmt: initial 3.0.2 update

This commit is contained in:
2024-12-14 11:17:56 +03:00
parent bbf76e4925
commit a6c9feb4d6
1292 changed files with 500838 additions and 2817 deletions

View File

@@ -0,0 +1,36 @@
/* Formatted output to strings.
Copyright (C) 1999, 2002, 2005-2007, 2009-2024 Free Software Foundation,
Inc.
This file is free software.
It is dual-licensed under "the GNU LGPLv3+ or the GNU GPLv2+".
You can redistribute it and/or modify it under either
- the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 3, or (at your
option) any later version, or
- the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option)
any later version, or
- the same dual license "the GNU LGPLv3+ or the GNU GPLv2+".
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License 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/>. */
DCHAR_T *
ASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, const FCHAR_T *format, ...)
{
va_list args;
DCHAR_T *result;
va_start (args, format);
result = VASNPRINTF (resultbuf, lengthp, format, args);
va_end (args);
return result;
}

View File

@@ -0,0 +1,36 @@
/* Formatted output to strings.
Copyright (C) 1999, 2002, 2005-2007, 2009-2024 Free Software Foundation,
Inc.
This file is free software.
It is dual-licensed under "the GNU LGPLv3+ or the GNU GPLv2+".
You can redistribute it and/or modify it under either
- the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 3, or (at your
option) any later version, or
- the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option)
any later version, or
- the same dual license "the GNU LGPLv3+ or the GNU GPLv2+".
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License 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
ASPRINTF (DCHAR_T **resultp, const FCHAR_T *format, ...)
{
va_list args;
int result;
va_start (args, format);
result = VASPRINTF (resultp, format, args);
va_end (args);
return result;
}

View File

@@ -0,0 +1,36 @@
/* Decomposed printf argument list.
Copyright (C) 1999, 2002, 2005-2007, 2009-2024 Free Software Foundation,
Inc.
This file is free software.
It is dual-licensed under "the GNU LGPLv3+ or the GNU GPLv2+".
You can redistribute it and/or modify it under either
- the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 3, or (at your
option) any later version, or
- the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option)
any later version, or
- the same dual license "the GNU LGPLv3+ or the GNU GPLv2+".
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License 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/>. */
#ifndef _U_PRINTF_ARGS_H
#define _U_PRINTF_ARGS_H
#include "unitypes.h"
/* Parametrization of printf-args.h. */
#define ENABLE_UNISTDIO 1
#define PRINTF_FETCHARGS u_printf_fetchargs
#include "printf-args.h"
#endif /* _U_PRINTF_ARGS_H */

View File

@@ -0,0 +1,36 @@
/* Parse printf format string.
Copyright (C) 1999, 2002, 2005, 2007, 2009-2024 Free Software Foundation,
Inc.
This file is free software.
It is dual-licensed under "the GNU LGPLv3+ or the GNU GPLv2+".
You can redistribute it and/or modify it under either
- the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 3, or (at your
option) any later version, or
- the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option)
any later version, or
- the same dual license "the GNU LGPLv3+ or the GNU GPLv2+".
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License 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/>. */
#ifndef _U_PRINTF_PARSE_H
#define _U_PRINTF_PARSE_H
#include "unistdio/u-printf-args.h"
/* Parametrization of printf-parse.h. */
#undef ENABLE_UNISTDIO
#define ENABLE_UNISTDIO 1
#include "printf-parse.h"
#endif /* _U_PRINTF_PARSE_H */

View File

@@ -0,0 +1,36 @@
/* Formatted output to strings.
Copyright (C) 1999, 2002, 2005-2007, 2009-2024 Free Software Foundation,
Inc.
This file is free software.
It is dual-licensed under "the GNU LGPLv3+ or the GNU GPLv2+".
You can redistribute it and/or modify it under either
- the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 3, or (at your
option) any later version, or
- the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option)
any later version, or
- the same dual license "the GNU LGPLv3+ or the GNU GPLv2+".
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License 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
SNPRINTF (DCHAR_T *buf, size_t size, const FCHAR_T *format, ...)
{
va_list args;
int result;
va_start (args, format);
result = VSNPRINTF (buf, size, format, args);
va_end (args);
return result;
}

View File

@@ -0,0 +1,36 @@
/* Formatted output to strings.
Copyright (C) 1999, 2002, 2005-2007, 2009-2024 Free Software Foundation,
Inc.
This file is free software.
It is dual-licensed under "the GNU LGPLv3+ or the GNU GPLv2+".
You can redistribute it and/or modify it under either
- the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 3, or (at your
option) any later version, or
- the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option)
any later version, or
- the same dual license "the GNU LGPLv3+ or the GNU GPLv2+".
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License 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
SPRINTF (DCHAR_T *buf, const FCHAR_T *format, ...)
{
va_list args;
int result;
va_start (args, format);
result = VSPRINTF (buf, format, args);
va_end (args);
return result;
}

View File

@@ -0,0 +1,43 @@
/* Formatted output to strings.
Copyright (C) 1999, 2002, 2006-2024 Free Software Foundation, Inc.
This file is free software.
It is dual-licensed under "the GNU LGPLv3+ or the GNU GPLv2+".
You can redistribute it and/or modify it under either
- the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 3, or (at your
option) any later version, or
- the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option)
any later version, or
- the same dual license "the GNU LGPLv3+ or the GNU GPLv2+".
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License 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
VASPRINTF (DCHAR_T **resultp, const FCHAR_T *format, va_list args)
{
size_t length;
DCHAR_T *result = VASNPRINTF (NULL, &length, format, args);
if (result == NULL)
return -1;
if (length > INT_MAX)
{
free (result);
errno = EOVERFLOW;
return -1;
}
*resultp = result;
/* Return the number of resulting units, excluding the trailing NUL. */
return length;
}

View File

@@ -0,0 +1,60 @@
/* Formatted output to strings.
Copyright (C) 1999, 2002, 2006-2024 Free Software Foundation, Inc.
This file is free software.
It is dual-licensed under "the GNU LGPLv3+ or the GNU GPLv2+".
You can redistribute it and/or modify it under either
- the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 3, or (at your
option) any later version, or
- the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option)
any later version, or
- the same dual license "the GNU LGPLv3+ or the GNU GPLv2+".
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License 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
VSNPRINTF (DCHAR_T *buf, size_t size, const FCHAR_T *format, va_list args)
{
size_t length;
DCHAR_T *result;
if (size == 0)
buf = NULL;
else
length = size;
result = VASNPRINTF (buf, &length, format, args);
if (result == NULL)
return -1;
if (result != buf)
{
if (size != 0)
{
/* The result did not fit into the buffer. Copy the initial segment
into the buffer, truncating it if necessary. */
size_t n = (length < size ? length : size - 1);
DCHAR_CPY (buf, result, n);
buf[n] = '\0';
}
free (result);
}
if (length > INT_MAX)
{
errno = EOVERFLOW;
return -1;
}
/* Return the number of resulting units, excluding the trailing NUL. */
return length;
}

View File

@@ -0,0 +1,66 @@
/* Formatted output to strings.
Copyright (C) 1999, 2002, 2006-2024 Free Software Foundation, Inc.
This file is free software.
It is dual-licensed under "the GNU LGPLv3+ or the GNU GPLv2+".
You can redistribute it and/or modify it under either
- the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 3, or (at your
option) any later version, or
- the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option)
any later version, or
- the same dual license "the GNU LGPLv3+ or the GNU GPLv2+".
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License 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/>. */
#ifndef SIZE_MAX
# define SIZE_MAX ((size_t) -1)
#endif
int
VSPRINTF (DCHAR_T *buf, const FCHAR_T *format, va_list args)
{
/* Pass an infinite length. But note that *vasnprintf may fail if the buffer
argument is larger than INT_MAX (if that fits into a 'size_t' at all).
Also note that glibc's iconv fails with E2BIG when we pass a length that
is so large that buf + length wraps around, i.e.
(uintptr_t) (buf + length) < (uintptr_t) buf. */
size_t length;
DCHAR_T *result;
/* Set length = min (SIZE_MAX, INT_MAX, - (uintptr_t) buf - 1). */
length = (SIZE_MAX < INT_MAX ? SIZE_MAX : INT_MAX);
if (length > (~ (uintptr_t) buf) / sizeof (DCHAR_T))
length = (~ (uintptr_t) buf) / sizeof (DCHAR_T);
result = VASNPRINTF (buf, &length, format, args);
if (result == NULL)
return -1;
/* The infinite buffer size guarantees that the result is not malloc()ed. */
if (result != buf)
{
/* length is near SIZE_MAX. */
free (result);
errno = EOVERFLOW;
return -1;
}
if (length > INT_MAX)
{
errno = EOVERFLOW;
return -1;
}
/* Return the number of resulting units, excluding the trailing NUL. */
return length;
}