Skip to content

Commit

Permalink
Check attributes color, type, and width for valid values
Browse files Browse the repository at this point in the history
  • Loading branch information
BenBE committed Jul 18, 2024
1 parent 91fbe48 commit cfcb5c5
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions check-pcp-style.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ check_file() {
split($0, pair, " = ")
name = trim(pair[1])
value = trim(pair[2])
group = ""
known = 0
Expand Down Expand Up @@ -102,6 +103,28 @@ check_file() {
seen[name] = 1
groups[group] = 1
if (name ~ /(^|\.)width$/) {
if (!(value ~ /^-?[0-9]{1,3}$/)) {
print "Error: Specified width " value " for " name " in section " section " is not an integer or out of range (-999..999)."
exit 1
}
}
if (name ~ /(^|\.)type$/) {
if (!(value ~ /^(bar|text|graph|led)$/)) {
print "Error: Specified type " value " for " name " in section " section " is not recognized."
exit 1
}
}
if (name ~ /(^|\.)color$/) {
if (!(value ~ /^(black|blue|green|red|cyan|magenta|yellow|(dark)?gray|white)$/)) {
print "Error: Specified color " value " for " name " in section " section " is not recognized."
exit 1
}
}
next
}
Expand Down

0 comments on commit cfcb5c5

Please sign in to comment.