diff options
author | midipix <writeonce@midipix.org> | 2018-06-29 01:23:06 -0400 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2018-06-29 01:37:45 -0400 |
commit | 2c013fe31593c64a59851010320287b9ed27397a (patch) | |
tree | dee5705d7a100ce2948eb746255662b9230b3c69 /src/internal | |
parent | 45a19f7285ca020a2fd3cc095c41c78055c949e6 (diff) | |
download | slibtool-2c013fe31593c64a59851010320287b9ed27397a.tar.bz2 slibtool-2c013fe31593c64a59851010320287b9ed27397a.tar.xz |
internals: re-implemented slbt_create_default_object_wrapper() w. pure fdio.
Diffstat (limited to 'src/internal')
-rw-r--r-- | src/internal/slibtool_objmeta_impl.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/internal/slibtool_objmeta_impl.c b/src/internal/slibtool_objmeta_impl.c index 9e9353b..09a6c97 100644 --- a/src/internal/slibtool_objmeta_impl.c +++ b/src/internal/slibtool_objmeta_impl.c @@ -4,8 +4,10 @@ /* Released under the Standard MIT License; see COPYING.SLIBTOOL. */ /*******************************************************************/ +#include <fcntl.h> #include <stdio.h> #include <slibtool/slibtool.h> +#include "slibtool_dprintf_impl.h" #include "slibtool_errinfo_impl.h" #include "slibtool_metafile_impl.h" @@ -14,15 +16,19 @@ static int slbt_create_default_object_wrapper( struct slbt_exec_ctx * ectx) { int ret; - FILE * fout; + int fdout; const struct slbt_source_version * verinfo; - if (!(fout = fopen(ectx->ltobjname,"w"))) + if ((fdout = openat( + AT_FDCWD, + ectx->ltobjname, + O_RDWR|O_CREAT|O_TRUNC, + 0644)) < 0) return SLBT_SYSTEM_ERROR(dctx); verinfo = slbt_source_version(); - ret = fprintf(fout, + ret = slbt_dprintf(fdout, "# libtool compatible object wrapper\n" "# Generated by %s (slibtool %d.%d.%d)\n" "# [commit reference: %s]\n\n" @@ -41,9 +47,9 @@ static int slbt_create_default_object_wrapper( ? ectx->aobjname : "none"); - return (ret <= 0) || fclose(fout) - ? SLBT_SYSTEM_ERROR(dctx) - : 0; + close(fdout); + + return (ret < 0) ? SLBT_SYSTEM_ERROR(dctx) : 0; } static int slbt_create_compatible_object_wrapper( |