mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-01-10 23:05:34 +00:00
Add option to replace inside strings for programs
This commit is contained in:
parent
3385cf4eec
commit
88323c70e8
|
@ -2,11 +2,12 @@
|
||||||
|
|
||||||
# test result with:
|
# test result with:
|
||||||
# make all check
|
# make all check
|
||||||
# ggrep -i --exclude-dir=mpg --exclude=.travis.yml --exclude=ChangeLog --exclude=extra-names --exclude=public-names polarssl . --exclude-dir=tmp G -v 'include|OU?=PolarSSL|PolarSSLTes' | cut -d':' -f1 | sort -u
|
# ggrep -i --exclude-dir=mpg --exclude=.travis.yml --exclude=ChangeLog --exclude=extra-names --exclude=public-names polarssl . --exclude-dir=tmp G -v 'OU?=PolarSSL|PolarSSLTes' | cut -d':' -f1 | sort -u
|
||||||
|
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
FILES='include/mbedtls/*.h library/*.c programs/*.c programs/*/*.c tests/suites/* configs/*.h scripts/data_files/*.fmt scripts/* tests/scripts/*'
|
tmp/analyze-names.sh
|
||||||
|
tmp/makelist.pl public-names extra-names > old2new
|
||||||
|
|
||||||
tmp/rename.pl old2new $FILES
|
tmp/rename.pl old2new include/mbedtls/*.h library/*.c tests/suites/* configs/*.h scripts/data_files/*.fmt scripts/* tests/scripts/*
|
||||||
# re-invoke on programs including strings
|
tmp/rename.pl old2new programs/*.c programs/*/*.c
|
||||||
|
|
|
@ -9,7 +9,13 @@ use open qw(:std utf8);
|
||||||
# apply substitutions from the table in the first arg to files
|
# apply substitutions from the table in the first arg to files
|
||||||
# expected usage: via invoke-rename.pl
|
# expected usage: via invoke-rename.pl
|
||||||
|
|
||||||
die "Usage: $0 names-file [filenames...]\n" if( @ARGV < 1 or ! -r $ARGV[0] );
|
my $do_strings = 0;
|
||||||
|
if( $ARGV[0] eq "-s" ) {
|
||||||
|
shift;
|
||||||
|
$do_strings = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
die "Usage: $0 [-s] names-file [filenames...]\n" if( @ARGV < 1 or ! -r $ARGV[0] );
|
||||||
|
|
||||||
open my $nfh, '<', shift or die;
|
open my $nfh, '<', shift or die;
|
||||||
my @names = <$nfh>;
|
my @names = <$nfh>;
|
||||||
|
@ -27,6 +33,10 @@ my $space = qr/\s+/;
|
||||||
my $idnum = qr/[a-zA-Z0-9_]+/;
|
my $idnum = qr/[a-zA-Z0-9_]+/;
|
||||||
my $symbols = qr/[!#%&'()*+,-.:;<=>?@^_`{|}~\$\/\[\\\]]+|"/;
|
my $symbols = qr/[!#%&'()*+,-.:;<=>?@^_`{|}~\$\/\[\\\]]+|"/;
|
||||||
|
|
||||||
|
# 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;
|
my %warnings;
|
||||||
|
|
||||||
while( my $filename = shift )
|
while( my $filename = shift )
|
||||||
|
@ -40,7 +50,7 @@ while( my $filename = shift )
|
||||||
|
|
||||||
my @out;
|
my @out;
|
||||||
for my $line (@lines) {
|
for my $line (@lines) {
|
||||||
my @words = ($line =~ /$string|$space|$idnum|$symbols/g);
|
my @words = ($line =~ /$token/g);
|
||||||
my $checkline = join '', @words;
|
my $checkline = join '', @words;
|
||||||
if( $checkline eq $line ) {
|
if( $checkline eq $line ) {
|
||||||
my @new = map { exists $subst{$_} ? $subst{$_} : $_ } @words;
|
my @new = map { exists $subst{$_} ? $subst{$_} : $_ } @words;
|
||||||
|
|
Loading…
Reference in a new issue