Mercurial > hg > octave-lojdl > gnulib-hg
annotate lib/rename.c @ 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.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Thu, 02 Jun 2005 20:41:04 +0000 |
parents | a48fb0e98c8c |
children | 96c32553b4c6 |
rev | line source |
---|---|
3102
a17f2d7d7ee1
Include stdlib.h, string.h or strings.h, and xalloc.h.
Jim Meyering <jim@meyering.net>
parents:
3099
diff
changeset
|
1 /* Work around the bug in some systems whereby rename fails when the source |
5907 | 2 file has a trailing slash. The rename functions of SunOS 4.1.1_U1 and |
3782
8784488b0ea1
Mention that this wrapper is needed also on mips-dec-ultrix4.4 systems.
Jim Meyering <jim@meyering.net>
parents:
3244
diff
changeset
|
3 mips-dec-ultrix4.4 have this bug. |
5907 | 4 Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc. |
3099 | 5 |
6 This program is free software; you can redistribute it and/or modify | |
7 it under the terms of the GNU General Public License as published by | |
8 the Free Software Foundation; either version 2, or (at your option) | |
9 any later version. | |
10 | |
11 This program is distributed in the hope that it will be useful, | |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 GNU General Public License for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with this program; if not, write to the Free Software Foundation, | |
5848
a48fb0e98c8c
*** empty log message ***
Paul Eggert <eggert@cs.ucla.edu>
parents:
4674
diff
changeset
|
18 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
3099 | 19 |
20 /* written by Volker Borchert */ | |
21 | |
4229
c7ddde35beec
Make this module usable in shared libraries.
Bruno Haible <bruno@clisp.org>
parents:
3782
diff
changeset
|
22 #if HAVE_CONFIG_H |
c7ddde35beec
Make this module usable in shared libraries.
Bruno Haible <bruno@clisp.org>
parents:
3782
diff
changeset
|
23 # include <config.h> |
c7ddde35beec
Make this module usable in shared libraries.
Bruno Haible <bruno@clisp.org>
parents:
3782
diff
changeset
|
24 #endif |
c7ddde35beec
Make this module usable in shared libraries.
Bruno Haible <bruno@clisp.org>
parents:
3782
diff
changeset
|
25 #undef rename |
c7ddde35beec
Make this module usable in shared libraries.
Bruno Haible <bruno@clisp.org>
parents:
3782
diff
changeset
|
26 |
3099 | 27 #include <stdio.h> |
4674 | 28 #include <stdlib.h> |
29 #include <string.h> | |
3102
a17f2d7d7ee1
Include stdlib.h, string.h or strings.h, and xalloc.h.
Jim Meyering <jim@meyering.net>
parents:
3099
diff
changeset
|
30 |
3244
5a129aed765a
Use "", not <> to include non-system header files.
Jim Meyering <jim@meyering.net>
parents:
3237
diff
changeset
|
31 #include "dirname.h" |
5a129aed765a
Use "", not <> to include non-system header files.
Jim Meyering <jim@meyering.net>
parents:
3237
diff
changeset
|
32 #include "xalloc.h" |
3099 | 33 |
5907 | 34 /* Rename the file SRC to DST, removing any trailing |
35 slashes from SRC. Needed for SunOS 4.1.1_U1. */ | |
3099 | 36 |
37 int | |
5907 | 38 rpl_rename (char const *src, char const *dst) |
3099 | 39 { |
40 char *src_temp; | |
3102
a17f2d7d7ee1
Include stdlib.h, string.h or strings.h, and xalloc.h.
Jim Meyering <jim@meyering.net>
parents:
3099
diff
changeset
|
41 int ret_val; |
5907 | 42 size_t s_len = strlen (src); |
3099 | 43 |
5907 | 44 if (s_len && src[s_len - 1] == '/') |
3099 | 45 { |
5907 | 46 src_temp = xstrdup (src); |
3102
a17f2d7d7ee1
Include stdlib.h, string.h or strings.h, and xalloc.h.
Jim Meyering <jim@meyering.net>
parents:
3099
diff
changeset
|
47 strip_trailing_slashes (src_temp); |
3099 | 48 } |
49 else | |
5907 | 50 src_temp = (char *) src; |
3099 | 51 |
5907 | 52 ret_val = rename (src_temp, dst); |
3099 | 53 |
5907 | 54 if (src_temp != src) |
3099 | 55 free (src_temp); |
56 | |
3102
a17f2d7d7ee1
Include stdlib.h, string.h or strings.h, and xalloc.h.
Jim Meyering <jim@meyering.net>
parents:
3099
diff
changeset
|
57 return ret_val; |
3099 | 58 } |