summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rwxr-xr-xscripts/qdebug-odebug.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/scripts/qdebug-odebug.py b/scripts/qdebug-odebug.py
index cc1b7ca..636c1b2 100755
--- a/scripts/qdebug-odebug.py
+++ b/scripts/qdebug-odebug.py
@@ -10,19 +10,21 @@ manual work may be needed after applying the script.
import sys, sre
qDebugExpression = sre.compile( '(.*)(qDebug)\(\s*(.*)\s*\);(.*)' )
qWarningExpression = sre.compile( '(.*)(qWarning)\(\s*(.*)\s*\);(.*)' )
qErrorExpression = sre.compile( '(.*)(qError)\(\s*(.*)\s*\);(.*)' )
qFatalExpression = sre.compile( '(.*)(qFatal)\(\s*(.*)\s*\);(.*)' )
+printfExpression = sre.compile( '(.*)(printf)\(\s*(.*)\s*\);(.*)' )
debugTable = { "qDebug" : "odebug",
"qWarning" : "owarn",
"qError" : "oerr",
- "qFatal" : "ofatal" }
+ "qFatal" : "ofatal",
+ "printf" : "odebug" }
-allExpressions = ( qDebugExpression, qWarningExpression, qErrorExpression, qFatalExpression )
+allExpressions = ( qDebugExpression, qWarningExpression, qErrorExpression, qFatalExpression, printfExpression )
####################################################################################################
def convert( fname ):
print >>sys.stderr, "<NOTE>: Dealing with %s..." % fname
@@ -33,22 +35,23 @@ def convert( fname ):
if m is None:
continue
else:
match = True
head, debug, content, tail = m.groups()
print >>sys.stderr, "<NOTE>: Groups = ", m.groups()
- sys.stdout.write( head.strip() )
+ sys.stdout.write( head ) # don't strip() here, because we want to keep indentation
sys.stdout.write( debugTable[debug.strip()] )
sys.stdout.write( " << " )
sys.stdout.write( transform( content ).strip() )
sys.stdout.write( " << oendl; " )
- sys.stdout.write( tail + "\n" )
+ sys.stdout.write( tail )
+ if not tail.endswith( "\n" ): sys.stdout.write( "\n" )
continue
# nothing applies
if not match:
- sys.stdout.write( line + "\n" )
+ sys.stdout.write( line )
####################################################################################################
def transform( s ):
print >>sys.stderr, "<NOTE>: Transforming '%s'..." % s
@@ -94,13 +97,13 @@ def transform( s ):
i += 1
while i < len( formatstring ) and formatstring[i] not in "%dDiouxXfegEscpn":
i += 1
if formatstring[i] == "%":
result += "%"
else:
- result += '" << %s << "' % substitutions[0]
+ result += '" << %s << "' % substitutions[0].replace( "(const char*)", "" ).replace( ".latin1()", "" )
del substitutions[0]
indirective = False
i += 1
print >>sys.stderr, "<NOTE>: Result seems to be '%s'" % result
return result.replace( "%%", "%" )