bug-gnulib
[Top][All Lists]
Advanced

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

[PATCH] tempname: allow compilation with C++


From: Mike Miller
Subject: [PATCH] tempname: allow compilation with C++
Date: Tue, 17 Feb 2015 13:34:17 -0500
User-agent: Mutt/1.5.23 (2014-03-12)

* lib/tempname.h: Specify extern "C" linkage with C++.
(try_tempname): Rename `try' to `tryfunc'.
* lib/tempname.c (__try_tempname, __gen_tempname): Rename `try' to
`tryfunc' for consistency.
---
 ChangeLog      |  8 ++++++++
 lib/tempname.c | 14 +++++++-------
 lib/tempname.h | 14 +++++++++++---
 3 files changed, 26 insertions(+), 10 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 5083e95..aa17a64 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2015-02-17  Mike Miller  <address@hidden>
+
+       tempname: allow compilation with C++
+       * lib/tempname.h: Specify extern "C" linkage with C++.
+       (try_tempname): Rename `try' to `tryfunc'.
+       * lib/tempname.c (__try_tempname, __gen_tempname): Rename `try' to
+       `tryfunc' for consistency.
+
 2015-02-16  Paul Eggert  <address@hidden>
 
        getdtablesize, dup2, fcntl: port to Android
diff --git a/lib/tempname.c b/lib/tempname.c
index 49c7df1..8e6d26c 100644
--- a/lib/tempname.c
+++ b/lib/tempname.c
@@ -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);
 }
diff --git a/lib/tempname.h b/lib/tempname.h
index 0df4381..e609360 100644
--- a/lib/tempname.h
+++ b/lib/tempname.h
@@ -32,6 +32,10 @@
 #  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
@@ -47,11 +51,15 @@
    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 */
-- 
2.1.4



reply via email to

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