Mercurial > hg > octave-jordi > gnulib-hg
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 |
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 | 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 | 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 | 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 | 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 | |
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 | 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 | 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 | 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 | 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 | 27 |
5907 | 28 /* Remove directory DIR. |
315 | 29 Return 0 if successful, -1 if not. */ |
30 | |
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 | 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 | 51 } |