- portability: vsnprintf/snprintf wrappers for those without (#34657).
authorjbj <devnull@localhost>
Tue, 17 Apr 2001 19:29:12 +0000 (19:29 +0000)
committerjbj <devnull@localhost>
Tue, 17 Apr 2001 19:29:12 +0000 (19:29 +0000)
CVS patchset: 4686
CVS date: 2001/04/17 19:29:12

CHANGES
configure.in
lib/problems.c
rpmio/rpmlog.c

diff --git a/CHANGES b/CHANGES
index f2bb5a7..24e29dc 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -26,6 +26,7 @@
        - fix: --excludepath was broken (#24434).
        - fix: s390 (and ppc?) could return CPIOERR_BAD_HEADER (#28645).
        - fix: Fwrite's are optimized out by aggressive compiler(irix) (#34711).
+       - portability: vsnprintf/snprintf wrappers for those without (#34657).
 
 4.0 -> 4.0.[12]
        - add doxygen and lclint annotations most everywhere.
index 062cb0e..bea687d 100644 (file)
@@ -295,6 +295,8 @@ AC_CHECK_FUNC(socket, [], [
 dnl Better not use fchmod at all.
 AC_CHECK_FUNC(fchmod)
 
+AC_CHECK_FUNCS(vsnprintf snprintf)
+
 dnl Temporary hack for MiNT.  Some functions (writev, snprintf) are
 dnl not in the libc but in libport (for political reasons).  This check
 dnl can hopefully be removed soon.  Please use the default action
index c90cd1a..5069304 100644 (file)
@@ -86,6 +86,25 @@ void printDepProblems(FILE * fp, struct rpmDependencyConflict * conflicts,
     }
 }
 
+#if !defined(HAVE_VSNPRINTF)
+static inline int vsnprintf(char * buf, /*@unused@*/ int nb,
+       const char * fmt, va_list ap)
+{
+    return vsprintf(buf, fmt, ap);
+}
+#endif
+#if !defined(HAVE_SNPRINTF)
+static inline int snprintf(char * buf, int nb, const char * fmt, ...)
+{
+    va_list ap;
+    int rc;
+    va_start(ap, fmt);
+    rc = vsnprintf(buf, nb, fmt, ap);
+    va_end(ap);
+    return rc;
+}
+#endif
+
 const char * rpmProblemString(rpmProblem prob) /*@*/
 {
     int nb =   (prob->pkgNEVR ? strlen(prob->pkgNEVR) : 0) +
index 1d5bdb5..8e060d8 100644 (file)
@@ -98,6 +98,14 @@ static char *rpmlogMsgPrefix[] = {
     "D: ",             /*!< RPMLOG_DEBUG */
 };
 
+#if !defined(HAVE_VSNPRINTF)
+static inline int vsnprintf(char * buf, /*@unused@*/ int nb,
+       const char * fmt, va_list ap)
+{
+    return vsprintf(buf, fmt, ap);
+}
+#endif
+
 static void vrpmlog (unsigned code, const char *fmt, va_list ap)
 {
     int pri = RPMLOG_PRI(code);