From ab2edb9e3307a172487bb16edcaf79600bf9ebea Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 2 Jun 2005 05:05:29 +0000 Subject: Don't use "path" or "filename" to mean "file name" in comments or local variable names. --- lib/getcwd.c | 60 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 30 insertions(+), 30 deletions(-) (limited to 'lib/getcwd.c') diff --git a/lib/getcwd.c b/lib/getcwd.c index d12b6c907..94e5ba3b5 100644 --- a/lib/getcwd.c +++ b/lib/getcwd.c @@ -1,5 +1,5 @@ -/* Copyright (C) 1991,92,93,94,95,96,97,98,99,2004 Free Software Foundation, - Inc. +/* Copyright (C) 1991,92,93,94,95,96,97,98,99,2004,2005 Free Software + Foundation, Inc. This file is part of the GNU C Library. This program is free software; you can redistribute it and/or modify @@ -114,7 +114,7 @@ # define __readdir readdir #endif -/* Get the pathname of the current working directory, and put it in SIZE +/* Get the name 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, @@ -147,8 +147,8 @@ __getcwd (char *buf, size_t size) DIR *dirstream = NULL; dev_t rootdev, thisdev; ino_t rootino, thisino; - char *path; - register char *pathp; + char *dir; + register char *dirp; struct stat st; size_t allocated = size; size_t used; @@ -161,9 +161,9 @@ __getcwd (char *buf, size_t size) So trust the system getcwd's results unless they look suspicious. */ # undef getcwd - path = getcwd (buf, size); - if (path || (errno != ERANGE && !is_ENAMETOOLONG (errno) && errno != ENOENT)) - return path; + dir = getcwd (buf, size); + if (dir || (errno != ERANGE && !is_ENAMETOOLONG (errno) && errno != ENOENT)) + return dir; #endif if (size == 0) @@ -179,15 +179,15 @@ __getcwd (char *buf, size_t size) if (buf == NULL) { - path = malloc (allocated); - if (path == NULL) + dir = malloc (allocated); + if (dir == NULL) return NULL; } else - path = buf; + dir = buf; - pathp = path + allocated; - *--pathp = '\0'; + dirp = dir + allocated; + *--dirp = '\0'; if (__lstat (".", &st) < 0) goto lose; @@ -318,10 +318,10 @@ __getcwd (char *buf, size_t size) } else { - size_t pathroom = pathp - path; + size_t dirroom = dirp - dir; size_t namlen = _D_EXACT_NAMLEN (d); - if (pathroom <= namlen) + if (dirroom <= namlen) { if (size != 0) { @@ -335,20 +335,20 @@ __getcwd (char *buf, size_t size) allocated += MAX (allocated, namlen); if (allocated < oldsize - || ! (tmp = realloc (path, allocated))) + || ! (tmp = realloc (dir, allocated))) goto memory_exhausted; /* Move current contents up to the end of the buffer. This is guaranteed to be non-overlapping. */ - pathp = memcpy (tmp + allocated - (oldsize - pathroom), - tmp + pathroom, - oldsize - pathroom); - path = tmp; + dirp = memcpy (tmp + allocated - (oldsize - dirroom), + tmp + dirroom, + oldsize - dirroom); + dir = tmp; } } - pathp -= namlen; - memcpy (pathp, d->d_name, namlen); - *--pathp = '/'; + dirp -= namlen; + memcpy (dirp, d->d_name, namlen); + *--dirp = '/'; } thisdev = dotdev; @@ -361,25 +361,25 @@ __getcwd (char *buf, size_t size) goto lose; } - if (pathp == &path[allocated - 1]) - *--pathp = '/'; + if (dirp == &dir[allocated - 1]) + *--dirp = '/'; #ifndef AT_FDCWD if (dotlist != dots) free (dotlist); #endif - used = path + allocated - pathp; - memmove (path, pathp, used); + used = dir + allocated - dirp; + memmove (dir, dirp, used); if (buf == NULL && size == 0) /* Ensure that the buffer is only as large as necessary. */ - buf = realloc (path, used); + buf = realloc (dir, used); if (buf == NULL) /* Either buf was NULL all along, or `realloc' failed but we still have the original string. */ - buf = path; + buf = dir; return buf; @@ -398,7 +398,7 @@ __getcwd (char *buf, size_t size) free (dotlist); #endif if (buf == NULL) - free (path); + free (dir); __set_errno (save); } return NULL; -- cgit v1.2.3-54-g00ecf