]> git.pld-linux.org Git - packages/kernel.git/commitdiff
- handle string options with white spaces inside, \" not supported yet
authorsparky <sparky@pld-linux.org>
Thu, 18 Sep 2008 14:45:26 +0000 (14:45 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
- allow tabs instead of spaces
- few minor changes

Changed files:
    kernel-config.awk -> 1.4

kernel-config.awk

index f7f10b41851629a9e1744f5eb6ce615fc8827a22..30cc398a931b76971f21746f04ec4ec026374bdc 100644 (file)
@@ -10,6 +10,9 @@
 #
 # Authors:
 # - Przemysław Iskra <sparky@pld-linux.org>
+# parts based on kernel-config.py, by:
+# - arekm@pld-linux.org
+# - glen@pld-linux.org
 # 
 # TODO:
 #  - smarter arch split, there could be strings with spaces
 #  - use as many warnings as possible, we want our configs to be clean
 
 # no:
-# CONFIG_SOMETHING=n           -- should warn
-# SOMETHING=n                  -- should warn
-# CONFIG_SOMETHING all=n       -- should warn
+# CONFIG_SOMETHING=n
+# SOMETHING=n
+# CONFIG_SOMETHING all=n
 # SOMETHING all=n
-# # CONFIG_SOMETHING is not set        -- special case
+# # CONFIG_SOMETHING is not set -- special case
 
 # yes/module/other
 # CONFIG_SOMETHING=y
-# SOMETHING=y                  -- should warn
-# CONFIG_SOMETHING all=y       -- should warn
+# SOMETHING=y
+# CONFIG_SOMETHING all=y
 # SOMETHING all=y
 
 
 # return actual file name (without path) and line number
 function fileLine() {
        f = FILENAME
-       gsub( /^.*\//, "", f ) # strip path
+       sub( /^.*\//, "", f ) # strip path
 
        return f " (" FNR ")"
 }
@@ -59,13 +62,13 @@ function dieLater( code ) {
 # # CONFIG_SOMETHING it not set
 # to:
 # SOMETHING all=n
-/^# CONFIG_[A-Za-z0-9_-]+ is not set$/ {
-       match( $0, /CONFIG_[A-Za-z0-9_-]+/ )
+/^# CONFIG_[A-Za-z0-9_]+ is not set$/ {
+       match( $0, /CONFIG_[A-Za-z0-9_]+/ )
        option = substr( $0, RSTART, RLENGTH)
        $0 = option " all=n"
 }
 
-# ignore all the comments
+# ignore all the comments and empty lines
 /^#/ || /^\s*$/ {
        next
 }
@@ -79,12 +82,24 @@ function dieLater( code ) {
        line = $0
        value = ""
        if ( option ~ /=/ ) {
-               gsub( /=.*$/, "", option )
-               gsub( /^[^=]*=/, "", line )
+               sub( /=.*$/, "", option )
+               sub( /^[^=]*=/, "", line )
                value = line
        } else {
-               gsub( "^" option IFS, "", line )
-               split( line, archs )
+               sub( "^" option, "", line )
+               sub( /^[ \t]*/, "", line )
+
+               if ( line ~ /"/ ) {
+                       # there can be white spaces
+                       i = 0
+                       while ( match( line, /^[^=]+="[^"]*"/ ) ) {
+                               archs[ (++i) ] = substr( line, RSTART, RLENGTH )
+                               line = substr( line, RSTART + RLENGTH )
+                               sub( /^[ \t]*/, "", line )
+                       }
+               } else {
+                       split( line, archs )
+               }
                for ( i in archs ) {
                        split( archs[i], opt, "=" );
                        if ( opt[1] == "all" )
@@ -110,11 +125,11 @@ function dieLater( code ) {
                        out = option "=" value
 
                        if ( value == "y" || value == "m" )
-                               ;
+                               ; # OK
                        else if ( value ~ /^"[^"]*"$/ )
-                               ;
+                               ; # OK
                        else if ( value ~ /^-?[0-9]+$/ || value ~ /^0x[0-9A-Fa-f]+$/ )
-                               ;
+                               ; # OK
                        else {
                                warn( "ERROR: Incorrect value: " $0 )
                                dieLater( 1 )
This page took 0.05427 seconds and 4 git commands to generate.