made cpu flag string code more readable

This commit is contained in:
inxi-svn 2009-08-03 07:07:31 +00:00
parent a18aa882a8
commit e792d57762

46
inxi
View file

@ -3388,42 +3388,44 @@ process_cpu_flags()
cpu_flags=$( echo "$cpu_flags" | gawk ' cpu_flags=$( echo "$cpu_flags" | gawk '
BEGIN { BEGIN {
RS=" " RS=" "
ssel["sse"] = 1 a_ssel["sse"] = 1
ssel["sse2"] = 2 a_ssel["sse2"] = 2
ssel["pni"] = 3 a_ssel["pni"] = 3
ssel["sse4a"] = 4 # 4a must precede 4 a_ssel["sse4a"] = 4 # 4a must precede 4
ssel["sse4"] = 5 a_ssel["sse4"] = 5
ssel["sse5"] = 6 a_ssel["sse5"] = 6
sses[1] = "sse" a_sses[1] = "sse"
sses[2] = "sse2" a_sses[2] = "sse2"
sses[3] = "sse3" a_sses[3] = "sse3"
sses[4] = "sse4a" a_sses[4] = "sse4a"
sses[5] = "sse4" a_sses[5] = "sse4"
sses[6] = "sse5" a_sses[6] = "sse5"
sseCounter = 0
flag_string = ""
} }
/^(nx|lm|svm|vmx)$/ { /^(nx|lm|svm|vmx)$/ {
if (s) { if ( flag_string != "" ) {
s = s " " $0 flag_string = flag_string " " $0
} }
else { else {
s = $0 flag_string = $0
} }
} }
/^(sse|sse2|sse4a|sse4|sse5|pni)$/ { /^(sse|sse2|sse4a|sse4|sse5|pni)$/ {
if (ssel[$0] > sse) { if ( a_ssel[$0] > sseCounter ) {
sse = ssel[$0] sseCounter = a_ssel[$0]
} }
} }
END { END {
if (sse) { if ( sseCounter > 0 ) {
if (s) { if ( flag_string != "" ) {
s = sses[sse] " " s flag_string = a_sses[sseCounter] " " flag_string
} }
else { else {
s = sses[sse] flag_string = a_sses[sseCounter]
} }
} }
print s print flag_string
}' ) }' )
#grep -oE '\<(nx|lm|sse[0-9]?|pni|svm|vmx)\>' | tr '\n' ' ')) #grep -oE '\<(nx|lm|sse[0-9]?|pni|svm|vmx)\>' | tr '\n' ' '))