Commit 2ea04fb78293f51929d307f8d9245138ae09972c

Daniel Mendler 2019-05-07T10:42:26

dep.pl: strip comments

diff --git a/callgraph.txt b/callgraph.txt
index daea322..9d56e7c 100644
--- a/callgraph.txt
+++ b/callgraph.txt
@@ -3189,6 +3189,7 @@ BN_MP_IS_SQUARE_C
 
 
 BN_MP_JACOBI_C
++--->BN_MP_CMP_D_C
 +--->BN_MP_KRONECKER_C
 |   +--->BN_MP_INIT_COPY_C
 |   |   +--->BN_MP_INIT_SIZE_C
@@ -3204,7 +3205,6 @@ BN_MP_JACOBI_C
 |   |   |   +--->BN_MP_CLAMP_C
 |   |   +--->BN_MP_RSHD_C
 |   |   +--->BN_MP_CLAMP_C
-|   +--->BN_MP_CMP_D_C
 |   +--->BN_MP_COPY_C
 |   |   +--->BN_MP_GROW_C
 |   +--->BN_MP_MOD_C
@@ -3258,7 +3258,6 @@ BN_MP_JACOBI_C
 |   |   |   |   +--->BN_MP_GROW_C
 |   |   |   |   +--->BN_MP_CLAMP_C
 |   +--->BN_MP_CLEAR_C
-+--->BN_MP_CMP_D_C
 
 
 BN_MP_KRONECKER_C
@@ -7028,9 +7027,6 @@ BN_MP_PRIME_IS_PRIME_C
 |   +--->BN_MP_CLEAR_MULTI_C
 |   |   +--->BN_MP_CLEAR_C
 +--->BN_MP_PRIME_STRONG_LUCAS_SELFRIDGE_C
-|   +--->BN_MP_MUL_D_C
-|   |   +--->BN_MP_GROW_C
-|   |   +--->BN_MP_CLAMP_C
 |   +--->BN_MP_INIT_C
 |   +--->BN_MP_SET_LONG_C
 |   +--->BN_MP_MUL_C
@@ -7088,6 +7084,9 @@ BN_MP_PRIME_IS_PRIME_C
 |   |   |   |   +--->BN_MP_GROW_C
 |   |   |   |   +--->BN_MP_LSHD_C
 |   |   |   |   +--->BN_MP_CLAMP_C
+|   |   |   +--->BN_MP_MUL_D_C
+|   |   |   |   +--->BN_MP_GROW_C
+|   |   |   |   +--->BN_MP_CLAMP_C
 |   |   |   +--->BN_MP_DIV_3_C
 |   |   |   |   +--->BN_MP_INIT_SIZE_C
 |   |   |   |   +--->BN_MP_CLAMP_C
@@ -7198,6 +7197,9 @@ BN_MP_PRIME_IS_PRIME_C
 |   |   |   |   +--->BN_MP_LSHD_C
 |   |   |   |   |   +--->BN_MP_GROW_C
 |   |   |   |   +--->BN_MP_RSHD_C
+|   |   |   |   +--->BN_MP_MUL_D_C
+|   |   |   |   |   +--->BN_MP_GROW_C
+|   |   |   |   |   +--->BN_MP_CLAMP_C
 |   |   |   |   +--->BN_MP_CLAMP_C
 |   |   |   +--->BN_MP_EXCH_C
 |   |   |   +--->BN_MP_ADD_C
@@ -7259,6 +7261,9 @@ BN_MP_PRIME_IS_PRIME_C
 |   |   |   +--->BN_MP_LSHD_C
 |   |   |   |   +--->BN_MP_GROW_C
 |   |   |   +--->BN_MP_RSHD_C
+|   |   |   +--->BN_MP_MUL_D_C
+|   |   |   |   +--->BN_MP_GROW_C
+|   |   |   |   +--->BN_MP_CLAMP_C
 |   |   |   +--->BN_MP_CLAMP_C
 |   |   +--->BN_MP_EXCH_C
 |   |   +--->BN_MP_ADD_C
@@ -7303,6 +7308,9 @@ BN_MP_PRIME_IS_PRIME_C
 |   |   |   |   +--->BN_MP_GROW_C
 |   |   |   |   +--->BN_MP_LSHD_C
 |   |   |   |   +--->BN_MP_CLAMP_C
