]> git.pld-linux.org Git - packages/kernel.git/commitdiff
- check value correctness and exit with non zero if any error
authorsparky <sparky@pld-linux.org>
Thu, 18 Sep 2008 13:23:15 +0000 (13:23 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    kernel-config.awk -> 1.3

kernel-config.awk

index 9408ad0cf6fea5fe7d73cc337d6e7b729c9dc895..f7f10b41851629a9e1744f5eb6ce615fc8827a22 100644 (file)
@@ -12,8 +12,6 @@
 # - Przemysław Iskra <sparky@pld-linux.org>
 # 
 # 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
 }
This page took 4.227583 seconds and 4 git commands to generate.