From: sparky Date: Thu, 18 Sep 2008 13:23:15 +0000 (+0000) Subject: - check value correctness and exit with non zero if any error X-Git-Tag: deadbranch-1.6.2~5 X-Git-Url: https://git.pld-linux.org/?a=commitdiff_plain;h=32610d56895fec752f6eab60853d3dfcf1d3fe4a;p=packages%2Fkernel.git - check value correctness and exit with non zero if any error Changed files: kernel-config.awk -> 1.3 --- diff --git a/kernel-config.awk b/kernel-config.awk index 9408ad0c..f7f10b41 100644 --- a/kernel-config.awk +++ b/kernel-config.awk @@ -12,8 +12,6 @@ # - Przemysław Iskra # # TODO: -# - check value correctness, should allow only: -# y, m, n, -[0-9]+, 0x[0-9A-Fa-f]+, ".*" # - smarter arch split, there could be strings with spaces # ( kernel-config.py does not suppoty it either ) # - use as many warnings as possible, we want our configs to be clean @@ -49,6 +47,12 @@ BEGIN { print "arch= must be specified" > "/dev/stderr" exit 1 } + shouldDie = 0 +} + +function dieLater( code ) { + if ( shouldDie < code ) + shouldDie = code } # convert special case: @@ -102,8 +106,20 @@ BEGIN { if ( length( value ) ) { if ( value == "n" ) out = "# " option " is not set" - else + else { out = option "=" value + + if ( value == "y" || value == "m" ) + ; + else if ( value ~ /^"[^"]*"$/ ) + ; + else if ( value ~ /^-?[0-9]+$/ || value ~ /^0x[0-9A-Fa-f]+$/ ) + ; + else { + warn( "ERROR: Incorrect value: " $0 ) + dieLater( 1 ) + } + } print out outputArray[ option ] = fileLine() @@ -111,4 +127,5 @@ BEGIN { } END { + exit shouldDie }