]>
git.ipfire.org Git - thirdparty/openssl.git/blob - util/withlibctx.pl
5 use File
::Temp qw
/tempfile/;
9 processallfiles
($topdir);
14 my @files = glob "$dir/*.c $dir/*.h $dir/*.h.in $dir/*.pod *dir/*.pod.in";
16 open (my $STDOUT_ORIG, '>&', STDOUT
);
18 foreach my $file (@files) {
19 my ($tmpfh, $tmpfile) = tempfile
();
21 print "Processing $file\n";
22 open(STDOUT
, '>>', $tmpfile);
24 processfile
(\
*INFILE
);
26 rename($tmpfile, $file);
29 open (STDOUT
, '>&', $STDOUT_ORIG);
32 #Recurse through subdirs
33 opendir my $dh, $dir or die "Cannot open directory";
35 while (defined(my $subdir = readdir $dh)) {
36 next unless -d
"$dir/$subdir";
37 next if (rindex $subdir, ".", 0) == 0;
38 processallfiles
("$dir/$subdir");
50 foreach my $line (<$fh>) {
53 if ($line =~ /^(.+)_with_libctx\((.*[^\\])$/) {
56 #Strip trailing whitespace
57 $postline =~ s/\s+$//;
58 print $preline.'_ex(';
59 my @rets = extracttoclose
($postline);
65 $paramstr = $postline;
66 $indent = (length $preline) + (length '_ex(');
69 #Any other reference to _with_libctx we just replace
70 $line =~ s/_with_libctx/_ex/g;
74 #Strip leading whitespace
76 #Strip trailing whitespace
78 my @rets = extracttoclose
($paramstr.$line);
80 my $pre = shift @rets;
81 my $post = shift @rets;
82 @params = split(",", $pre);
83 my @params = grep(s/^\s*|\s*$//g, @params);
84 formatparams
($indent, @params);
93 die "End of multiline not found" if $multiline;
101 my $param = shift @params;
102 my $lensofar += $indent + (length $param) + 1;
105 print "," if @params;
108 my $param = shift @params;
110 if (($lensofar + (length $param) + 2) > 80) {
111 print "\n".(" " x
$indent);
113 $lensofar = $indent + (length $param) + 1;
116 $lensofar += (length $param) + 2;
118 print "," if @params;
127 while ($inline =~ /^([^\)]*?)\((.*)$/) {
128 my @rets = extracttoclose
($2);
132 my $inside = shift @rets;
133 my $post = shift @rets;
134 $outline .= $1.'('.$inside.')';
137 if ($inline =~ /^(.*?)\)(.*)$/) {
138 return ($outline.$1, $2);