+|   |   |   +--->BN_MP_MUL_D_C
+|   |   |   |   +--->BN_MP_GROW_C
+|   |   |   |   +--->BN_MP_CLAMP_C
 |   |   |   +--->BN_MP_DIV_3_C
 |   |   |   |   +--->BN_MP_INIT_SIZE_C
 |   |   |   |   +--->BN_MP_CLAMP_C
@@ -9632,9 +9640,6 @@ BN_MP_PRIME_NEXT_PRIME_C
 |   |   +--->BN_MP_CLEAR_MULTI_C
 |   |   |   +--->BN_MP_CLEAR_C
 |   +--->BN_MP_PRIME_STRONG_LUCAS_SELFRIDGE_C
-|   |   +--->BN_MP_MUL_D_C
-|   |   |   +--->BN_MP_GROW_C
-|   |   |   +--->BN_MP_CLAMP_C
 |   |   +--->BN_MP_SET_LONG_C
 |   |   +--->BN_MP_MUL_C
 |   |   |   +--->BN_S_MP_BALANCE_MUL_C
@@ -9691,6 +9696,9 @@ BN_MP_PRIME_NEXT_PRIME_C
 |   |   |   |   |   +--->BN_MP_GROW_C
 |   |   |   |   |   +--->BN_MP_LSHD_C
 |   |   |   |   |   +--->BN_MP_CLAMP_C
+|   |   |   |   +--->BN_MP_MUL_D_C
+|   |   |   |   |   +--->BN_MP_GROW_C
+|   |   |   |   |   +--->BN_MP_CLAMP_C
 |   |   |   |   +--->BN_MP_DIV_3_C
 |   |   |   |   |   +--->BN_MP_INIT_SIZE_C
 |   |   |   |   |   +--->BN_MP_CLAMP_C
@@ -9800,6 +9808,9 @@ BN_MP_PRIME_NEXT_PRIME_C
 |   |   |   |   |   +--->BN_MP_LSHD_C
 |   |   |   |   |   |   +--->BN_MP_GROW_C
 |   |   |   |   |   +--->BN_MP_RSHD_C
+|   |   |   |   |   +--->BN_MP_MUL_D_C
+|   |   |   |   |   |   +--->BN_MP_GROW_C
+|   |   |   |   |   |   +--->BN_MP_CLAMP_C
 |   |   |   |   |   +--->BN_MP_CLAMP_C
 |   |   |   |   +--->BN_MP_EXCH_C
 |   |   |   |   +--->BN_MP_ADD_C
@@ -9854,6 +9865,9 @@ BN_MP_PRIME_NEXT_PRIME_C
 |   |   |   |   +--->BN_MP_LSHD_C
 |   |   |   |   |   +--->BN_MP_GROW_C
 |   |   |   |   +--->BN_MP_RSHD_C
+|   |   |   |   +--->BN_MP_MUL_D_C
+|   |   |   |   |   +--->BN_MP_GROW_C
+|   |   |   |   |   +--->BN_MP_CLAMP_C
 |   |   |   |   +--->BN_MP_CLAMP_C
 |   |   |   +--->BN_MP_EXCH_C
 |   |   |   +--->BN_MP_ADD_C
@@ -9898,6 +9912,9 @@ BN_MP_PRIME_NEXT_PRIME_C
 |   |   |   |   |   +--->BN_MP_GROW_C
 |   |   |   |   |   +--->BN_MP_LSHD_C
 |   |   |   |   |   +--->BN_MP_CLAMP_C
+|   |   |   |   +--->BN_MP_MUL_D_C
+|   |   |   |   |   +--->BN_MP_GROW_C
+|   |   |   |   |   +--->BN_MP_CLAMP_C
 |   |   |   |   +--->BN_MP_DIV_3_C
 |   |   |   |   |   +--->BN_MP_INIT_SIZE_C
 |   |   |   |   |   +--->BN_MP_CLAMP_C
@@ -11401,9 +11418,6 @@ BN_MP_PRIME_RANDOM_EX_C
 |   |   +--->BN_MP_CLEAR_MULTI_C
 |   |   |   +--->BN_MP_CLEAR_C
 |   +--->BN_MP_PRIME_STRONG_LUCAS_SELFRIDGE_C
