tests: ok(0,"foo") prints a '\n'!
Glen
gkaukola at earthlink.net
Mon Dec 30 16:00:01 CST 2002
Francois Gouget wrote:
>So if noone objects I'll send a patch that stops 'ok' from appending
>this '\n', and adds a '\n' to all calls to ok. Actually, I would be
>pretty happy if someone could come up with a perl script doing the
>latter...
>
>
I came up with a perl script that does what you want. It may not be
perfect though so use it with caution.
Enjoy,
Glen Kaukola
#!/usr/bin/perl
sub fix_oks
{
my $c_file = $_[0];
open(FILE_HANDLE, "<$c_file") or die("Error opening file $c_file\n");
my @contents = <FILE_HANDLE>;
close(FILE_HANDLE);
#add a new line to the end of any ok calls we find
s/(.*)(\bok\(.*)([^\"])(^\"*)(\")(.*)/$1$2$3$4\\n$5$6/g for @contents;
open(FILE_HANDLE, ">$c_file");
print(FILE_HANDLE @contents);
close(FILE_HANDLE);
}
sub do_current_dir
{
my $i = 0;
#get the current directory's listing
opendir(DIR_HANDLE, ".") or die("Error opening $directory\n");
my @dir_listing = grep { !/^\.\.?/ } readdir(DIR_HANDLE);
closedir(DIR_HANDLE);
#for each file in the directory
while($dir_listing[$i])
{
#if a directory is found then do that one too
if(-d $dir_listing[$i])
{
chdir $dir_listing[$i];
do_current_dir();
chdir "..";
}
#if it's a c file then fix the calls to ok
if($dir_listing[$i] =~ /\.c$/)
{
fix_oks($dir_listing[$i]);
}
$i++;
}
}
do_current_dir();
More information about the wine-devel
mailing list