summaryrefslogtreecommitdiff
path: root/gl/lib/getcwd-lgpl.c
diff options
context:
space:
mode:
Diffstat (limited to 'gl/lib/getcwd-lgpl.c')
-rw-r--r--gl/lib/getcwd-lgpl.c32
1 files changed, 14 insertions, 18 deletions
diff --git a/gl/lib/getcwd-lgpl.c b/gl/lib/getcwd-lgpl.c
index fca6bdef..f449ac85 100644
--- a/gl/lib/getcwd-lgpl.c
+++ b/gl/lib/getcwd-lgpl.c
@@ -1,17 +1,17 @@
-/* Copyright (C) 2011-2020 Free Software Foundation, Inc.
+/* Copyright (C) 2011-2022 Free Software Foundation, Inc.
This file is part of gnulib.
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
+ 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 program is distributed in the hope that it will be useful,
+ 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 General Public License for more details.
+ GNU Lesser General Public License for more details.
- You should have received a copy of the GNU General Public License
+ 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>
@@ -38,6 +38,10 @@ typedef int dummy;
necessary. */
# undef getcwd
+# if defined _WIN32 && !defined __CYGWIN__
+# define getcwd _getcwd
+# endif
+
char *
rpl_getcwd (char *buf, size_t size)
{
@@ -65,11 +69,7 @@ rpl_getcwd (char *buf, size_t size)
}
result = getcwd (buf, size);
if (!result)
- {
- int saved_errno = errno;
- free (buf);
- errno = saved_errno;
- }
+ free (buf);
return result;
}
@@ -108,11 +108,7 @@ rpl_getcwd (char *buf, size_t size)
while (!result && errno == ERANGE);
if (!result)
- {
- int saved_errno = errno;
- free (buf);
- errno = saved_errno;
- }
+ free (buf);
else
{
/* Here result == buf. */