[svn-commits] seanbright: trunk r398 - /trunk/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Nov 5 10:14:17 CST 2008


Author: seanbright
Date: Sat Oct 11 08:40:38 2008
New Revision: 398

URL: http://svn.digium.com/view/menuselect?view=rev&rev=398
Log:
Add --enable-debug to configure to toggle menuselect debugging on and off.

Modified:
    trunk/Makefile
    trunk/configure
    trunk/configure.ac
    trunk/makeopts.in
    trunk/menuselect.c

Modified: trunk/Makefile
URL: http://svn.digium.com/view/menuselect/trunk/Makefile?view=diff&rev=398&r1=397&r2=398
==============================================================================
--- trunk/Makefile (original)
+++ trunk/Makefile Sat Oct 11 08:40:38 2008
@@ -19,6 +19,10 @@
 # Basic set of sources and flags/libraries/includes
 OBJS:=menuselect.o strcompat.o
 CFLAGS:=-g -c -D_GNU_SOURCE -Wall
+
+ifeq ($(MENUSELECT_DEBUG),yes)
+  CFLAGS += -DMENUSELECT_DEBUG
+endif
 
 ifdef NCURSES_LIB
   C_OBJS += menuselect_curses.o

Modified: trunk/configure.ac
URL: http://svn.digium.com/view/menuselect/trunk/configure.ac?view=diff&rev=398&r1=397&r2=398
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Sat Oct 11 08:40:38 2008
@@ -43,6 +43,15 @@
 
 AC_LANG(C)
 
+AC_ARG_ENABLE([debug],
+	[AS_HELP_STRING([--enable-debug], [Turn on debug mode])],
+	[case "${enableval}" in
+		y|ye|yes) MENUSELECT_DEBUG=yes ;;
+		n|no)  MENUSELECT_DEBUG=no ;;
+		*) AC_MSG_ERROR(bad value ${enableval} for --enable-debug)  ;;
+    esac])
+AC_SUBST(MENUSELECT_DEBUG)
+
 AC_CHECK_FUNCS([asprintf getloadavg setenv strcasestr strndup strnlen strsep strtoq unsetenv vasprintf])
 
 # The frontend can use curses, ncurses, newt or GTK2 so check for all of them

Modified: trunk/makeopts.in
URL: http://svn.digium.com/view/menuselect/trunk/makeopts.in?view=diff&rev=398&r1=397&r2=398
==============================================================================
--- trunk/makeopts.in (original)
+++ trunk/makeopts.in Sat Oct 11 08:40:38 2008
@@ -5,6 +5,7 @@
 CC=@CC@
 
 OSARCH=@HOST_OS@
+MENUSELECT_DEBUG=@MENUSELECT_DEBUG@
 
 # The frontend can use curses, ncurses, newt or gtk2
 

Modified: trunk/menuselect.c
URL: http://svn.digium.com/view/menuselect/trunk/menuselect.c?view=diff&rev=398&r1=397&r2=398
==============================================================================
--- trunk/menuselect.c (original)
+++ trunk/menuselect.c Sat Oct 11 08:40:38 2008
@@ -34,7 +34,6 @@
 #include "linkedlists.h"
 #include "menuselect.h"
 
-#undef MENUSELECT_DEBUG
 #ifdef MENUSELECT_DEBUG
 static FILE *debug;
 #endif
@@ -110,6 +109,17 @@
 	return str;
 }
 
+static int open_debug(void)
+{
+#ifdef MENUSELECT_DEBUG
+	if (!(debug = fopen("menuselect_debug.txt", "w"))) {
+		fprintf(stderr, "Failed to open menuselect_debug.txt for debug output.\n");
+		return -1;
+	}
+#endif
+	return 0;
+}
+
 static void print_debug(const char *format, ...)
 {
 #ifdef MENUSELECT_DEBUG
@@ -120,6 +130,14 @@
 	va_end(ap);
 
 	fflush(debug);
+#endif
+}
+
+static void close_debug(void)
+{
+#ifdef MENUSELECT_DEBUG
+	if (debug)
+		fclose(debug);
 #endif
 }
 
@@ -850,10 +868,8 @@
 	int lineno = 0;
 
 	if (!(f = fopen(infile, "r"))) {
-#ifdef MENUSELECT_DEBUG
 		/* This isn't really an error, so only print the message in debug mode */
-		fprintf(stderr, "Unable to open '%s' for reading existing config.\n", infile);
-#endif	
+		print_debug("Unable to open '%s' for reading existing config.\n", infile);
 		return -1;
 	}
 
@@ -1066,10 +1082,10 @@
 	return 0;
 }
 
-#ifdef MENUSELECT_DEBUG
 /*! \brief Print out all of the information contained in our tree */
 static void dump_member_list(void)
 {
+#ifdef MENUSELECT_DEBUG
 	struct category *cat;
 	struct member *mem;
 	struct depend *dep;
@@ -1092,8 +1108,8 @@
 				fprintf(stderr, "      --> Conflicts Found: %s\n", mem->conflictsfailed ? "Yes" : "No");
 		}
 	}
-}
 #endif
+}
 
 /*! \brief Free all categories and their members */
 static void free_member_list(void)
@@ -1236,15 +1252,9 @@
 	int res = 0;
 	unsigned int x;
 
-	/* Make the compiler happy */
-	print_debug("");
-
-#ifdef MENUSELECT_DEBUG
-	if (!(debug = fopen("menuselect_debug.txt", "w"))) {
-		fprintf(stderr, "Failed to open menuselect_debug.txt for debug output.\n");
+	if (open_debug()) {
 		exit(1);
 	}
-#endif
 
 	/* Parse the input XML files to build the list of available options */
 	if ((res = build_member_list()))
@@ -1272,10 +1282,8 @@
 		}
 	}
 
-#ifdef MENUSELECT_DEBUG
 	/* Dump the list produced by parsing the various input files */
 	dump_member_list();
-#endif
 
 	while (calc_dep_failures(0) || calc_conflict_failures(0));
 
@@ -1302,10 +1310,7 @@
 	free_trees();
 	free_member_list();
 
-#ifdef MENUSELECT_DEBUG
-	if (debug)
-		fclose(debug);
-#endif
+	close_debug();
 
 	exit(res);
 }




More information about the svn-commits mailing list