OK, it's late, but here's a tool that will reformat the
printf() style qdebug calls to the new style. I'll look at it
tomorrow. When invoked thusly
./fixqDebug -v -n *.cpp
-v verbose
-n dry run (eg. dont change file)
it outputs to stdout the proposed changes. Indent handling is
AFU (tabs). It fixes the qdebugs in comments too.
What about qwarnings? ANd the include file? It seems to compile
with include QtDebug or QDebug.
It's a horrid perl crock.
It will not catch bad printf() calls, eg. formats without
and arg, or args without a format; but I could make it check
for that.
#!/usr/bin/perl -w
# Fix all the qDebug()s
use Getopt::Std;
use vars qw/$opt_n $opt_v/;
getopts ('nv');
foreach (@ARGV) {
print "File: $_\n" if $opt_v;
&process ($_);
}
# Process each input file.
#
sub process {
my $fn= shift;
my $ofn= "$fn.temp";
my $needwrite= 0;
open (I, "<$fn") or die ("Can't read $fn?!");
open (O, ">$ofn") or die ("Can't create temp file $ofn!");
while (<I>) {
# Match one of these, sets $fmt, $argstring accordingly.
# qDebug ("format", arg1, arg2); (with
arg(s))
# qDebug ("foox"); (no
args)
my ($indent, $fmt, $argstring)= /(\s*\/{0,2}\s*)qDebug
*\("(.+)" *, *(.*)\);/;
if (not defined $fmt) {
$argstring= ""; # will
be no args,
($indent, $fmt)= /(\s*\/{0,2}\s*)qDebug *\("(.+)"\);/
# just format string
}
if (not $fmt) { # no
match? copy to output
print O $_;
next;
}
# Found target string.
++$needwrite;
my $was= $_; # for
output later
# Now interpret the format string, and whenever we find %format, output the
format
# string up to that point, then the first argument in the list.
my (@F)= split (/\%[-\.\d]*[A-Za-z]/, $fmt); # %s
%-2d %-4.2e
my (@A)= split (/\s*,\s*/, $argstring); # list
of args
# Commented out lines need a bit of handling. Sometimes they're
# // qDebug
#// qDebug
# // qDebug
my $cmt= "";
if ($indent =~ /\//) { # if
comment in indent,
$indent =~ s/\// /g; #
remove them,
$cmt= "//";
}
my $out= "qDebug()";
foreach (@F) {
$out .= " << " . "\"$_\"";
if (scalar @A) { $out.= " << " . shift @A; }
}
$out .= ";\n";
my $prefwas= $indent;
$prefwas =~ s/^.......//;
print "//was$prefwas$was$indent$cmt$out" if $opt_v;
print O "$prefwas$was$indent$cmt$out";
}
close I;
close O;
if (!$opt_n && $needwrite) {
`mv $fn $fn.orig`;
`mv $ofn $fn`;
} else {
`rm $ofn`;
}
}
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Mixxx-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mixxx-devel