]> Savannah Git Hosting - gnulib.git/commitdiff
tempname: allow compilation with C++ (trivial)
authorMike Miller <mtmiller@ieee.org>
Wed, 18 Feb 2015 06:04:51 +0000 (22:04 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 18 Feb 2015 06:05:16 +0000 (22:05 -0800)
* lib/tempname.h [C++]: Specify extern "C" linkage.
* lib/tempname.h (try_tempname):
* lib/tempname.c (__try_tempname, __gen_tempname):
Rename 'try' to 'tryfunc'.

ChangeLog
lib/tempname.c
lib/tempname.h

index f3b7b3ac51f4e28ad14cfc9c9aee7136da6399e9..37b77485b84d4f95e033e3422dfbe08f8adcfa20 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2015-02-17  Mike Miller  <mtmiller@ieee.org>
+
+       tempname: allow compilation with C++ (trivial)
+       * lib/tempname.h [C++]: Specify extern "C" linkage.
+       * lib/tempname.h (try_tempname):
+       * lib/tempname.c (__try_tempname, __gen_tempname):
+       Rename 'try' to 'tryfunc'.
+
 2015-02-17  Paul Eggert  <eggert@cs.ucla.edu>
 
        dup2, fcntl: port to AIX
index 49c7df1d1b4e82fa2574dfada2c903faac870d99..8e6d26cc4859c83aa5a44534f41bdb7b9713d4df 100644 (file)
@@ -179,7 +179,7 @@ static const char letters[] =
 
 int
 __try_tempname (char *tmpl, int suffixlen, void *args,
-                int (*try) (char *, void *))
+                int (*tryfunc) (char *, void *))
 {
   int len;
   char *XXXXXX;
@@ -244,7 +244,7 @@ __try_tempname (char *tmpl, int suffixlen, void *args,
       v /= 62;
       XXXXXX[5] = letters[v % 62];
 
-      fd = try (tmpl, args);
+      fd = tryfunc (tmpl, args);
       if (fd >= 0)
         {
           __set_errno (save_errno);
@@ -300,25 +300,25 @@ try_nocreate (char *tmpl, void *flags)
 int
 __gen_tempname (char *tmpl, int suffixlen, int flags, int kind)
 {
-  int (*try) (char *, void *);
+  int (*tryfunc) (char *, void *);
 
   switch (kind)
     {
     case __GT_FILE:
-      try = try_file;
+      tryfunc = try_file;
       break;
 
     case __GT_DIR:
-      try = try_dir;
+      tryfunc = try_dir;
       break;
 
     case __GT_NOCREATE:
-      try = try_nocreate;
+      tryfunc = try_nocreate;
       break;
 
     default:
       assert (! "invalid KIND in __gen_tempname");
       abort ();
     }
-  return __try_tempname (tmpl, suffixlen, &flags, try);
+  return __try_tempname (tmpl, suffixlen, &flags, tryfunc);
 }
index 0df4381c6c5e8e5b5a5ae04d5d7a2fa8a8b57c7c..e6093607463c113edbafa52d19b86ce47d825f28 100644 (file)
 #  define GT_NOCREATE 2
 # endif
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Generate a temporary file name based on TMPL.  TMPL must match the
    rules for mk[s]temp (i.e. end in "XXXXXX", possibly with a suffix).
    The name constructed does not exist at the time of the call to
    We use a clever algorithm to get hard-to-predict names. */
 extern int gen_tempname (char *tmpl, int suffixlen, int flags, int kind);
 
-/* Similar to gen_tempname, but TRY is called for each temporary
-   name to try.  If TRY returns a non-negative number, TRY_GEN_TEMPNAME
+/* Similar to gen_tempname, but TRYFUNC is called for each temporary
+   name to try.  If TRYFUNC returns a non-negative number, TRY_GEN_TEMPNAME
    returns with this value.  Otherwise, if errno is set to EEXIST, another
    name is tried, or else TRY_GEN_TEMPNAME returns -1. */
 extern int try_tempname (char *tmpl, int suffixlen, void *args,
-                         int (*try) (char *, void *));
+                         int (*tryfunc) (char *, void *));
+
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* GL_TEMPNAME_H */