-|   |   +--->BN_MP_MUL_D_C
-|   |   |   +--->BN_MP_GROW_C
-|   |   |   +--->BN_MP_CLAMP_C
 |   |   +--->BN_MP_INIT_C
 |   |   +--->BN_MP_SET_LONG_C
 |   |   +--->BN_MP_MUL_C
@@ -11461,6 +11475,9 @@ BN_MP_PRIME_RANDOM_EX_C
 |   |   |   |   |   +--->BN_MP_GROW_C
 |   |   |   |   |   +--->BN_MP_LSHD_C
 |   |   |   |   |   +--->BN_MP_CLAMP_C
+|   |   |   |   +--->BN_MP_MUL_D_C
+|   |   |   |   |   +--->BN_MP_GROW_C
+|   |   |   |   |   +--->BN_MP_CLAMP_C
 |   |   |   |   +--->BN_MP_DIV_3_C
 |   |   |   |   |   +--->BN_MP_INIT_SIZE_C
 |   |   |   |   |   +--->BN_MP_CLAMP_C
@@ -11571,6 +11588,9 @@ BN_MP_PRIME_RANDOM_EX_C
 |   |   |   |   |   +--->BN_MP_LSHD_C
 |   |   |   |   |   |   +--->BN_MP_GROW_C
 |   |   |   |   |   +--->BN_MP_RSHD_C
+|   |   |   |   |   +--->BN_MP_MUL_D_C
+|   |   |   |   |   |   +--->BN_MP_GROW_C
+|   |   |   |   |   |   +--->BN_MP_CLAMP_C
 |   |   |   |   |   +--->BN_MP_CLAMP_C
 |   |   |   |   +--->BN_MP_EXCH_C
 |   |   |   |   +--->BN_MP_ADD_C
@@ -11632,6 +11652,9 @@ BN_MP_PRIME_RANDOM_EX_C
 |   |   |   |   +--->BN_MP_LSHD_C
 |   |   |   |   |   +--->BN_MP_GROW_C
 |   |   |   |   +--->BN_MP_RSHD_C
+|   |   |   |   +--->BN_MP_MUL_D_C
+|   |   |   |   |   +--->BN_MP_GROW_C
+|   |   |   |   |   +--->BN_MP_CLAMP_C
 |   |   |   |   +--->BN_MP_CLAMP_C
 |   |   |   +--->BN_MP_EXCH_C
 |   |   |   +--->BN_MP_ADD_C
@@ -11676,6 +11699,9 @@ BN_MP_PRIME_RANDOM_EX_C
 |   |   |   |   |   +--->BN_MP_GROW_C
 |   |   |   |   |   +--->BN_MP_LSHD_C
 |   |   |   |   |   +--->BN_MP_CLAMP_C
+|   |   |   |   +--->BN_MP_MUL_D_C
+|   |   |   |   |   +--->BN_MP_GROW_C
+|   |   |   |   |   +--->BN_MP_CLAMP_C
 |   |   |   |   +--->BN_MP_DIV_3_C
 |   |   |   |   |   +--->BN_MP_INIT_SIZE_C
 |   |   |   |   |   +--->BN_MP_CLAMP_C
@@ -11774,9 +11800,6 @@ BN_MP_PRIME_RANDOM_EX_C
 
 
 BN_MP_PRIME_STRONG_LUCAS_SELFRIDGE_C
-+--->BN_MP_MUL_D_C
-|   +--->BN_MP_GROW_C
-|   +--->BN_MP_CLAMP_C
 +--->BN_MP_INIT_C
 +--->BN_MP_SET_LONG_C
 +--->BN_MP_MUL_C
@@ -11834,6 +11857,9 @@ BN_MP_PRIME_STRONG_LUCAS_SELFRIDGE_C
 |   |   |   +--->BN_MP_GROW_C
 |   |   |   +--->BN_MP_LSHD_C
 |   |   |   +--->BN_MP_CLAMP_C
