m4-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: branch-1_4 maketemp cleanup


From: Eric Blake
Subject: Re: branch-1_4 maketemp cleanup
Date: Fri, 27 Oct 2006 15:16:15 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Eric Blake <ebb9 <at> byu.net> writes:

> >>> Would it make sense to also implement a mkdtemp macro for head?
> > 
> > Sure, that seems like a great idea to me.
> 
> Done:

And cleaned up a bit, now that gnulib provides a tempname module.

2006-10-27  Eric Blake  <address@hidden>

        * ltdl/m4/gnulib-cache.m4: Augment with 'gnulib-tool --import
        tempname'.
        * modules/m4.c (m4_make_temp): Use it.
        * tests/builtins.at (mkstemp, mkdtemp): Update message wording.

Index: ltdl/m4/gnulib-cache.m4
===================================================================
RCS file: /sources/m4/m4/ltdl/m4/gnulib-cache.m4,v
retrieving revision 1.16
diff -u -r1.16 gnulib-cache.m4
--- ltdl/m4/gnulib-cache.m4     26 Oct 2006 23:19:12 -0000      1.16
+++ ltdl/m4/gnulib-cache.m4     27 Oct 2006 15:14:03 -0000
@@ -15,11 +15,11 @@
 
 
 # Specification in the form of a command-line invocation:
-#   gnulib-tool --import --dir=. --lib=libgnu --source-base=gnu --m4-
base=ltdl/m4 --doc-base=doc --aux-dir=ltdl/config --libtool --macro-prefix=M4 
assert avltree-list binary-io clean-temp cloexec close-stream closeout 
configmake dirname error exit fdl filenamecat fopen-safer free gendocs gettext 
gnupload mkstemp obstack progname regex regexprops-generic stdbool stdlib-safer 
strnlen strtol unlocked-io verror xalloc xalloc-die xstrndup xstrtol xvasprintf
+#   gnulib-tool --import --dir=. --lib=libgnu --source-base=gnu --m4-
base=ltdl/m4 --doc-base=doc --aux-dir=ltdl/config --libtool --macro-prefix=M4 
assert avltree-list binary-io clean-temp cloexec close-stream closeout 
configmake dirname error exit fdl filenamecat fopen-safer free gendocs gettext 
gnupload mkstemp obstack progname regex regexprops-generic stdbool stdlib-safer 
strnlen strtol tempname unlocked-io verror xalloc xalloc-die xstrndup xstrtol 
xvasprintf
 
 # Specification in the form of a few gnulib-tool.m4 macro invocations:
 gl_LOCAL_DIR([])
-gl_MODULES([assert avltree-list binary-io clean-temp cloexec close-stream 
closeout configmake dirname error exit fdl filenamecat fopen-safer free gendocs 
gettext gnupload mkstemp obstack progname regex regexprops-generic stdbool 
stdlib-safer strnlen strtol unlocked-io verror xalloc xalloc-die xstrndup 
xstrtol xvasprintf])
+gl_MODULES([assert avltree-list binary-io clean-temp cloexec close-stream 
closeout configmake dirname error exit fdl filenamecat fopen-safer free gendocs 
gettext gnupload mkstemp obstack progname regex regexprops-generic stdbool 
stdlib-safer strnlen strtol tempname unlocked-io verror xalloc xalloc-die 
xstrndup xstrtol xvasprintf])
 gl_AVOID([])
 gl_SOURCE_BASE([gnu])
 gl_M4_BASE([ltdl/m4])
Index: modules/m4.c
===================================================================
RCS file: /sources/m4/m4/modules/m4.c,v
retrieving revision 1.87
diff -u -r1.87 m4.c
--- modules/m4.c        25 Oct 2006 23:19:19 -0000      1.87
+++ modules/m4.c        27 Oct 2006 15:14:03 -0000
@@ -23,6 +23,7 @@
 #include <errno.h>
 
 #include "stdlib--.h"
+#include "tempname.h"
 #include "unistd--.h"
 
 #if HAVE_SYS_WAIT_H
@@ -708,18 +709,15 @@
 
   /* Make the temporary object.  */
   errno = 0;
-  if (dir)
-    fd = mkdtemp (obstack_base (obs)) ? 0 : -1;
-  else
-    fd = mkstemp_safer (obstack_base (obs));
+  fd = gen_tempname (obstack_base (obs), dir ? GT_DIR : GT_FILE);
   if (fd < 0)
     {
       /* This use of _() will need to change if xgettext ever changes
         its undocumented behavior of parsing both string options.  */
 
       m4_error (context, 0, errno,
-               _(dir ? "%s: cannot create directory `%s'"
-                 : "%s: cannot create file `%s'"),
+               _(dir ? "%s: cannot create directory from template `%s'"
+                 : "%s: cannot create file from template `%s'"),
                macro, name);
       obstack_free (obs, obstack_finish (obs));
     }
Index: tests/builtins.at
===================================================================
RCS file: /sources/m4/m4/tests/builtins.at,v
retrieving revision 1.28
diff -u -r1.28 builtins.at
--- tests/builtins.at   26 Oct 2006 23:19:12 -0000      1.28
+++ tests/builtins.at   27 Oct 2006 15:14:03 -0000
@@ -515,7 +515,7 @@
 [[mkdtemp(`no_such_dir/m4-fooXXXXXX')
 ]])
 AT_CHECK_M4([in], [1], [[
-]], [[m4:in:1: mkdtemp: cannot create directory `no_such_dir/m4-fooXXXXXX': No 
such file or directory
+]], [[m4:in:1: mkdtemp: cannot create directory from template `no_such_dir/m4-
fooXXXXXX': No such file or directory
 ]])
 
 dnl Check that umask has an effect
@@ -541,7 +541,7 @@
 [[mkstemp(`no_such_dir/m4-fooXXXXXX')
 ]])
 AT_CHECK_M4([in], [1], [[
-]], [[m4:in:1: mkstemp: cannot create file `no_such_dir/m4-fooXXXXXX': No such 
file or directory
+]], [[m4:in:1: mkstemp: cannot create file from template `no_such_dir/m4-
fooXXXXXX': No such file or directory
 ]])
 
 dnl Check that umask has an effect







reply via email to

[Prev in Thread] Current Thread [Next in Thread]