* [PATCH] tempname: allow compilation with C++
@ 2015-02-17 18:34 Mike Miller
2015-02-18 6:06 ` Paul Eggert
0 siblings, 1 reply; 2+ messages in thread
From: Mike Miller @ 2015-02-17 18:34 UTC (permalink / raw
To: bug-gnulib
* 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 <mtmiller@ieee.org>
+
+ 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 <eggert@cs.ucla.edu>
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] tempname: allow compilation with C++
2015-02-17 18:34 [PATCH] tempname: allow compilation with C++ Mike Miller
@ 2015-02-18 6:06 ` Paul Eggert
0 siblings, 0 replies; 2+ messages in thread
From: Paul Eggert @ 2015-02-18 6:06 UTC (permalink / raw
To: Mike Miller, bug-gnulib
Thanks, I installed that, with a slightly different changelog entry. I marked
the change as "(trivial)" since it's small enough so that we don't need a
copyright assignment for it.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-02-18 6:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-17 18:34 [PATCH] tempname: allow compilation with C++ Mike Miller
2015-02-18 6:06 ` Paul Eggert
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).