aumix (2.9.1-2) 07_interactive.patch

Summary

 src/common.c |   17 +++++++++++++----
 src/common.h |    1 +
 2 files changed, 14 insertions(+), 4 deletions(-)

    
download this patch

Patch contents

This patch fixes the interacting/non-interacting mode detecton for
aumix.  In the old situation, specifying any option on the command line
(like -d) caused aumix to enter non-interactive mode, which of course
doesn't make sense for any but the -q, -L and -S command line option.

Patch by Bas Zoetekouw <bas@debian.org>
diff -Naur aumix-2.9.orig//src/common.c aumix-2.9/src/common.c
--- aumix-2.9.orig//src/common.c	2010-04-19 05:03:54.273472866 +0200
+++ aumix-2.9/src/common.c	2010-04-19 05:04:07.431411010 +0200
@@ -125,7 +125,9 @@
 	I18nInitialize();
 #endif				/* ENABLE_NLS */
 
-	interactive = FALSE;
+	/* interactive will be set to FALSE if
+	 * non-interactive command line options are specified */
+	interactive = IN_UNSPECIFIED;
 
 #ifdef __linux__
 	if (access(device_filename, F_OK) != 0)
@@ -150,6 +152,7 @@
    a cast". */
 		if ((mopt = (char *) strchr(moptindx, optn))) {
 			usage_ok = 0;
+			if (interactive == IN_UNSPECIFIED) interactive = FALSE;
 			if (mixer_fd == -1)
 				ErrorExitWarn(InitializeMixer(device_filename), 'e');
 			ErrorExitWarn(SetShowNoninter(mopt - moptindx), 'e');
@@ -158,6 +161,8 @@
 			switch (optn) {
 			case 'q':	/* query */
 				optarg = "q";
+				if (interactive == IN_UNSPECIFIED)
+					interactive = FALSE;
 				if (mixer_fd == -1)
 					ErrorExitWarn(InitializeMixer(device_filename), 'e');
 				for (ii = 0; ii < SOUND_MIXER_NRDEVICES; ii++) {
@@ -189,18 +194,22 @@
 				break;
 #endif				/* HAVE_CURSES */
 			case 'S':	/* Save to file. */
+				if (interactive == IN_UNSPECIFIED)
+					interactive = FALSE;
 				if (mixer_fd == -1)
 					ErrorExitWarn(InitializeMixer(device_filename), 'e');
 				ErrorExitWarn(SaveSettings(), 'e');
 				break;
 			case 'L':	/* Load from file. */
+				if (interactive == IN_UNSPECIFIED)
+					interactive = FALSE;
 				if (mixer_fd == -1)
 					ErrorExitWarn(InitializeMixer(device_filename), 'e');
 				ErrorExitWarn(LoadSettings(), 'e');
 				break;
 #if defined (HAVE_CURSES) || defined (HAVE_GTK)
 			case 'I':	/* User asked for interactive mode. */
-				if (!interactive)
+				if ((interactive == FALSE) || (interactive == IN_UNSPECIFIED))
 					interactive = IN_ANY;
 				break;
 #endif				/* HAVE_CURSES || HAVE_GTK */
@@ -213,8 +222,8 @@
 		}
 	}
 #if defined (HAVE_CURSES) || defined (HAVE_GTK)
-/* Be interactive if no options were given. */
-	if (!interactive && argc <= 1)
+/* Be interactive if no options specifying otherwise were given. */
+	if (interactive == IN_UNSPECIFIED)
 		interactive = IN_ANY;
 /* By now we've decided whether to go interactive.
    The -C (color scheme) option implies curses, even if GTK is available.
diff -Naur aumix-2.9.orig//src/common.h aumix-2.9/src/common.h
--- aumix-2.9.orig//src/common.h	2010-04-19 04:51:04.191738578 +0200
+++ aumix-2.9/src/common.h	2010-04-19 05:04:07.431411010 +0200
@@ -26,6 +26,7 @@
 #define IN_CURSES 1
 #define IN_GTK 2
 #define IN_ANY 3
+#define IN_UNSPECIFIED 4
 #endif				/* HAVE_CURSES || HAVE_GTK */
 #ifndef TRUE			/* defined in ncurses.h */
 #define TRUE 1