diff options
| author | Paul Eggert | 2019-10-11 18:23:47 -0700 |
|---|---|---|
| committer | Paul Eggert | 2019-10-11 18:24:19 -0700 |
| commit | 4b60e0722d0a79751f345bd470d07db0d635aa28 (patch) | |
| tree | 9ebcaa21ec5f08c0caafc7190daf34ed047f8e1f /lib/open.c | |
| parent | f9d8babe6a28b19c781778c361e45b93f7a01f17 (diff) | |
| download | emacs-4b60e0722d0a79751f345bd470d07db0d635aa28.tar.gz emacs-4b60e0722d0a79751f345bd470d07db0d635aa28.zip | |
Update from Gnulib
This incorporates:
2019-10-11 Simplify and regularize regex use of ‘assert’
2019-10-09 regex: omit debug assignment when not debugging
2019-10-09 regex: tell compiler there’s at most 256 arcs out
2019-10-09 regex: simplify by assuming C99
2019-10-09 regex: avoid copying of uninitialized storage
2019-09-29 fbufmode: Fix compilation error on glibc >= 2.28 systems
2019-09-28 Update comments that refer to POSIX
2019-09-23 Update URLs and associated text
* doc/misc/texinfo.tex, lib/open.c, lib/regcomp.c:
* lib/regex_internal.c, lib/regex_internal.h, lib/regexec.c:
* lib/stdio-impl.h:
Copy from Gnulib.
Diffstat (limited to 'lib/open.c')
| -rw-r--r-- | lib/open.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/open.c b/lib/open.c index 4572ebf6cd2..0c2742bbda6 100644 --- a/lib/open.c +++ b/lib/open.c | |||
| @@ -92,9 +92,13 @@ open (const char *filename, int flags, ...) | |||
| 92 | #endif | 92 | #endif |
| 93 | 93 | ||
| 94 | #if OPEN_TRAILING_SLASH_BUG | 94 | #if OPEN_TRAILING_SLASH_BUG |
| 95 | /* If the filename ends in a slash and one of O_CREAT, O_WRONLY, O_RDWR | 95 | /* Fail if one of O_CREAT, O_WRONLY, O_RDWR is specified and the filename |
| 96 | is specified, then fail. | 96 | ends in a slash, as POSIX says such a filename must name a directory |
| 97 | Rationale: POSIX <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html> | 97 | <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13>: |
| 98 | "A pathname that contains at least one non-<slash> character and that | ||
| 99 | ends with one or more trailing <slash> characters shall not be resolved | ||
| 100 | successfully unless the last pathname component before the trailing | ||
| 101 | <slash> characters names an existing directory" | ||
| 98 | If the named file already exists as a directory, then | 102 | If the named file already exists as a directory, then |
| 99 | - if O_CREAT is specified, open() must fail because of the semantics | 103 | - if O_CREAT is specified, open() must fail because of the semantics |
| 100 | of O_CREAT, | 104 | of O_CREAT, |
| @@ -164,6 +168,12 @@ open (const char *filename, int flags, ...) | |||
| 164 | #if OPEN_TRAILING_SLASH_BUG | 168 | #if OPEN_TRAILING_SLASH_BUG |
| 165 | /* If the filename ends in a slash and fd does not refer to a directory, | 169 | /* If the filename ends in a slash and fd does not refer to a directory, |
| 166 | then fail. | 170 | then fail. |
| 171 | Rationale: POSIX says such a filename must name a directory | ||
| 172 | <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13>: | ||
| 173 | "A pathname that contains at least one non-<slash> character and that | ||
| 174 | ends with one or more trailing <slash> characters shall not be resolved | ||
| 175 | successfully unless the last pathname component before the trailing | ||
| 176 | <slash> characters names an existing directory" | ||
| 167 | If the named file without the slash is not a directory, open() must fail | 177 | If the named file without the slash is not a directory, open() must fail |
| 168 | with ENOTDIR. */ | 178 | with ENOTDIR. */ |
| 169 | if (fd >= 0) | 179 | if (fd >= 0) |