summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2016-07-16 15:34:41 +0200
committerAndy Wingo <wingo@pobox.com>2016-07-25 11:46:18 +0200
commitaae356158412662c97b7178768bfe4be41749a3b (patch)
tree7aa62f3b9a505ecc4f5008a60221e54f2def5317 /lib
parente868fae6585d82c0b46a9a840913f0674dde0d3e (diff)
downloadguile-aae356158412662c97b7178768bfe4be41749a3b.tar.gz
Allow mkstemp! to have optional "mode" argument
* m4/mkstemp.m4: Remove. * lib/mkstemp.c: Remove. * lib/mkostemp.c: New file. * m4/mkostemp.m4: New file. * lib/Makefile.am: * m4/gnulib-cache.m4: * m4/gnulib-comp.m4: Remove mkstemp module, replace with mkostemp. * libguile/fports.h: * libguile/fports.c (scm_i_mode_to_open_flags): Factor out helper to parse mode string to open flags. (scm_open_file_with_encoding): Use the new helper. * libguile/filesys.c: (scm_i_mkstemp): Adapt to take optional second argument, being a mode string. Use mkostemp. (scm_mkstemp): Backwards compatible shim that calls scm_i_mkstemp. * doc/ref/posix.texi: * NEWS: Update. * module/system/base/compile.scm (call-with-output-file/atomic): Pass "wb" as mode, to cause O_BINARY to be added on MinGW.
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile.am10
-rw-r--r--lib/mkostemp.c (renamed from lib/mkstemp.c)12
2 files changed, 9 insertions, 13 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am
index adf95373e..b9749062b 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -21,7 +21,7 @@
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
-# Reproduce by: gnulib-tool --import --local-dir=gnulib-local --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=lock --avoid=unistr/base --avoid=unistr/u8-mbtouc --avoid=unistr/u8-mbtouc-unsafe --avoid=unistr/u8-mbtoucr --avoid=unistr/u8-prev --avoid=unistr/u8-uctomb --avoid=unitypes --lgpl=3 --conditional-dependencies --libtool --macro-prefix=gl --no-vc-files accept alignof alloca-opt announce-gen autobuild bind byteswap c-strcase canonicalize-lgpl ceil clock-time close connect copysign dirfd duplocale environ extensions flock floor fpieee frexp fstat fsync full-read full-write func gendocs getaddrinfo getlogin getpeername getsockname getsockopt git-version-gen gitlog-to-changelog gnu-web-doc-update gnupload havelib iconv_open-utf inet_ntop inet_pton isfinite isinf isnan ldexp lib-symbol-versions lib-symbol-visibility libunistring link listen localcharset locale log1p lstat maintainer-makefile malloc-gnu malloca mkdir mkstemp nl_langinfo nproc open pipe-posix pipe2 poll putenv readlink recv recvfrom regex rename rmdir select send sendto setenv setsockopt shutdown socket stat-time stdlib strftime striconveh string sys_stat time times trunc unistd verify vsnprintf warnings wchar
+# Reproduce by: gnulib-tool --import --local-dir=gnulib-local --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=lock --avoid=unistr/base --avoid=unistr/u8-mbtouc --avoid=unistr/u8-mbtouc-unsafe --avoid=unistr/u8-mbtoucr --avoid=unistr/u8-prev --avoid=unistr/u8-uctomb --avoid=unitypes --lgpl=3 --conditional-dependencies --libtool --macro-prefix=gl --no-vc-files accept alignof alloca-opt announce-gen autobuild bind byteswap c-strcase canonicalize-lgpl ceil clock-time close connect copysign dirfd duplocale environ extensions flock floor fpieee frexp fstat fsync full-read full-write func gendocs getaddrinfo getlogin getpeername getsockname getsockopt git-version-gen gitlog-to-changelog gnu-web-doc-update gnupload havelib iconv_open-utf inet_ntop inet_pton isfinite isinf isnan ldexp lib-symbol-versions lib-symbol-visibility libunistring link listen localcharset locale log1p lstat maintainer-makefile malloc-gnu malloca mkdir mkostemp nl_langinfo nproc open pipe-posix pipe2 poll putenv readlink recv recvfrom regex rename rmdir select send sendto setenv setsockopt shutdown socket stat-time stdlib strftime striconveh string sys_stat time times trunc unistd verify vsnprintf warnings wchar
AUTOMAKE_OPTIONS = 1.9.6 gnits
@@ -1500,14 +1500,14 @@ EXTRA_libgnu_la_SOURCES += mkdir.c
## end gnulib module mkdir
-## begin gnulib module mkstemp
+## begin gnulib module mkostemp
-EXTRA_DIST += mkstemp.c
+EXTRA_DIST += mkostemp.c
-EXTRA_libgnu_la_SOURCES += mkstemp.c
+EXTRA_libgnu_la_SOURCES += mkostemp.c
-## end gnulib module mkstemp
+## end gnulib module mkostemp
## begin gnulib module mktime
diff --git a/lib/mkstemp.c b/lib/mkostemp.c
index bbad5f9cd..25a63b7b1 100644
--- a/lib/mkstemp.c
+++ b/lib/mkostemp.c
@@ -24,7 +24,7 @@
#if !_LIBC
# include "tempname.h"
# define __gen_tempname gen_tempname
-# ifndef __GT_FILE
+# ifndef __GTFILE
# define __GT_FILE GT_FILE
# endif
#endif
@@ -38,13 +38,9 @@
/* Generate a unique temporary file name from XTEMPLATE.
The last six characters of XTEMPLATE must be "XXXXXX";
they are replaced with a string that makes the file name unique.
- Then open the file and return a fd.
-
- If you are creating temporary files which will later be removed,
- consider using the clean-temp module, which avoids several pitfalls
- of using mkstemp directly. */
+ Then open the file and return a fd. */
int
-mkstemp (char *xtemplate)
+mkostemp (char *xtemplate, int flags)
{
- return __gen_tempname (xtemplate, 0, 0, __GT_FILE);
+ return __gen_tempname (xtemplate, 0, flags, __GT_FILE);
}