[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 38/55: Fix binary output on files created by mkstemp!
From: |
Andy Wingo |
Subject: |
[Guile-commits] 38/55: Fix binary output on files created by mkstemp! |
Date: |
Thu, 23 May 2019 11:52:42 -0400 (EDT) |
wingo pushed a commit to branch master
in repository guile.
commit a5df94e78c3aaed257c9b8dbaafff28cf506cca8
Author: Mike Gran <address@hidden>
Date: Sat Feb 9 16:59:38 2019 -0800
Fix binary output on files created by mkstemp!
Some operating systems require a O_BINARY flag.
* libguile/filesys.c (scm_i_mkstemp): Don't mask out O_BINARY flag
* test-suite/tests/posix.test ("binary mode honored"): new test
---
libguile/filesys.c | 6 +++---
test-suite/tests/posix.test | 17 ++++++++++++++++-
2 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/libguile/filesys.c b/libguile/filesys.c
index 113cf78..ccec10b 100644
--- a/libguile/filesys.c
+++ b/libguile/filesys.c
@@ -1513,9 +1513,9 @@ SCM_DEFINE (scm_i_mkstemp, "mkstemp!", 1, 1, 0,
/* mkostemp(2) only defines O_APPEND, O_SYNC, and O_CLOEXEC to be
useful, as O_RDWR|O_CREAT|O_EXCL are implicitly added. It also
notes that other flags may error on some systems, which turns
- out to be the case. Of those flags, O_APPEND is the only one
- of interest anyway, so limit to that flag. */
- open_flags &= O_APPEND;
+ out to be the case. Of those flags, O_APPEND and O_BINARY are
+ the only ones of interest anyway, so limit to those flags. */
+ open_flags &= O_APPEND | O_BINARY;
mode_bits = scm_i_mode_bits (mode);
}
diff --git a/test-suite/tests/posix.test b/test-suite/tests/posix.test
index aa1605a..aa0dbc1 100644
--- a/test-suite/tests/posix.test
+++ b/test-suite/tests/posix.test
@@ -76,7 +76,22 @@
(result (not (string=? str template))))
(close-port port)
(delete-file str)
- result)))
+ result))
+
+ (pass-if "binary mode honored"
+ (let* ((template "T-XXXXXX")
+ (str (string-copy template))
+ (outport (mkstemp! str "wb")))
+ (display "\n" outport)
+ (close-port outport)
+ (let* ((inport (open-input-file str #:binary #t))
+ (char1 (read-char inport))
+ (char2 (read-char inport))
+ (result (and (char=? char1 #\newline)
+ (eof-object? char2))))
+ (close-port inport)
+ (delete-file str)
+ result))))
;;
;; putenv
- [Guile-commits] 10/55: Fix 'round-ash' of negative integers by huge right shift counts., (continued)
- [Guile-commits] 10/55: Fix 'round-ash' of negative integers by huge right shift counts., Andy Wingo, 2019/05/23
- [Guile-commits] 12/55: Clarify the manual's "Processes" section., Andy Wingo, 2019/05/23
- [Guile-commits] 09/55: Gracefully handle huge shift counts in 'ash' and 'round-ash'., Andy Wingo, 2019/05/23
- [Guile-commits] 24/55: SRFI-19: time-utc->date: Support non-integer nanoseconds values., Andy Wingo, 2019/05/23
- [Guile-commits] 21/55: SRFI-19: Add a few more tests., Andy Wingo, 2019/05/23
- [Guile-commits] 11/55: In 'ash' and 'round-ash', handle right shift count of LONG_MIN., Andy Wingo, 2019/05/23
- [Guile-commits] 16/55: Add tests for type inferencing for 'nil?' and 'null?' predicates., Andy Wingo, 2019/05/23
- [Guile-commits] 22/55: SRFI-19: Fix normalization of seconds and nanoseconds in time records., Andy Wingo, 2019/05/23
- [Guile-commits] 20/55: SRFI-19: Fix handling of negative years and negative julian days., Andy Wingo, 2019/05/23
- [Guile-commits] 37/55: Avoid leaking a file descriptor in test-unwind, Andy Wingo, 2019/05/23
- [Guile-commits] 38/55: Fix binary output on files created by mkstemp!,
Andy Wingo <=
- [Guile-commits] 43/55: Fix typo in comment., Andy Wingo, 2019/05/23
- [Guile-commits] 04/55: Define AT_SYMLINK_NOFOLLOW et al., Andy Wingo, 2019/05/23
- [Guile-commits] 08/55: Fix list validation of *list->bytevector procedures., Andy Wingo, 2019/05/23
- [Guile-commits] 13/55: Update SRFI-19 leap second table., Andy Wingo, 2019/05/23
- [Guile-commits] 05/55: Fix 'atomic-box-compare-and-swap!'., Andy Wingo, 2019/05/23
- [Guile-commits] 26/55: Add texinfo dependency to README, Andy Wingo, 2019/05/23
- [Guile-commits] 27/55: Bootstrap optimization, Andy Wingo, 2019/05/23
- [Guile-commits] 32/55: Fix tests for SRFI-19 date->string ~N, Andy Wingo, 2019/05/23
- [Guile-commits] 33/55: Do not warn the user when 'madvise' returns ENOSYS., Andy Wingo, 2019/05/23
- [Guile-commits] 30/55: Update (ice-9 match) to include selected bug fixes from upstream., Andy Wingo, 2019/05/23