]> granicus.if.org Git - sudo/commitdiff
Allow sudo to compile without variadic macro support in cpp.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 18 Nov 2013 16:10:09 +0000 (09:10 -0700)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 18 Nov 2013 16:10:09 +0000 (09:10 -0700)
Debugging support will be limited (no file info from warnings.)
From Daniel Richard G.; Bug #621

common/sudo_debug.c
config.h.in
configure
configure.ac
include/fatal.h
include/sudo_debug.h

index 7e51ff279632c5bfee83f707813eaa9d33183cbc..33a081a13faaf302ae829b92ca419b8c538478a7 100644 (file)
@@ -458,6 +458,18 @@ sudo_debug_vprintf2(const char *func, const char *file, int lineno, int level,
     errno = saved_errno;
 }
 
+#ifdef NO_VARIADIC_MACROS
+void
+sudo_debug_printf_nvm(int pri, const char *fmt, ...)
+{
+    va_list ap;
+
+    va_start(ap, fmt);
+    sudo_debug_vprintf2(NULL, NULL, 0, pri, fmt, ap);
+    va_end(ap);
+}
+#endif /* NO_VARIADIC_MACROS */
+
 void
 sudo_debug_printf2(const char *func, const char *file, int lineno, int level,
     const char *fmt, ...)
index 98c355cf920e6f2c2edd0fe237cc5ef4b281afdc..9d42f063e0c452f37c2680007e76718f2ba0509b 100644 (file)
 /* Define to 1 if you want a single ticket file instead of per-tty files. */
 #undef NO_TTY_TICKETS
 
+/* Define if your C preprocessor does not support variadic macros. */
+#undef NO_VARIADIC_MACROS
+
 /* Define to the address where bug reports for this package should be sent. */
 #undef PACKAGE_BUGREPORT
 
index f979b74e8a3ea0697320746a563656c9104909ff..7f0ecd9d3ec835222c5928c0dfccc79fc5fbcfeb 100755 (executable)
--- a/configure
+++ b/configure
@@ -14872,7 +14872,8 @@ $as_echo "#define volatile /**/" >>confdefs.h
 
 fi
 
-# Check for variadic macro support in cpp
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for variadic macro support in cpp" >&5
+$as_echo_n "checking for variadic macro support in cpp... " >&6; }
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -14892,9 +14893,16 @@ sudo_fprintf(stderr, "a %s", "test");
 }
 _ACEOF
 if ac_fn_c_try_compile "$LINENO"; then :
-
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
 else
-  as_fn_error $? "Your C compiler doesn't support variadic macros, try building with gcc instead" "$LINENO" 5
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+$as_echo "#define NO_VARIADIC_MACROS 1" >>confdefs.h
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Your C compiler doesn't support variadic macros, debugging support will be limited" >&5
+$as_echo "$as_me: WARNING: Your C compiler doesn't support variadic macros, debugging support will be limited" >&2;}
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
@@ -16132,7 +16140,7 @@ _ACEOF
 fi
 
 ac_fn_c_check_type "$LINENO" "struct timespec" "ac_cv_type_struct_timespec" "#include <sys/types.h>
-#if TIME_WITH_SYS_TIME
+#ifdef TIME_WITH_SYS_TIME
 # include <sys/time.h>
 #endif
 #include <time.h>
index 08232ec9da56ee4bd045423bea306b6388d51ccd..682e25fbe54384f080fe67598f8d2074b39cdab6 100644 (file)
@@ -2066,7 +2066,7 @@ dnl
 AC_PROG_GCC_TRADITIONAL
 AC_C_CONST
 AC_C_VOLATILE
-# Check for variadic macro support in cpp
+AC_MSG_CHECKING([for variadic macro support in cpp])
 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
 AC_INCLUDES_DEFAULT
 #if defined(__GNUC__) && __GNUC__ == 2
