summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-08-29 08:22:44 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-08-29 08:22:44 -0700
commit2a1c55fc153bc793256cd3dbb97dd568c782a561 (patch)
treeb1de9d7c4370f22d2469c10cc157441259f4bae1
parent469cd5ab27bba7679bebe60cd0617e09f4838e50 (diff)
downloadtxr-2a1c55fc153bc793256cd3dbb97dd568c782a561.tar.gz
txr-2a1c55fc153bc793256cd3dbb97dd568c782a561.tar.bz2
txr-2a1c55fc153bc793256cd3dbb97dd568c782a561.zip
open-file: improvement: "a" mode sets create flag.
* stream.c (w_fopen_mode): Only test the m.create flag as the basis for O_CREAT, not m.append. (do_parse_mode): In the 'a' case, set m.create = 1, since all variants of append mode create the file.
-rw-r--r--stream.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/stream.c b/stream.c
index 1183f7f5..9db94380 100644
--- a/stream.c
+++ b/stream.c
@@ -1127,8 +1127,7 @@ static FILE *w_fopen_mode(const wchar_t *wname, const wchar_t *mode,
int flags = (if3(m.read && m.write, O_RDWR, 0) |
if3(m.read && !m.write, O_RDONLY, 0) |
if3(!m.read && m.write, O_WRONLY, 0) |
- if3(m.create || m.append,
- if3(!m.notrunc, O_TRUNC, 0) | O_CREAT, 0) |
+ if3(m.create, if3(!m.notrunc, O_TRUNC, 0) | O_CREAT, 0) |
if3(m.append, O_APPEND, 0) |
if3(m.excl, O_EXCL, 0) |
if3(m.nonblock, O_NONBLOCK, 0));
@@ -1459,6 +1458,7 @@ static struct stdio_mode do_parse_mode(val mode_str, struct stdio_mode m_dfl,
case 'a':
ms++;
m.write = 1;
+ m.create = 1;
m.append = 1;
m.notrunc = 1;
break;