* lib/unistd.in.h (getcwd): Mention the module 'getcwd-lgpl'.
* lib/getcwd-lgpl.c (rpl_getcwd): Minimize scope of local variables.
* tests/test-getcwd-lgpl.c (main): Use GNU coding style.
+2023-09-30 Bruno Haible <bruno@clisp.org>
+
+ getcwd-lgpl: Tweaks.
+ * lib/unistd.in.h (getcwd): Mention the module 'getcwd-lgpl'.
+ * lib/getcwd-lgpl.c (rpl_getcwd): Minimize scope of local variables.
+ * tests/test-getcwd-lgpl.c (main): Use GNU coding style.
+
2023-09-29 Bruno Haible <bruno@clisp.org>
Allow different --libtool options from multiple gnulib-tool invocations.
char *
rpl_getcwd (char *buf, size_t size)
{
- char *ptr;
char *result;
/* Handle single size operations. */
if (buf)
{
+ /* Check SIZE argument. */
if (!size)
{
errno = EINVAL;
{
char tmp[4032];
size = sizeof tmp;
- ptr = getcwd (tmp, size);
+ char *ptr = getcwd (tmp, size);
if (ptr)
{
result = strdup (ptr);
do
{
size <<= 1;
- ptr = realloc (buf, size);
+ char *ptr = realloc (buf, size);
if (ptr == NULL)
{
free (buf);
or SIZE was too small.
See the POSIX:2008 specification
<https://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>.
- Additionally, the gnulib module 'getcwd' guarantees the following GNU
- extension: If BUF is NULL, an array is allocated with 'malloc'; the array
- is SIZE bytes long, unless SIZE == 0, in which case it is as big as
- necessary. */
+ Additionally, the gnulib module 'getcwd' or 'getcwd-lgpl' guarantees the
+ following GNU extension: If BUF is NULL, an array is allocated with
+ 'malloc'; the array is SIZE bytes long, unless SIZE == 0, in which case
+ it is as big as necessary. */
# if @REPLACE_GETCWD@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define getcwd rpl_getcwd
/* Validate a POSIX requirement on size. */
errno = 0;
- ASSERT (getcwd(pwd2, 0) == NULL);
+ ASSERT (getcwd (pwd2, 0) == NULL);
ASSERT (errno == EINVAL);
free (pwd1);