Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Tor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mike Perry
Tor
Commits
7faec93e
Commit
7faec93e
authored
20 years ago
by
Nick Mathewson
Browse files
Options
Downloads
Patches
Plain Diff
Make mdd.py marginally less kludgey
svn:r1861
parent
5ba92358
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
contrib/mdd.py
+17
-4
17 additions, 4 deletions
contrib/mdd.py
with
17 additions
and
4 deletions
contrib/mdd.py
+
17
−
4
View file @
7faec93e
#!/
home/nickm
/bin/python2.3
#!/
usr
/bin/
env
python2.3
import
re
,
sys
import
textwrap
...
...
@@ -10,17 +10,25 @@ functionCalls = {}
funcCalledByFile
=
{}
funcCalledByFunc
=
{}
cpp_re
=
re
.
compile
(
r
'
//.*$
'
)
c_re
=
re
.
compile
(
r
'
/[*]+(?:[^*]+|[*]+[^/*])*[*]+/
'
,
re
.
M
|
re
.
S
)
for
fname
in
files
:
f
=
open
(
fname
,
'
r
'
)
curFunc
=
"
???
"
functionCalls
.
setdefault
(
curFunc
,{})
lineno
=
0
for
line
in
f
.
xreadlines
():
body
=
f
.
read
()
body
=
cpp_re
.
sub
(
"
"
,
body
)
body
=
c_re
.
sub
(
"
"
,
body
)
#if fname == 'dns.c': print body
for
line
in
body
.
split
(
"
\n
"
):
lineno
+=
1
m
=
re
.
match
(
r
'
^[^\s/].*\s(\w+)\([^;]*$
'
,
line
)
if
m
:
#print line, "->", m.group(1)
curFunc
=
m
.
group
(
1
)
if
curFunc
[
0
]
==
'
_
'
:
curFunc
=
curFunc
[
1
:]
functionCalls
.
setdefault
(
curFunc
,{})
funcDeclaredIn
[
m
.
group
(
1
)]
=
fname
fileDeclares
.
setdefault
(
fname
,
{})[
m
.
group
(
1
)]
=
1
...
...
@@ -29,6 +37,7 @@ for fname in files:
if
m
:
#print line, "->", m.group(1)
curFunc
=
m
.
group
(
1
)
if
curFunc
[
0
]
==
'
_
'
:
curFunc
=
curFunc
[
1
:]
functionCalls
.
setdefault
(
curFunc
,{})
funcDeclaredIn
[
m
.
group
(
1
)]
=
fname
fileDeclares
.
setdefault
(
fname
,
{})[
m
.
group
(
1
)]
=
1
...
...
@@ -36,7 +45,10 @@ for fname in files:
while
line
:
m
=
re
.
search
(
r
'
(\w+)\(
'
,
line
)
if
not
m
:
break
#print line, "->", m.group(1)
#print fname, line, curFunc, "->", m.group(1)
fn
=
m
.
group
(
1
)
if
fn
[
0
]
==
'
_
'
:
fn
=
fn
[
1
:]
functionCalls
[
curFunc
][
m
.
group
(
1
)]
=
1
#if curFunc == "???":
# print ">>!!!!! at %s:%s"%(fname,lineno)
...
...
@@ -92,7 +104,8 @@ if 1:
callers
=
[
c
for
c
in
funcCalledByFunc
.
get
(
func
,{}).
keys
()
if
c
!=
"
???
"
]
callers
.
sort
()
called
=
[
c
for
c
in
functionCalls
[
func
].
keys
()
if
c
!=
"
???
"
]
called
=
[
c
for
c
in
functionCalls
[
func
].
keys
()
if
c
!=
"
???
"
and
c
in
funcnames
]
called
.
sort
()
print
wrap
(
"
"
.
join
(
callers
),
"
Called by:
"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment