From 5f3dd352bd8e5fe1ab5dd2debf5e8d97e6ccc2de Mon Sep 17 00:00:00 2001
From: genone <genone@gentoo.org>
Date: Fri, 17 Feb 2006 01:32:41 +0000
Subject: [PATCH] fixing bug 95432

svn path=/; revision=281
---
 trunk/ChangeLog     | 4 ++++
 trunk/src/euse/euse | 9 ++++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/trunk/ChangeLog b/trunk/ChangeLog
index bcac6c2..c74fc7d 100644
--- a/trunk/ChangeLog
+++ b/trunk/ChangeLog
@@ -1,3 +1,7 @@
+2006-02-16 Marius Mauch <genone@gentoo.org>
+	* euse: add/remove use flags even if there is no USE= statement in make.conf
+	(bug #95432)
+
 2006-02-16 Marius Mauch <genone@gentoo.org>
 	* glsa-check: Fix bug causing the wrong summary to be displayed 
 	for --test --verbose (bug #123084)
diff --git a/trunk/src/euse/euse b/trunk/src/euse/euse
index d34c7e4..299ba18 100755
--- a/trunk/src/euse/euse
+++ b/trunk/src/euse/euse
@@ -387,6 +387,7 @@ modify() {
 	# on our own here. Basically just skip everything between USE=" and the 
 	# closing ", printing our new USE line there instead.
 	inuse=0
+	had_use=0
 	(while read -r line; do
 		[ "${line:0:4}" == "USE=" ] && inuse=1
 		[ "${inuse}" == "0" ] && echo -E "${line}"
@@ -395,8 +396,14 @@ modify() {
 			echo -ne "${NEW_MAKE_CONF_USE_2%% }"
 			echo '"'
 		 	inuse=0
+			had_use=1
 		fi
-	done ) < "${MAKE_CONF_BACKUP_PATH}" | sed -e 's:\\ $:\\:' > "${MAKE_CONF_PATH}"
+	done
+	if [ ${haduse} -eq 0 ]; then
+		echo -n 'USE="'
+		echo -ne "${NEW_MAKE_CONF_USE_2%% }"
+		echo '"'
+	fi ) < "${MAKE_CONF_BACKUP_PATH}" | sed -e 's:\\ $:\\:' > "${MAKE_CONF_PATH}"
 	
 	echo "${MAKE_CONF_PATH} was modified, a backup copy has been placed at ${MAKE_CONF_BACKUP_PATH}"
 }
-- 
2.26.2