annotate lib/rmdir.c @ 14379:2330aac2ae54

maint: adjust cpp indentation to reflect nesting depth I.e., in a block of code that begins with an unnested "#if", put one space between the "#" in column 1 and following token. For example, -#include <sys/vfs.h> +# include <sys/vfs.h> Do this only in .c files that are part of a module I maintain. * lib/linkat.c: Filter through cppi. * lib/nanosleep.c: Likewise. * lib/openat.c: Likewise. * lib/openat-die.c: Likewise. * lib/dup3.c: Likewise. * lib/fchownat.c: Likewise. * lib/flock.c: Likewise. * lib/fsync.c: Likewise. * lib/fts.c: Likewise. * lib/getpass.c: Likewise. * lib/gettimeofday.c: Likewise. * lib/userspec.c: Likewise. * Makefile (sc_cpp_indent_check): New rule, to check this.
author Jim Meyering <meyering@redhat.com>
date Sun, 20 Feb 2011 23:02:43 +0100
parents 97fc9a21a8fb
children 9f47f8c334f2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11993
767d867147de rmdir: work around cygwin 1.5.x and mingw bugs
Eric Blake <ebb9@byu.net>
parents: 9309
diff changeset
1 /* Work around rmdir bugs.
4665
dc6d827f3011 Remove K&R cruft.
Paul Eggert <eggert@cs.ucla.edu>
parents: 2807
diff changeset
2
14079
97fc9a21a8fb maint: update almost all copyright ranges to include 2011
Jim Meyering <meyering@redhat.com>
parents: 13183
diff changeset
3 Copyright (C) 1988, 1990, 1999, 2003-2006, 2009-2011 Free Software
12559
c2cbabec01dd update nearly all FSF copyright year lists to include 2010
Jim Meyering <meyering@redhat.com>
parents: 12518
diff changeset
4 Foundation, Inc.
315
21c5085366d5 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
5
9309
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 7581
diff changeset
6 This program is free software: you can redistribute it and/or modify
315
21c5085366d5 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
9309
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 7581
diff changeset
8 the Free Software Foundation; either version 3 of the License, or
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 7581
diff changeset
9 (at your option) any later version.
315
21c5085366d5 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
10
21c5085366d5 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
11 This program is distributed in the hope that it will be useful,
21c5085366d5 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
21c5085366d5 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21c5085366d5 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
14 GNU General Public License for more details.
21c5085366d5 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
15
21c5085366d5 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
9309
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 7581
diff changeset
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
315
21c5085366d5 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
18
7302
8a1a9361108c * _fpending.c: Include <config.h> unconditionally, since we no
Paul Eggert <eggert@cs.ucla.edu>
parents: 6259
diff changeset
19 #include <config.h>
315
21c5085366d5 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
20
11993
767d867147de rmdir: work around cygwin 1.5.x and mingw bugs
Eric Blake <ebb9@byu.net>
parents: 9309
diff changeset
21 #include <unistd.h>
767d867147de rmdir: work around cygwin 1.5.x and mingw bugs
Eric Blake <ebb9@byu.net>
parents: 9309
diff changeset
22
315
21c5085366d5 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
23 #include <errno.h>
11993
767d867147de rmdir: work around cygwin 1.5.x and mingw bugs
Eric Blake <ebb9@byu.net>
parents: 9309
diff changeset
24 #include <string.h>
315
21c5085366d5 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
25
11993
767d867147de rmdir: work around cygwin 1.5.x and mingw bugs
Eric Blake <ebb9@byu.net>
parents: 9309
diff changeset
26 #undef rmdir
315
21c5085366d5 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
27
5907
c47674a83a78 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
28 /* Remove directory DIR.
315
21c5085366d5 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
29 Return 0 if successful, -1 if not. */
21c5085366d5 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
30
21c5085366d5 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
31 int
11993
767d867147de rmdir: work around cygwin 1.5.x and mingw bugs
Eric Blake <ebb9@byu.net>
parents: 9309
diff changeset
32 rpl_rmdir (char const *dir)
315
21c5085366d5 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
33 {
11993
767d867147de rmdir: work around cygwin 1.5.x and mingw bugs
Eric Blake <ebb9@byu.net>
parents: 9309
diff changeset
34 /* Work around cygwin 1.5.x bug where rmdir("dir/./") succeeds. */
767d867147de rmdir: work around cygwin 1.5.x and mingw bugs
Eric Blake <ebb9@byu.net>
parents: 9309
diff changeset
35 size_t len = strlen (dir);
767d867147de rmdir: work around cygwin 1.5.x and mingw bugs
Eric Blake <ebb9@byu.net>
parents: 9309
diff changeset
36 int result;
767d867147de rmdir: work around cygwin 1.5.x and mingw bugs
Eric Blake <ebb9@byu.net>
parents: 9309
diff changeset
37 while (len && ISSLASH (dir[len - 1]))
767d867147de rmdir: work around cygwin 1.5.x and mingw bugs
Eric Blake <ebb9@byu.net>
parents: 9309
diff changeset
38 len--;
767d867147de rmdir: work around cygwin 1.5.x and mingw bugs
Eric Blake <ebb9@byu.net>
parents: 9309
diff changeset
39 if (len && dir[len - 1] == '.' && (1 == len || ISSLASH (dir[len - 2])))
767d867147de rmdir: work around cygwin 1.5.x and mingw bugs
Eric Blake <ebb9@byu.net>
parents: 9309
diff changeset
40 {
767d867147de rmdir: work around cygwin 1.5.x and mingw bugs
Eric Blake <ebb9@byu.net>
parents: 9309
diff changeset
41 errno = EINVAL;
767d867147de rmdir: work around cygwin 1.5.x and mingw bugs
Eric Blake <ebb9@byu.net>
parents: 9309
diff changeset
42 return -1;
767d867147de rmdir: work around cygwin 1.5.x and mingw bugs
Eric Blake <ebb9@byu.net>
parents: 9309
diff changeset
43 }
767d867147de rmdir: work around cygwin 1.5.x and mingw bugs
Eric Blake <ebb9@byu.net>
parents: 9309
diff changeset
44 result = rmdir (dir);
767d867147de rmdir: work around cygwin 1.5.x and mingw bugs
Eric Blake <ebb9@byu.net>
parents: 9309
diff changeset
45 /* Work around mingw bug, where rmdir("file/") fails with EINVAL
767d867147de rmdir: work around cygwin 1.5.x and mingw bugs
Eric Blake <ebb9@byu.net>
parents: 9309
diff changeset
46 instead of ENOTDIR. We've already filtered out trailing ., the
767d867147de rmdir: work around cygwin 1.5.x and mingw bugs
Eric Blake <ebb9@byu.net>
parents: 9309
diff changeset
47 only reason allowed by POSIX for EINVAL. */
767d867147de rmdir: work around cygwin 1.5.x and mingw bugs
Eric Blake <ebb9@byu.net>
parents: 9309
diff changeset
48 if (result == -1 && errno == EINVAL)
767d867147de rmdir: work around cygwin 1.5.x and mingw bugs
Eric Blake <ebb9@byu.net>
parents: 9309
diff changeset
49 errno = ENOTDIR;
767d867147de rmdir: work around cygwin 1.5.x and mingw bugs
Eric Blake <ebb9@byu.net>
parents: 9309
diff changeset
50 return result;
315
21c5085366d5 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
51 }