-
Notifications
You must be signed in to change notification settings - Fork 790
Expand file tree
/
Copy pathchksample
More file actions
executable file
·98 lines (87 loc) · 1.95 KB
/
chksample
File metadata and controls
executable file
·98 lines (87 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/local/bin/perl
# Verify the following in the sample style sheet:
# 1) All properties are correct
# 2) All properties are represented
# Ian Jacobs - ij@w3.org
# $Id: chksample,v 1.5 2006-10-09 18:55:52 ihickson Exp $
# To use long names like $INPUT_RECORD_SEPARATOR.
use English;
$PROGNAME = substr($0, rindex($0, "/") + 1);
if (!$ARGV[0] || !$ARGV[1]) {
print "Usage: $PROGNAME style_sheet propertydb\n";
exit 1;
} else {
$style = $ARGV[0];
shift;
$propdbf = $ARGV[0];
shift;
}
if (($_ = $ARGV[0], /^-e/) && $ARGV[1]) {
shift;
$elements = $ARGV[1];
shift;
} else {
$elements = "";
}
# regexps
$sp = "[ \t\n]*"; # whitespace
$propname = "[a-zA-Z-]+";
$propval = "[a-zA-Z0-9.-]+";
$patt = "$sp(.*?)$sp";
$blockst = "[/][*]";
$blocket = "[*][/]";
sub readdbfile {
if (!open(DBASE, $_[0])) {
print STDERR "$PROGNAME Error: Cannot open dbfile: $_[0]\n";
return;
}
$dbbuf = "";
while (<DBASE>) {
$dbbuf .= $_;
}
$_ = $dbbuf;
while (/$blockst$patt;;.*?$blocket/s) {
$placeholder = $';
# Initialize each property to "False"
my @propnames = split(/\s+/, $1);
foreach my $i (@propnames) {
$propdb{$i} = "False";
}
$_ = $placeholder;
}
}
sub readstyle {
if (!open(STYLE, $_[0])) {
print STDERR "$PROGNAME Error: Cannot open style sheet: $_[0]\n";
return;
}
$buf = "";
$INPUT_RECORD_SEPARATOR="{";
while ($buf = <STYLE>) {
$INPUT_RECORD_SEPARATOR="}";
unless (eof(STYLE)) {
$rule = <STYLE>;
$INPUT_RECORD_SEPARATOR="{";
$_ = $rule;
while (/$sp($propname)$sp:$sp($propval);?/) {
$placeholder = $';
$property = $1;
if (! exists $propdb{$property}) {
print STDERR "Unknown: $property.\n";
} else {
$propdb{$property} = "True";
}
$_ = $placeholder;
}
}
}
}
### main
@propdb = ();
readdbfile($propdbf);
readstyle($style);
foreach $key (sort %propdb) {
if ($propdb{$key} eq "False") {
print STDOUT "Unused: $key\n";
}
}