Mercurial > hg > octave-lyh > gnulib-hg
changeset 5907:c47674a83a78
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 <limits.h> 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.
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2005-06-02 Paul Eggert <eggert@cs.ucla.edu> + + 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 <bruno@clisp.org> * modules/csharpexec: New file.
--- a/MODULES.html.sh +++ b/MODULES.html.sh @@ -1817,14 +1817,14 @@ 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
--- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,56 @@ +2005-06-02 Paul Eggert <eggert@cs.ucla.edu> + + 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 <limits.h> 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 <bruno@clisp.org> * csharpexec.h: New file, from GNU gettext.
--- 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 @@ 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
--- 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
--- a/lib/canonicalize.c +++ b/lib/canonicalize.c @@ -48,7 +48,7 @@ #include <stddef.h> #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 @@ #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 @@ /* 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 @@ 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 @@ #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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ } } } - 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; }
--- 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. */
--- 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 <string.h> #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 @@ 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; }
--- 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_ */
--- 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 <libgen.h> #endif -#ifndef _POSIX_VERSION -uid_t getuid (); -gid_t getgid (); -uid_t geteuid (); -gid_t getegid (); -#endif - #include <errno.h> #ifndef __set_errno # define __set_errno(val) errno = (val) @@ -84,21 +77,21 @@ #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 @@ safe. */ if (mode == F_OK) - return stat (path, &stats); + return stat (file, &stats); else { int result; @@ -128,7 +121,7 @@ if (gid != egid) setregid (egid, gid); - result = access (path, mode); + result = access (file, mode); saved_errno = errno; /* Restore them. */ @@ -150,9 +143,9 @@ 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
--- 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 @@ /* 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 @@ 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 @@ 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)
--- 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 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 *);
new file mode 100644 --- /dev/null +++ b/lib/filenamecat.c @@ -0,0 +1,126 @@ +/* Concatenate two arbitrary file names. + + Copyright (C) 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 + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program 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. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* Written by Jim Meyering. */ + +#if HAVE_CONFIG_H +# include <config.h> +#endif + +/* Specification. */ +#include "filenamecat.h" + +#include <string.h> + +#include "dirname.h" +#include "xalloc.h" + +#if ! HAVE_MEMPCPY && ! defined mempcpy +# define mempcpy(D, S, N) ((void *) ((char *) memcpy (D, S, N) + (N))) +#endif + +/* Return the longest suffix of F that is a relative file name. + If it has no such suffix, return the empty string. */ + +static char const * +longest_relative_suffix (char const *f) +{ + for (f += FILE_SYSTEM_PREFIX_LEN (f); ISSLASH (*f); f++) + continue; + return f; +} + +/* 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 + file system prefixes and leading separators removed. + Arrange for a directory separator if necessary between DIR and BASE + in the result, removing any redundant separators. + In any case, if BASE_IN_RESULT is non-NULL, set + *BASE_IN_RESULT to point to the copy of ABASE in the returned + concatenation. However, if ABASE begins with more than one slash, + set *BASE_IN_RESULT to point to the sole corresponding slash that + is copied into the result buffer. + + Report an error if memory is exhausted. */ + +char * +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); + size_t dirlen = dirbase - dir + dirbaselen; + size_t needs_separator = (dirbaselen && ! ISSLASH (dirbase[dirbaselen - 1])); + + char const *base = longest_relative_suffix (abase); + size_t baselen = strlen (base); + + char *p_concat = xmalloc (dirlen + needs_separator + baselen + 1); + char *p; + + p = mempcpy (p_concat, dir, dirlen); + *p = DIRECTORY_SEPARATOR; + p += needs_separator; + + if (base_in_result) + *base_in_result = p - IS_ABSOLUTE_FILE_NAME (abase); + + p = mempcpy (p, base, baselen); + *p = '\0'; + + return p_concat; +} + +#ifdef TEST_FILE_NAME_CONCAT +# include <stdlib.h> +# include <stdio.h> +int +main () +{ + static char const *const tests[][3] = + { + {"a", "b", "a/b"}, + {"a/", "b", "a/b"}, + {"a/", "/b", "a/b"}, + {"a", "/b", "a/b"}, + + {"/", "b", "/b"}, + {"/", "/b", "/b"}, + {"/", "/", "/"}, + {"a", "/", "a/"}, /* this might deserve a diagnostic */ + {"/a", "/", "/a/"}, /* this might deserve a diagnostic */ + {"a", "//b", "a/b"}, + }; + size_t i; + bool fail = false; + for (i = 0; i < sizeof tests / sizeof tests[0]; i++) + { + char *base_in_result; + char const *const *t = tests[i]; + 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]); + fail = true; + } + } + exit (fail ? EXIT_FAILURE : EXIT_SUCCESS); +} +#endif
new file mode 100644 --- /dev/null +++ b/lib/filenamecat.h @@ -0,0 +1,22 @@ +/* Concatenate two arbitrary file names. + + 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 + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program 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. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* Written by Jim Meyering. */ + +char *file_name_concat (char const *dir, char const *base, + char **base_in_result);
--- 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 @@ # 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);
--- 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)
--- 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 @@ struct fs_data fsd; - if (statfs (path, &fsd) != 1) + if (statfs (file, &fsd) != 1) return -1; fsp->fsu_blocksize = 1024; @@ -181,7 +181,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ /* 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;
--- 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 @@ 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
--- 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;
--- a/lib/fts.c +++ b/lib/fts.c @@ -244,8 +244,8 @@ 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 @@ /* 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 @@ /* * 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 @@ * 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 @@ 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 @@ } /* - * 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 @@ /* * 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 @@ 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 @@ 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 @@ 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 @@ * 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 @@ /* * 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 @@ 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 @@ 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 @@ 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 @@ /* * 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 @@ } /* - * 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 @@ } /* - * 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 @@ } /* - * 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 @@ 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;
--- a/lib/fts_.h +++ b/lib/fts_.h @@ -71,7 +71,7 @@ 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 @@ 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) */
--- 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 @@ 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 @@ 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 @@ 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 @@ } 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 @@ 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 @@ 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 @@ free (dotlist); #endif if (buf == NULL) - free (path); + free (dir); __set_errno (save); } return NULL;
--- 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.
--- 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
deleted file mode 100644 --- a/lib/makepath.c +++ /dev/null @@ -1,398 +0,0 @@ -/* makepath.c -- Ensure that a directory path exists. - - Copyright (C) 1990, 1997, 1998, 1999, 2000, 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 - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program 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. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - -/* Written by David MacKenzie <djm@gnu.ai.mit.edu> and Jim Meyering. */ - -#if HAVE_CONFIG_H -# include <config.h> -#endif - -#include "makepath.h" - -#include <alloca.h> - -#include <stdio.h> -#include <sys/types.h> -#include <sys/stat.h> -#if HAVE_UNISTD_H -# include <unistd.h> -#endif - -#include <stdlib.h> -#include <errno.h> -#include <string.h> - -#include "gettext.h" -#define _(msgid) gettext (msgid) - -#include "save-cwd.h" -#include "dirname.h" -#include "error.h" -#include "quote.h" -#include "stat-macros.h" - -#define WX_USR (S_IWUSR | S_IXUSR) - -#define CLEANUP_CWD \ - do \ - { \ - /* We're done operating on basename_dir. \ - Restore working directory. */ \ - if (do_chdir) \ - { \ - if (restore_cwd (&cwd) != 0) \ - { \ - int _saved_errno = errno; \ - error (0, errno, \ - _("failed to return to initial working directory")); \ - free_cwd (&cwd); \ - errno = _saved_errno; \ - return 1; \ - } \ - free_cwd (&cwd); \ - } \ - } \ - while (0) - -#define CLEANUP \ - do \ - { \ - umask (oldmask); \ - CLEANUP_CWD; \ - } \ - while (0) - -/* Attempt to create directory DIR (aka DIRPATH) 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. - 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, - bool *created_dir_p) -{ - bool ok = true; - bool created_dir; - - created_dir = (mkdir (dir, mode) == 0); - - if (!created_dir) - { - struct stat stats; - int saved_errno = errno; - - /* The mkdir and stat calls below may appear to be reversed. - They are not. It is important to call mkdir first and then to - call stat (to distinguish the three cases) only if mkdir fails. - The alternative to this approach is to `stat' each directory, - then to call mkdir if it doesn't exist. But if some other process - were to create the directory between the stat & mkdir, the mkdir - would fail with EEXIST. */ - - if (stat (dir, &stats)) - { - error (0, saved_errno, _("cannot create directory %s"), - quote (dirpath)); - ok = false; - } - else if (!S_ISDIR (stats.st_mode)) - { - error (0, 0, _("%s exists but is not a directory"), quote (dirpath)); - ok = false; - } - else - { - /* DIR (aka DIRPATH) already exists and is a directory. */ - } - } - - if (created_dir_p) - *created_dir_p = created_dir; - - return ok; -} - -/* Ensure that the directory ARGPATH 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 - 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, - then do not attempt to set its permissions and ownership. - - Return true iff ARGPATH 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) -{ - struct stat stats; - bool retval = true; - - if (stat (argpath, &stats)) - { - char *slash; - mode_t tmp_mode; /* Initial perms for leading dirs. */ - bool re_protect; /* Should leading dirs be unwritable? */ - struct ptr_list - { - char *dirname_end; - struct ptr_list *next; - }; - struct ptr_list *p, *leading_dirs = NULL; - bool do_chdir; /* Whether to chdir before each mkdir. */ - struct saved_cwd cwd; - char *basename_dir; - char *dirpath; - - /* 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); - - /* If leading directories shouldn't be writable or executable, - or should have set[ug]id or sticky bits set and we are setting - their owners, we need to fix their permissions after making them. */ - if (((parent_mode & WX_USR) != WX_USR) - || ((owner != (uid_t) -1 || group != (gid_t) -1) - && (parent_mode & (S_ISUID | S_ISGID | S_ISVTX)) != 0)) - { - tmp_mode = S_IRWXU; - re_protect = true; - } - else - { - tmp_mode = parent_mode; - re_protect = false; - } - - /* If we can record the current working directory, we may be able - to do the chdir optimization. */ - do_chdir = (save_cwd (&cwd) == 0); - - /* If we've saved the cwd and DIRPATH is an absolute pathname, - we must chdir to `/' in order to enable the chdir optimization. - So if chdir ("/") fails, turn off the optimization. */ - if (do_chdir && dirpath[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] == '/'); - if (chdir (root) != 0) - do_chdir = false; - } - - slash = dirpath; - - /* Skip over leading slashes. */ - while (*slash == '/') - slash++; - - while (1) - { - bool newly_created_dir; - - /* slash points to the leftmost unprocessed component of dirpath. */ - basename_dir = slash; - - slash = strchr (slash, '/'); - if (slash == NULL) - break; - - /* 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; - - *slash = '\0'; - if (! make_dir (basename_dir, dirpath, tmp_mode, &newly_created_dir)) - { - CLEANUP; - return false; - } - - if (newly_created_dir) - { - if (verbose_fmt_string) - error (0, 0, verbose_fmt_string, quote (dirpath)); - - if ((owner != (uid_t) -1 || group != (gid_t) -1) - && chown (basename_dir, owner, group) -#if defined AFS && defined EPERM - && errno != EPERM -#endif - ) - { - error (0, errno, _("cannot change owner and/or group of %s"), - quote (dirpath)); - CLEANUP; - return false; - } - - if (re_protect) - { - struct ptr_list *new = (struct ptr_list *) - alloca (sizeof (struct ptr_list)); - new->dirname_end = slash; - new->next = leading_dirs; - leading_dirs = new; - } - } - - /* If we were able to save the initial working directory, - then we can use chdir to change into each directory before - creating an entry in that directory. This avoids making - stat and mkdir process O(n^2) file name components. */ - if (do_chdir && chdir (basename_dir) < 0) - { - error (0, errno, _("cannot chdir to directory %s"), - quote (dirpath)); - CLEANUP; - return false; - } - - *slash++ = '/'; - - /* Avoid unnecessary calls to `stat' when given - pathnames containing multiple adjacent slashes. */ - while (*slash == '/') - slash++; - } - - if (!do_chdir) - basename_dir = dirpath; - - /* Done creating leading directories. Restore original umask. */ - umask (oldmask); - - /* We're done making leading directories. - Create the final component of the path. */ - - if (! make_dir (basename_dir, dirpath, mode, NULL)) - { - CLEANUP; - return false; - } - - if (verbose_fmt_string != NULL) - error (0, 0, verbose_fmt_string, quote (dirpath)); - - if (owner != (uid_t) -1 || group != (gid_t) -1) - { - if (chown (basename_dir, owner, group) -#ifdef AFS - && errno != EPERM -#endif - ) - { - error (0, errno, _("cannot change owner and/or group of %s"), - quote (dirpath)); - retval = false; - } - } - - /* The above chown may have turned off some permission bits in MODE. - Another reason we may have to use chmod here is that mkdir(2) is - required to honor only the file permission bits. In particular, - it need not honor the `special' bits, so if MODE includes any - special bits, set them here. */ - if ((mode & ~S_IRWXUGO) - && chmod (basename_dir, mode)) - { - error (0, errno, _("cannot change permissions of %s"), - quote (dirpath)); - retval = false; - } - - CLEANUP_CWD; - - /* If the mode for leading directories didn't include owner "wx" - privileges, we have to reset their protections to the correct - value. */ - for (p = leading_dirs; p != NULL; p = p->next) - { - *(p->dirname_end) = '\0'; - if (chmod (dirpath, parent_mode)) - { - error (0, errno, _("cannot change permissions of %s"), - quote (dirpath)); - retval = false; - } - } - } - else - { - /* We get here if the entire path already exists. */ - - const char *dirpath = argpath; - - if (!S_ISDIR (stats.st_mode)) - { - error (0, 0, _("%s exists but is not a directory"), quote (dirpath)); - return false; - } - - if (!preserve_existing) - { - /* chown must precede chmod because on some systems, - chown clears the set[ug]id bits for non-superusers, - resulting in incorrect permissions. - On System V, users can give away files with chown and then not - be able to chmod them. So don't give files away. */ - - if ((owner != (uid_t) -1 || group != (gid_t) -1) - && chown (dirpath, owner, group) -#ifdef AFS - && errno != EPERM -#endif - ) - { - error (0, errno, _("cannot change owner and/or group of %s"), - quote (dirpath)); - retval = false; - } - if (chmod (dirpath, mode)) - { - error (0, errno, _("cannot change permissions of %s"), - quote (dirpath)); - retval = false; - } - } - } - - return retval; -}
deleted file mode 100644 --- a/lib/makepath.h +++ /dev/null @@ -1,36 +0,0 @@ -/* makepath.c -- Ensure that a directory path exists. - - Copyright (C) 1994, 1995, 1996, 1997, 2000, 2003, 2004 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 - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program 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. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - -/* Written by David MacKenzie <djm@gnu.ai.mit.edu> and Jim Meyering. */ - -#include <stdbool.h> -#include <sys/types.h> - -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 (const char *dir, - const char *dirpath, - mode_t mode, - bool *created_dir_p);
new file mode 100644 --- /dev/null +++ b/lib/mkdir-p.c @@ -0,0 +1,398 @@ +/* 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. + + 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 2, or (at your option) + any later version. + + This program 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. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* Written by David MacKenzie <djm@gnu.ai.mit.edu> and Jim Meyering. */ + +#if HAVE_CONFIG_H +# include <config.h> +#endif + +#include "mkdir-p.h" + +#include <alloca.h> + +#include <stdio.h> +#include <sys/types.h> +#include <sys/stat.h> +#if HAVE_UNISTD_H +# include <unistd.h> +#endif + +#include <stdlib.h> +#include <errno.h> +#include <string.h> + +#include "gettext.h" +#define _(msgid) gettext (msgid) + +#include "save-cwd.h" +#include "dirname.h" +#include "error.h" +#include "quote.h" +#include "stat-macros.h" + +#define WX_USR (S_IWUSR | S_IXUSR) + +#define CLEANUP_CWD \ + do \ + { \ + /* We're done operating on basename_dir. \ + Restore working directory. */ \ + if (do_chdir) \ + { \ + if (restore_cwd (&cwd) != 0) \ + { \ + int _saved_errno = errno; \ + error (0, errno, \ + _("failed to return to initial working directory")); \ + free_cwd (&cwd); \ + errno = _saved_errno; \ + return 1; \ + } \ + free_cwd (&cwd); \ + } \ + } \ + while (0) + +#define CLEANUP \ + do \ + { \ + umask (oldmask); \ + CLEANUP_CWD; \ + } \ + while (0) + +/* 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 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 (char const *dir, char const *fulldir, mode_t mode, + bool *created_dir_p) +{ + bool ok = true; + bool created_dir; + + created_dir = (mkdir (dir, mode) == 0); + + if (!created_dir) + { + struct stat stats; + int saved_errno = errno; + + /* The mkdir and stat calls below may appear to be reversed. + They are not. It is important to call mkdir first and then to + call stat (to distinguish the three cases) only if mkdir fails. + The alternative to this approach is to `stat' each directory, + then to call mkdir if it doesn't exist. But if some other process + were to create the directory between the stat & mkdir, the mkdir + would fail with EEXIST. */ + + if (stat (dir, &stats)) + { + error (0, saved_errno, _("cannot create directory %s"), + quote (fulldir)); + ok = false; + } + else if (!S_ISDIR (stats.st_mode)) + { + error (0, 0, _("%s exists but is not a directory"), quote (fulldir)); + ok = false; + } + else + { + /* DIR (aka FULLDIR) already exists and is a directory. */ + } + } + + if (created_dir_p) + *created_dir_p = created_dir; + + return ok; +} + +/* Ensure that the directory ARG exists. + + Create any leading directories that don't already exist, with + permissions PARENT_MODE. + 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 ARG is an existing directory, + then do not attempt to set its permissions and ownership. + + Return true iff ARG exists as a directory with the proper + ownership and permissions when done. */ + +bool +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 (arg, &stats) != 0) + { + char *slash; + mode_t tmp_mode; /* Initial perms for leading dirs. */ + bool re_protect; /* Should leading dirs be unwritable? */ + struct ptr_list + { + char *dirname_end; + struct ptr_list *next; + }; + struct ptr_list *p, *leading_dirs = NULL; + bool do_chdir; /* Whether to chdir before each mkdir. */ + struct saved_cwd cwd; + char *basename_dir; + char *dir; + + /* Temporarily relax umask in case it's overly restrictive. */ + mode_t oldmask = umask (0); + + /* 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 + their owners, we need to fix their permissions after making them. */ + if (((parent_mode & WX_USR) != WX_USR) + || ((owner != (uid_t) -1 || group != (gid_t) -1) + && (parent_mode & (S_ISUID | S_ISGID | S_ISVTX)) != 0)) + { + tmp_mode = S_IRWXU; + re_protect = true; + } + else + { + tmp_mode = parent_mode; + re_protect = false; + } + + /* If we can record the current working directory, we may be able + to do the chdir optimization. */ + do_chdir = (save_cwd (&cwd) == 0); + + /* 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 && dir[0] == '/') + { + /* POSIX says "//" might be special, so chdir to "//" if the + file name starts with exactly two slashes. */ + char const *root = "//" + (dir[1] != '/' || dir[2] == '/'); + if (chdir (root) != 0) + do_chdir = false; + } + + slash = dir; + + /* Skip over leading slashes. */ + while (*slash == '/') + slash++; + + while (1) + { + bool newly_created_dir; + + /* slash points to the leftmost unprocessed component of dir. */ + basename_dir = slash; + + slash = strchr (slash, '/'); + if (slash == NULL) + break; + + /* 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 = dir; + + *slash = '\0'; + if (! make_dir (basename_dir, dir, tmp_mode, &newly_created_dir)) + { + CLEANUP; + return false; + } + + if (newly_created_dir) + { + if (verbose_fmt_string) + error (0, 0, verbose_fmt_string, quote (dir)); + + if ((owner != (uid_t) -1 || group != (gid_t) -1) + && chown (basename_dir, owner, group) +#if defined AFS && defined EPERM + && errno != EPERM +#endif + ) + { + error (0, errno, _("cannot change owner and/or group of %s"), + quote (dir)); + CLEANUP; + return false; + } + + if (re_protect) + { + struct ptr_list *new = (struct ptr_list *) + alloca (sizeof (struct ptr_list)); + new->dirname_end = slash; + new->next = leading_dirs; + leading_dirs = new; + } + } + + /* If we were able to save the initial working directory, + then we can use chdir to change into each directory before + creating an entry in that directory. This avoids making + stat and mkdir process O(n^2) file name components. */ + if (do_chdir && chdir (basename_dir) < 0) + { + error (0, errno, _("cannot chdir to directory %s"), + quote (dir)); + CLEANUP; + return false; + } + + *slash++ = '/'; + + /* Avoid unnecessary calls to `stat' when given + file names containing multiple adjacent slashes. */ + while (*slash == '/') + slash++; + } + + if (!do_chdir) + basename_dir = dir; + + /* Done creating leading directories. Restore original umask. */ + umask (oldmask); + + /* We're done making leading directories. + Create the final component of the file name. */ + + if (! make_dir (basename_dir, dir, mode, NULL)) + { + CLEANUP; + return false; + } + + if (verbose_fmt_string != NULL) + error (0, 0, verbose_fmt_string, quote (dir)); + + if (owner != (uid_t) -1 || group != (gid_t) -1) + { + if (chown (basename_dir, owner, group) +#ifdef AFS + && errno != EPERM +#endif + ) + { + error (0, errno, _("cannot change owner and/or group of %s"), + quote (dir)); + retval = false; + } + } + + /* The above chown may have turned off some permission bits in MODE. + Another reason we may have to use chmod here is that mkdir(2) is + required to honor only the file permission bits. In particular, + it need not honor the `special' bits, so if MODE includes any + special bits, set them here. */ + if ((mode & ~S_IRWXUGO) + && chmod (basename_dir, mode)) + { + error (0, errno, _("cannot change permissions of %s"), + quote (dir)); + retval = false; + } + + CLEANUP_CWD; + + /* If the mode for leading directories didn't include owner "wx" + privileges, we have to reset their protections to the correct + value. */ + for (p = leading_dirs; p != NULL; p = p->next) + { + *(p->dirname_end) = '\0'; + if (chmod (dir, parent_mode) != 0) + { + error (0, errno, _("cannot change permissions of %s"), + quote (dir)); + retval = false; + } + } + } + else + { + /* We get here if the file already exists. */ + + char const *dir = arg; + + if (!S_ISDIR (stats.st_mode)) + { + error (0, 0, _("%s exists but is not a directory"), quote (dir)); + return false; + } + + if (!preserve_existing) + { + /* chown must precede chmod because on some systems, + chown clears the set[ug]id bits for non-superusers, + resulting in incorrect permissions. + On System V, users can give away files with chown and then not + be able to chmod them. So don't give files away. */ + + if ((owner != (uid_t) -1 || group != (gid_t) -1) + && chown (dir, owner, group) +#ifdef AFS + && errno != EPERM +#endif + ) + { + error (0, errno, _("cannot change owner and/or group of %s"), + quote (dir)); + retval = false; + } + if (chmod (dir, mode) != 0) + { + error (0, errno, _("cannot change permissions of %s"), + quote (dir)); + retval = false; + } + } + } + + return retval; +}
new file mode 100644 --- /dev/null +++ b/lib/mkdir-p.h @@ -0,0 +1,36 @@ +/* mkdir-p.h -- Ensure that a directory and its parents exist. + + 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 + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program 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. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* Written by David MacKenzie <djm@gnu.ai.mit.edu> and Jim Meyering. */ + +#include <stdbool.h> +#include <sys/types.h> + +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 (char const *dir, + char const *fulldir, + mode_t mode, + bool *created_dir_p);
--- 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 @@ /* 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)
--- a/lib/mountlist.c +++ b/lib/mountlist.c @@ -755,16 +755,16 @@ 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 {
--- 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. */
--- 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ } 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)
--- 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
deleted file mode 100644 --- a/lib/path-concat.c +++ /dev/null @@ -1,126 +0,0 @@ -/* path-concat.c -- concatenate two arbitrary pathnames - - Copyright (C) 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 - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program 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. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - -/* Written by Jim Meyering. */ - -#if HAVE_CONFIG_H -# include <config.h> -#endif - -/* Specification. */ -#include "path-concat.h" - -#include <string.h> - -#include "dirname.h" -#include "xalloc.h" - -#if ! HAVE_MEMPCPY && ! defined mempcpy -# define mempcpy(D, S, N) ((void *) ((char *) memcpy (D, S, N) + (N))) -#endif - -/* Return the longest suffix of F that is a relative file name. - If it has no such suffix, return the empty string. */ - -static char const * -longest_relative_suffix (char const *f) -{ - for (f += FILE_SYSTEM_PREFIX_LEN (f); ISSLASH (*f); f++) - continue; - return f; -} - -/* Concatenate two pathname 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 - file system prefixes and leading separators removed. - Arrange for a directory separator if necessary between DIR and BASE - in the result, removing any redundant separators. - In any case, if BASE_IN_RESULT is non-NULL, set - *BASE_IN_RESULT to point to the copy of ABASE in the returned - concatenation. However, if ABASE begins with more than one slash, - set *BASE_IN_RESULT to point to the sole corresponding slash that - is copied into the result buffer. - - Report an error if memory is exhausted. */ - -char * -path_concat (char const *dir, char const *abase, char **base_in_result) -{ - char const *dirbase = base_name (dir); - size_t dirbaselen = base_len (dirbase); - size_t dirlen = dirbase - dir + dirbaselen; - size_t needs_separator = (dirbaselen && ! ISSLASH (dirbase[dirbaselen - 1])); - - char const *base = longest_relative_suffix (abase); - size_t baselen = strlen (base); - - char *p_concat = xmalloc (dirlen + needs_separator + baselen + 1); - char *p; - - p = mempcpy (p_concat, dir, dirlen); - *p = DIRECTORY_SEPARATOR; - p += needs_separator; - - if (base_in_result) - *base_in_result = p - IS_ABSOLUTE_FILE_NAME (abase); - - p = mempcpy (p, base, baselen); - *p = '\0'; - - return p_concat; -} - -#ifdef TEST_PATH_CONCAT -# include <stdlib.h> -# include <stdio.h> -int -main () -{ - static char const *const tests[][3] = - { - {"a", "b", "a/b"}, - {"a/", "b", "a/b"}, - {"a/", "/b", "a/b"}, - {"a", "/b", "a/b"}, - - {"/", "b", "/b"}, - {"/", "/b", "/b"}, - {"/", "/", "/"}, - {"a", "/", "a/"}, /* this might deserve a diagnostic */ - {"/a", "/", "/a/"}, /* this might deserve a diagnostic */ - {"a", "//b", "a/b"}, - }; - size_t i; - bool fail = false; - for (i = 0; i < sizeof tests / sizeof tests[0]; i++) - { - char *base_in_result; - char const *const *t = tests[i]; - char *res = path_concat (t[0], t[1], &base_in_result); - if (strcmp (res, t[2]) != 0) - { - printf ("got %s, expected %s\n", res, t[2]); - fail = true; - } - } - exit (fail ? EXIT_FAILURE : EXIT_SUCCESS); -} -#endif
deleted file mode 100644 --- a/lib/path-concat.h +++ /dev/null @@ -1,26 +0,0 @@ -/* Concatenate two arbitrary pathnames. - - Copyright (C) 1996, 1997, 2003 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 - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program 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. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - -/* 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
--- 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 <unistd.h> # 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 <limits.h> -# endif +# include <limits.h> # ifndef _POSIX_PATH_MAX -# define _POSIX_PATH_MAX 255 +# define _POSIX_PATH_MAX 256 # endif # if !defined PATH_MAX && defined _PC_PATH_MAX
--- a/lib/readutmp.c +++ b/lib/readutmp.c @@ -72,7 +72,7 @@ || (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 @@ #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 @@ 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 @@ #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;
--- a/lib/readutmp.h +++ b/lib/readutmp.h @@ -205,7 +205,7 @@ }; 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__ */
--- 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;
--- 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 @@ 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 */
--- 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 @@ 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;
--- 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. */
--- 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';
--- 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 @@ return 0; } -/* These are the characters used in temporary filenames. */ +/* These are the characters used in temporary file names. */ static const char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
--- 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
--- 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 @@ 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
--- a/m4/ChangeLog +++ b/m4/ChangeLog @@ -1,3 +1,18 @@ +2005-06-02 Paul Eggert <eggert@cs.ucla.edu> + + 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 <bruno@clisp.org> * csharp.m4: New file, from GNU gettext.
new file mode 100644 --- /dev/null +++ b/m4/filenamecat.m4 @@ -0,0 +1,14 @@ +# 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_FILE_NAME_CONCAT], +[ + AC_LIBSOURCES([filenamecat.c, filenamecat.h]) + AC_LIBOBJ([filenamecat]) + + dnl Prerequisites of lib/filenamecat.c. + AC_CHECK_FUNCS_ONCE(mempcpy) +])
--- 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.
deleted file mode 100644 --- a/m4/makepath.m4 +++ /dev/null @@ -1,16 +0,0 @@ -# makepath.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_MAKEPATH], -[ - AC_LIBSOURCES([makepath.c, makepath.h]) - AC_LIBOBJ([makepath]) - - dnl Prerequisites of lib/makepath.c. - AC_REQUIRE([AC_FUNC_ALLOCA]) - AC_CHECK_HEADERS_ONCE(unistd.h) - AC_REQUIRE([gl_AFS]) -])
new file mode 100644 --- /dev/null +++ b/m4/mkdir-p.m4 @@ -0,0 +1,16 @@ +# 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_MKDIR_PARENTS], +[ + AC_LIBSOURCES([mkdir-p.c, mkdir-p.h]) + AC_LIBOBJ([mkdir-p]) + + dnl Prerequisites of lib/mkdir-p.c. + AC_REQUIRE([AC_FUNC_ALLOCA]) + AC_CHECK_HEADERS_ONCE(unistd.h) + AC_REQUIRE([gl_AFS]) +])
deleted file mode 100644 --- a/m4/path-concat.m4 +++ /dev/null @@ -1,14 +0,0 @@ -# path-concat.m4 serial 6 -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_LIBSOURCES([path-concat.c, path-concat.h]) - AC_LIBOBJ([path-concat]) - - dnl Prerequisites of lib/path-concat.c. - AC_CHECK_FUNCS_ONCE(mempcpy) -])
--- 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_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 ])
--- a/modules/canonicalize +++ b/modules/canonicalize @@ -8,7 +8,7 @@ Depends-on: cycle-check -path-concat +filenamecat stat-macros xalloc xgetcwd
new file mode 100644 --- /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
deleted file mode 100644 --- a/modules/makepath +++ /dev/null @@ -1,33 +0,0 @@ -Description: -Ensure that a directory path exists. - -Files: -lib/makepath.h -lib/makepath.c -m4/afs.m4 -m4/makepath.m4 - -Depends-on: -alloca -chown -gettext -save-cwd -dirname -error -quote -stat-macros -stdbool - -configure.ac: -gl_MAKEPATH - -Makefile.am: - -Include: -"makepath.h" - -License: -GPL - -Maintainer: -Jim Meyering
new file mode 100644 --- /dev/null +++ b/modules/mkdir-p @@ -0,0 +1,33 @@ +Description: +Ensure that a directory and its parents exist. + +Files: +lib/mkdir-p.h +lib/mkdir-p.c +m4/afs.m4 +m4/mkdir-p.m4 + +Depends-on: +alloca +chown +gettext +save-cwd +dirname +error +quote +stat-macros +stdbool + +configure.ac: +gl_MKDIR_PARENTS + +Makefile.am: + +Include: +"mkdir-p.h" + +License: +GPL + +Maintainer: +Jim Meyering
deleted file mode 100644 --- 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