[PATCH] Configure mangles hex values

Linux Kernel Mailing List <[email protected]>
Newsgroups gmane.linux.kernel.commits.2-4
Message-ID <[email protected]>
ChangeSet 1.1582, 2005/01/28 07:46:20-02:00, [email protected]

	[PATCH] Configure mangles hex values
	
	When doing a make oldconfig, the hex function strips the leading '0x' from hex
	values.  The '0x' is needed in the final autoconf.h, and its absence causes
	the following problem.
	
	If I start with a hex value in my config file like this:
	CONFIG_LOWMEM_SIZE=0x40000000
	When I run make oldconfig, it strips out the '0x' leaving this:
	CONFIG_LOWMEM_SIZE=40000000
	Then if I run make xconfig, this is not considered a valid hex value, so it
	replaces my value with the default:
	CONFIG_LOWMEM_SIZE=0x20000000
	
	The following patch removes the lines that strip the 0x from the hex value.
	It also checks the result for the leading 0x and inserts it if necessary.



 Configure |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)


diff -Nru a/scripts/Configure b/scripts/Configure
--- a/scripts/Configure	2005-01-30 15:36:59 -08:00
+++ b/scripts/Configure	2005-01-30 15:36:59 -08:00
@@ -378,15 +378,18 @@
 function hex () {
 	old=$(eval echo "\${$2}")
 	def=${old:-$3}
-	def=${def#*[x,X]}
 	while :; do
 	  readln "$1 ($2) [$def] " "$def" "$old"
-	  ans=${ans#*[x,X]}
-	  if expr "$ans" : '[0-9a-fA-F][0-9a-fA-F]*$' > /dev/null; then
+	  if expr "$ans" : '0x[0-9a-fA-F][0-9a-fA-F]*$' > /dev/null; then
 	    define_hex "$2" "$ans"
 	    break
 	  else
-	    help "$2"
+	    if expr "$ans" : '[0-9a-fA-F][0-9a-fA-F]*$' > /dev/null; then
+	      define_hex "$2" "0x$ans"
+	      break
+	    else
+	      help "$2"
+	    fi
 	  fi
 	done
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.