]> git.ipfire.org Git - thirdparty/make.git/commit
Enhance get_tmpfile() and add get_tmppath()
authorPaul Smith <psmith@gnu.org>
Mon, 1 Aug 2022 16:57:12 +0000 (12:57 -0400)
committerPaul Smith <psmith@gnu.org>
Wed, 3 Aug 2022 03:36:35 +0000 (23:36 -0400)
commit09cce75c308a6e7ae0f3635724d2ae87e72f9800
tree76b706491cd21acd9f87d80da6c8ea4852506692
parent07eea3aa496184bb763b7306e9de6a40a94605c9
Enhance get_tmpfile() and add get_tmppath()

Move all the logic on creating temporary files into misc.c, and add
a new function get_tmppath() that returns the pathname to a temporary
file without creating or opening it.

* src/makeint.h: Add a declaration for get_tmppath().  Remove the
template argument from get_tmpfile(): it will compute its own.
* src/main.c (main): Remove the logic for computing templates.
* src/vmsjobs.c (child_execute_job): Ditto.
* src/misc.c (get_tmptemplate): New function to return an allocated
template string for use with various mktemp-style functions.
(get_tmppath): Return an allocated path to a temporary file, but do
not create it.  Generally this should be avoided due to TOCTOU issues.
(get_tmpfile): Use get_tmptemplate() to generate a template rather
than using one passed in.  If we don't have mkstemp() then use
get_tmppath() to compute the path of a temp file.
src/main.c
src/makeint.h
src/misc.c
src/vmsjobs.c