From 45a19f7285ca020a2fd3cc095c41c78055c949e6 Mon Sep 17 00:00:00 2001 From: midipix Date: Fri, 29 Jun 2018 01:19:55 -0400 Subject: internals: re-implemented slbt_create_compatible_library_wrapper() w. pure fdio. --- src/internal/slibtool_libmeta_impl.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/internal/slibtool_libmeta_impl.c b/src/internal/slibtool_libmeta_impl.c index bc4fca2..c1366d9 100644 --- a/src/internal/slibtool_libmeta_impl.c +++ b/src/internal/slibtool_libmeta_impl.c @@ -135,7 +135,7 @@ static int slbt_create_compatible_library_wrapper( char * solnk) { int ret; - FILE * fout; + int fdout; const char * base; bool fnover; bool fvernum; @@ -147,7 +147,11 @@ static int slbt_create_compatible_library_wrapper( (void)ectx; /* create */ - if (!(fout = fopen(dctx->cctx->output,"w"))) + if ((fdout = openat( + AT_FDCWD, + dctx->cctx->output, + O_RDWR|O_CREAT|O_TRUNC, + 0644)) < 0) return SLBT_SYSTEM_ERROR(dctx); /* version info */ @@ -171,7 +175,7 @@ static int slbt_create_compatible_library_wrapper( verinfo = slbt_source_version(); /* wrapper content */ - ret = fprintf(fout, + ret = slbt_dprintf(fdout, "# %s - a libtool library file\n" "# Generated by %s (slibtool %d.%d.%d)\n" "# [commit reference: %s]\n" @@ -256,9 +260,9 @@ static int slbt_create_compatible_library_wrapper( /* libdir */ dctx->cctx->rpath ? dctx->cctx->rpath : ""); - return (ret <= 0) || fclose(fout) - ? SLBT_SYSTEM_ERROR(dctx) - : 0; + close(fdout); + + return (ret < 0) ? SLBT_SYSTEM_ERROR(dctx) : 0; } int slbt_create_library_wrapper( -- cgit v1.2.3