summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAllen Winter <allen.winter@kdab.com>2022-04-28 17:32:37 -0400
committerAllen Winter <allen.winter@kdab.com>2022-04-28 17:32:37 -0400
commit61ecac16f68c7c7c1459e1ebf708edb91c373586 (patch)
tree43504fcc4355828e89f557b31bc3a4d55fb026e3 /scripts
parent43cb2e215a8ed10e03989f19db5457f89fc2412a (diff)
downloadlibical-git-61ecac16f68c7c7c1459e1ebf708edb91c373586.tar.gz
scripts/readvaluesfile.pl - add some sanity checking
errors if: - a Name is used more than once - a kind enum is used more than once
Diffstat (limited to 'scripts')
-rw-r--r--scripts/readvaluesfile.pl46
1 files changed, 39 insertions, 7 deletions
diff --git a/scripts/readvaluesfile.pl b/scripts/readvaluesfile.pl
index 460cf7e7..255ceb05 100644
--- a/scripts/readvaluesfile.pl
+++ b/scripts/readvaluesfile.pl
@@ -18,10 +18,13 @@ sub read_values_file
my $path = shift;
my %h;
+ my @SEEN_ENUMS;
open(F, $path) || die "Can't open values file $path";
+ my $line = 0;
while (<F>) {
+ $line++;
chop;
@@ -34,8 +37,16 @@ sub read_values_file
@column = split(/,/, $_);
my $value_name = $column[0];
- my $enumConst = $column[1];
-
+ if (exists($h{$value_name})) {
+ die "Previously defined value=$value_name line $line in $path";
+ }
+ my $enumConst = $column[1];
+ if ($enumConst !~ /FIXME/) {
+ if (grep(/^$enumConst$/, @SEEN)) {
+ die "Reusing kindEnum=$enumConst line $line in $path";
+ }
+ push(@SEEN, $enumConst);
+ }
my $c_type_str = $column[2];
my $c_autogen = ($c_type_str =~ /\(a\)/);
@@ -79,11 +90,13 @@ sub read_properties_file
my $path = shift;
my %h;
+ my @SEEN;
open(F, $path) || die "Can't open properties file $path";
+ my $line = 0;
while (<F>) {
-
+ $line++;
chop;
s/#.*$//g;
@@ -95,8 +108,16 @@ sub read_properties_file
@column = split(/,/, $_);
my $property_name = $column[0];
-
- my $enumConst = $column[1];
+ if ($property_name && exists($h{$property_name})) {
+ die "Previously defined property=$property_name line $line in $path";
+ }
+ my $enumConst = $column[1];
+ if ($enumConst !~ /FIXME/) {
+ if (grep(/^$enumConst$/, @SEEN)) {
+ die "Reusing kindEnum=$enumConst line $line in $path";
+ }
+ push(@SEEN, $enumConst);
+ }
my $lic_value = $column[2];
my $default_value = $column[3];
my $flags = $column[4];
@@ -124,10 +145,13 @@ sub read_parameters_file
my $path = shift;
my %h;
+ my @SEEN;
open(F, $path) || die "Can't open parameters file $path";
+ my $line = 0;
while (<F>) {
+ $line++;
chop;
@@ -140,8 +164,16 @@ sub read_parameters_file
@column = split(/\,/, $_);
my $parameter_name = $column[0];
-
- my $enumConst = $column[1];
+ if (exists($h{$parameter_name})) {
+ die "Previously defined parameter=$parameter_name line $line in $path";
+ }
+ my $enumConst = $column[1];
+ if ($enumConst !~ /FIXME/) {
+ if (grep(/^$enumConst$/, @SEEN)) {
+ die "Reusing kindEnum=$enumConst line $line in $path";
+ }
+ push(@SEEN, $enumConst);
+ }
my $data_type = $column[2];
my $enum_string = $column[3];