Skip to content

[Perl] Use pragma to restrict unsafe constructs #669

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 12, 2016
Merged
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
14 changes: 8 additions & 6 deletions utils/error_enum_to_cases.pl
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/perl -w

use strict;
use English;

sub translateAvailability($) {
Expand All @@ -9,12 +11,12 @@ ($)
return "introduced=$1.$2";
}

$prefixLength = 2;
my $prefixLength = 2;
my %minimumValues = ();
my %maximumValues = ();
my %rangeAvailability = ();
my $prev_had_availability = 0;
foreach $line (<STDIN>) {
foreach my $line (<STDIN>) {
chomp $line;
if ($line =~ /([A-Za-z_][A-Za-z_0-9]+).*=[^0-9A-Za-z_-]*([A-Za-z0-9_-]+)/) {
my $fullname = $1;
Expand All @@ -25,8 +27,8 @@ ($)
# if ($line =~ /AVAILABLE\s*[(](([0-9]+_[0-9]+)|(NA))[ ]*,[ ]*(([0-9]+_[0-9]+)|(NA))[)]/) {
if ($line =~ /AVAILABLE[ ]*[(]([^),]*),([^)]*)[)]/) {
$has_availability = 1;
$osx = $1;
$ios = $2;
my $osx = $1;
my $ios = $2;
$osx = translateAvailability($osx);
$ios = translateAvailability($ios);
$availability = " \@available(OSX, $osx) \@available(iOS, $ios)\n";
Expand All @@ -49,7 +51,7 @@ ($)
}
print("$availability");
}
$casename = substr $fullname, $prefixLength;
my $casename = substr $fullname, $prefixLength;
print(" case $casename = $value\n");

if ($availability ne "") {
Expand All @@ -63,7 +65,7 @@ ($)
}

# Print properties for the ranges.
foreach $key (sort keys(%minimumValues)) {
foreach my $key (sort keys(%minimumValues)) {
my $minimum = $minimumValues{$key};
my $maximum = $maximumValues{$key};
my $availability = $rangeAvailability{$key};
Expand Down