author | mickeyl <mickeyl> | 2004-04-03 13:45:37 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-04-03 13:45:37 (UTC) |
commit | a8e37033a05dd7771cc1e73f387004f31683049d (patch) (unidiff) | |
tree | 0791911c75cea495fd69b6ef13aef6430a8738ee | |
parent | e995afe17ead003dd0b4bc12604d7f8cb5cd4493 (diff) | |
download | opie-a8e37033a05dd7771cc1e73f387004f31683049d.zip opie-a8e37033a05dd7771cc1e73f387004f31683049d.tar.gz opie-a8e37033a05dd7771cc1e73f387004f31683049d.tar.bz2 |
small fixes and add 'printf' to the number of substituted constructs
the script seems to work good, i converted the whole 'noncore' which
will be commited in a few hours. basically the only amount of handwork
after applying the script is adding #include <opie2/odebug.h> and
using namespace Opie::Core - if it's not already there.
-rwxr-xr-x | scripts/qdebug-odebug.py | 15 |
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 | |||
@@ -13,13 +13,15 @@ qDebugExpression = sre.compile( '(.*)(qDebug)\(\s*(.*)\s*\);(.*)' ) | |||
13 | qWarningExpression = sre.compile( '(.*)(qWarning)\(\s*(.*)\s*\);(.*)' ) | 13 | qWarningExpression = sre.compile( '(.*)(qWarning)\(\s*(.*)\s*\);(.*)' ) |
14 | qErrorExpression = sre.compile( '(.*)(qError)\(\s*(.*)\s*\);(.*)' ) | 14 | qErrorExpression = sre.compile( '(.*)(qError)\(\s*(.*)\s*\);(.*)' ) |
15 | qFatalExpression = sre.compile( '(.*)(qFatal)\(\s*(.*)\s*\);(.*)' ) | 15 | qFatalExpression = sre.compile( '(.*)(qFatal)\(\s*(.*)\s*\);(.*)' ) |
16 | printfExpression = sre.compile( '(.*)(printf)\(\s*(.*)\s*\);(.*)' ) | ||
16 | 17 | ||
17 | debugTable = { "qDebug" : "odebug", | 18 | debugTable = { "qDebug" : "odebug", |
18 | "qWarning" : "owarn", | 19 | "qWarning" : "owarn", |
19 | "qError" : "oerr", | 20 | "qError" : "oerr", |
20 | "qFatal" : "ofatal" } | 21 | "qFatal" : "ofatal", |
22 | "printf" : "odebug" } | ||
21 | 23 | ||
22 | allExpressions = ( qDebugExpression, qWarningExpression, qErrorExpression, qFatalExpression ) | 24 | allExpressions = ( qDebugExpression, qWarningExpression, qErrorExpression, qFatalExpression, printfExpression ) |
23 | 25 | ||
24 | #################################################################################################### | 26 | #################################################################################################### |
25 | 27 | ||
@@ -36,16 +38,17 @@ def convert( fname ): | |||
36 | match = True | 38 | match = True |
37 | head, debug, content, tail = m.groups() | 39 | head, debug, content, tail = m.groups() |
38 | print >>sys.stderr, "<NOTE>: Groups = ", m.groups() | 40 | print >>sys.stderr, "<NOTE>: Groups = ", m.groups() |
39 | sys.stdout.write( head.strip() ) | 41 | sys.stdout.write( head ) # don't strip() here, because we want to keep indentation |
40 | sys.stdout.write( debugTable[debug.strip()] ) | 42 | sys.stdout.write( debugTable[debug.strip()] ) |
41 | sys.stdout.write( " << " ) | 43 | sys.stdout.write( " << " ) |
42 | sys.stdout.write( transform( content ).strip() ) | 44 | sys.stdout.write( transform( content ).strip() ) |
43 | sys.stdout.write( " << oendl; " ) | 45 | sys.stdout.write( " << oendl; " ) |
44 | sys.stdout.write( tail + "\n" ) | 46 | sys.stdout.write( tail ) |
47 | if not tail.endswith( "\n" ): sys.stdout.write( "\n" ) | ||
45 | continue | 48 | continue |
46 | # nothing applies | 49 | # nothing applies |
47 | if not match: | 50 | if not match: |
48 | sys.stdout.write( line + "\n" ) | 51 | sys.stdout.write( line ) |
49 | 52 | ||
50 | #################################################################################################### | 53 | #################################################################################################### |
51 | 54 | ||
@@ -97,7 +100,7 @@ def transform( s ): | |||
97 | if formatstring[i] == "%": | 100 | if formatstring[i] == "%": |
98 | result += "%" | 101 | result += "%" |
99 | else: | 102 | else: |
100 | result += '" << %s << "' % substitutions[0] | 103 | result += '" << %s << "' % substitutions[0].replace( "(const char*)", "" ).replace( ".latin1()", "" ) |
101 | del substitutions[0] | 104 | del substitutions[0] |
102 | indirective = False | 105 | indirective = False |
103 | i += 1 | 106 | i += 1 |