bsd-snprintf.c w/out varargs

mouring at etoh.eviladmin.org mouring at etoh.eviladmin.org
Tue Feb 13 12:40:07 EST 2001


There is alot of other stuff I'd like to do with bsd-snprintf.c, but if
you use this patch does things compile better?  (And they will be done,
but I doubt wants a patch that reformats the whole bsd-snprintf.c in their
mailbox. =)

I pretty much removed 'varargs' and expanded the macros which did a simple
clean up.

Before people start yelling about the lack of 'varargs' in my defence.. We
don't support them anywhere else.. Therefor it seems silly to support them
in bsd-snprintf.c. =)

- Ben


--- ../../openssh/openbsd-compat/bsd-snprintf.c	Thu Feb  8 20:57:55 2001
+++ bsd-snprintf.c	Mon Feb 12 19:35:53 2001
@@ -50,39 +50,6 @@
 
 #if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF)
 
-#include <string.h>
-# include <ctype.h>
-#include <sys/types.h>
-
-/* Define this as a fall through, HAVE_STDARG_H is probably already set */
-
-#define HAVE_VARARGS_H
-
-/* varargs declarations: */
-
-#if defined(HAVE_STDARG_H)
-# include <stdarg.h>
-# define HAVE_STDARGS    /* let's hope that works everywhere (mj) */
-# define VA_LOCAL_DECL   va_list ap
-# define VA_START(f)     va_start(ap, f)
-# define VA_SHIFT(v,t)  ;   /* no-op for ANSI */
-# define VA_END          va_end(ap)
-#else
-# if defined(HAVE_VARARGS_H)
-#  include <varargs.h>
-#  undef HAVE_STDARGS
-#  define VA_LOCAL_DECL   va_list ap
-#  define VA_START(f)     va_start(ap)      /* f is ignored! */
-#  define VA_SHIFT(v,t) v = va_arg(ap,t)
-#  define VA_END        va_end(ap)
-# else
-/*XX ** NO VARARGS ** XX*/
-# endif
-#endif
-
-/*int snprintf (char *str, size_t count, const char *fmt, ...);*/
-/*int vsnprintf (char *str, size_t count, const char *fmt, va_list arg);*/
-
 static void dopr (char *buffer, size_t maxlen, const char *format, 
                   va_list args);
 static void fmtstr (char *buffer, size_t *currlen, size_t maxlen,
@@ -718,27 +685,15 @@
 #endif /* !HAVE_VSNPRINTF */
 
 #ifndef HAVE_SNPRINTF
-/* VARARGS3 */
-#ifdef HAVE_STDARGS
 int snprintf (char *str,size_t count,const char *fmt,...)
-#else
-int snprintf (va_alist) va_dcl
-#endif
 {
-#ifndef HAVE_STDARGS
-  char *str;
-  size_t count;
-  char *fmt;
-#endif
-  VA_LOCAL_DECL;
-    
-  VA_START (fmt);
-  VA_SHIFT (str, char *);
-  VA_SHIFT (count, size_t );
-  VA_SHIFT (fmt, char *);
-  (void) vsnprintf(str, count, fmt, ap);
-  VA_END;
-  return(strlen(str));
+	va_list ap;
+
+	va_start(ap, fmt);
+	(void) vsnprintf(str, count, fmt, ap);
+	va_end(ap);
+
+	return(strlen(str));
 }
 
 #ifdef TEST_SNPRINTF






More information about the openssh-unix-dev mailing list