summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2013-12-12 12:18:05 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2013-12-12 12:18:05 +0000
commitafe1eed10464cad7f6d92d4f53baa875a7020fc2 (patch)
tree72ab8f243e3e3b5e5eb79a17156a52029c42c0b7 /tools
parentf4b40d76fa776dc22dedfe83d35cf51786252a39 (diff)
downloadmpfr-afe1eed10464cad7f6d92d4f53baa875a7020fc2.tar.gz
Added tools/repl-variadic Perl script to replace the variadic functions
mpfr_clears, mpfr_inits and mpfr_inits2, in case they are not supported by the compiler. git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@8721 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tools')
-rwxr-xr-xtools/repl-variadic30
1 files changed, 30 insertions, 0 deletions
diff --git a/tools/repl-variadic b/tools/repl-variadic
new file mode 100755
index 000000000..164ef4f4c
--- /dev/null
+++ b/tools/repl-variadic
@@ -0,0 +1,30 @@
+#!/usr/bin/env perl
+
+# Replace the variadic functions mpfr_clears, mpfr_inits and mpfr_inits2,
+# in case they are not supported by the compiler.
+#
+# Example of usage: perl -i tools/repl-variadic {src,tests}/*.{c,h}
+
+use strict;
+
+while (<>)
+ {
+ while (/\bmpfr_(clears|inits2?).*, *$/)
+ { chomp; $_ .= <>; }
+ my ($beg,$fct,$vars,$end) =
+ /^(.*?) *\bmpfr_(clears|inits2?) *\((.*?), *\(mpfr_ptr\) *0\)(.*?)$/
+ or print, next;
+ print "$beg\n" if $beg ne '';
+ my @vars = split /, */, $vars;
+ $fct =~ tr/s//d;
+ print "/* !!! Replaced with repl-variadic !!! */ do {\n";
+ my $prec = '';
+ if ($fct eq 'init2')
+ {
+ print " mpfr_prec_t _repl_prec = (", shift(@vars), ");\n";
+ $prec = ", _repl_prec";
+ }
+ foreach my $var (@vars)
+ { print " mpfr_$fct ($var$prec);\n" }
+ print "} while (0)$end\n";
+ }