[1370] in Kerberos-V5-bugs

home help back first fref pref prev next nref lref last post

portability improvement in telnet: varargs vs stdard

daemon@ATHENA.MIT.EDU (Scott Schwartz)
Mon May 8 18:43:19 1995

To: krb5-bugs@MIT.EDU
Date: 	Mon, 8 May 1995 18:42:53 -0400
From: Scott Schwartz <schwartz@galapagos.cse.psu.edu>

CenterLine was unhappy with varargs in telnet/commands.c for some
reason, so here's a quick and dirty patch to use stdarg.

*** 1.1	1995/05/08 21:35:49
--- commands.c	1995/05/08 22:28:39
***************
*** 57,63 ****
--- 57,67 ----
  #include <netdb.h>
  #include <ctype.h>
  #include <pwd.h>
+ #ifndef STDC_HEADERS
  #include <varargs.h>
+ #else 
+ #include <stdarg.h>
+ #endif
  #include <errno.h>
  #ifdef HAVE_VFORK_H
  #include <vfork.h>
***************
*** 99,105 ****
--- 103,114 ----
  extern char **genget();
  extern int Ambiguous();
  
+ typedef int (*intrtn_t)();
+ #ifdef __STDC__
+ static call(intrtn_t routine, ...);
+ #else
  static call();
+ #endif
  
  typedef struct {
  	char	*name;		/* command name */
***************
*** 2539,2545 ****
  /*
   * Call routine with argc, argv set from args (terminated by 0).
   */
! 
      /*VARARGS1*/
      static
  call(va_alist)
--- 2548,2554 ----
  /*
   * Call routine with argc, argv set from args (terminated by 0).
   */
! #ifndef STDC_HEADERS
      /*VARARGS1*/
      static
  call(va_alist)
***************
*** 2546,2552 ****
      va_dcl
  {
      va_list ap;
-     typedef int (*intrtn_t)();
      intrtn_t routine;
      char *args[100];
      int argno = 0;
--- 2555,2560 ----
***************
*** 2559,2565 ****
--- 2567,2588 ----
      va_end(ap);
      return (*routine)(argno-1, args);
  }
+ #else
+     static
+ call(intrtn_t routine, ...)
+ {
+     va_list ap;
+     char *args[100];
+     int argno = 0;
  
+     va_start(ap, routine);
+     while ((args[argno++] = va_arg(ap, char *)) != 0) {
+ 	;
+     }
+     va_end(ap);
+     return (*routine)(argno-1, args);
+ }
+ #endif
  
      static Command *
  getcmd(name)

home help back first fref pref prev next nref lref last post