Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 22 additions & 18 deletions smatch_data/db/init_constraints.pl
Original file line number Diff line number Diff line change
Expand Up @@ -50,26 +50,30 @@ ($$)
return;
}

open(FILE, "$dir/$project.constraints");
while (<FILE>) {
s/\n//;
$db->do("insert or ignore into constraints (str) values ('$_')");
if (open(FILE, "$dir/$project.constraints"))
{
while (<FILE>) {
s/\n//;
$db->do("insert or ignore into constraints (str) values ('$_')");
}
close(FILE);
}
close(FILE);

open(FILE, "$dir/$project.constraints_required");
while (<FILE>) {
my $limit;
my $dummy;

($dummy, $dummy, $limit) = split(/,/);
$limit =~ s/^ +//;
$limit =~ s/\n//;
try {
$db->do("insert or ignore into constraints (str) values ('$limit')");
} catch {}

if (open(FILE, "$dir/$project.constraints_required"))
{
while (<FILE>) {
my $limit;
my $dummy;

($dummy, $dummy, $limit) = split(/,/);
$limit =~ s/^ +//;
$limit =~ s/\n//;
try {
$db->do("insert or ignore into constraints (str) values ('$limit')");
} catch {}
}
close(FILE);
}
close(FILE);

$db->commit();
}
Expand Down
18 changes: 10 additions & 8 deletions smatch_data/db/init_constraints_required.pl
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,17 @@ ($$)
return;
}

open(FILE, "$dir/$project.constraints_required");
while (<FILE>) {
($data, $op, $limit) = split(/,/);
$op =~ s/ //g;
$limit =~ s/^ +//;
$limit =~ s/\n//;
$db->do("insert into constraints_required values (?, ?, ?);", undef, $data, $op, $limit);
if(open(FILE, "$dir/$project.constraints_required"))
{
while (<FILE>) {
($data, $op, $limit) = split(/,/);
$op =~ s/ //g;
$limit =~ s/^ +//;
$limit =~ s/\n//;
$db->do("insert into constraints_required values (?, ?, ?);", undef, $data, $op, $limit);
}
close(FILE);
}
close(FILE);

$db->commit();
}
Expand Down
54 changes: 28 additions & 26 deletions smatch_data/db/insert_manual_states.pl
Original file line number Diff line number Diff line change
Expand Up @@ -64,38 +64,40 @@ ($$$$$$$)

my ($ret, $insert, $file, $func, $type, $param, $key, $value);

open(FILE, "<$insertions");
while (<FILE>) {

if ($_ =~ /^\s*#/) {
next;
}
if (open(FILE, "<$insertions"))
{
while (<FILE>) {

($ret, $insert) = split(/\|/, $_);
if ($_ =~ /^\s*#/) {
next;
}

if ($ret =~ /(.+),\W*(.+),\W*"(.*)"/) {
$file = $1;
$func = $2;
$ret = $3;
} elsif ($ret =~ /(.+),\W*"(.*)"/) {
$file = "";
$func = $1;
$ret = $2;
} else {
next;
}
($ret, $insert) = split(/\|/, $_);

if ($ret =~ /(.+),\W*(.+),\W*"(.*)"/) {
$file = $1;
$func = $2;
$ret = $3;
} elsif ($ret =~ /(.+),\W*"(.*)"/) {
$file = "";
$func = $1;
$ret = $2;
} else {
next;
}

($type, $param, $key, $value) = split(/,/, $insert);
($type, $param, $key, $value) = split(/,/, $insert);

$type = int($type);
$param = int($param);
$key =~ s/^["\s]+|["\s]+$//g;
$value =~ s/^["\s]+|["\s]+$//g;
chomp($value);
$type = int($type);
$param = int($param);
$key =~ s/^["\s]+|["\s]+$//g;
$value =~ s/^["\s]+|["\s]+$//g;
chomp($value);

insert_record($file, $func, $ret, $type, $param, $key, $value);
insert_record($file, $func, $ret, $type, $param, $key, $value);
}
close(FILE);
}
close(FILE);

$db->commit();
$db->disconnect();