aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/posix
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/posix')
-rw-r--r--sysdeps/posix/getcwd.c29
-rw-r--r--sysdeps/posix/tempname.c19
2 files changed, 30 insertions, 18 deletions
diff --git a/sysdeps/posix/getcwd.c b/sysdeps/posix/getcwd.c
index af858a2643..05f626f869 100644
--- a/sysdeps/posix/getcwd.c
+++ b/sysdeps/posix/getcwd.c
@@ -180,18 +180,15 @@ extern char *alloca ();
#define __lstat stat
#endif
-#ifndef _LIBC
-#define __getcwd getcwd
-#endif
-
-/* Get the pathname of the current working directory, and put it in SIZE
+/* Get the canonical absolute name of the named directory, and put it in SIZE
bytes of BUF. Returns NULL if the directory couldn't be determined or
SIZE was too small. If successful, returns BUF. In GNU, 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. */
char *
-__getcwd (buf, size)
+__canonicalize_directory_name_internal (thisdir, buf, size)
+ const char *thisdir;
char *buf;
size_t size;
{
@@ -230,7 +227,7 @@ __getcwd (buf, size)
pathp = path + size;
*--pathp = '\0';
- if (__lstat (".", &st) < 0)
+ if (__lstat (thisdir, &st) < 0)
return NULL;
thisdev = st.st_dev;
thisino = st.st_ino;
@@ -369,6 +366,24 @@ __getcwd (buf, size)
free ((__ptr_t) dotlist);
return NULL;
}
+
+/* Get the pathname of the current working directory, and put it in SIZE
+ bytes of BUF. Returns NULL if the directory couldn't be determined or
+ SIZE was too small. If successful, returns BUF. In GNU, 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. */
+
+#ifndef _LIBC
+#define __getcwd getcwd
+#endif
+
+char *
+__getcwd (buf, size)
+ char *buf;
+ size_t size;
+{
+ return __canonicalize_directory_name_internal (".", buf, size);
+}
#ifdef _LIBC
weak_alias (__getcwd, getcwd)
diff --git a/sysdeps/posix/tempname.c b/sysdeps/posix/tempname.c
index c70a6e8d35..fdddae2d0c 100644
--- a/sysdeps/posix/tempname.c
+++ b/sysdeps/posix/tempname.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 92, 93, 94, 95, 96 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -16,7 +16,6 @@ License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
-#include <ansidecl.h>
#include <errno.h>
#include <stddef.h>
#include <stdio.h>
@@ -34,7 +33,7 @@ Cambridge, MA 02139, USA. */
/* Return nonzero if DIR is an existent directory. */
static int
-DEFUN(diraccess, (dir), CONST char *dir)
+diraccess (const char *dir)
{
struct stat buf;
return __stat (dir, &buf) == 0 && S_ISDIR (buf.st_mode);
@@ -42,7 +41,7 @@ DEFUN(diraccess, (dir), CONST char *dir)
/* Return nonzero if FILE exists. */
static int
-DEFUN(exists, (file), CONST char *file)
+exists (const char *file)
{
/* We can stat the file even if we can't read its data. */
struct stat st;
@@ -64,7 +63,7 @@ DEFUN(exists, (file), CONST char *file)
/* These are the characters used in temporary filenames. */
-static CONST char letters[] =
+static const char letters[] =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
/* Generate a temporary filename and return it (in a static buffer). If
@@ -82,13 +81,11 @@ static CONST char letters[] =
existing file will be returned. When the cycle reaches its end
(12345ZZZ), NULL is returned. */
char *
-DEFUN(__stdio_gen_tempname, (dir, pfx, dir_search, lenptr, streamptr),
- CONST char *dir AND CONST char *pfx AND
- int dir_search AND size_t *lenptr AND
- FILE **streamptr)
+__stdio_gen_tempname (const char *dir, const char *pfx, int dir_search,
+ size_t *lenptr, FILE **streamptr)
{
int saverrno = errno;
- static CONST char tmpdir[] = P_tmpdir;
+ static const char tmpdir[] = P_tmpdir;
static size_t indices[2];
size_t *idx;
static char buf[FILENAME_MAX];
@@ -98,7 +95,7 @@ DEFUN(__stdio_gen_tempname, (dir, pfx, dir_search, lenptr, streamptr),
if (dir_search)
{
- register CONST char *d = getenv ("TMPDIR");
+ register const char *d = getenv ("TMPDIR");
if (d != NULL && !diraccess (d))
d = NULL;
if (d == NULL && dir != NULL && diraccess (dir))