m4-commit
[Top][All Lists]
Advanced

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

Changes to m4/modules/m4.c,v


From: Eric Blake
Subject: Changes to m4/modules/m4.c,v
Date: Sat, 21 Oct 2006 22:15:53 +0000

CVSROOT:        /sources/m4
Module name:    m4
Changes by:     Eric Blake <ericb>      06/10/21 22:15:52

Index: modules/m4.c
===================================================================
RCS file: /sources/m4/m4/modules/m4.c,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -b -r1.84 -r1.85
--- modules/m4.c        19 Oct 2006 23:13:45 -0000      1.84
+++ modules/m4.c        21 Oct 2006 22:15:52 -0000      1.85
@@ -53,6 +53,8 @@
 extern void m4_dump_symbols  (m4 *context, m4_dump_symbol_data *data, int argc,
                              m4_symbol_value **argv, bool complain);
 extern const char *m4_expand_ranges (const char *s, m4_obstack *obs);
+extern void m4_make_temp     (m4 *context, m4_obstack *obs, const char *macro,
+                             const char *name, bool dir);
 
 /* Maintain each of the builtins implemented in this modules along
    with their details in a single table for easy maintenance.
@@ -673,17 +675,17 @@
 /* Use the first argument as at template for a temporary file name.
    FIXME - should we add a mkdtemp builtin in the gnu module, then
    export this function as a helper to that?  */
-static void
-m4_make_temp (m4 *context, m4_obstack *obs, int argc, m4_symbol_value **argv)
+void
+m4_make_temp (m4 *context, m4_obstack *obs, const char *macro,
+             const char *name, bool dir)
 {
   int fd;
   int len;
   int i;
-  const char *name = M4ARG (1);
 
   if (m4_get_safer_opt (context))
     {
-      m4_error (context, 0, 0, _("%s: disabled by --safer"), M4ARG (0));
+      m4_error (context, 0, 0, _("%s: disabled by --safer"), macro);
       return;
     }
 
@@ -699,15 +701,24 @@
     obstack_1grow (obs, 'X');
   obstack_1grow (obs, '\0');
 
+  /* Make the temporary object.  */
   errno = 0;
+  if (dir)
+    fd = mkdtemp (obstack_base (obs)) ? 0 : -1;
+  else
   fd = mkstemp (obstack_base (obs));
   if (fd < 0)
     {
-      m4_error (context, 0, errno, _("%s: cannot create tempfile `%s'"),
-               M4ARG (0), name);
+      /* 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'"),
+               macro, name);
       obstack_free (obs, obstack_finish (obs));
     }
-  else
+  else if (! dir)
      close (fd);
 }
 
@@ -748,13 +759,13 @@
        }
     }
   else
-    m4_make_temp (context, obs, argc, argv);
+    m4_make_temp (context, obs, M4ARG (0), M4ARG (1), false);
 }
 
 /* Use the first argument as a template for a temporary file name.  */
 M4BUILTIN_HANDLER (mkstemp)
 {
-  m4_make_temp (context, obs, argc, argv);
+  m4_make_temp (context, obs, M4ARG (0), M4ARG (1), false);
 }
 
 /* Print all arguments on standard error.  */




reply via email to

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