From 359c0a71713e606f440d40f55a43c77349df2aaa Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 2 Jun 2005 20:41:04 +0000 Subject: [PATCH] Sync from coreutils. Use "file name" when talking about file names, instead of "filename" or "path", as per the GNU coding standards. * MODULES.html.sh: mkdir-p renamed from makepath. filenamecat renamed from path-concat. * modules/filenamecat: Renamed from modules/path-concat. (Files): filenamecat.h and filenamecat.c renamed from path-concat.h and path-concat.c. (configure.ac): gl_FILE_NAME_CONCAT, not gl_PATH_CONCAT. (Include): filenamecat.h, not path-concat.h. * modules/mkdir-p: Renamed from modules/makepath. (Files): mkdir-p.h and mkdir-p.c renamed from makepath.h and makepath.c. (configure.ac): gl_MKDIR_PARENTS, not gl_MAKEPATH. (Include): mkdir-p.h, not makepath.h. * lib/mkdir-p.c: Renamed from makepath.c. (make_dir_parents): Renamed from make_path. All callers changed. * lib/mkdir-p.h: Likewise. All includers changed. * lib/filenamecat.c: Renamed from path-concat.c. (file_name_concat): Renamed from path_concat. All callers changed. [TEST_FILE_NAME_CONCAT]: Renamed from TEST_PATH_CONCAT. * lib/filenamecat.h: Likewise. All includers changed. * lib/acl.c: Don't use "path" or "filename" to mean "file name" in comments or local variable names. * lib/basename.c: Likewise. * lib/canonicalize.c, canonicalize.h: Likewise. * lib/dirname.c, dirname.h: Likewise. * lib/euidaccess.c: Likewise. * lib/exclude.c: Likewise * lib/fnmatch_.h, fnmatch_loop.c: Likewise. * lib/fsusage.c, fsuage.h: Likewise. * lib/fts.c, fts_.h: Likewise. * lib/getcwd.c: Likewise. * lib/getloadavg.c: Likewise. * lib/mkstemp.c: Likewise. * lib/mountlist.c, mountlist.h: Likewise. * lib/openat.c, openat.h: Likewise. * lib/readlink-stub.c: Likewise. * lib/readutmp.c, readutmp.h: Likewise. * lib/rename.c: Likewise. * lib/rmdir.c: Likewise. * lib/same.c: Likewise. * lib/savedir.c: Likewise. * lib/stripslash.c: Likewise. * lib/tempname.c: Likewise. * lib/xreadlink.c: Likewise. * lib/exclude.c (excluded_file_name): Renamed from excluded_filename. All uses changed. * lib/exclude.h: Likewise. * m4/mkdir-p.m4: Renamed from makepath.m4. (gl_MKDIR_PARENTS): Renamed from gl_MAKEPATH. All uses changed. Rename files from makepath.c to mkdir-p.c, and from makepath.h to mkdir-p.h. * m4/filenamecat.m4: Renamed from path-concat.m4. (gl_FILE_NAME_CONCAT): Renamed from gl_PATH_CONCAT. All uses changed. Rename files from path-concat.c to filenamecat.c, and from path-concat.h to filenamecat.h. * m4/getcwd-path-max.m4: Don't use "path" or "filename" to mean "file name" in local variables or comments. * rename.m4: Likewise. * lib/euidaccess.c (getuid, getgid, getuid, getegid) [!defined _POSIX_VERSION]: Remove decls; not needed these days. * lib/idcache.c (getpwuid, getpwnam, getgrgid, getgrnam) [!defined _POSIX_VERSION]: Remove decls; not needed these days. * lib/pathmax.h: Include unconditionally, since other files have been getting away with it for years (MORE/BSD 4.3 is extinct now). * lib/userspec.c (getpwnam, getgrnam, getgrgid) [!defined _POSIX_VERSION]: Remove decls; not needed these days. * lib/pathmax.h (_POSIX_PATH_MAX) [!defined _POSIX_PATH_MAX]: Define to 256, not 255, as per modern POSIX. --- ChangeLog | 17 ++++++ MODULES.html.sh | 4 +- lib/ChangeLog | 53 ++++++++++++++++++ lib/acl.c | 10 ++-- lib/basename.c | 4 +- lib/canonicalize.c | 78 +++++++++++++------------- lib/canonicalize.h | 6 +- lib/dirname.c | 42 +++++++------- lib/dirname.h | 14 ++--- lib/euidaccess.c | 27 ++++----- lib/exclude.c | 12 ++-- lib/exclude.h | 6 +- lib/{path-concat.c => filenamecat.c} | 12 ++-- lib/{path-concat.h => filenamecat.h} | 12 ++-- lib/fnmatch_.h | 6 +- lib/fnmatch_loop.c | 4 +- lib/fsusage.c | 26 ++++----- lib/fsusage.h | 4 +- lib/fts-cycle.c | 2 +- lib/fts.c | 64 ++++++++++----------- lib/fts_.h | 6 +- lib/getcwd.c | 60 ++++++++++---------- lib/getloadavg.c | 2 +- lib/idcache.c | 12 +--- lib/{makepath.c => mkdir-p.c} | 102 +++++++++++++++++----------------- lib/{makepath.h => mkdir-p.h} | 22 ++++---- lib/mkstemp.c | 4 +- lib/mountlist.c | 10 ++-- lib/mountlist.h | 4 +- lib/openat.c | 18 +++--- lib/openat.h | 4 +- lib/pathmax.h | 11 +--- lib/readutmp.c | 10 ++-- lib/readutmp.h | 2 +- lib/rename.c | 22 ++++---- lib/rmdir.c | 11 ++-- lib/same.c | 4 +- lib/savedir.c | 4 +- lib/stripslash.c | 13 +++-- lib/tempname.c | 6 +- lib/userspec.c | 6 -- lib/xreadlink.c | 8 +-- m4/ChangeLog | 15 +++++ m4/{path-concat.m4 => filenamecat.m4} | 10 ++-- m4/getcwd-path-max.m4 | 4 +- m4/{makepath.m4 => mkdir-p.m4} | 10 ++-- m4/rename.m4 | 10 ++-- modules/canonicalize | 2 +- modules/filenamecat | 26 +++++++++ modules/{makepath => mkdir-p} | 12 ++-- modules/path-concat | 27 --------- 51 files changed, 461 insertions(+), 399 deletions(-) rename lib/{path-concat.c => filenamecat.c} (92%) rename lib/{path-concat.h => filenamecat.h} (75%) rename lib/{makepath.c => mkdir-p.c} (80%) rename lib/{makepath.h => mkdir-p.h} (69%) rename m4/{path-concat.m4 => filenamecat.m4} (63%) rename m4/{makepath.m4 => mkdir-p.m4} (70%) create mode 100644 modules/filenamecat rename modules/{makepath => mkdir-p} (62%) delete mode 100644 modules/path-concat diff --git a/ChangeLog b/ChangeLog index 37ff9492f..f3319ad62 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2005-06-02 Paul Eggert + + Sync from coreutils. + Use "file name" when talking about file names, instead of "filename" + or "path", as per the GNU coding standards. + * MODULES.html.sh: mkdir-p renamed from makepath. + filenamecat renamed from path-concat. + * modules/filenamecat: Renamed from modules/path-concat. + (Files): filenamecat.h and filenamecat.c renamed from + path-concat.h and path-concat.c. + (configure.ac): gl_FILE_NAME_CONCAT, not gl_PATH_CONCAT. + (Include): filenamecat.h, not path-concat.h. + * modules/mkdir-p: Renamed from modules/makepath. + (Files): mkdir-p.h and mkdir-p.c renamed from makepath.h and makepath.c. + (configure.ac): gl_MKDIR_PARENTS, not gl_MAKEPATH. + (Include): mkdir-p.h, not makepath.h. + 2005-06-01 Bruno Haible * modules/csharpexec: New file. diff --git a/MODULES.html.sh b/MODULES.html.sh index cd7e5e224..03620bc35 100755 --- a/MODULES.html.sh +++ b/MODULES.html.sh @@ -1817,14 +1817,14 @@ func_all_modules () func_module file-type func_module fileblocks func_module filemode + func_module filenamecat func_module fts func_module fts-lgpl func_module isdir func_module lchown - func_module makepath + func_module mkdir-p func_module modechange func_module mountlist - func_module path-concat func_module pathname func_module pathmax func_module same diff --git a/lib/ChangeLog b/lib/ChangeLog index 31e0a9204..f8269a586 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,56 @@ +2005-06-02 Paul Eggert + + Sync from coreutils. + Use "file name" when talking about file names, instead of "filename" + or "path", as per the GNU coding standards. + * mkdir-p.c: Renamed from makepath.c. + (make_dir_parents): Renamed from make_path. All callers changed. + * mkdir-p.h: Likewise. All includers changed. + * filenamecat.c: Renamed from path-concat.c. + (file_name_concat): Renamed from path_concat. All callers changed. + [TEST_FILE_NAME_CONCAT]: Renamed from TEST_PATH_CONCAT. + * filenamecat.h: Likewise. All includers changed. + * acl.c: Don't use "path" or "filename" to mean "file name" + in comments or local variable names. + * basename.c: Likewise. + * canonicalize.c, canonicalize.h: Likewise. + * dirname.c, dirname.h: Likewise. + * euidaccess.c: Likewise. + * exclude.c: Likewise + * fnmatch_.h, fnmatch_loop.c: Likewise. + * fsusage.c, fsuage.h: Likewise. + * fts.c, fts_.h: Likewise. + * getcwd.c: Likewise. + * getloadavg.c: Likewise. + * mkstemp.c: Likewise. + * mountlist.c, mountlist.h: Likewise. + * openat.c, openat.h: Likewise. + * readlink-stub.c: Likewise. + * readutmp.c, readutmp.h: Likewise. + * rename.c: Likewise. + * rmdir.c: Likewise. + * same.c: Likewise. + * savedir.c: Likewise. + * stripslash.c: Likewise. + * tempname.c: Likewise. + * xreadlink.c: Likewise. + * exclude.c (excluded_file_name): Renamed from excluded_filename. + All uses changed. + * exclude.h: Likewise. + + * euidaccess.c (getuid, getgid, getuid, getegid) + [!defined _POSIX_VERSION]: Remove decls; not needed these days. + * idcache.c (getpwuid, getpwnam, getgrgid, getgrnam) + [!defined _POSIX_VERSION]: Remove decls; not needed these days. + * pathmax.h: Include unconditionally, since other + files have been getting away with it for years (MORE/BSD 4.3 + is extinct now). + * userspec.c (getpwnam, getgrnam, getgrgid) + [!defined _POSIX_VERSION]: Remove decls; not needed these days. + + * pathmax.h (_POSIX_PATH_MAX) [!defined _POSIX_PATH_MAX]: + Define to 256, not 255, as per modern POSIX. + 2005-06-01 Bruno Haible * csharpexec.h: New file, from GNU gettext. diff --git a/lib/acl.c b/lib/acl.c index 4e759cdde..47b73bd23 100644 --- a/lib/acl.c +++ b/lib/acl.c @@ -1,6 +1,6 @@ /* acl.c - access control lists - Copyright (C) 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc. 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 @@ -39,11 +39,11 @@ # define MIN_ACL_ENTRIES 4 #endif -/* Return 1 if PATH has a nontrivial access control list, 0 if not, +/* Return 1 if FILE has a nontrivial access control list, 0 if not, and -1 (setting errno) if an error is encountered. */ int -file_has_acl (char const *path, struct stat const *pathstat) +file_has_acl (char const *file, struct stat const *filestat) { /* FIXME: This implementation should work on recent-enough versions of HP-UX, Solaris, and Unixware, but it simply returns 0 with @@ -52,9 +52,9 @@ file_has_acl (char const *path, struct stat const *pathstat) fix-related ideas. */ #if HAVE_ACL && defined GETACLCNT - if (! S_ISLNK (pathstat->st_mode)) + if (! S_ISLNK (filestat->st_mode)) { - int n = acl (path, GETACLCNT, 0, NULL); + int n = acl (file, GETACLCNT, 0, NULL); return n < 0 ? (errno == ENOSYS ? 0 : -1) : (MIN_ACL_ENTRIES < n); } #endif diff --git a/lib/basename.c b/lib/basename.c index b6de3d610..00adc0015 100644 --- a/lib/basename.c +++ b/lib/basename.c @@ -1,6 +1,6 @@ -/* basename.c -- return the last element in a path +/* basename.c -- return the last element in a file name - Copyright (C) 1990, 1998, 1999, 2000, 2001, 2003, 2004 Free + Copyright (C) 1990, 1998, 1999, 2000, 2001, 2003, 2004, 2005 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify diff --git a/lib/canonicalize.c b/lib/canonicalize.c index 822fe6f75..571fa19e2 100644 --- a/lib/canonicalize.c +++ b/lib/canonicalize.c @@ -48,7 +48,7 @@ void free (); #include #include "cycle-check.h" -#include "path-concat.h" +#include "filenamecat.h" #include "stat-macros.h" #include "xalloc.h" #include "xgetcwd.h" @@ -62,8 +62,8 @@ void free (); #if !HAVE_CANONICALIZE_FILE_NAME /* Return the canonical absolute name of file NAME. A canonical name - does not contain any `.', `..' components nor any repeated path - separators ('/') or symlinks. All path components must exist. + does not contain any `.', `..' components nor any repeated file name + separators ('/') or symlinks. All components must exist. The result is malloc'd. */ char * @@ -89,7 +89,7 @@ canonicalize_file_name (const char *name) /* All known hosts with resolvepath (e.g. Solaris 7) don't turn relative names into absolute ones, so prepend the working - directory if the path is not absolute. */ + directory if the file name is not absolute. */ if (name[0] != '/') { char *wd; @@ -97,7 +97,7 @@ canonicalize_file_name (const char *name) if (!(wd = xgetcwd ())) return NULL; - extra_buf = path_concat (wd, name, NULL); + extra_buf = file_name_concat (wd, name, NULL); name = extra_buf; free (wd); } @@ -135,15 +135,17 @@ canonicalize_file_name (const char *name) #endif /* !HAVE_CANONICALIZE_FILE_NAME */ /* Return the canonical absolute name of file NAME. A canonical name - does not contain any `.', `..' components nor any repeated path - separators ('/') or symlinks. Whether path components must exist + does not contain any `.', `..' components nor any repeated file name + separators ('/') or symlinks. Whether components must exist or not depends on canonicalize mode. The result is malloc'd. */ char * canonicalize_filename_mode (const char *name, canonicalize_mode_t can_mode) { - char *rpath, *dest, *extra_buf = NULL; - const char *start, *end, *rpath_limit; + char *rname, *dest, *extra_buf = NULL; + char const *start; + char const *end; + char const *rname_limit; size_t extra_len = 0; struct cycle_check_state cycle_state; @@ -161,38 +163,38 @@ canonicalize_filename_mode (const char *name, canonicalize_mode_t can_mode) if (name[0] != '/') { - rpath = xgetcwd (); - if (!rpath) + rname = xgetcwd (); + if (!rname) return NULL; - dest = strchr (rpath, '\0'); - if (dest - rpath < PATH_MAX) + dest = strchr (rname, '\0'); + if (dest - rname < PATH_MAX) { - char *p = xrealloc (rpath, PATH_MAX); - dest = p + (dest - rpath); - rpath = p; - rpath_limit = rpath + PATH_MAX; + char *p = xrealloc (rname, PATH_MAX); + dest = p + (dest - rname); + rname = p; + rname_limit = rname + PATH_MAX; } else { - rpath_limit = dest; + rname_limit = dest; } } else { - rpath = xmalloc (PATH_MAX); - rpath_limit = rpath + PATH_MAX; - rpath[0] = '/'; - dest = rpath + 1; + rname = xmalloc (PATH_MAX); + rname_limit = rname + PATH_MAX; + rname[0] = '/'; + dest = rname + 1; } cycle_check_init (&cycle_state); for (start = end = name; *start; start = end) { - /* Skip sequence of multiple path-separators. */ + /* Skip sequence of multiple file name separators. */ while (*start == '/') ++start; - /* Find end of path component. */ + /* Find end of component. */ for (end = start; *end && *end != '/'; ++end) /* Nothing. */; @@ -203,7 +205,7 @@ canonicalize_filename_mode (const char *name, canonicalize_mode_t can_mode) else if (end - start == 2 && start[0] == '.' && start[1] == '.') { /* Back up to previous component, ignore if at root already. */ - if (dest > rpath + 1) + if (dest > rname + 1) while ((--dest)[-1] != '/'); } else @@ -213,26 +215,26 @@ canonicalize_filename_mode (const char *name, canonicalize_mode_t can_mode) if (dest[-1] != '/') *dest++ = '/'; - if (dest + (end - start) >= rpath_limit) + if (dest + (end - start) >= rname_limit) { - ptrdiff_t dest_offset = dest - rpath; - size_t new_size = rpath_limit - rpath; + ptrdiff_t dest_offset = dest - rname; + size_t new_size = rname_limit - rname; if (end - start + 1 > PATH_MAX) new_size += end - start + 1; else new_size += PATH_MAX; - rpath = xrealloc (rpath, new_size); - rpath_limit = rpath + new_size; + rname = xrealloc (rname, new_size); + rname_limit = rname + new_size; - dest = rpath + dest_offset; + dest = rname + dest_offset; } dest = memcpy (dest, start, end - start); dest += end - start; *dest = '\0'; - if (lstat (rpath, &st) < 0) + if (lstat (rname, &st) != 0) { if (can_mode == CAN_EXISTING) goto error; @@ -255,7 +257,7 @@ canonicalize_filename_mode (const char *name, canonicalize_mode_t can_mode) goto error; } - buf = xreadlink (rpath, st.st_size); + buf = xreadlink (rname, st.st_size); if (!buf) { if (can_mode == CAN_MISSING) @@ -284,10 +286,10 @@ canonicalize_filename_mode (const char *name, canonicalize_mode_t can_mode) name = end = memcpy (extra_buf, buf, n); if (buf[0] == '/') - dest = rpath + 1; /* It's an absolute symlink */ + dest = rname + 1; /* It's an absolute symlink */ else /* Back up to previous component, ignore if at root already: */ - if (dest > rpath + 1) + if (dest > rname + 1) while ((--dest)[-1] != '/'); free (buf); @@ -302,15 +304,15 @@ canonicalize_filename_mode (const char *name, canonicalize_mode_t can_mode) } } } - if (dest > rpath + 1 && dest[-1] == '/') + if (dest > rname + 1 && dest[-1] == '/') --dest; *dest = '\0'; free (extra_buf); - return rpath; + return rname; error: free (extra_buf); - free (rpath); + free (rname); return NULL; } diff --git a/lib/canonicalize.h b/lib/canonicalize.h index 4c9596f98..4cae3c551 100644 --- a/lib/canonicalize.h +++ b/lib/canonicalize.h @@ -1,5 +1,5 @@ /* Return the canonical absolute name of a given file. - Copyright (C) 1996-2004 Free Software Foundation, Inc. + Copyright (C) 1996-2005 Free Software Foundation, Inc. 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 @@ -21,10 +21,10 @@ enum canonicalize_mode_t { - /* All path components must exist. */ + /* All components must exist. */ CAN_EXISTING = 0, - /* All path components excluding last one must exist. */ + /* All components excluding last one must exist. */ CAN_ALL_BUT_LAST = 1, /* No requirements on components existence. */ diff --git a/lib/dirname.c b/lib/dirname.c index 9b6007656..f1930c8d2 100644 --- a/lib/dirname.c +++ b/lib/dirname.c @@ -1,6 +1,6 @@ -/* dirname.c -- return all but the last element in a path +/* dirname.c -- return all but the last element in a file name - Copyright (C) 1990, 1998, 2000, 2001, 2003, 2004 Free Software + Copyright (C) 1990, 1998, 2000, 2001, 2003, 2004, 2005 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify @@ -26,40 +26,40 @@ #include #include "xalloc.h" -/* Return the length of `dirname (PATH)', or zero if PATH is +/* Return the length of `dirname (FILE)', or zero if FILE is in the working directory. Works properly even if there are trailing slashes (by effectively ignoring them). */ size_t -dir_len (char const *path) +dir_len (char const *file) { - size_t prefix_length = FILE_SYSTEM_PREFIX_LEN (path); + size_t prefix_length = FILE_SYSTEM_PREFIX_LEN (file); size_t length; /* Strip the basename and any redundant slashes before it. */ - for (length = base_name (path) - path; prefix_length < length; length--) - if (! ISSLASH (path[length - 1])) + for (length = base_name (file) - file; prefix_length < length; length--) + if (! ISSLASH (file[length - 1])) return length; /* But don't strip the only slash from "/". */ - return prefix_length + ISSLASH (path[prefix_length]); + return prefix_length + ISSLASH (file[prefix_length]); } -/* Return the leading directories part of PATH, +/* Return the leading directories part of FILE, allocated with xmalloc. Works properly even if there are trailing slashes (by effectively ignoring them). */ char * -dir_name (char const *path) +dir_name (char const *file) { - size_t length = dir_len (path); - bool append_dot = (length == FILE_SYSTEM_PREFIX_LEN (path)); - char *newpath = xmalloc (length + append_dot + 1); - memcpy (newpath, path, length); + size_t length = dir_len (file); + bool append_dot = (length == FILE_SYSTEM_PREFIX_LEN (file)); + char *dir = xmalloc (length + append_dot + 1); + memcpy (dir, file, length); if (append_dot) - newpath[length++] = '.'; - newpath[length] = 0; - return newpath; + dir[length++] = '.'; + dir[length] = 0; + return dir; } #ifdef TEST_DIRNAME @@ -108,13 +108,13 @@ main (int argc, char *argv[]) buff[MAX_BUFF_LEN] = 0; while (fgets (buff, MAX_BUFF_LEN, stdin) && buff[0]) { - char path[MAX_BUFF_LEN]; + char file[MAX_BUFF_LEN]; char expected_result[MAX_BUFF_LEN]; char const *result; - sscanf (buff, "%s %s", path, expected_result); - result = dir_name (path); + sscanf (buff, "%s %s", file, expected_result); + result = dir_name (file); if (strcmp (result, expected_result)) - printf ("%s: got %s, expected %s\n", path, result, expected_result); + printf ("%s: got %s, expected %s\n", file, result, expected_result); } return 0; } diff --git a/lib/dirname.h b/lib/dirname.h index 5c3c93050..1688ae810 100644 --- a/lib/dirname.h +++ b/lib/dirname.h @@ -1,6 +1,6 @@ /* Take file names apart into directory and base names. - Copyright (C) 1998, 2001, 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 1998, 2001, 2003, 2004, 2005 Free Software Foundation, Inc. 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 @@ -31,17 +31,17 @@ # endif # ifndef FILE_SYSTEM_PREFIX_LEN -# define FILE_SYSTEM_PREFIX_LEN(Filename) 0 +# define FILE_SYSTEM_PREFIX_LEN(File_name) 0 # endif # define IS_ABSOLUTE_FILE_NAME(F) ISSLASH ((F)[FILE_SYSTEM_PREFIX_LEN (F)]) # define IS_RELATIVE_FILE_NAME(F) (! IS_ABSOLUTE_FILE_NAME (F)) -char *base_name (char const *path); -char *dir_name (char const *path); -size_t base_len (char const *path); -size_t dir_len (char const *path); +char *base_name (char const *file); +char *dir_name (char const *file); +size_t base_len (char const *file); +size_t dir_len (char const *file); -bool strip_trailing_slashes (char *path); +bool strip_trailing_slashes (char *file); #endif /* not DIRNAME_H_ */ diff --git a/lib/euidaccess.c b/lib/euidaccess.c index 7f8c238e2..4bb93aa0b 100644 --- a/lib/euidaccess.c +++ b/lib/euidaccess.c @@ -1,6 +1,6 @@ /* euidaccess -- check if effective user id can access file - Copyright (C) 1990, 1991, 1995, 1998, 2000, 2003, 2004 Free + Copyright (C) 1990, 1991, 1995, 1998, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -41,13 +41,6 @@ # include #endif -#ifndef _POSIX_VERSION -uid_t getuid (); -gid_t getgid (); -uid_t geteuid (); -gid_t getegid (); -#endif - #include #ifndef __set_errno # define __set_errno(val) errno = (val) @@ -84,21 +77,21 @@ gid_t getegid (); #endif -/* Return 0 if the user has permission of type MODE on file PATH; +/* Return 0 if the user has permission of type MODE on FILE; otherwise, return -1 and set `errno'. Like access, except that it uses the effective user and group id's instead of the real ones, and it does not always check for read-only file system, text busy, etc. */ int -euidaccess (const char *path, int mode) +euidaccess (const char *file, int mode) { #if defined EFF_ONLY_OK - return access (path, mode | EFF_ONLY_OK); + return access (file, mode | EFF_ONLY_OK); #elif defined ACC_SELF - return accessx (path, mode, ACC_SELF); + return accessx (file, mode, ACC_SELF); #elif HAVE_EACCESS - return eaccess (path, mode); + return eaccess (file, mode); #else uid_t uid = getuid (); @@ -117,7 +110,7 @@ euidaccess (const char *path, int mode) safe. */ if (mode == F_OK) - return stat (path, &stats); + return stat (file, &stats); else { int result; @@ -128,7 +121,7 @@ euidaccess (const char *path, int mode) if (gid != egid) setregid (egid, gid); - result = access (path, mode); + result = access (file, mode); saved_errno = errno; /* Restore them. */ @@ -150,9 +143,9 @@ euidaccess (const char *path, int mode) unsigned int granted; if (uid == euid && gid == egid) /* If we are not set-uid or set-gid, access does the same. */ - return access (path, mode); + return access (file, mode); - if (stat (path, &stats)) + if (stat (file, &stats) != 0) return -1; /* The super-user can read and write any file, and execute any file diff --git a/lib/exclude.c b/lib/exclude.c index 39101c783..955c28956 100644 --- a/lib/exclude.c +++ b/lib/exclude.c @@ -1,7 +1,7 @@ /* exclude.c -- exclude file names Copyright (C) 1992, 1993, 1994, 1997, 1999, 2000, 2001, 2002, 2003, - 2004 Free Software Foundation, Inc. + 2004, 2005 Free Software Foundation, Inc. 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 @@ -134,7 +134,7 @@ fnmatch_no_wildcards (char const *pattern, char const *f, int options) /* Return true if EX excludes F. */ bool -excluded_filename (struct exclude const *ex, char const *f) +excluded_file_name (struct exclude const *ex, char const *f) { size_t exclude_count = ex->exclude_count; @@ -193,17 +193,17 @@ add_exclude (struct exclude *ex, char const *pattern, int options) patopts->options = options; } -/* Use ADD_FUNC to append to EX the patterns in FILENAME, each with +/* Use ADD_FUNC to append to EX the patterns in FILE_NAME, each with OPTIONS. LINE_END terminates each pattern in the file. If LINE_END is a space character, ignore trailing spaces and empty lines in FILE. Return -1 on failure, 0 on success. */ int add_exclude_file (void (*add_func) (struct exclude *, char const *, int), - struct exclude *ex, char const *filename, int options, + struct exclude *ex, char const *file_name, int options, char line_end) { - bool use_stdin = filename[0] == '-' && !filename[1]; + bool use_stdin = file_name[0] == '-' && !file_name[1]; FILE *in; char *buf = NULL; char *p; @@ -216,7 +216,7 @@ add_exclude_file (void (*add_func) (struct exclude *, char const *, int), if (use_stdin) in = stdin; - else if (! (in = fopen (filename, "r"))) + else if (! (in = fopen (file_name, "r"))) return -1; while ((c = getc (in)) != EOF) diff --git a/lib/exclude.h b/lib/exclude.h index 784d4389c..6923efa5f 100644 --- a/lib/exclude.h +++ b/lib/exclude.h @@ -1,7 +1,7 @@ /* exclude.h -- declarations for excluding file names - Copyright (C) 1992, 1993, 1994, 1997, 1999, 2001, 2002, 2003 Free - Software Foundation, Inc. + Copyright (C) 1992, 1993, 1994, 1997, 1999, 2001, 2002, 2003, 2005 + Free Software Foundation, Inc. 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 @@ -40,4 +40,4 @@ void free_exclude (struct exclude *); void add_exclude (struct exclude *, char const *, int); int add_exclude_file (void (*) (struct exclude *, char const *, int), struct exclude *, char const *, int, char); -bool excluded_filename (struct exclude const *, char const *); +bool excluded_file_name (struct exclude const *, char const *); diff --git a/lib/path-concat.c b/lib/filenamecat.c similarity index 92% rename from lib/path-concat.c rename to lib/filenamecat.c index 364081f15..f56697a6d 100644 --- a/lib/path-concat.c +++ b/lib/filenamecat.c @@ -1,4 +1,4 @@ -/* path-concat.c -- concatenate two arbitrary pathnames +/* Concatenate two arbitrary file names. Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. @@ -24,7 +24,7 @@ #endif /* Specification. */ -#include "path-concat.h" +#include "filenamecat.h" #include @@ -46,7 +46,7 @@ longest_relative_suffix (char const *f) return f; } -/* Concatenate two pathname components, DIR and ABASE, in +/* Concatenate two file name components, DIR and ABASE, in newly-allocated storage and return the result. The resulting file name F is such that the commands "ls F" and "(cd DIR; ls BASE)" refer to the same file, where BASE is ABASE with any @@ -62,7 +62,7 @@ longest_relative_suffix (char const *f) Report an error if memory is exhausted. */ char * -path_concat (char const *dir, char const *abase, char **base_in_result) +file_name_concat (char const *dir, char const *abase, char **base_in_result) { char const *dirbase = base_name (dir); size_t dirbaselen = base_len (dirbase); @@ -88,7 +88,7 @@ path_concat (char const *dir, char const *abase, char **base_in_result) return p_concat; } -#ifdef TEST_PATH_CONCAT +#ifdef TEST_FILE_NAME_CONCAT # include # include int @@ -114,7 +114,7 @@ main () { char *base_in_result; char const *const *t = tests[i]; - char *res = path_concat (t[0], t[1], &base_in_result); + char *res = file_name_concat (t[0], t[1], &base_in_result); if (strcmp (res, t[2]) != 0) { printf ("got %s, expected %s\n", res, t[2]); diff --git a/lib/path-concat.h b/lib/filenamecat.h similarity index 75% rename from lib/path-concat.h rename to lib/filenamecat.h index 7121796af..c943b67d7 100644 --- a/lib/path-concat.h +++ b/lib/filenamecat.h @@ -1,6 +1,6 @@ -/* Concatenate two arbitrary pathnames. +/* Concatenate two arbitrary file names. - Copyright (C) 1996, 1997, 2003 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 2003, 2005 Free Software Foundation, Inc. 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 @@ -18,9 +18,5 @@ /* Written by Jim Meyering. */ -#if ! defined PATH_CONCAT_H_ -# define PATH_CONCAT_H_ - -char *path_concat (const char *dir, const char *base, char **base_in_result); - -#endif +char *file_name_concat (char const *dir, char const *base, + char **base_in_result); diff --git a/lib/fnmatch_.h b/lib/fnmatch_.h index a88d323a3..fecada57f 100644 --- a/lib/fnmatch_.h +++ b/lib/fnmatch_.h @@ -1,5 +1,5 @@ -/* Copyright (C) 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2001, 2002, 2003 - Free Software Foundation, Inc. +/* Copyright (C) 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2001, 2002, 2003, + 2005 Free Software Foundation, Inc. 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 @@ -51,7 +51,7 @@ extern "C" { # define FNM_NOSYS (-1) # endif -/* Match NAME against the filename pattern PATTERN, +/* Match NAME against the file name pattern PATTERN, returning zero if it matches, FNM_NOMATCH if not. */ extern int fnmatch (const char *__pattern, const char *__name, int __flags); diff --git a/lib/fnmatch_loop.c b/lib/fnmatch_loop.c index feb73c1b1..35d598061 100644 --- a/lib/fnmatch_loop.c +++ b/lib/fnmatch_loop.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991,1992,1993,1996,1997,1998,1999,2000,2001,2002,2003,2004 +/* Copyright (C) 1991,1992,1993,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify @@ -15,7 +15,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -/* Match STRING against the filename pattern PATTERN, returning zero if +/* Match STRING against the file name pattern PATTERN, returning zero if it matches, nonzero if not. */ static int EXT (INT opt, const CHAR *pattern, const CHAR *string, const CHAR *string_end, bool no_leading_period, int flags) diff --git a/lib/fsusage.c b/lib/fsusage.c index d2a6cc21f..972d88f12 100644 --- a/lib/fsusage.c +++ b/lib/fsusage.c @@ -1,7 +1,7 @@ /* fsusage.c -- return space usage of mounted file systems - Copyright (C) 1991, 1992, 1996, 1998, 1999, 2002, 2003, 2004 Free - Software Foundation, Inc. + Copyright (C) 1991, 1992, 1996, 1998, 1999, 2002, 2003, 2004, 2005 + Free Software Foundation, Inc. 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 @@ -103,20 +103,20 @@ #define PROPAGATE_TOP_BIT(x) ((x) | ~ (EXTRACT_TOP_BIT (x) - 1)) /* Fill in the fields of FSP with information about space usage for - the file system on which PATH resides. - DISK is the device on which PATH is mounted, for space-getting + the file system on which FILE resides. + DISK is the device on which FILE is mounted, for space-getting methods that need to know it. Return 0 if successful, -1 if not. When returning -1, ensure that ERRNO is either a system error value, or zero if DISK is NULL on a system that requires a non-NULL value. */ int -get_fs_usage (const char *path, const char *disk, struct fs_usage *fsp) +get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp) { #ifdef STAT_STATFS3_OSF1 struct statfs fsd; - if (statfs (path, &fsd, sizeof (struct statfs)) != 0) + if (statfs (file, &fsd, sizeof (struct statfs)) != 0) return -1; fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_fsize); @@ -127,7 +127,7 @@ get_fs_usage (const char *path, const char *disk, struct fs_usage *fsp) struct fs_data fsd; - if (statfs (path, &fsd) != 1) + if (statfs (file, &fsd) != 1) return -1; fsp->fsu_blocksize = 1024; @@ -181,7 +181,7 @@ get_fs_usage (const char *path, const char *disk, struct fs_usage *fsp) struct statfs fsd; - if (statfs (path, &fsd) < 0) + if (statfs (file, &fsd) < 0) return -1; fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_bsize); @@ -207,7 +207,7 @@ get_fs_usage (const char *path, const char *disk, struct fs_usage *fsp) struct statfs fsd; - if (statfs (path, &fsd) < 0) + if (statfs (file, &fsd) < 0) return -1; fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_fsize); @@ -222,7 +222,7 @@ get_fs_usage (const char *path, const char *disk, struct fs_usage *fsp) struct statfs fsd; - if (statfs (path, &fsd, sizeof fsd, 0) < 0) + if (statfs (file, &fsd, sizeof fsd, 0) < 0) return -1; /* Empirically, the block counts on most SVR3 and SVR3-derived @@ -240,7 +240,7 @@ get_fs_usage (const char *path, const char *disk, struct fs_usage *fsp) struct statvfs fsd; - if (statvfs (path, &fsd) < 0) + if (statvfs (file, &fsd) < 0) return -1; /* f_frsize isn't guaranteed to be supported. */ @@ -269,12 +269,12 @@ get_fs_usage (const char *path, const char *disk, struct fs_usage *fsp) /* AIX PS/2 does not supply statfs. */ int -statfs (char *path, struct statfs *fsb) +statfs (char *file, struct statfs *fsb) { struct stat stats; struct dustat fsd; - if (stat (path, &stats)) + if (stat (file, &stats) != 0) return -1; if (dustat (stats.st_dev, 0, &fsd, sizeof (fsd))) return -1; diff --git a/lib/fsusage.h b/lib/fsusage.h index 2d4172a39..f3eda2d09 100644 --- a/lib/fsusage.h +++ b/lib/fsusage.h @@ -1,6 +1,6 @@ /* fsusage.h -- declarations for file system space usage info - Copyright (C) 1991, 1992, 1997, 2003, 2004 Free Software + Copyright (C) 1991, 1992, 1997, 2003, 2004, 2005 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify @@ -35,6 +35,6 @@ struct fs_usage uintmax_t fsu_ffree; /* Free file nodes. */ }; -int get_fs_usage (const char *path, const char *disk, struct fs_usage *fsp); +int get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp); #endif diff --git a/lib/fts-cycle.c b/lib/fts-cycle.c index a0310c2e5..0fb1a03c7 100644 --- a/lib/fts-cycle.c +++ b/lib/fts-cycle.c @@ -21,7 +21,7 @@ #include "cycle-check.h" #include "hash.h" -/* Use these each of these to map a device/inode pair to an FTSENT. */ +/* Use each of these to map a device/inode pair to an FTSENT. */ struct Active_dir { dev_t dev; diff --git a/lib/fts.c b/lib/fts.c index a9abe0f10..d3bef85f3 100644 --- a/lib/fts.c +++ b/lib/fts.c @@ -244,8 +244,8 @@ fts_open (char * const *argv, SET(FTS_NOCHDIR); /* - * Start out with 1K of path space, and enough, in any case, - * to hold the user's paths. + * Start out with 1K of file name space, and enough, in any case, + * to hold the user's file names. */ #ifndef MAXPATHLEN # define MAXPATHLEN 1024 @@ -260,7 +260,7 @@ fts_open (char * const *argv, /* Allocate/initialize root(s). */ for (root = NULL, nitems = 0; *argv != NULL; ++argv, ++nitems) { - /* Don't allow zero-length paths. */ + /* Don't allow zero-length file names. */ if ((len = strlen(*argv)) == 0) { __set_errno (ENOENT); goto mem3; @@ -311,7 +311,7 @@ fts_open (char * const *argv, /* * If using chdir(2), grab a file descriptor pointing to dot to ensure - * that we can get back here; this could be avoided for some paths, + * that we can get back here; this could be avoided for some file names, * but almost certainly not worth the effort. Slashes, symbolic links, * and ".." are all fairly nasty problems. Note, if we can't get the * descriptor we run anyway, just more slowly. @@ -341,7 +341,7 @@ fts_load (FTS *sp, register FTSENT *p) * actually enter the directory until after the preorder visit, set * the fts_accpath field specially so the chdir gets done to the right * place and the user can access the first node. From fts_open it's - * known that the path will fit. + * known that the file name will fit. */ len = p->fts_pathlen = p->fts_namelen; memmove(sp->fts_path, p->fts_name, len + 1); @@ -374,7 +374,7 @@ fts_close (FTS *sp) free(p); } - /* Free up child linked list, sort array, path buffer. */ + /* Free up child linked list, sort array, file name buffer. */ if (sp->fts_child) fts_lfree(sp->fts_child); if (sp->fts_array) @@ -403,8 +403,8 @@ fts_close (FTS *sp) } /* - * Special case of "/" at the end of the path so that slashes aren't - * appended which would cause paths to be written as "....//foo". + * Special case of "/" at the end of the file name so that slashes aren't + * appended which would cause file names to be written as "....//foo". */ #define NAPPEND(p) \ (p->fts_path[p->fts_pathlen - 1] == '/' \ @@ -524,7 +524,8 @@ next: tmp = p; /* * If reached the top, return to the original directory (or - * the root of the tree), and load the paths for the next root. + * the root of the tree), and load the file names for the next + * root. */ if (p->fts_level == FTS_ROOTLEVEL) { if (FCHDIR(sp, sp->fts_rfd)) { @@ -585,7 +586,7 @@ check_for_dir: return (sp->fts_cur = NULL); } - /* NUL terminate the pathname. */ + /* NUL terminate the file name. */ sp->fts_path[p->fts_pathlen] = '\0'; /* @@ -685,8 +686,8 @@ fts_children (register FTS *sp, int instr) instr = BCHILD; /* - * If using chdir on a relative path and called BEFORE fts_read does - * its chdir to the root of a traversal, we can lose -- we need to + * If using chdir on a relative file name and called BEFORE fts_read + * does its chdir to the root of a traversal, we can lose -- we need to * chdir into the subdirectory, and we don't know where the current * directory is, so we can't get back so that the upcoming chdir by * fts_read will work. @@ -753,7 +754,7 @@ fts_build (register FTS *sp, int type) else oflag = DTF_HIDEW|DTF_NODUP|DTF_REWIND; #else -# define __opendir2(path, flag) opendir(path) +# define __opendir2(file, flag) opendir(file) #endif if ((dirp = __opendir2(cur->fts_accpath, oflag)) == NULL) { if (type == BREAD) { @@ -787,7 +788,7 @@ fts_build (register FTS *sp, int type) * but set a flag so we don't chdir after the post-order visit. * We won't be able to stat anything, but we can still return the * names themselves. Note, that since fts_read won't be able to - * chdir into the directory, it will have to return different path + * chdir into the directory, it will have to return different file * names than before, i.e. "a/b" instead of "b". Since the node * has already been visited in pre-order, have to wait until the * post-order visit to return the error. There is a special case @@ -813,13 +814,13 @@ fts_build (register FTS *sp, int type) /* * Figure out the max file name length that can be stored in the - * current path -- the inner loop allocates more path as necessary. + * current buffer -- the inner loop allocates more space as necessary. * We really wouldn't have to do the maxlen calculations here, we - * could do them in fts_read before returning the path, but it's a + * could do them in fts_read before returning the name, but it's a * lot easier here since the length is part of the dirent structure. * * If not changing directories set a pointer so that can just append - * each new name into the path. + * each new component into the file name. */ len = NAPPEND(cur); if (ISSET(FTS_NOCHDIR)) { @@ -846,7 +847,7 @@ fts_build (register FTS *sp, int type) oldaddr = sp->fts_path; if (! fts_palloc(sp, NAMLEN (dp) + len + 1)) { /* - * No more memory for path or structures. Save + * No more memory. Save * errno, free up the current structure and the * structures already allocated. */ @@ -873,7 +874,7 @@ mem1: saved_errno = errno; if (new_len < len) { /* * In the unlikely even that we would end up - * with a path longer than SIZE_MAX, free up + * with a file name longer than SIZE_MAX, free up * the current structure and the structures already * allocated, then error out with ENAMETOOLONG. */ @@ -940,14 +941,14 @@ mem1: saved_errno = errno; closedir(dirp); /* - * If realloc() changed the address of the path, adjust the + * If realloc() changed the address of the file name, adjust the * addresses for the rest of the tree and the dir list. */ if (doadjust) fts_padjust(sp, head); /* - * If not changing directories, reset the path back to original + * If not changing directories, reset the file name back to original * state. */ if (ISSET(FTS_NOCHDIR)) { @@ -959,7 +960,7 @@ mem1: saved_errno = errno; /* * If descended after called from fts_children or after called from * fts_read and nothing found, get back. At the root level we use - * the saved fd; if one of fts_open()'s arguments is a relative path + * the saved fd; if one of fts_open()'s arguments is a relative name * to an empty directory, we wind up here with no other way back. If * can't get back, we're done. */ @@ -1226,10 +1227,11 @@ fts_lfree (register FTSENT *head) } /* - * Allow essentially unlimited paths; find, rm, ls should all work on any tree. - * Most systems will allow creation of paths much longer than MAXPATHLEN, even - * though the kernel won't resolve them. Add the size (not just what's needed) - * plus 256 bytes so don't realloc the path 2 bytes at a time. + * Allow essentially unlimited file name lengths; find, rm, ls should + * all work on any tree. Most systems will allow creation of file + * names much longer than MAXPATHLEN, even though the kernel won't + * resolve them. Add the size (not just what's needed) plus 256 bytes + * so don't realloc the file name 2 bytes at a time. */ static bool internal_function @@ -1262,8 +1264,8 @@ fts_palloc (FTS *sp, size_t more) } /* - * When the path is realloc'd, have to fix all of the pointers in structures - * already returned. + * When the file name is realloc'd, have to fix all of the pointers in + * structures already returned. */ static void internal_function @@ -1303,13 +1305,13 @@ fts_maxarglen (char * const *argv) } /* - * Change to dir specified by fd or path without getting + * Change to dir specified by fd or file name without getting * tricked by someone changing the world out from underneath us. * Assumes p->fts_statp->st_dev and p->fts_statp->st_ino are filled in. */ static int internal_function -fts_safe_changedir (FTS *sp, FTSENT *p, int fd, char const *path) +fts_safe_changedir (FTS *sp, FTSENT *p, int fd, char const *dir) { int ret, oerrno, newfd; struct stat sb; @@ -1317,7 +1319,7 @@ fts_safe_changedir (FTS *sp, FTSENT *p, int fd, char const *path) newfd = fd; if (ISSET(FTS_NOCHDIR)) return (0); - if (fd < 0 && (newfd = fd_safer (diropen (path))) < 0) + if (fd < 0 && (newfd = fd_safer (diropen (dir))) < 0) return (-1); if (fstat(newfd, &sb)) { ret = -1; diff --git a/lib/fts_.h b/lib/fts_.h index 954ba569b..4bf903bd3 100644 --- a/lib/fts_.h +++ b/lib/fts_.h @@ -71,7 +71,7 @@ typedef struct { struct _ftsent *fts_child; /* linked list of children */ struct _ftsent **fts_array; /* sort array */ dev_t fts_dev; /* starting device # */ - char *fts_path; /* path for this descent */ + char *fts_path; /* file name for this descent */ int fts_rfd; /* fd for root */ size_t fts_pathlen; /* sizeof(path) */ size_t fts_nitems; /* elements in the sort array */ @@ -135,8 +135,8 @@ typedef struct _ftsent { struct _ftsent *fts_link; /* next file in directory */ long fts_number; /* local numeric value */ void *fts_pointer; /* local address value */ - char *fts_accpath; /* access path */ - char *fts_path; /* root path; == fts_fts->fts_path */ + char *fts_accpath; /* access file name */ + char *fts_path; /* root name; == fts_fts->fts_path */ int fts_errno; /* errno for this node */ int fts_symfd; /* fd for symlink */ size_t fts_pathlen; /* strlen(fts_path) */ 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; diff --git a/lib/getloadavg.c b/lib/getloadavg.c index 6be6e3716..8fe542fbb 100644 --- a/lib/getloadavg.c +++ b/lib/getloadavg.c @@ -32,7 +32,7 @@ AC_CHECK_FUNCS(pstat_getdynamic) in your configure.in file. FIXUP_KERNEL_SYMBOL_ADDR() Adjust address in returned struct nlist. - KERNEL_FILE Pathname of the kernel to nlist. + KERNEL_FILE Name of the kernel file to nlist. LDAV_CVT() Scale the load average from the kernel. Returns a double. LDAV_SYMBOL Name of kernel symbol giving load average. diff --git a/lib/idcache.c b/lib/idcache.c index 87c85d809..b3de8bbaf 100644 --- a/lib/idcache.c +++ b/lib/idcache.c @@ -1,6 +1,7 @@ /* idcache.c -- map user and group IDs, cached for speed - Copyright (C) 1985, 1988, 1989, 1990, 1997, 1998, 2003 Free Software - Foundation, Inc. + + Copyright (C) 1985, 1988, 1989, 1990, 1997, 1998, 2003, 2005 Free + Software Foundation, Inc. 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 @@ -32,13 +33,6 @@ #include "xalloc.h" -#ifndef _POSIX_VERSION -struct passwd *getpwuid (); -struct passwd *getpwnam (); -struct group *getgrgid (); -struct group *getgrnam (); -#endif - #ifdef __DJGPP__ static char digits[] = "0123456789"; #endif diff --git a/lib/makepath.c b/lib/mkdir-p.c similarity index 80% rename from lib/makepath.c rename to lib/mkdir-p.c index 19ad1f4a8..433d871ae 100644 --- a/lib/makepath.c +++ b/lib/mkdir-p.c @@ -1,4 +1,4 @@ -/* makepath.c -- Ensure that a directory path exists. +/* mkdir-p.c -- Ensure that a directory and its parents exist. Copyright (C) 1990, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. @@ -23,7 +23,7 @@ # include #endif -#include "makepath.h" +#include "mkdir-p.h" #include @@ -78,16 +78,16 @@ } \ while (0) -/* Attempt to create directory DIR (aka DIRPATH) with the specified MODE. +/* Attempt to create directory DIR (aka FULLDIR) with the specified MODE. If CREATED_DIR_P is non-NULL, set *CREATED_DIR_P if this function creates DIR and clear it otherwise. Give a diagnostic and return false if DIR cannot be created or cannot be determined to - exist already. Use DIRPATH in any diagnostic, not DIR. + exist already. Use FULLDIR in any diagnostic, not DIR. Note that if DIR already exists, this function returns true (indicating success) and clears *CREATED_DIR_P. */ bool -make_dir (const char *dir, const char *dirpath, mode_t mode, +make_dir (char const *dir, char const *fulldir, mode_t mode, bool *created_dir_p) { bool ok = true; @@ -111,17 +111,17 @@ make_dir (const char *dir, const char *dirpath, mode_t mode, if (stat (dir, &stats)) { error (0, saved_errno, _("cannot create directory %s"), - quote (dirpath)); + quote (fulldir)); ok = false; } else if (!S_ISDIR (stats.st_mode)) { - error (0, 0, _("%s exists but is not a directory"), quote (dirpath)); + error (0, 0, _("%s exists but is not a directory"), quote (fulldir)); ok = false; } else { - /* DIR (aka DIRPATH) already exists and is a directory. */ + /* DIR (aka FULLDIR) already exists and is a directory. */ } } @@ -131,36 +131,36 @@ make_dir (const char *dir, const char *dirpath, mode_t mode, return ok; } -/* Ensure that the directory ARGPATH exists. +/* Ensure that the directory ARG exists. Create any leading directories that don't already exist, with permissions PARENT_MODE. - If the last element of ARGPATH does not exist, create it as + If the last element of ARG does not exist, create it as a new directory with permissions MODE. If OWNER and GROUP are non-negative, use them to set the UID and GID of any created directories. If VERBOSE_FMT_STRING is nonzero, use it as a printf format string for printing a message after successfully making a directory, with the name of the directory that was just made as an argument. - If PRESERVE_EXISTING is true and ARGPATH is an existing directory, + If PRESERVE_EXISTING is true and ARG is an existing directory, then do not attempt to set its permissions and ownership. - Return true iff ARGPATH exists as a directory with the proper + Return true iff ARG exists as a directory with the proper ownership and permissions when done. */ bool -make_path (const char *argpath, - mode_t mode, - mode_t parent_mode, - uid_t owner, - gid_t group, - bool preserve_existing, - const char *verbose_fmt_string) +make_dir_parents (char const *arg, + mode_t mode, + mode_t parent_mode, + uid_t owner, + gid_t group, + bool preserve_existing, + char const *verbose_fmt_string) { struct stat stats; bool retval = true; - if (stat (argpath, &stats)) + if (stat (arg, &stats) != 0) { char *slash; mode_t tmp_mode; /* Initial perms for leading dirs. */ @@ -174,15 +174,15 @@ make_path (const char *argpath, bool do_chdir; /* Whether to chdir before each mkdir. */ struct saved_cwd cwd; char *basename_dir; - char *dirpath; + char *dir; /* Temporarily relax umask in case it's overly restrictive. */ mode_t oldmask = umask (0); - /* Make a copy of ARGPATH that we can scribble NULs on. */ - dirpath = (char *) alloca (strlen (argpath) + 1); - strcpy (dirpath, argpath); - strip_trailing_slashes (dirpath); + /* Make a copy of ARG that we can scribble NULs on. */ + dir = (char *) alloca (strlen (arg) + 1); + strcpy (dir, arg); + strip_trailing_slashes (dir); /* If leading directories shouldn't be writable or executable, or should have set[ug]id or sticky bits set and we are setting @@ -204,19 +204,19 @@ make_path (const char *argpath, to do the chdir optimization. */ do_chdir = (save_cwd (&cwd) == 0); - /* If we've saved the cwd and DIRPATH is an absolute pathname, + /* If we've saved the cwd and DIR is an absolute file name, we must chdir to `/' in order to enable the chdir optimization. So if chdir ("/") fails, turn off the optimization. */ - if (do_chdir && dirpath[0] == '/') + if (do_chdir && dir[0] == '/') { /* POSIX says "//" might be special, so chdir to "//" if the file name starts with exactly two slashes. */ - char const *root = "//" + (dirpath[1] != '/' || dirpath[2] == '/'); + char const *root = "//" + (dir[1] != '/' || dir[2] == '/'); if (chdir (root) != 0) do_chdir = false; } - slash = dirpath; + slash = dir; /* Skip over leading slashes. */ while (*slash == '/') @@ -226,7 +226,7 @@ make_path (const char *argpath, { bool newly_created_dir; - /* slash points to the leftmost unprocessed component of dirpath. */ + /* slash points to the leftmost unprocessed component of dir. */ basename_dir = slash; slash = strchr (slash, '/'); @@ -236,10 +236,10 @@ make_path (const char *argpath, /* If we're *not* doing chdir before each mkdir, then we have to refer to the target using the full (multi-component) directory name. */ if (!do_chdir) - basename_dir = dirpath; + basename_dir = dir; *slash = '\0'; - if (! make_dir (basename_dir, dirpath, tmp_mode, &newly_created_dir)) + if (! make_dir (basename_dir, dir, tmp_mode, &newly_created_dir)) { CLEANUP; return false; @@ -248,7 +248,7 @@ make_path (const char *argpath, if (newly_created_dir) { if (verbose_fmt_string) - error (0, 0, verbose_fmt_string, quote (dirpath)); + error (0, 0, verbose_fmt_string, quote (dir)); if ((owner != (uid_t) -1 || group != (gid_t) -1) && chown (basename_dir, owner, group) @@ -258,7 +258,7 @@ make_path (const char *argpath, ) { error (0, errno, _("cannot change owner and/or group of %s"), - quote (dirpath)); + quote (dir)); CLEANUP; return false; } @@ -280,7 +280,7 @@ make_path (const char *argpath, if (do_chdir && chdir (basename_dir) < 0) { error (0, errno, _("cannot chdir to directory %s"), - quote (dirpath)); + quote (dir)); CLEANUP; return false; } @@ -288,28 +288,28 @@ make_path (const char *argpath, *slash++ = '/'; /* Avoid unnecessary calls to `stat' when given - pathnames containing multiple adjacent slashes. */ + file names containing multiple adjacent slashes. */ while (*slash == '/') slash++; } if (!do_chdir) - basename_dir = dirpath; + basename_dir = dir; /* Done creating leading directories. Restore original umask. */ umask (oldmask); /* We're done making leading directories. - Create the final component of the path. */ + Create the final component of the file name. */ - if (! make_dir (basename_dir, dirpath, mode, NULL)) + if (! make_dir (basename_dir, dir, mode, NULL)) { CLEANUP; return false; } if (verbose_fmt_string != NULL) - error (0, 0, verbose_fmt_string, quote (dirpath)); + error (0, 0, verbose_fmt_string, quote (dir)); if (owner != (uid_t) -1 || group != (gid_t) -1) { @@ -320,7 +320,7 @@ make_path (const char *argpath, ) { error (0, errno, _("cannot change owner and/or group of %s"), - quote (dirpath)); + quote (dir)); retval = false; } } @@ -334,7 +334,7 @@ make_path (const char *argpath, && chmod (basename_dir, mode)) { error (0, errno, _("cannot change permissions of %s"), - quote (dirpath)); + quote (dir)); retval = false; } @@ -346,23 +346,23 @@ make_path (const char *argpath, for (p = leading_dirs; p != NULL; p = p->next) { *(p->dirname_end) = '\0'; - if (chmod (dirpath, parent_mode)) + if (chmod (dir, parent_mode) != 0) { error (0, errno, _("cannot change permissions of %s"), - quote (dirpath)); + quote (dir)); retval = false; } } } else { - /* We get here if the entire path already exists. */ + /* We get here if the file already exists. */ - const char *dirpath = argpath; + char const *dir = arg; if (!S_ISDIR (stats.st_mode)) { - error (0, 0, _("%s exists but is not a directory"), quote (dirpath)); + error (0, 0, _("%s exists but is not a directory"), quote (dir)); return false; } @@ -375,20 +375,20 @@ make_path (const char *argpath, be able to chmod them. So don't give files away. */ if ((owner != (uid_t) -1 || group != (gid_t) -1) - && chown (dirpath, owner, group) + && chown (dir, owner, group) #ifdef AFS && errno != EPERM #endif ) { error (0, errno, _("cannot change owner and/or group of %s"), - quote (dirpath)); + quote (dir)); retval = false; } - if (chmod (dirpath, mode)) + if (chmod (dir, mode) != 0) { error (0, errno, _("cannot change permissions of %s"), - quote (dirpath)); + quote (dir)); retval = false; } } diff --git a/lib/makepath.h b/lib/mkdir-p.h similarity index 69% rename from lib/makepath.h rename to lib/mkdir-p.h index 1fd432cd8..1aef883bb 100644 --- a/lib/makepath.h +++ b/lib/mkdir-p.h @@ -1,6 +1,6 @@ -/* makepath.c -- Ensure that a directory path exists. +/* mkdir-p.h -- Ensure that a directory and its parents exist. - Copyright (C) 1994, 1995, 1996, 1997, 2000, 2003, 2004 Free + Copyright (C) 1994, 1995, 1996, 1997, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify @@ -22,15 +22,15 @@ #include #include -bool make_path (const char *argpath, - mode_t mode, - mode_t parent_mode, - uid_t owner, - gid_t group, - bool preserve_existing, - const char *verbose_fmt_string); +bool make_dir_parents (char const *argname, + mode_t mode, + mode_t parent_mode, + uid_t owner, + gid_t group, + bool preserve_existing, + char const *verbose_fmt_string); -bool make_dir (const char *dir, - const char *dirpath, +bool make_dir (char const *dir, + char const *fulldir, mode_t mode, bool *created_dir_p); diff --git a/lib/mkstemp.c b/lib/mkstemp.c index ab635e6b4..2683e4b8f 100644 --- a/lib/mkstemp.c +++ b/lib/mkstemp.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc. +/* Copyright (C) 1998, 1999, 2001, 2005 Free Software Foundation, Inc. This file is derived from the one in the GNU C Library. This program is free software; you can redistribute it and/or modify @@ -33,7 +33,7 @@ int __gen_tempname (); /* Generate a unique temporary file name from TEMPLATE. The last six characters of TEMPLATE must be "XXXXXX"; - they are replaced with a string that makes the filename unique. + they are replaced with a string that makes the file name unique. Then open the file and return a fd. */ int rpl_mkstemp (char *template) diff --git a/lib/mountlist.c b/lib/mountlist.c index 49dcf4247..129e0a438 100644 --- a/lib/mountlist.c +++ b/lib/mountlist.c @@ -755,16 +755,16 @@ read_file_system_list (bool need_fs_type) me = xmalloc (sizeof *me); if (vmp->vmt_flags & MNT_REMOTE) { - char *host, *path; + char *host, *dir; me->me_remote = 1; - /* Prepend the remote pathname. */ + /* Prepend the remote dirname. */ host = thisent + vmp->vmt_data[VMT_HOSTNAME].vmt_off; - path = thisent + vmp->vmt_data[VMT_OBJECT].vmt_off; - me->me_devname = xmalloc (strlen (host) + strlen (path) + 2); + dir = thisent + vmp->vmt_data[VMT_OBJECT].vmt_off; + me->me_devname = xmalloc (strlen (host) + strlen (dir) + 2); strcpy (me->me_devname, host); strcat (me->me_devname, ":"); - strcat (me->me_devname, path); + strcat (me->me_devname, dir); } else { diff --git a/lib/mountlist.h b/lib/mountlist.h index cacfe45cd..7f5a6f77a 100644 --- a/lib/mountlist.h +++ b/lib/mountlist.h @@ -26,8 +26,8 @@ /* A mount table entry. */ struct mount_entry { - char *me_devname; /* Device node pathname, including "/dev/". */ - char *me_mountdir; /* Mount point directory pathname. */ + char *me_devname; /* Device node name, including "/dev/". */ + char *me_mountdir; /* Mount point directory name. */ char *me_type; /* "nfs", "4.2", etc. */ dev_t me_dev; /* Device number of me_mountdir. */ unsigned int me_dummy : 1; /* Nonzero for dummy file systems. */ diff --git a/lib/openat.c b/lib/openat.c index fe539de16..ec51b2d13 100644 --- a/lib/openat.c +++ b/lib/openat.c @@ -43,7 +43,7 @@ Otherwise, upon failure, set errno and return -1, as openat does. Upon successful completion, return a file descriptor. */ int -rpl_openat (int fd, char const *filename, int flags, ...) +rpl_openat (int fd, char const *file, int flags, ...) { struct saved_cwd saved_cwd; int saved_errno; @@ -62,8 +62,8 @@ rpl_openat (int fd, char const *filename, int flags, ...) va_end (arg); } - if (fd == AT_FDCWD || *filename == '/') - return open (filename, flags, mode); + if (fd == AT_FDCWD || *file == '/') + return open (file, flags, mode); if (save_cwd (&saved_cwd) != 0) error (exit_failure, errno, @@ -77,7 +77,7 @@ rpl_openat (int fd, char const *filename, int flags, ...) return -1; } - new_fd = open (filename, flags, mode); + new_fd = open (file, flags, mode); saved_errno = errno; if (restore_cwd (&saved_cwd) != 0) @@ -140,7 +140,7 @@ fdopendir (int fd) then give a diagnostic and exit nonzero. Otherwise, this function works just like Solaris' fstatat. */ int -fstatat (int fd, char const *filename, struct stat *st, int flag) +fstatat (int fd, char const *file, struct stat *st, int flag) { struct saved_cwd saved_cwd; int saved_errno; @@ -148,8 +148,8 @@ fstatat (int fd, char const *filename, struct stat *st, int flag) if (fd == AT_FDCWD) return (flag == AT_SYMLINK_NOFOLLOW - ? lstat (filename, st) - : stat (filename, st)); + ? lstat (file, st) + : stat (file, st)); if (save_cwd (&saved_cwd) != 0) error (exit_failure, errno, @@ -164,8 +164,8 @@ fstatat (int fd, char const *filename, struct stat *st, int flag) } err = (flag == AT_SYMLINK_NOFOLLOW - ? lstat (filename, st) - : stat (filename, st)); + ? lstat (file, st) + : stat (file, st)); saved_errno = errno; if (restore_cwd (&saved_cwd) != 0) diff --git a/lib/openat.h b/lib/openat.h index d8db9cea5..6639f732a 100644 --- a/lib/openat.h +++ b/lib/openat.h @@ -36,11 +36,11 @@ # define __OPENAT_XCONCAT(x, y) __OPENAT_CONCAT (x, y) # define __OPENAT_ID(y) __OPENAT_XCONCAT (__OPENAT_PREFIX, y) # define openat __OPENAT_ID (openat) -int openat (int fd, char const *filename, int flags, /* mode_t mode */ ...); +int openat (int fd, char const *file, int flags, /* mode_t mode */ ...); # define fdopendir __OPENAT_ID (fdopendir) DIR *fdopendir (int fd); # define fstatat __OPENAT_ID (fstatat) -int fstatat (int fd, char const *filename, struct stat *st, int flag); +int fstatat (int fd, char const *file, struct stat *st, int flag); # endif #endif diff --git a/lib/pathmax.h b/lib/pathmax.h index 48ba92a70..613c56c09 100644 --- a/lib/pathmax.h +++ b/lib/pathmax.h @@ -1,5 +1,5 @@ /* Define PATH_MAX somehow. Requires sys/types.h. - Copyright (C) 1992, 1999, 2001, 2003 Free Software Foundation, Inc. + Copyright (C) 1992, 1999, 2001, 2003, 2005 Free Software Foundation, Inc. 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 @@ -22,15 +22,10 @@ # include # endif -/* Non-POSIX BSD systems might have gcc's limits.h, which doesn't define - PATH_MAX but might cause redefinition warnings when sys/param.h is - later included (as on MORE/BSD 4.3). */ -# if defined _POSIX_VERSION || !defined __GNUC__ -# include -# endif +# include # ifndef _POSIX_PATH_MAX -# define _POSIX_PATH_MAX 255 +# define _POSIX_PATH_MAX 256 # endif # if !defined PATH_MAX && defined _PC_PATH_MAX diff --git a/lib/readutmp.c b/lib/readutmp.c index a6d91bd42..ca4472c65 100644 --- a/lib/readutmp.c +++ b/lib/readutmp.c @@ -72,7 +72,7 @@ desirable_utmp_entry (STRUCT_UTMP const *u, int options) || (kill (UT_PID (u), 0) < 0 && errno == ESRCH))); } -/* Read the utmp entries corresponding to file FILENAME into freshly- +/* Read the utmp entries corresponding to file FILE into freshly- malloc'd storage, set *UTMP_BUF to that pointer, set *N_ENTRIES to the number of entries, and return zero. If there is any error, return -1, setting errno, and don't modify the parameters. @@ -82,7 +82,7 @@ desirable_utmp_entry (STRUCT_UTMP const *u, int options) #ifdef UTMP_NAME_FUNCTION int -read_utmp (const char *filename, size_t *n_entries, STRUCT_UTMP **utmp_buf, +read_utmp (char const *file, size_t *n_entries, STRUCT_UTMP **utmp_buf, int options) { size_t n_read = 0; @@ -94,7 +94,7 @@ read_utmp (const char *filename, size_t *n_entries, STRUCT_UTMP **utmp_buf, Solaris' utmpname returns 1 upon success -- which is contrary to what the GNU libc version does. In addition, older GNU libc versions are actually void. */ - UTMP_NAME_FUNCTION (filename); + UTMP_NAME_FUNCTION (file); SET_UTMP_ENT (); @@ -118,14 +118,14 @@ read_utmp (const char *filename, size_t *n_entries, STRUCT_UTMP **utmp_buf, #else int -read_utmp (const char *filename, size_t *n_entries, STRUCT_UTMP **utmp_buf, +read_utmp (char const *file, size_t *n_entries, STRUCT_UTMP **utmp_buf, int options) { size_t n_read = 0; size_t n_alloc = 0; STRUCT_UTMP *utmp = NULL; int saved_errno; - FILE *f = fopen (filename, "r"); + FILE *f = fopen (file, "r"); if (! f) return -1; diff --git a/lib/readutmp.h b/lib/readutmp.h index 6cacc400e..f5797ebe9 100644 --- a/lib/readutmp.h +++ b/lib/readutmp.h @@ -205,7 +205,7 @@ enum }; char *extract_trimmed_name (const STRUCT_UTMP *ut); -int read_utmp (const char *filename, size_t *n_entries, STRUCT_UTMP **utmp_buf, +int read_utmp (char const *file, size_t *n_entries, STRUCT_UTMP **utmp_buf, int options); #endif /* __READUTMP_H__ */ diff --git a/lib/rename.c b/lib/rename.c index 44cc1d292..6f77fd09c 100644 --- a/lib/rename.c +++ b/lib/rename.c @@ -1,7 +1,7 @@ /* Work around the bug in some systems whereby rename fails when the source - path has a trailing slash. The rename functions of SunOS 4.1.1_U1 and + file has a trailing slash. The rename functions of SunOS 4.1.1_U1 and mips-dec-ultrix4.4 have this bug. - Copyright (C) 2001-2003 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc. 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 @@ -31,27 +31,27 @@ #include "dirname.h" #include "xalloc.h" -/* Rename the file SRC_PATH to DST_PATH, removing any trailing - slashes from SRC_PATH. Needed for SunOS 4.1.1_U1. */ +/* Rename the file SRC to DST, removing any trailing + slashes from SRC. Needed for SunOS 4.1.1_U1. */ int -rpl_rename (const char *src_path, const char *dst_path) +rpl_rename (char const *src, char const *dst) { char *src_temp; int ret_val; - size_t s_len = strlen (src_path); + size_t s_len = strlen (src); - if (s_len && src_path[s_len - 1] == '/') + if (s_len && src[s_len - 1] == '/') { - src_temp = xstrdup (src_path); + src_temp = xstrdup (src); strip_trailing_slashes (src_temp); } else - src_temp = (char *) src_path; + src_temp = (char *) src; - ret_val = rename (src_temp, dst_path); + ret_val = rename (src_temp, dst); - if (src_temp != src_path) + if (src_temp != src) free (src_temp); return ret_val; diff --git a/lib/rmdir.c b/lib/rmdir.c index 73d8e4339..ad026a641 100644 --- a/lib/rmdir.c +++ b/lib/rmdir.c @@ -1,6 +1,7 @@ /* BSD compatible remove directory function for System V - Copyright (C) 1988, 1990, 1999, 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 1988, 1990, 1999, 2003, 2004, 2005 Free Software + Foundation, Inc. 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 @@ -28,17 +29,17 @@ /* rmdir adapted from GNU tar. */ -/* Remove directory DPATH. +/* Remove directory DIR. Return 0 if successful, -1 if not. */ int -rmdir (char const *dpath) +rmdir (char const *dir) { pid_t cpid; int status; struct stat statbuf; - if (stat (dpath, &statbuf) != 0) + if (stat (dir, &statbuf) != 0) return -1; /* errno already set */ if (!S_ISDIR (statbuf.st_mode)) @@ -54,7 +55,7 @@ rmdir (char const *dpath) return -1; /* errno already set */ case 0: /* child process */ - execl ("/bin/rmdir", "rmdir", dpath, (char *) 0); + execl ("/bin/rmdir", "rmdir", dir, (char *) 0); _exit (1); default: /* parent process */ diff --git a/lib/same.c b/lib/same.c index ecbc58fdb..89ee47dd0 100644 --- a/lib/same.c +++ b/lib/same.c @@ -1,6 +1,6 @@ /* Determine whether two file names refer to the same file. - Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2004 Free + Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify @@ -72,7 +72,7 @@ same_name (const char *source, const char *dest) bool same = false; #if ! _POSIX_NO_TRUNC && HAVE_PATHCONF && defined _PC_NAME_MAX - /* This implementation silently truncates pathname components. If + /* This implementation silently truncates components of file names. If the base names might be truncated, check whether the truncated base names are the same, while checking the directories. */ size_t slen_max = HAVE_LONG_FILE_NAMES ? 255 : _POSIX_NAME_MAX; diff --git a/lib/savedir.c b/lib/savedir.c index 73cc374f4..4eeda0193 100644 --- a/lib/savedir.c +++ b/lib/savedir.c @@ -1,6 +1,6 @@ /* savedir.c -- save the list of files in a directory in a string - Copyright 1990, 1997, 1998, 1999, 2000, 2001, 2003, 2004 Free + Copyright 1990, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify @@ -57,7 +57,7 @@ #include "xalloc.h" -/* Return a freshly allocated string containing the filenames +/* Return a freshly allocated string containing the file names in directory DIR, separated by '\0' characters; the end is marked by two '\0' characters in a row. Return NULL (setting errno) if DIR cannot be opened, read, or closed. */ diff --git a/lib/stripslash.c b/lib/stripslash.c index 1a472f50a..870a66f38 100644 --- a/lib/stripslash.c +++ b/lib/stripslash.c @@ -1,5 +1,6 @@ /* stripslash.c -- remove redundant trailing slashes from a file name - Copyright (C) 1990, 2001, 2003, 2004 Free Software Foundation, Inc. + + Copyright (C) 1990, 2001, 2003, 2004, 2005 Free Software Foundation, Inc. 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 @@ -21,17 +22,17 @@ #include "dirname.h" -/* Remove trailing slashes from PATH. +/* Remove trailing slashes from FILE. Return true if a trailing slash was removed. - This is useful when using filename completion from a shell that + This is useful when using file name completion from a shell that adds a "/" after directory names (such as tcsh and bash), because the Unix rename and rmdir system calls return an "Invalid argument" error - when given a path that ends in "/" (except for the root directory). */ + when given a file that ends in "/" (except for the root directory). */ bool -strip_trailing_slashes (char *path) +strip_trailing_slashes (char *file) { - char *base = base_name (path); + char *base = base_name (file); char *base_lim = base + base_len (base); bool had_slash = (*base_lim != '\0'); *base_lim = '\0'; diff --git a/lib/tempname.c b/lib/tempname.c index 3de699b42..eda6235ae 100644 --- a/lib/tempname.c +++ b/lib/tempname.c @@ -78,8 +78,8 @@ # define __mkdir mkdir # define __open open # define __open64 open -# define __lxstat64(version, path, buf) lstat (path, buf) -# define __xstat64(version, path, buf) stat (path, buf) +# define __lxstat64(version, file, buf) lstat (file, buf) +# define __xstat64(version, file, buf) stat (file, buf) #endif #if ! (HAVE___SECURE_GETENV || _LIBC) @@ -185,7 +185,7 @@ __path_search (char *tmpl, size_t tmpl_len, const char *dir, const char *pfx, return 0; } -/* These are the characters used in temporary filenames. */ +/* These are the characters used in temporary file names. */ static const char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; diff --git a/lib/userspec.c b/lib/userspec.c index c3992d288..5f5c5bf43 100644 --- a/lib/userspec.c +++ b/lib/userspec.c @@ -53,12 +53,6 @@ #define _(msgid) gettext (msgid) #define N_(msgid) msgid -#ifndef _POSIX_VERSION -struct passwd *getpwnam (); -struct group *getgrnam (); -struct group *getgrgid (); -#endif - #ifndef HAVE_ENDGRENT # define endgrent() ((void) 0) #endif diff --git a/lib/xreadlink.c b/lib/xreadlink.c index 0e260757c..d56d2a6af 100644 --- a/lib/xreadlink.c +++ b/lib/xreadlink.c @@ -1,6 +1,6 @@ /* xreadlink.c -- readlink wrapper to return the link name in malloc'd storage - Copyright (C) 2001, 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 2001, 2003, 2004, 2005 Free Software Foundation, Inc. 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 @@ -45,7 +45,7 @@ #include "xalloc.h" -/* Call readlink to get the symbolic link value of FILENAME. +/* Call readlink to get the symbolic link value of FILE. SIZE is a hint as to how long the link is expected to be; typically it is taken from st_size. It need not be correct. Return a pointer to that NUL-terminated string in malloc'd storage. @@ -54,7 +54,7 @@ give a diagnostic and exit. */ char * -xreadlink (char const *filename, size_t size) +xreadlink (char const *file, size_t size) { /* The initial buffer size for the link value. A power of 2 detects arithmetic overflow earlier, but is not required. */ @@ -63,7 +63,7 @@ xreadlink (char const *filename, size_t size) while (1) { char *buffer = xmalloc (buf_size); - ssize_t r = readlink (filename, buffer, buf_size); + ssize_t r = readlink (file, buffer, buf_size); size_t link_length = r; /* On AIX 5L v5.3 and HP-UX 11i v2 04/09, readlink returns -1 diff --git a/m4/ChangeLog b/m4/ChangeLog index 479d07b9d..7530e3db3 100644 --- a/m4/ChangeLog +++ b/m4/ChangeLog @@ -1,3 +1,18 @@ +2005-06-02 Paul Eggert + + Sync from coreutils. + * mkdir-p.m4: Renamed from makepath.m4. + (gl_MKDIR_PARENTS): Renamed from gl_MAKEPATH. All uses changed. + Rename files from makepath.c to mkdir-p.c, and from + makepath.h to mkdir-p.h. + * filenamecat.m4: Renamed from path-concat.m4. + (gl_FILE_NAME_CONCAT): Renamed from gl_PATH_CONCAT. All uses changed. + Rename files from path-concat.c to filenamecat.c, + and from path-concat.h to filenamecat.h. + * getcwd-path-max.m4: Don't use "path" or "filename" to mean + "file name" in local variables or comments. + * rename.m4: Likewise. + 2005-06-01 Bruno Haible * csharp.m4: New file, from GNU gettext. diff --git a/m4/path-concat.m4 b/m4/filenamecat.m4 similarity index 63% rename from m4/path-concat.m4 rename to m4/filenamecat.m4 index 48a8db3a8..c75a57d06 100644 --- a/m4/path-concat.m4 +++ b/m4/filenamecat.m4 @@ -1,14 +1,14 @@ -# path-concat.m4 serial 6 +# filenamecat.m4 serial 7 dnl Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. -AC_DEFUN([gl_PATH_CONCAT], +AC_DEFUN([gl_FILE_NAME_CONCAT], [ - AC_LIBSOURCES([path-concat.c, path-concat.h]) - AC_LIBOBJ([path-concat]) + AC_LIBSOURCES([filenamecat.c, filenamecat.h]) + AC_LIBOBJ([filenamecat]) - dnl Prerequisites of lib/path-concat.c. + dnl Prerequisites of lib/filenamecat.c. AC_CHECK_FUNCS_ONCE(mempcpy) ]) diff --git a/m4/getcwd-path-max.m4 b/m4/getcwd-path-max.m4 index d632c4239..74570dfff 100644 --- a/m4/getcwd-path-max.m4 +++ b/m4/getcwd-path-max.m4 @@ -1,5 +1,5 @@ -#serial 8 -# Check for several getcwd bugs with long paths. +#serial 9 +# Check for several getcwd bugs with long file names. # If so, arrange to compile the wrapper function. # This is necessary for at least GNU libc on linux-2.4.19 and 2.4.20. diff --git a/m4/makepath.m4 b/m4/mkdir-p.m4 similarity index 70% rename from m4/makepath.m4 rename to m4/mkdir-p.m4 index b7408430a..a92e66a38 100644 --- a/m4/makepath.m4 +++ b/m4/mkdir-p.m4 @@ -1,15 +1,15 @@ -# makepath.m4 serial 7 +# mkdir-p.m4 serial 8 dnl Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. -AC_DEFUN([gl_MAKEPATH], +AC_DEFUN([gl_MKDIR_PARENTS], [ - AC_LIBSOURCES([makepath.c, makepath.h]) - AC_LIBOBJ([makepath]) + AC_LIBSOURCES([mkdir-p.c, mkdir-p.h]) + AC_LIBOBJ([mkdir-p]) - dnl Prerequisites of lib/makepath.c. + dnl Prerequisites of lib/mkdir-p.c. AC_REQUIRE([AC_FUNC_ALLOCA]) AC_CHECK_HEADERS_ONCE(unistd.h) AC_REQUIRE([gl_AFS]) diff --git a/m4/rename.m4 b/m4/rename.m4 index 7d5916036..1c9e0e98e 100644 --- a/m4/rename.m4 +++ b/m4/rename.m4 @@ -1,12 +1,12 @@ -#serial 7 +#serial 8 -# Copyright (C) 2001, 2003 Free Software Foundation, Inc. +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. dnl From Volker Borchert. -dnl Determine whether rename works for source paths with a trailing slash. +dnl Determine whether rename works for source file names with a trailing slash. dnl The rename from SunOS 4.1.1_U1 doesn't. dnl dnl If it doesn't, then define RENAME_TRAILING_SLASH_BUG and arrange @@ -41,8 +41,8 @@ AC_DEFUN([vb_FUNC_RENAME], AC_DEFINE(rename, rpl_rename, [Define to rpl_rename if the replacement function should be used.]) AC_DEFINE(RENAME_TRAILING_SLASH_BUG, 1, - [Define if rename does not work for source paths with a trailing slash, - like the one from SunOS 4.1.1_U1.]) + [Define if rename does not work for source file names with a trailing + slash, like the one from SunOS 4.1.1_U1.]) gl_PREREQ_RENAME fi ]) diff --git a/modules/canonicalize b/modules/canonicalize index 42b50fcaf..be574faa3 100644 --- a/modules/canonicalize +++ b/modules/canonicalize @@ -8,7 +8,7 @@ m4/canonicalize.m4 Depends-on: cycle-check -path-concat +filenamecat stat-macros xalloc xgetcwd diff --git a/modules/filenamecat b/modules/filenamecat new file mode 100644 index 000000000..fb1786b84 --- /dev/null +++ b/modules/filenamecat @@ -0,0 +1,26 @@ +Description: +Concatenate two arbitrary file names. + +Files: +lib/filenamecat.h +lib/filenamecat.c +m4/dos.m4 +m4/filenamecat.m4 + +Depends-on: +xalloc +dirname + +configure.ac: +gl_FILE_NAME_CONCAT + +Makefile.am: + +Include: +"filenamecat.h" + +License: +GPL + +Maintainer: +Jim Meyering diff --git a/modules/makepath b/modules/mkdir-p similarity index 62% rename from modules/makepath rename to modules/mkdir-p index 5dc5bf79e..b3f787bda 100644 --- a/modules/makepath +++ b/modules/mkdir-p @@ -1,11 +1,11 @@ Description: -Ensure that a directory path exists. +Ensure that a directory and its parents exist. Files: -lib/makepath.h -lib/makepath.c +lib/mkdir-p.h +lib/mkdir-p.c m4/afs.m4 -m4/makepath.m4 +m4/mkdir-p.m4 Depends-on: alloca @@ -19,12 +19,12 @@ stat-macros stdbool configure.ac: -gl_MAKEPATH +gl_MKDIR_PARENTS Makefile.am: Include: -"makepath.h" +"mkdir-p.h" License: GPL diff --git a/modules/path-concat b/modules/path-concat deleted file mode 100644 index e108c55af..000000000 --- a/modules/path-concat +++ /dev/null @@ -1,27 +0,0 @@ -Description: -Construct a full pathname by concatenating a directory name and a relative -filename. - -Files: -lib/path-concat.h -lib/path-concat.c -m4/dos.m4 -m4/path-concat.m4 - -Depends-on: -xalloc -dirname - -configure.ac: -gl_PATH_CONCAT - -Makefile.am: - -Include: -"path-concat.h" - -License: -GPL - -Maintainer: -Jim Meyering -- 2.11.0