[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ft-devel] Re: trace_gloader is registered in fttrace.h
From: |
mpsuzuki |
Subject: |
[ft-devel] Re: trace_gloader is registered in fttrace.h |
Date: |
Fri, 10 Jul 2009 15:53:28 +0900 |
Hi,
Just I've finished the translation from Perl to Python.
This is my first scripting by Python, so any comments to
improve/cleanup by experts are welcomed.
On Core Duo 1GHz + 2GB RAM laptop, the speed of Python
version is 4 times faster than previous Perl version :-).
$ time ./src/tools/chktrcmp.pl > /dev/null
real 0m4.527s
user 0m3.182s
sys 0m1.349s
$ time ./src/tools/chktrcmp.py > /dev/null
real 0m0.849s
user 0m0.557s
sys 0m0.047s
On Thu, 09 Jul 2009 08:10:22 +0200 (CEST)
Werner LEMBERG <address@hidden> wrote:
>> Trace component any (defined in fttrace.h:22) is not used.
>
>This is a false alarm, of course; I use `any' all the time while
>debugging. Maybe it makes sense to catch this in the script.
OK, `any' is excluded as a special case from "defined-but-
not-used" warning.
#!/usr/bin/env python
import os
import re
SRC_FILE_LIST = []
USED_COMPONENT = {}
KNOWN_COMPONENT = {}
c_pathname_pat = re.compile( '^.*\.[ch]$', re.IGNORECASE )
trace_use_pat = re.compile( '^[ \t]*#define[ \t]+FT_COMPONENT[ \t]+trace_' )
for (p,dlst,flst) in os.walk( "src" ):
for f in flst:
if c_pathname_pat.match( f ) != None:
# SRC_FILE_LIST.append( os.path.join( p, f ) )
# print "+ %s" % os.path.join( p, f )
src_pathname = os.path.join( p, f )
line_num = 0
for src_line in open( src_pathname, 'r' ):
line_num = line_num + 1
src_line = src_line.strip()
if trace_use_pat.match( src_line ) != None:
component_name = trace_use_pat.sub( '', src_line )
if component_name in USED_COMPONENT:
USED_COMPONENT[component_name].append( "%s:%d" % ( src_pathname,
line_num ) )
else:
USED_COMPONENT[component_name] = [ "%s:%d" % ( src_pathname,
line_num ) ]
# cmpnt = USED_COMPONENT.keys()
# cmpnt.sort()
# for c in cmpnt:
# print "[%s] used in %s" % ( c, ", ".join( USED_COMPONENT[c] ) )
trace_def_pat_opn = re.compile( '^.*FT_TRACE_DEF[ \t]*\([ \t]*' )
trace_def_pat_cls = re.compile( '[ \t\)].*$' )
line_num = 0
for fttrace_h_line in open( "include/freetype/internal/fttrace.h", 'r' ):
line_num = line_num + 1
fttrace_h_line = fttrace_h_line.strip()
if trace_def_pat_opn.match( fttrace_h_line ) != None:
component_name = trace_def_pat_opn.sub( '', fttrace_h_line )
component_name = trace_def_pat_cls.sub( '', component_name )
if component_name in KNOWN_COMPONENT:
print "trace component %s is defined twice, see %s and fttrace.h:%d" % \
( component_name, KNOWN_COMPONENT[component_name], line_num )
else:
KNOWN_COMPONENT[component_name] = "fttrace.h:%d" % line_num
# cmpnt = KNOWN_COMPONENT.keys()
# cmpnt.sort()
# for c in cmpnt:
# print "[%s] defined in %s" % ( c, KNOWN_COMPONENT[c] )
print "# Trace component used in the implementations but not defined in
fttrace.h."
cmpnt = USED_COMPONENT.keys()
cmpnt.sort()
for c in cmpnt:
if c not in KNOWN_COMPONENT:
print "Trace component %s (used in %s) is not defined." % ( c, ", ".join(
USED_COMPONENT[c] ) )
print "# Trace component is defined but not used in the implementations."
cmpnt = KNOWN_COMPONENT.keys()
cmpnt.sort()
for c in cmpnt:
if c not in USED_COMPONENT:
if c != "any":
print "Trace component %s (defined in %s) is not used." % ( c,
KNOWN_COMPONENT[c] )