|
| 1 | +#!/bin/bash |
| 2 | +function rename { |
| 3 | + old_file=$1 |
| 4 | + new_file=$2 |
| 5 | + old_name=$3 |
| 6 | + new_name=$4 |
| 7 | + grep $old_name "tommath_private.h" | perl -p -e "s/^(.*)$old_name(.*)/MP_DEPRECATED($new_name) \\1$old_name\\2/" >> deprecated.h |
| 8 | + echo "#ifdef ${old_file^^}_C" >> bn_deprecated.c |
| 9 | + grep $old_name "tommath_private.h" \ |
| 10 | + | perl -p -e "s/^int $old_name(.*);/\$b=\$1;\$x=\$1;\$x =~ s#(const *)?mp_int *\* *|(int|mp_digit|unsigned char *\*) *##g;\"int $old_name\$b { return $new_name\$x; }\"/e" \ |
| 11 | + | perl -p -e "s/^void $old_name(.*);/\$b=\$1;\$x=\$1;\$x =~ s#(const *)?mp_int *\* *|(int|mp_digit|unsigned char *\*) *##g;\"void $old_name\$b { $new_name\$x; }\"/e" >> bn_deprecated.c |
| 12 | + echo "#endif" >> bn_deprecated.c |
| 13 | + git mv $old_file.c $new_file.c |
| 14 | + git ls-files | grep -v rename.sh | grep -v changes.txt | xargs sed -E -i "s/$old_name([^\.])/$new_name\1/g" |
| 15 | + git ls-files | grep -v rename.sh | grep -v changes.txt | xargs sed -E -i "s/$old_file\./$new_file./g" |
| 16 | + git ls-files | grep -v rename.sh | grep -v changes.txt | xargs sed -E -i "s/${old_file^^}/${new_file^^}/g" |
| 17 | +} |
| 18 | + |
| 19 | +echo -n > deprecated.h |
| 20 | +echo "#define MP_DEPRECATED(n)" >> bn_deprecated.c |
| 21 | +echo "#include <tommath_private.h>" > bn_deprecated.c |
| 22 | + |
| 23 | +rename bn_fast_mp_invmod bn_s_mp_invmod_fast fast_mp_invmod s_mp_invmod_fast |
| 24 | +rename bn_fast_mp_montgomery_reduce bn_s_mp_montgomery_reduce_fast fast_mp_montgomery_reduce s_mp_montgomery_reduce_fast |
| 25 | +rename bn_fast_s_mp_mul_digs bn_s_mp_mul_digs_fast fast_s_mp_mul_digs s_mp_mul_digs_fast |
| 26 | +rename bn_fast_s_mp_mul_high_digs bn_s_mp_mul_high_digs_fast fast_s_mp_mul_high_digs s_mp_mul_high_digs_fast |
| 27 | +rename bn_fast_s_mp_sqr bn_s_mp_sqr_fast fast_s_mp_sqr s_mp_sqr_fast |
| 28 | +rename bn_mp_balance_mul bn_s_mp_balance_mul mp_balance_mul s_mp_balance_mul |
| 29 | +rename bn_mp_exptmod_fast bn_s_mp_exptmod_fast mp_exptmod_fast s_mp_exptmod_fast |
| 30 | +rename bn_mp_invmod_slow bn_s_mp_invmod_slow mp_invmod_slow s_mp_invmod_slow |
| 31 | +rename bn_mp_karatsuba_mul bn_s_mp_karatsuba_mul mp_karatsuba_mul s_mp_karatsuba_mul |
| 32 | +rename bn_mp_karatsuba_sqr bn_s_mp_karatsuba_sqr mp_karatsuba_sqr s_mp_karatsuba_sqr |
| 33 | +rename bn_mp_toom_mul bn_s_mp_toom_mul mp_toom_mul s_mp_toom_mul |
| 34 | +rename bn_mp_toom_sqr bn_s_mp_toom_sqr mp_toom_sqr s_mp_toom_sqr |
| 35 | +rename bn_reverse bn_s_mp_reverse bn_reverse s_mp_reverse |
| 36 | + |
| 37 | +deprecated=$(cat deprecated.h) |
| 38 | +rm deprecated.h |
| 39 | +perl -pi -e "s/\/\* deprecated functions \*\/\n/\/* deprecated functions *\/\n$deprecated\n/g" tommath_private.h |
| 40 | + |
| 41 | +git ls-files | grep makefile | xargs sed -E -i "s/bn_error.o/bn_deprecated.o bn_error.o/g" |
0 commit comments