All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] kconfig: fix another bug of savedefconfig
@ 2014-09-03  6:46 Masahiro Yamada
  0 siblings, 0 replies; only message in thread
From: Masahiro Yamada @ 2014-09-03  6:46 UTC (permalink / raw)
  To: u-boot

Commit 3ff291f371fa9858426774f3732924bacb61ed1c
(kconfig: convert Kconfig helper script into a shell script)
introduced another, serious bug.

make saveconfig outputs

  # CONFIG_FOO is not set

into:

  #
  CONFIG_FOO
  is
  not
  set

Whitespaces should not be treated as separators.
(Shell scripts for text processing tend to be too complicated.)

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
---

 scripts/multiconfig.sh | 37 +++++++++++++++++++++++++++++--------
 1 file changed, 29 insertions(+), 8 deletions(-)

diff --git a/scripts/multiconfig.sh b/scripts/multiconfig.sh
index 785f563..70996b9 100644
--- a/scripts/multiconfig.sh
+++ b/scripts/multiconfig.sh
@@ -170,7 +170,7 @@ do_savedefconfig () {
 	# backslashes as an escape character
 	while read -r line
 	do
-		output_lines="$output_lines $line"
+		output_lines="$output_lines%$line"
 	done < defconfig
 
 	for img in $subimages
@@ -185,43 +185,64 @@ do_savedefconfig () {
 			tmp=
 			match=
 
+			# "# CONFIG_FOO is not set" should not be divided.
+			# Use "%" as a separator, instead of a whitespace.
+			# "%" is unlikely to appear in Kconfig context.
+			save_IFS=$IFS
+			IFS=%
 			# coalesce common lines together
 			for i in $output_lines
 			do
 				case "$i" in
 				"[+A-Z]*:$line")
-					tmp="$tmp $unmatched"
+					tmp="$tmp%$unmatched"
 					i=$(echo "$i" | \
 					    sed -e "s/^\([^:]\)*/\1$symbol/")
-					tmp="$tmp $i"
+					tmp="$tmp%$i"
 					match=1
 					;;
 				"$line")
-					tmp="$tmp $unmatched"
-					tmp="$tmp +$symbol:$i"
+					tmp="$tmp%$unmatched"
+					tmp="$tmp%+$symbol:$i"
 					match=1
 					;;
 				*)
-					tmp="$tmp $i"
+					tmp="$tmp%$i"
 					;;
 				esac
 			done
 
+			# Restore the default separator for the outer for loop.
+			IFS=$save_IFS
+
 			if [ "$match" ]; then
 				output_lines="$tmp"
 				unmatched=
 			else
-				unmatched="$unmatched $symbol:$line"
+				unmatched="$unmatched%$symbol:$line"
 			fi
 		done < defconfig
 	done
 
 	rm -f defconfig
 	touch defconfig
+
+	save_IFS=$IFS
+	IFS=%
+
 	for line in $output_lines
 	do
-		echo $line >> defconfig
+		case "$line" in
+		"")
+			# do not output blank lines
+			;;
+		*)
+			echo $line >> defconfig
+			;;
+		esac
 	done
+
+	IFS=$save_IFS
 }
 
 # Usage:
-- 
1.9.1

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2014-09-03  6:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-03  6:46 [U-Boot] [PATCH] kconfig: fix another bug of savedefconfig Masahiro Yamada

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.