@@ -2074,7 +2074,10 @@ AC_INCLUDES_DEFAULT
 #else
 # define sudo_fprintf(fp, ...) fprintf((fp), __VA_ARGS__)
 #endif
-], [sudo_fprintf(stderr, "a %s", "test");])], [], [AC_MSG_ERROR([Your C compiler doesn't support variadic macros, try building with gcc instead])])
+], [sudo_fprintf(stderr, "a %s", "test");])], [AC_MSG_RESULT([yes])],
+[AC_MSG_RESULT([no])
+ AC_DEFINE([NO_VARIADIC_MACROS], [1], [Define if your C preprocessor does not support variadic macros.])
+ AC_MSG_WARN([Your C compiler doesn't support variadic macros, debugging support will be limited])])
 
 dnl
 dnl Program checks
index 18bf640141de50c9755ea9c29a31ff6753296da0..9963b0f78c2d47ba6e4367743b42ea5eefa730fc 100644 (file)
  * We wrap fatal/fatalx and warning/warningx so that the same output can
  * go to the debug file, if there is one.
  */
-#if defined(SUDO_ERROR_WRAP) && SUDO_ERROR_WRAP == 0
-# if defined(__GNUC__) && __GNUC__ == 2
-#  define fatal(fmt...) fatal_nodebug(fmt)
-#  define fatalx(fmt...) fatalx_nodebug(fmt)
-#  define warning(fmt...) warning_nodebug(fmt)
-#  define warningx(fmt...) warningx_nodebug(fmt)
-# else
-#  define fatal(...) fatal_nodebug(__VA_ARGS__)
-#  define fatalx(...) fatalx_nodebug(__VA_ARGS__)
-#  define warning(...) warning_nodebug(__VA_ARGS__)
-#  define warningx(...) warningx_nodebug(__VA_ARGS__)
-# endif /* __GNUC__ == 2 */
+#if (defined(SUDO_ERROR_WRAP) && SUDO_ERROR_WRAP == 0) || defined(NO_VARIADIC_MACROS)
+# define fatal fatal_nodebug
+# define fatalx fatalx_nodebug
+# define warning warning_nodebug
+# define warningx warningx_nodebug
 # define vfatal(fmt, ap) fatal_nodebug((fmt), (ap))
 # define vfatalx(fmt, ap) fatalx_nodebug((fmt), (ap))
 # define vwarning(fmt, ap) warning_nodebug((fmt), (ap))
index 4803df0bf3217d5fde257718404d10293e1bdd23..9a17211c8bf2e3e96202d22a6ee828b7d4c7331a 100644 (file)
  * Variadic macros are a C99 feature but GNU cpp has supported
  * a (different) version of them for a long time.
  */
-#if defined(__GNUC__) && __GNUC__ == 2
+#if defined(NO_VARIADIC_MACROS)
+# define sudo_debug_printf sudo_debug_printf_nvm
+#elif defined(__GNUC__) && __GNUC__ == 2
 # define sudo_debug_printf(pri, fmt...) \
     sudo_debug_printf2(__func__, __FILE__, __LINE__, (pri)|sudo_debug_subsys, \
     fmt)
@@ -218,6 +220,7 @@ void sudo_debug_exit_str_masked(const char *func, const char *file, int line, in
 void sudo_debug_exit_ptr(const char *func, const char *file, int line, int subsys, const void *rval);
 int sudo_debug_fd_set(int fd);
 int sudo_debug_init(const char *debugfile, const char *settings);
+void sudo_debug_printf_nvm(int pri, const char *fmt, ...) __printf0like(2, 3);
 void sudo_debug_printf2(const char *func, const char *file, int line, int level, const char *fmt, ...) __printf0like(5, 6);
 void sudo_debug_vprintf2(const char *func, const char *file, int line, int level, const char *fmt, va_list ap) __printf0like(5, 0);
 void sudo_debug_write(const char *str, int len, int errno_val);