+|   |   +--->BN_MP_MUL_D_C
+|   |   |   +--->BN_MP_GROW_C
+|   |   |   +--->BN_MP_CLAMP_C
 |   |   +--->BN_MP_DIV_3_C
 |   |   |   +--->BN_MP_INIT_SIZE_C
 |   |   |   +--->BN_MP_CLAMP_C
@@ -11945,6 +11971,9 @@ BN_MP_PRIME_STRONG_LUCAS_SELFRIDGE_C
 |   |   |   +--->BN_MP_LSHD_C
 |   |   |   |   +--->BN_MP_GROW_C
 |   |   |   +--->BN_MP_RSHD_C
+|   |   |   +--->BN_MP_MUL_D_C
+|   |   |   |   +--->BN_MP_GROW_C
+|   |   |   |   +--->BN_MP_CLAMP_C
 |   |   |   +--->BN_MP_CLAMP_C
 |   |   +--->BN_MP_EXCH_C
 |   |   +--->BN_MP_ADD_C
@@ -12006,6 +12035,9 @@ BN_MP_PRIME_STRONG_LUCAS_SELFRIDGE_C
 |   |   +--->BN_MP_LSHD_C
 |   |   |   +--->BN_MP_GROW_C
 |   |   +--->BN_MP_RSHD_C
+|   |   +--->BN_MP_MUL_D_C
+|   |   |   +--->BN_MP_GROW_C
+|   |   |   +--->BN_MP_CLAMP_C
 |   |   +--->BN_MP_CLAMP_C
 |   +--->BN_MP_EXCH_C
 |   +--->BN_MP_ADD_C
@@ -12050,6 +12082,9 @@ BN_MP_PRIME_STRONG_LUCAS_SELFRIDGE_C
 |   |   |   +--->BN_MP_GROW_C
 |   |   |   +--->BN_MP_LSHD_C
 |   |   |   +--->BN_MP_CLAMP_C
+|   |   +--->BN_MP_MUL_D_C
+|   |   |   +--->BN_MP_GROW_C
+|   |   |   +--->BN_MP_CLAMP_C
 |   |   +--->BN_MP_DIV_3_C
 |   |   |   +--->BN_MP_INIT_SIZE_C
 |   |   |   +--->BN_MP_CLAMP_C
diff --git a/dep.pl b/dep.pl
index 45a3c63..fb610c1 100755
--- a/dep.pl
+++ b/dep.pl
@@ -79,6 +79,8 @@ EOS
 
 foreach my $filename (glob 'bn*.c') {
    open(my $src, '<', $filename) or die "Can't open source file!\n";
+   read $src, my $content, -s $src;
+   close $src;
 
    # convert filename to upper case so we can use it as a define
    $filename =~ tr/[a-z]/[A-Z]/;
@@ -89,9 +91,11 @@ foreach my $filename (glob 'bn*.c') {
 EOS
    my $list = $filename;
 
+   # strip comments
+   $content =~ s{/\*.*?\*/}{}gs;
+
    # scan for mp_* and make classes
-   while (<$src>) {
-      my $line = $_;
+   foreach my $line (split /\n/, $content) {
       while ($line =~ /(fast_)?(s_)?mp\_[a-z_0-9]*(?=\()/g) {
           my $a = $&;
           $a =~ tr/[a-z]/[A-Z]/;
@@ -110,7 +114,6 @@ EOS
 #endif
 
 EOS
-   close $src;
 }
 
 print {$class} << 'EOS';
diff --git a/tommath_class.h b/tommath_class.h
index 940d8b8..9ed6247 100644
--- a/tommath_class.h
+++ b/tommath_class.h
@@ -505,8 +505,8 @@
 #endif
 
 #if defined(BN_MP_JACOBI_C)
-#   define BN_MP_KRONECKER_C
 #   define BN_MP_CMP_D_C
+#   define BN_MP_KRONECKER_C
 #endif
 
 #if defined(BN_MP_KRONECKER_C)
@@ -722,7 +722,6 @@
 #endif
 
 #if defined(BN_MP_PRIME_STRONG_LUCAS_SELFRIDGE_C)
-#   define BN_MP_MUL_D_C
 #   define BN_S_MP_MUL_SI_C
 #   define BN_MP_INIT_C
 #   define BN_MP_SET_LONG_C