Adds checks to 1.3->2.0 API migration script

This commit is contained in:
Simon Butcher 2016-06-19 22:49:58 +01:00
parent 02c4a38013
commit 6dc7c9c5e1

View file

@ -1,12 +1,25 @@
#!/usr/bin/perl
# rename identifiers (functions, types, enum constant, etc)
# on upgrades of major version according to a list
#
# This file is part of mbed TLS (https://tls.mbed.org)
#
# Copyright (c) 2015-2016, ARM Limited, All Rights Reserved
#
# Purpose
#
# This script migrates application source code from the mbed TLS 1.3 API to the
# mbed TLS 2.0 API.
#
# The script processes the given source code and renames identifiers - functions
# types, enums etc, as
#
# Usage: rename.pl [-f datafile] [-s] [--] [filenames...]
#
use warnings;
use strict;
use utf8;
use Path::Class;
use open qw(:std utf8);
my $usage = "Usage: $0 [-f datafile] [-s] [--] [filenames...]\n";
@ -45,15 +58,28 @@ my $space = qr/\s+/;
my $idnum = qr/[a-zA-Z0-9_]+/;
my $symbols = qr/[-!#\$%&'()*+,.\/:;<=>?@[\\\]^_`{|}~]+|"/;
my $lib_include_dir = dir($0)->parent->parent->subdir('include', 'mbedtls');
my $lib_source_dir = dir($0)->parent->parent->subdir('library');
# if we replace inside strings, we don't consider them a token
my $token = $do_strings ? qr/$space|$idnum|$symbols/
: qr/$string|$space|$idnum|$symbols/;
my %warnings;
# If no files were passed, exit...
if ( not defined($ARGV[0]) ){ die $usage; }
while( my $filename = shift )
{
print STDERR "$filename... ";
if( dir($filename)->parent eq $lib_include_dir ||
dir($filename)->parent eq $lib_source_dir )
{
die "Script cannot be executed on the mbed TLS library itself.";
}
if( -d $filename ) { print STDERR "skip (directory)\n"; next }
open my $rfh, '<', $filename or die;