Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
83b41822
Commit
83b41822
authored
Sep 24, 2018
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
A train-trip worth of python3 migration and other polishing
parent
3ed8d7db
Changes
16
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
1374 additions
and
1370 deletions
+1374
-1370
huffman_gen.py
bin/varnishtest/huffman_gen.py
+56
-56
witness.py
bin/varnishtest/witness.py
+31
-31
vtc-syntax.py
doc/sphinx/vtc-syntax.py
+42
-43
Makefile.am
include/Makefile.am
+2
-2
generate.py
include/generate.py
+20
-21
h2_settings.h
include/tbl/h2_settings.h
+5
-0
htc.h
include/tbl/htc.h
+4
-3
style.py
include/tbl/style.py
+53
-51
vsl_tags.h
include/tbl/vsl_tags.h
+11
-10
waiters.h
include/tbl/waiters.h
+2
-0
generate.py
lib/libvarnishapi/generate.py
+89
-90
generate.py
lib/libvcc/generate.py
+482
-488
vmodtool.py
lib/libvcc/vmodtool.py
+34
-35
vsctool.py
lib/libvcc/vsctool.py
+371
-366
gcov_digest.py
tools/gcov_digest.py
+139
-139
include_wash.py
tools/include_wash.py
+33
-35
No files found.
bin/varnishtest/huffman_gen.py
View file @
83b41822
...
...
@@ -7,50 +7,50 @@ import sys
regex
=
re
.
compile
(
"^HPH
\
((.{4}), (.{10}), +(.{1,3})
\
)"
)
if
len
(
sys
.
argv
)
!=
2
:
print
(
"{} takes one and only one argument"
.
format
(
sys
.
argv
[
0
]))
sys
.
exit
(
2
)
print
(
"{} takes one and only one argument"
.
format
(
sys
.
argv
[
0
]))
sys
.
exit
(
2
)
class
sym
:
def
__init__
(
self
,
bigval
,
bigvall
,
chr
=
0
,
esc
=
None
):
self
.
vall
=
bigvall
%
8
if
bigvall
%
8
else
8
self
.
val
=
bigval
&
((
1
<<
self
.
vall
)
-
1
)
self
.
pfx
=
(
bigval
>>
self
.
vall
)
# & 0xff
self
.
chr
=
chr
self
.
esc
=
esc
def
__init__
(
self
,
bigval
,
bigvall
,
chr
=
0
,
esc
=
None
):
self
.
vall
=
bigvall
%
8
if
bigvall
%
8
else
8
self
.
val
=
bigval
&
((
1
<<
self
.
vall
)
-
1
)
self
.
pfx
=
(
bigval
>>
self
.
vall
)
# & 0xff
self
.
chr
=
chr
self
.
esc
=
esc
tbls
=
{}
msl
=
{}
# max sym length
f
=
open
(
sys
.
argv
[
1
])
for
l
in
f
:
grp
=
1
match
=
regex
.
match
(
l
)
if
not
match
:
continue
ch
r
=
int
(
match
.
group
(
grp
),
16
)
grp
+=
1
val
=
int
(
match
.
group
(
grp
),
16
)
grp
+=
1
vall
=
int
(
match
.
group
(
grp
))
s
=
sym
(
val
,
vall
,
ch
r
)
if
s
.
pfx
not
in
tbls
:
tbls
[
s
.
pfx
]
=
{}
if
(
s
.
val
in
tbls
[
s
.
pfx
])
:
assert
(
tbls
[
s
.
pfx
][
s
.
val
]
.
e
)
tbls
[
s
.
pfx
][
s
.
val
]
=
s
# add the escape entry in the "previous" table
if
s
.
pfx
:
pp
=
s
.
pfx
>>
8
pv
=
s
.
pfx
&
0xff
if
pp
not
in
tbls
:
tbls
[
pp
]
=
{}
tbls
[
pp
][
pv
]
=
sym
(
pv
,
8
,
0
,
"&tbl_{:x}"
.
format
(
s
.
pfx
))
grp
=
1
match
=
regex
.
match
(
l
)
if
not
match
:
continue
cha
r
=
int
(
match
.
group
(
grp
),
16
)
grp
+=
1
val
=
int
(
match
.
group
(
grp
),
16
)
grp
+=
1
vall
=
int
(
match
.
group
(
grp
))
s
=
sym
(
val
,
vall
,
cha
r
)
if
s
.
pfx
not
in
tbls
:
tbls
[
s
.
pfx
]
=
{}
if
s
.
val
in
tbls
[
s
.
pfx
]
:
assert
tbls
[
s
.
pfx
][
s
.
val
]
.
e
tbls
[
s
.
pfx
][
s
.
val
]
=
s
# add the escape entry in the "previous" table
if
s
.
pfx
:
pp
=
s
.
pfx
>>
8
pv
=
s
.
pfx
&
0xff
if
pp
not
in
tbls
:
tbls
[
pp
]
=
{}
tbls
[
pp
][
pv
]
=
sym
(
pv
,
8
,
0
,
"&tbl_{:x}"
.
format
(
s
.
pfx
))
f
.
close
()
# add the EOS case
...
...
@@ -64,33 +64,33 @@ print('''/* NB: This file is machine generated, DO NOT EDIT!
struct stbl;
struct ssym {
uint8_t csm;
/* bits consumed */
uint8_t chr;
/* character */
struct stbl *nxt;
/* next table */
uint8_t csm;
/* bits consumed */
uint8_t chr;
/* character */
struct stbl *nxt;
/* next table */
};
struct stbl {
int msk;
struct ssym *syms;
int msk;
struct ssym *syms;
};
'''
)
for
pfx
in
sorted
(
tbls
.
keys
(),
reverse
=
True
):
msl
=
max
([
x
.
vall
for
x
in
tbls
[
pfx
]
.
values
()
])
for
s
in
tbls
[
pfx
]
.
values
():
s
.
val
=
s
.
val
<<
(
msl
-
s
.
vall
)
tbl
=
sorted
(
tbls
[
pfx
]
.
values
(),
key
=
lambda
x
:
x
.
val
)
print
(
"
\n
static struct ssym sym_{:x}_array[] = {{"
.
format
(
pfx
))
for
s
in
tbl
:
for
j
in
range
(
2
**
(
msl
-
s
.
vall
)):
print
(
"
{} {{{}, {:3d}, {}}},"
.
format
(
"
\t
"
if
j
else
"/* idx {:3d} */"
.
format
(
s
.
val
+
j
),
s
.
vall
,
s
.
chr
%
256
,
s
.
esc
if
s
.
esc
else
"NULL"
))
print
(
'''}};
msl
=
max
([
x
.
vall
for
x
in
tbls
[
pfx
]
.
values
()
])
for
s
in
tbls
[
pfx
]
.
values
():
s
.
val
=
s
.
val
<<
(
msl
-
s
.
vall
)
tbl
=
sorted
(
tbls
[
pfx
]
.
values
(),
key
=
lambda
x
:
x
.
val
)
print
(
"
\n
static struct ssym sym_{:x}_array[] = {{"
.
format
(
pfx
))
for
s
in
tbl
:
for
j
in
range
(
2
**
(
msl
-
s
.
vall
)):
print
(
"
{} {{{}, {:3d}, {}}},"
.
format
(
"
\t
"
if
j
else
"/* idx {:3d} */"
.
format
(
s
.
val
+
j
),
s
.
vall
,
s
.
chr
%
256
,
s
.
esc
if
s
.
esc
else
"NULL"
))
print
(
'''}};
static struct stbl tbl_{:x} = {{
{},
sym_{:x}_array
{},
sym_{:x}_array
}};'''
.
format
(
pfx
,
msl
,
pfx
))
bin/varnishtest/witness.py
View file @
83b41822
...
...
@@ -3,9 +3,9 @@
# This script is in the public domain
#
# Run instructions:
#
varnishtest -W -iv -j <pick_a_number> > _.w
#
python witness.py
#
dot -Tpng /tmp/_.dot > /tmp/_.png
#
varnishtest -W -iv -j <pick_a_number> > _.w
#
python witness.py
#
dot -Tpng /tmp/_.dot > /tmp/_.png
from
__future__
import
print_function
...
...
@@ -16,37 +16,37 @@ fi = open("_.w")
fo
=
open
(
"/tmp/_.dot"
,
"w"
)
fo
.
write
(
'''digraph {
#rotate="90"
#page="8.2,11.7"
size="8.2,11.7"
rankdir="LR"
node [fontname="Inconsolata", fontsize="10"]
edge [fontname="Inconsolata", fontsize="10"]
#rotate="90"
#page="8.2,11.7"
size="8.2,11.7"
rankdir="LR"
node [fontname="Inconsolata", fontsize="10"]
edge [fontname="Inconsolata", fontsize="10"]
'''
)
for
i
in
fi
:
l
=
"ROOT"
j
=
i
.
split
()
if
len
(
j
)
<
8
:
continue
if
j
[
1
][
0
]
!=
'v'
:
continue
if
j
[
3
]
!=
"vsl|"
:
continue
if
j
[
5
]
!=
"Witness"
:
continue
t
=
j
[
7
:]
tt
=
str
(
t
)
if
tt
in
d
:
continue
d
[
tt
]
=
True
for
e
in
t
:
f
=
e
.
split
(
","
)
x
=
'"
%
s" -> "
%
s" [label="
%
s(
%
s)"]
\n
'
%
(
l
,
f
[
0
],
f
[
1
],
f
[
2
])
if
not
x
in
a
:
a
[
x
]
=
True
fo
.
write
(
x
)
l
=
f
[
0
]
l
=
"ROOT"
j
=
i
.
split
()
if
len
(
j
)
<
8
:
continue
if
j
[
1
][
0
]
!=
'v'
:
continue
if
j
[
3
]
!=
"vsl|"
:
continue
if
j
[
5
]
!=
"Witness"
:
continue
t
=
j
[
7
:]
tt
=
str
(
t
)
if
tt
in
d
:
continue
d
[
tt
]
=
True
for
e
in
t
:
f
=
e
.
split
(
","
)
x
=
'"
%
s" -> "
%
s" [label="
%
s(
%
s)"]
\n
'
%
(
l
,
f
[
0
],
f
[
1
],
f
[
2
])
if
not
x
in
a
:
a
[
x
]
=
True
fo
.
write
(
x
)
l
=
f
[
0
]
fo
.
write
(
"}
\n
"
)
doc/sphinx/vtc-syntax.py
View file @
83b41822
...
...
@@ -35,50 +35,49 @@ import re
def
parse_file
(
fn
,
cl
,
tl
,
sl
):
p
=
False
section
=
""
resec
=
re
.
compile
(
"[ /]
\
* SECTION: "
)
p
=
False
section
=
""
resec
=
re
.
compile
(
"[ /]
\
* SECTION: "
)
f
=
open
(
fn
,
"r"
)
f
=
open
(
fn
,
"r"
)
for
l
in
f
:
if
"*/"
in
l
:
p
=
0
if
resec
.
match
(
l
):
a
=
l
.
split
()
section
=
a
[
2
]
sl
.
append
(
section
)
cl
[
section
]
=
[]
if
len
(
a
)
>
3
:
tl
[
section
]
=
re
.
sub
(
r"^[\t ]*\/?\* SECTION: [^ ]+ +"
,
""
,
l
)
else
:
tl
[
section
]
=
""
p
=
1
elif
p
:
cl
[
section
]
.
append
(
re
.
sub
(
r"^ \* ?"
,
""
,
l
))
f
.
close
()
for
l
in
f
:
if
"*/"
in
l
:
p
=
0
if
resec
.
match
(
l
):
a
=
l
.
split
()
section
=
a
[
2
]
sl
.
append
(
section
)
cl
[
section
]
=
[]
if
len
(
a
)
>
3
:
tl
[
section
]
=
re
.
sub
(
r"^[\t ]*\/?\* SECTION: [^ ]+ +"
,
""
,
l
)
else
:
tl
[
section
]
=
""
p
=
1
elif
p
:
cl
[
section
]
.
append
(
re
.
sub
(
r"^ \* ?"
,
""
,
l
))
f
.
close
()
if
__name__
==
"__main__"
:
cl
=
{}
tl
=
{}
sl
=
[]
for
fn
in
sys
.
argv
[
1
:]:
parse_file
(
fn
,
cl
,
tl
,
sl
)
sl
.
sort
()
for
section
in
sl
:
print
(
tl
[
section
],
end
=
""
)
a
=
section
c
=
section
.
count
(
"."
)
if
c
==
0
:
r
=
"-"
elif
c
==
1
:
r
=
"~"
elif
c
==
2
:
r
=
"."
else
:
r
=
"*"
print
(
re
.
sub
(
r"."
,
r
,
tl
[
section
]),
end
=
""
)
print
(
""
.
join
(
cl
[
section
]))
cl
=
{}
tl
=
{}
sl
=
[]
for
fn
in
sys
.
argv
[
1
:]:
parse_file
(
fn
,
cl
,
tl
,
sl
)
sl
.
sort
()
for
section
in
sl
:
print
(
tl
[
section
],
end
=
""
)
a
=
section
c
=
section
.
count
(
"."
)
if
c
==
0
:
r
=
"-"
elif
c
==
1
:
r
=
"~"
elif
c
==
2
:
r
=
"."
else
:
r
=
"*"
print
(
re
.
sub
(
r"."
,
r
,
tl
[
section
]),
end
=
""
)
print
(
""
.
join
(
cl
[
section
]))
include/Makefile.am
View file @
83b41822
...
...
@@ -108,7 +108,7 @@ vcl.h: \
$(top_srcdir)/include/vrt.h
\
$(top_srcdir)/doc/sphinx/reference/vcl_var.rst
mkdir
-p
$(top_builddir)
/include/tbl
@
PYTHON@
$(top_srcdir)
/lib/libvcc/generate.py
\
${
PYTHON
}
$(top_srcdir)
/lib/libvcc/generate.py
\
$(top_srcdir)
$(top_builddir)
GEN_H
=
\
...
...
@@ -128,7 +128,7 @@ vcs_version.h:
@
if
test
-e
$(top_srcdir)
/.git
||
\
!
test
-f
$(srcdir)
/vmod_abi.h
||
\
!
test
-f
$(srcdir)
/vcs_version.h
;
then
\
@PYTHON@
$(srcdir)
/generate.py
\
${
PYTHON
}
$(srcdir)
/generate.py
\
$(top_srcdir)
$(top_builddir)
;
\
fi
...
...
include/generate.py
View file @
83b41822
...
...
@@ -32,22 +32,21 @@
from
__future__
import
print_function
import
subprocess
import
collections
import
os
import
sys
srcroot
=
"../.."
buildroot
=
"../.."
if
len
(
sys
.
argv
)
==
3
:
srcroot
=
sys
.
argv
[
1
]
buildroot
=
sys
.
argv
[
2
]
srcroot
=
sys
.
argv
[
1
]
buildroot
=
sys
.
argv
[
2
]
elif
len
(
sys
.
argv
)
!=
1
:
print
(
"Two arguments or none"
)
exit
(
2
)
print
(
"Two arguments or none"
)
exit
(
2
)
#######################################################################
def
file_header
(
fo
):
fo
.
write
(
"""/*
fo
.
write
(
"""/*
* NB: This file is machine generated, DO NOT EDIT!
*
* Edit and run include/generate.py instead.
...
...
@@ -66,25 +65,25 @@ v = subprocess.check_output([
vcsfn
=
os
.
path
.
join
(
srcroot
,
"include"
,
"vcs_version.h"
)
try
:
i
=
open
(
vcsfn
)
.
readline
()
i
=
open
(
vcsfn
)
.
readline
()
except
IOError
:
i
=
""
i
=
""
ident
=
"/* "
+
v
+
" */
\n
"
if
i
!=
ident
:
fo
=
open
(
vcsfn
,
"w"
)
fo
.
write
(
ident
)
file_header
(
fo
)
fo
.
write
(
'#define VCS_Version "
%
s"
\n
'
%
v
)
fo
.
close
()
fo
=
open
(
vcsfn
,
"w"
)
fo
.
write
(
ident
)
file_header
(
fo
)
fo
.
write
(
'#define VCS_Version "
%
s"
\n
'
%
v
)
fo
.
close
()
for
i
in
open
(
os
.
path
.
join
(
buildroot
,
"Makefile"
)):
if
i
[:
14
]
==
"PACKAGE_STRING"
:
break
i
=
i
.
split
(
"="
)[
1
]
.
strip
()
for
i
in
open
(
os
.
path
.
join
(
buildroot
,
"Makefile"
)):
if
i
[:
14
]
==
"PACKAGE_STRING"
:
break
i
=
i
.
split
(
"="
)[
1
]
.
strip
()
fo
=
open
(
os
.
path
.
join
(
srcroot
,
"include"
,
"vmod_abi.h"
),
"w"
)
file_header
(
fo
)
fo
.
write
(
'#define VMOD_ABI_Version "
%
s
%
s"
\n
'
%
(
i
,
v
))
fo
.
close
()
fo
=
open
(
os
.
path
.
join
(
srcroot
,
"include"
,
"vmod_abi.h"
),
"w"
)
file_header
(
fo
)
fo
.
write
(
'#define VMOD_ABI_Version "
%
s
%
s"
\n
'
%
(
i
,
v
))
fo
.
close
()
include/tbl/h2_settings.h
View file @
83b41822
...
...
@@ -47,6 +47,7 @@ H2_SETTING( // rfc7540,l,2097,2103
0xffffffff
,
0
)
#ifndef H2_SETTINGS_PARAM_ONLY
H2_SETTING
(
// rfc7540,l,2105,2114
ENABLE_PUSH
,
...
...
@@ -58,6 +59,7 @@ H2_SETTING( // rfc7540,l,2105,2114
H2CE_PROTOCOL_ERROR
)
#endif
H2_SETTING
(
// rfc7540,l,2116,2121
MAX_CONCURRENT_STREAMS
,
max_concurrent_streams
,
...
...
@@ -67,6 +69,7 @@ H2_SETTING( // rfc7540,l,2116,2121
0xffffffff
,
0
)
H2_SETTING
(
// rfc7540,l,2139,2148
INITIAL_WINDOW_SIZE
,
initial_window_size
,
...
...
@@ -76,6 +79,7 @@ H2_SETTING( // rfc7540,l,2139,2148
0x7fffffff
,
H2CE_FLOW_CONTROL_ERROR
)
H2_SETTING
(
// rfc7540,l,2150,2157
MAX_FRAME_SIZE
,
max_frame_size
,
...
...
@@ -85,6 +89,7 @@ H2_SETTING( // rfc7540,l,2150,2157
0x00ffffff
,
H2CE_PROTOCOL_ERROR
)
H2_SETTING
(
// rfc7540,l,2159,2167
MAX_HEADER_LIST_SIZE
,
max_header_list_size
,
...
...
include/tbl/htc.h
View file @
83b41822
...
...
@@ -36,10 +36,11 @@ HTC_STATUS(JUNK, -5, "junk", "Received unexpected data")
HTC_STATUS
(
CLOSE
,
-
4
,
"close"
,
"Connection closed"
)
// unused?
HTC_STATUS
(
TIMEOUT
,
-
3
,
"timeout"
,
"Timed out"
)
HTC_STATUS
(
OVERFLOW
,
-
2
,
"overflow"
,
"Buffer/workspace too small"
)
HTC_STATUS
(
EOF
,
-
1
,
"eof"
,
"Unexpected end of input"
)
HTC_STATUS
(
EOF
,
-
1
,
"eof"
,
"Unexpected end of input"
)
HTC_STATUS
(
EMPTY
,
0
,
"empty"
,
"Empty response"
)
HTC_STATUS
(
MORE
,
1
,
"more"
,
"More data required"
)
HTC_STATUS
(
MORE
,
1
,
"more"
,
"More data required"
)
HTC_STATUS
(
COMPLETE
,
2
,
"complete"
,
"Data complete (no error)"
)
HTC_STATUS
(
IDLE
,
3
,
"idle"
,
"Connection was closed while idle"
)
HTC_STATUS
(
IDLE
,
3
,
"idle"
,
"Connection was closed while idle"
)
#undef HTC_STATUS
/*lint -restore */
include/tbl/style.py
View file @
83b41822
...
...
@@ -7,66 +7,68 @@ from __future__ import print_function
import
glob
def
check_file
(
fn
):
s
=
0
ll
=
[]
for
l
in
open
(
fn
):
ll
.
append
(
l
)
print
(
"Check"
,
fn
)
ll
=
[]
for
l
in
open
(
fn
):
ll
.
append
(
l
)
assert
ll
.
pop
(
0
)[:
2
]
==
"/*"
assert
ll
.
pop
(
0
)[:
2
]
==
"/*"
while
ll
.
pop
(
0
)
!=
" */
\n
"
:
continue
while
ll
.
pop
(
0
)
!=
" */
\n
"
:
continue
assert
len
(
ll
)
>
5
assert
len
(
ll
)
>
5
assert
ll
.
pop
(
0
)
==
"
\n
"
assert
ll
.
pop
(
0
)
==
"/*lint -save -e525 -e539 */
\n
"
assert
ll
.
pop
(
0
)
==
"
\n
"
assert
ll
.
pop
(
0
)
==
"
\n
"
i
=
ll
.
pop
(
0
)
assert
i
==
"/*lint -save -e525 -e539 */
\n
"
or
\
i
==
"/*lint -save -e525 -e539 -e835 */
\n
"
assert
ll
.
pop
(
0
)
==
"
\n
"
assert
ll
.
pop
(
-
1
)
==
"/*lint -restore */
\n
"
assert
ll
.
pop
(
-
1
)
==
"
\n
"
assert
ll
.
pop
(
-
1
)
==
"/*lint -restore */
\n
"
assert
ll
.
pop
(
-
1
)
==
"
\n
"
for
i
in
range
(
0
,
len
(
ll
)
-
1
):
assert
ll
[
i
]
!=
"
\n
"
or
ll
[
i
+
1
]
!=
"
\n
"
assert
ll
[
i
]
!=
")
\n
"
or
ll
[
i
+
1
]
==
"
\n
"
or
ll
[
i
+
1
][
0
]
==
"#"
for
i
in
range
(
0
,
len
(
ll
)
-
1
):
assert
ll
[
i
]
!=
"
\n
"
or
ll
[
i
+
1
]
!=
"
\n
"
assert
ll
[
i
]
!=
")
\n
"
or
ll
[
i
+
1
]
==
"
\n
"
or
ll
[
i
+
1
][
0
]
==
"#"
m
=
{}
while
len
(
ll
)
>
0
:
i
=
ll
.
pop
(
0
)
if
i
==
"
\n
"
:
continue
l
=
i
.
lstrip
()
if
l
[
0
]
>=
'A'
and
l
[
0
]
<=
'Z'
:
j
=
l
.
split
(
'('
)
m
[
j
[
0
]]
=
"Called"
l
=
l
.
split
(
'//'
)[
0
]
l
=
l
.
split
(
'/*'
)[
0
]
l
=
l
.
rstrip
()
if
l
[
-
1
]
!=
')'
:
while
ll
.
pop
(
0
)
!=
')
\n
'
:
continue
elif
l
[
0
]
==
"#"
:
j
=
l
[
1
:]
.
lstrip
()
.
split
()
# print("#", j[0])
if
j
[
0
]
==
"define"
:
m
[
j
[
1
]
.
split
(
"("
)[
0
]
.
strip
()]
=
"Defined"
if
j
[
0
]
==
"undef"
:
m
[
j
[
1
]]
=
"Undef"
while
l
[
-
2
:]
==
"
\\\n
"
:
l
=
ll
.
pop
(
0
)
else
:
pass
# print(l)
rv
=
0
for
i
in
m
:
if
m
[
i
]
!=
"Undef"
:
print
(
"ERROR"
,
fn
,
i
,
m
[
i
])
rv
+=
1
return
rv
m
=
{}
while
ll
:
i
=
ll
.
pop
(
0
)
if
i
==
"
\n
"
:
continue
l
=
i
.
lstrip
()
if
l
[
0
]
>=
'A'
and
l
[
0
]
<=
'Z'
:
j
=
l
.
split
(
'('
)
m
[
j
[
0
]]
=
"Called"
l
=
l
.
split
(
'//'
)[
0
]
l
=
l
.
split
(
'/*'
)[
0
]
l
=
l
.
rstrip
()
if
l
[
-
1
]
!=
')'
:
while
ll
.
pop
(
0
)
.
strip
()
!=
')
'
:
continue
elif
l
[
0
]
==
"#"
:
j
=
l
[
1
:]
.
lstrip
()
.
split
()
# print("#", j[0])
if
j
[
0
]
==
"define"
:
m
[
j
[
1
]
.
split
(
"("
)[
0
]
.
strip
()]
=
"Defined"
if
j
[
0
]
==
"undef"
:
m
[
j
[
1
]]
=
"Undef"
while
l
[
-
2
:]
==
"
\\\n
"
:
l
=
ll
.
pop
(
0
)
else
:
pass
# print(l)
rv
=
0
for
i
in
m
:
if
m
[
i
]
!=
"Undef"
:
print
(
"ERROR"
,
fn
,
i
,
m
[
i
])
rv
+=
1
return
rv
rv
=
0
for
fn
in
glob
.
glob
(
"*.h"
):
rv
+=
check_file
(
fn
)
rv
+=
check_file
(
fn
)
if
rv
!=
0
:
print
(
rv
,
"Errors"
)
print
(
rv
,
"Errors"
)
exit
(
rv
)
include/tbl/vsl_tags.h
View file @
83b41822
...
...
@@ -181,16 +181,17 @@ SLTM(Length, 0, "Size of object body",
"Logs the size of a fetch object body.
\n\n
"
)
/* XXX generate HTC info from tbl include */
#if 0
#include <stdio.h>
int main(void) {
#define HTC_STATUS(e, n, s, l) \
printf("\t\"\\t* %s (%d): %s\\n\"\n", s, n, l);
#include "include/tbl/htc.h"
return (0);
}
#endif
/*
* XXX generate HTC info below from tbl include
*
* #include <stdio.h>
* int main(void) {
* #define HTC_STATUS(e, n, s, l) \
* printf("\t\"\\t* %s (%d): %s\\n\"\n", s, n, l);
* #include "include/tbl/htc.h"
* return (0);
* }
*/
SLTM
(
FetchError
,
0
,
"Error while fetching object"
,
"Logs the error message of a failed fetch operation.
\n\n
"
...
...
include/tbl/waiters.h
View file @
83b41822
...
...
@@ -44,3 +44,5 @@
WAITER
(
poll
)
#undef WAITER
/*lint -restore */
lib/libvarnishapi/generate.py
View file @
83b41822
...
...
@@ -37,122 +37,121 @@ import copy
srcroot
=
"../.."
buildroot
=
"../.."
if
len
(
sys
.
argv
)
==
3
:
srcroot
=
sys
.
argv
[
1
]
buildroot
=
sys
.
argv
[
2
]
srcroot
=
sys
.
argv
[
1
]
buildroot
=
sys
.
argv
[
2
]
#######################################################################
# These are our tokens
tokens
=
{
# Numerical comparisons
"T_EQ"
:
"=="
,
"T_NEQ"
:
"!="
,
"T_LEQ"
:
"<="
,
"T_GEQ"
:
">="
,
# String comparisons
"T_SEQ"
:
"eq"
,
"T_SNEQ"
:
"ne"
,
# Regular expression matching
"T_NOMATCH"
:
"!~"
,
# Boolean operators
"T_AND"
:
"and"
,
"T_OR"
:
"or"
,
"T_NOT"
:
"not"
,
# Miscellaneous
None
:
"<>~[]{}():,"
,
# These have handwritten recognizers
"VAL"
:
None
,
"EOI"
:
None
,
# Special
"T_TRUE"
:
None
,
"VXID"
:
"vxid"
,
# Numerical comparisons
"T_EQ"
:
"=="
,
"T_NEQ"
:
"!="
,
"T_LEQ"
:
"<="
,
"T_GEQ"
:
">="
,
# String comparisons
"T_SEQ"
:
"eq"
,
"T_SNEQ"
:
"ne"
,
# Regular expression matching
"T_NOMATCH"
:
"!~"
,
# Boolean operators
"T_AND"
:
"and"
,
"T_OR"
:
"or"
,
"T_NOT"
:
"not"
,
# Miscellaneous
None
:
"<>~[]{}():,"
,
# These have handwritten recognizers
"VAL"
:
None
,
"EOI"
:
None
,
# Special
"T_TRUE"
:
None
,
"VXID"
:
"vxid"
,
}
#######################################################################
# Emit a function to recognize tokens in a string
def
emit_vxp_fixed_token
(
fo
,
tokens
):
recog
=
list
()
emit
=
dict
()
for
i
in
tokens
:
j
=
tokens
[
i
]
if
(
j
!=
None
)
:
recog
.
append
(
j
)
emit
[
j
]
=
i
recog
.
sort
()
rrecog
=
copy
.
copy
(
recog
)
rrecog
.
sort
(
key
=
lambda
x
:
-
len
(
x
))
fo
.
write
(
"""
recog
=
list
()
emit
=
dict
()
for
i
in
tokens
:
j
=
tokens
[
i
]
if
j
is
not
None
:
recog
.
append
(
j
)
emit
[
j
]
=
i
recog
.
sort
()
rrecog
=
copy
.
copy
(
recog
)
rrecog
.
sort
(
key
=
lambda
x
:
-
len
(
x
))
fo
.
write
(
"""
unsigned
vxp_fixed_token(const char *p, const char **q)
{
\t
switch (p[0]) {
"""
)
last_initial
=
None
for
i
in
recog
:
if
(
i
[
0
]
==
last_initial
):
continue
last_initial
=
i
[
0
]
fo
.
write
(
"
\t
case '
%
s':
\n
"
%
last_initial
)
for
j
in
rrecog
:
if
(
j
[
0
]
!=
last_initial
):
continue
fo
.
write
(
"
\t\t
if ("
)
k
=
1
l
=
len
(
j
)
while
(
k
<
l
):
fo
.
write
(
"p[
%
d] == '
%
s'"
%
(
k
,
j
[
k
]))
fo
.
write
(
" &&
\n\t\t
"
)
k
+=
1
fo
.
write
(
"(isword(p[
%
d]) ? !isword(p[
%
d]) : 1)) {
\n
"
%
(
l
-
1
,
l
))
fo
.
write
(
"
\t\t\t
*q = p +
%
d;
\n
"
%
l
)
fo
.
write
(
"
\t\t\t
return (
%
s);
\n
"
%
emit
[
j
])
fo
.
write
(
"
\t\t
}
\n
"
)
fo
.
write
(
"
\t\t
return (0);
\n
"
)
fo
.
write
(
"
\t
default:
\n\t\t
return (0);
\n\t
}
\n
}
\n
"
)
last_initial
=
None
for
i
in
recog
:
if
i
[
0
]
==
last_initial
:
continue
last_initial
=
i
[
0
]
fo
.
write
(
"
\t
case '
%
s':
\n
"
%
last_initial
)
for
j
in
rrecog
:
if
j
[
0
]
!=
last_initial
:
continue
fo
.
write
(
"
\t\t
if ("
)
k
=
1
l
=
len
(
j
)
while
k
<
l
:
fo
.
write
(
"p[
%
d] == '
%
s'"
%
(
k
,
j
[
k
]))
fo
.
write
(
" &&
\n\t\t
"
)
k
+=
1
fo
.
write
(
"(isword(p[
%
d]) ? !isword(p[
%
d]) : 1)) {
\n
"
%
(
l
-
1
,
l
))
fo
.
write
(
"
\t\t\t
*q = p +
%
d;
\n
"
%
l
)
fo
.
write
(
"
\t\t\t
return (
%
s);
\n
"
%
emit
[
j
])
fo
.
write
(
"
\t\t
}
\n
"
)
fo
.
write
(
"
\t\t
return (0);
\n
"
)
fo
.
write
(
"
\t
default:
\n\t\t
return (0);
\n\t
}
\n
}
\n
"
)
#######################################################################
# Emit the vxp_tnames (token->string) conversion array
def
emit_vxp_tnames
(
fo
,
tokens
):
fo
.
write
(
"
\n
const char * const vxp_tnames[256] = {
\n
"
)
l
=
list
(
tokens
.
keys
())
l
.
sort
()
for
i
in
l
:
j
=
tokens
[
i
]
if
j
==
None
:
j
=
i
if
i
[
0
]
==
"'"
:
j
=
i
fo
.
write
(
"
\t
[
%
s] =
\"
%
s
\"
,
\n
"
%
(
i
,
j
))
fo
.
write
(
"};
\n
"
)
fo
.
write
(
"
\n
const char * const vxp_tnames[256] = {
\n
"
)
l
=
list
(
tokens
.
keys
())
l
.
sort
()
for
i
in
l
:
j
=
tokens
[
i
]
if
j
is
None
:
j
=
i
if
i
[
0
]
==
"'"
:
j
=
i
fo
.
write
(
"
\t
[
%
s] =
\"
%
s
\"
,
\n
"
%
(
i
,
j
))
fo
.
write
(
"};
\n
"
)
#######################################################################
def
polish_tokens
(
tokens
):
# Expand single char tokens
st
=
tokens
[
None
]
del
tokens
[
None
]
# Expand single char tokens
st
=
tokens
[
None
]
del
tokens
[
None
]
for
i
in
st
:
tokens
[
"'"
+
i
+
"'"
]
=
i
for
i
in
st
:
tokens
[
"'"
+
i
+
"'"
]
=
i
#######################################################################
def
file_header
(
fo
):
fo
.
write
(
"""/*
fo
.
write
(
"""/*
* NB: This file is machine generated, DO NOT EDIT!
*
* Edit and run lib/libvarnishapi/generate.py instead
...
...
@@ -171,11 +170,11 @@ j = 128
l
=
list
(
tokens
.
keys
())
l
.
sort
()
for
i
in
l
:
if
i
[
0
]
==
"'"
:
continue
fo
.
write
(
"#define
\t
%
s
%
d
\n
"
%
(
i
,
j
))
j
+=
1
assert
j
<
256
if
i
[
0
]
==
"'"
:
continue
fo
.
write
(
"#define
\t
%
s
%
d
\n
"
%
(
i
,
j
))
j
+=
1
assert
j
<
256
fo
.
close
()
...
...
lib/libvcc/generate.py
View file @
83b41822
This diff is collapsed.
Click to expand it.
lib/libvcc/vmodtool.py
View file @
83b41822
...
...
@@ -41,7 +41,6 @@ import sys
import
re
import
optparse
import
unittest
import
random
import
copy
import
json
import
hashlib
...
...
@@ -254,7 +253,7 @@ class CType(object):
def
json
(
self
,
jl
):
jl
.
append
([
self
.
vt
])
while
jl
[
-
1
][
-
1
]
is
None
:
jl
[
-
1
]
.
pop
(
-
1
)
jl
[
-
1
]
.
pop
(
-
1
)
#######################################################################
...
...
@@ -290,7 +289,7 @@ class arg(CType):
def
json
(
self
,
jl
):
jl
.
append
([
self
.
vt
,
self
.
nm
,
self
.
defval
,
self
.
spec
])
if
self
.
opt
:
jl
[
-
1
]
.
append
(
True
)
jl
[
-
1
]
.
append
(
True
)
while
jl
[
-
1
][
-
1
]
is
None
:
jl
[
-
1
]
.
pop
(
-
1
)
...
...
@@ -366,7 +365,7 @@ class ProtoType(object):
err
(
"
%
s(): Illegal C-name
\n
"
%
self
.
cname
(),
warn
=
False
)
if
len
(
wl
)
==
2
and
wl
[
0
]
==
'('
and
wl
[
1
]
==
')'
:
return
return
if
wl
[
0
]
!=
"("
:
err
(
"Syntax error: Expected '(', got '
%
s'"
%
wl
[
0
],
warn
=
False
)
...
...
@@ -386,17 +385,17 @@ class ProtoType(object):
if
not
wl
:
break
if
wl
[
0
]
==
'['
:
wl
.
pop
(
0
)
t
=
arg
(
wl
,
names
,
st
.
vcc
.
enums
,
']'
)
if
t
.
nm
is
None
:
err
(
"Optional arguments must have names"
,
warn
=
False
)
t
.
opt
=
True
x
=
wl
.
pop
(
0
)
if
x
!=
']'
:
err
(
"Expected ']' found '
%
s'"
%
x
,
warn
=
False
)
self
.
argstruct
=
True
wl
.
pop
(
0
)
t
=
arg
(
wl
,
names
,
st
.
vcc
.
enums
,
']'
)
if
t
.
nm
is
None
:
err
(
"Optional arguments must have names"
,
warn
=
False
)
t
.
opt
=
True
x
=
wl
.
pop
(
0
)
if
x
!=
']'
:
err
(
"Expected ']' found '
%
s'"
%
x
,
warn
=
False
)
self
.
argstruct
=
True
else
:
t
=
arg
(
wl
,
names
,
st
.
vcc
.
enums
,
','
)
t
=
arg
(
wl
,
names
,
st
.
vcc
.
enums
,
','
)
if
t
.
nm
is
None
:
t
.
nm2
=
"arg
%
d"
%
n
else
:
...
...
@@ -466,10 +465,10 @@ class ProtoType(object):
s
=
self
.
retval
.
ct
+
" "
+
name
+
'('
ll
=
args
if
self
.
argstruct
:
ll
.
append
(
self
.
argstructname
()
+
"*"
)
ll
.
append
(
self
.
argstructname
()
+
"*"
)
else
:
for
i
in
self
.
args
:
ll
.
append
(
i
.
ct
)
for
i
in
self
.
args
:
ll
.
append
(
i
.
ct
)
s
+=
", "
.
join
(
ll
)
return
s
+
');'
...
...
@@ -483,31 +482,31 @@ class ProtoType(object):
def
argstructure
(
self
):
s
=
"
\n
"
+
self
.
argstructname
()
+
" {
\n
"
for
i
in
self
.
args
:
if
i
.
opt
:
assert
i
.
nm
is
not
None
s
+=
"
\t
char
\t\t\t
valid_
%
s;
\n
"
%
i
.
nm
if
i
.
opt
:
assert
i
.
nm
is
not
None
s
+=
"
\t
char
\t\t\t
valid_
%
s;
\n
"
%
i
.
nm
for
i
in
self
.
args
:
s
+=
"
\t
"
+
i
.
ct
if
len
(
i
.
ct
)
<
8
:
s
+=
"
\t
"
if
len
(
i
.
ct
)
<
16
:
s
+=
"
\t
"
s
+=
"
\t
"
+
i
.
nm2
+
";
\n
"
s
+=
"
\t
"
+
i
.
ct
if
len
(
i
.
ct
)
<
8
:
s
+=
"
\t
"
if
len
(
i
.
ct
)
<
16
:
s
+=
"
\t
"
s
+=
"
\t
"
+
i
.
nm2
+
";
\n
"
s
+=
"};
\n
"
return
s
def
cstuff
(
self
,
args
,
where
):
s
=
""
if
where
==
'h'
:
if
self
.
argstruct
:
s
+=
self
.
argstructure
()
s
+=
lwrap
(
self
.
proto
(
args
,
self
.
cname
(
True
)))
if
self
.
argstruct
:
s
+=
self
.
argstructure
()
s
+=
lwrap
(
self
.
proto
(
args
,
self
.
cname
(
True
)))
elif
where
==
'c'
:
s
+=
lwrap
(
self
.
typedef
(
args
))
s
+=
lwrap
(
self
.
typedef
(
args
))
elif
where
==
'o'
:
if
self
.
argstruct
:
s
+=
self
.
argstructure
()
s
+=
lwrap
(
self
.
typedef
(
args
))
if
self
.
argstruct
:
s
+=
self
.
argstructure
()
s
+=
lwrap
(
self
.
typedef
(
args
))
else
:
assert
False
return
s
...
...
@@ -517,9 +516,9 @@ class ProtoType(object):
self
.
retval
.
json
(
ll
)
ll
.
append
(
'Vmod_
%
s_Func.
%
s'
%
(
self
.
st
.
vcc
.
modname
,
cfunc
))
if
self
.
argstruct
:
ll
.
append
(
self
.
argstructname
())
ll
.
append
(
self
.
argstructname
())
else
:
ll
.
append
(
""
)
ll
.
append
(
""
)
for
i
in
self
.
args
:
i
.
json
(
ll
)
jl
.
append
(
ll
)
...
...
lib/libvcc/vsctool.py
View file @
83b41822
This diff is collapsed.
Click to expand it.
tools/gcov_digest.py
View file @
83b41822
...
...
@@ -32,19 +32,19 @@ found in a subdirectory tree.
Options:
-g gcov-program
default:gcov6
-g gcov-program
default:gcov6
-o output-filename
default: stdout
-o output-filename
default: stdout
-x exclude-subdir
default ".git" and ".deps"
-x exclude-subdir
default ".git" and ".deps"
Arguments:
directories to process.
default: .
directories to process.
default: .
"""
...
...
@@ -61,141 +61,141 @@ lengths = {}
exclude
=
[
".git"
,
".deps"
,]
def
process_gcov
(
fn
,
sn
):
""" Sum .gcov file into counts, then delete it """
dd
=
counts
.
get
(
sn
)
if
dd
is
None
:
dd
=
{}
for
ln
in
open
(
fn
):
d
=
ln
.
split
(
":"
)
cnt
=
d
[
0
]
.
strip
()
ll
=
d
[
1
]
if
cnt
==
"-"
:
continue
if
cnt
==
"#####"
:
cnt
=
0
else
:
cnt
=
int
(
cnt
)
lno
=
int
(
d
[
1
])
if
lno
not
in
dd
:
dd
[
lno
]
=
0
dd
[
lno
]
+=
cnt
counts
[
sn
]
=
dd
pl
=
lengths
.
get
(
sn
)
ll
=
ll
.
strip
()
if
d
[
2
]
==
"/*EOF*/
\n
"
:
ll
=
pl
elif
pl
!=
ll
and
not
pl
is
None
:
print
(
"CONFLICT"
,
fn
,
ll
,
pl
)
ll
=
"-1"
lengths
[
sn
]
=
ll
os
.
remove
(
fn
)
""" Sum .gcov file into counts, then delete it """
dd
=
counts
.
get
(
sn
)
if
dd
is
None
:
dd
=
{}
for
ln
in
open
(
fn
):
d
=
ln
.
split
(
":"
)
cnt
=
d
[
0
]
.
strip
()
ll
=
d
[
1
]
if
cnt
==
"-"
:
continue
if
cnt
==
"#####"
:
cnt
=
0
else
:
cnt
=
int
(
cnt
)
lno
=
int
(
d
[
1
])
if
lno
not
in
dd
:
dd
[
lno
]
=
0
dd
[
lno
]
+=
cnt
counts
[
sn
]
=
dd
pl
=
lengths
.
get
(
sn
)
ll
=
ll
.
strip
()
if
d
[
2
]
==
"/*EOF*/
\n
"
:
ll
=
pl
elif
pl
!=
ll
and
not
pl
is
None
:
print
(
"CONFLICT"
,
fn
,
ll
,
pl
)
ll
=
"-1"
lengths
[
sn
]
=
ll
os
.
remove
(
fn
)
def
run_gcov
(
prog
,
subdir
):
""" Walk tree, run gcov, process output """
for
root
,
dirs
,
files
in
os
.
walk
(
subdir
):
for
i
in
exclude
:
if
i
in
dirs
:
dirs
.
remove
(
i
)
if
" "
.
join
(
files
)
.
find
(
".gcda"
)
==
-
1
:
continue
for
fn
in
files
:
if
fn
[
-
2
:]
!=
".o"
:
continue
# if we find the .o file in a .../.libs the sources
# must be found relative to the parent directory
if
root
[
-
6
:]
==
"/.libs"
:
x
=
subprocess
.
check_output
(
[
"cd "
+
root
+
"/.. && "
+
"exec "
+
prog
+
" -r .libs/"
+
fn
],
stderr
=
subprocess
.
STDOUT
,
shell
=
True
,
universal_newlines
=
True
)
pf
=
".."
else
:
x
=
subprocess
.
check_output
(
[
"cd "
+
root
+
" && "
+
"exec "
+
prog
+
" -r "
+
fn
],
stderr
=
subprocess
.
STDOUT
,
shell
=
True
,
universal_newlines
=
True
)
pf
=
""
for
ln
in
x
.
split
(
"
\n
"
):
ln
=
ln
.
split
()
if
len
(
ln
)
==
0
:
continue
if
ln
[
0
]
==
"Creating"
:
gn
=
ln
[
1
]
.
strip
(
"'"
)
assert
gn
[
-
5
:]
==
".gcov"
sn
=
gn
[:
-
5
]
process_gcov
(
os
.
path
.
join
(
root
,
pf
,
gn
),
sn
)
""" Walk tree, run gcov, process output """
for
root
,
dirs
,
files
in
os
.
walk
(
subdir
):
for
i
in
exclude
:
if
i
in
dirs
:
dirs
.
remove
(
i
)
if
" "
.
join
(
files
)
.
find
(
".gcda"
)
==
-
1
:
continue
for
fn
in
files
:
if
fn
[
-
2
:]
!=
".o"
:
continue
# if we find the .o file in a .../.libs the sources
# must be found relative to the parent directory
if
root
[
-
6
:]
==
"/.libs"
:
x
=
subprocess
.
check_output
(
[
"cd "
+
root
+
"/.. && "
+
"exec "
+
prog
+
" -r .libs/"
+
fn
],
stderr
=
subprocess
.
STDOUT
,
shell
=
True
,
universal_newlines
=
True
)
pf
=
".."
else
:
x
=
subprocess
.
check_output
(
[
"cd "
+
root
+
" && "
+
"exec "
+
prog
+
" -r "
+
fn
],
stderr
=
subprocess
.
STDOUT
,
shell
=
True
,
universal_newlines
=
True
)
pf
=
""
for
ln
in
x
.
split
(
"
\n
"
):
ln
=
ln
.
split
()
if
not
ln
:
continue
if
ln
[
0
]
==
"Creating"
:
gn
=
ln
[
1
]
.
strip
(
"'"
)
assert
gn
[
-
5
:]
==
".gcov"
sn
=
gn
[:
-
5
]
process_gcov
(
os
.
path
.
join
(
root
,
pf
,
gn
),
sn
)
def
produce_output
(
fdo
):
"""
Produce compact output file
Format:
linefm [lineto] count
"+" in linefm means "previous line + 1"
"." in count means "same as previous count"
"""
for
sn
,
cnt
in
counts
.
items
():
fdo
.
write
(
"/"
+
sn
+
" "
+
str
(
lengths
[
sn
])
+
"
\n
"
)
lnos
=
list
(
cnt
.
items
())
lnos
.
sort
()
pln
=
-
1
pcn
=
-
1
while
len
(
lnos
)
>
0
:
ln
,
cn
=
lnos
.
pop
(
0
)
lnl
=
ln
while
len
(
lnos
)
>
0
:
lnn
,
cnn
=
lnos
[
0
]
if
lnl
+
1
!=
lnn
or
cnn
!=
cn
:
break
lnos
.
pop
(
0
)
lnl
=
lnn
if
ln
==
pln
+
1
:
s
=
"+ "
else
:
s
=
"
%
d "
%
ln
if
ln
!=
lnl
:
s
+=
"
%
d "
%
lnl
pln
=
lnl
else
:
pln
=
ln
if
cn
==
pcn
:
s
+=
"."
else
:
s
+=
"
%
d"
%
cn
pcn
=
cn
fdo
.
write
(
s
+
"
\n
"
)
"""
Produce compact output file
Format:
linefm [lineto] count
"+" in linefm means "previous line + 1"
"." in count means "same as previous count"
"""
for
sn
,
cnt
in
counts
.
items
():
fdo
.
write
(
"/"
+
sn
+
" "
+
str
(
lengths
[
sn
])
+
"
\n
"
)
lnos
=
list
(
cnt
.
items
())
lnos
.
sort
()
pln
=
-
1
pcn
=
-
1
while
lnos
:
ln
,
cn
=
lnos
.
pop
(
0
)
lnl
=
ln
while
lnos
:
lnn
,
cnn
=
lnos
[
0
]
if
lnl
+
1
!=
lnn
or
cnn
!=
cn
:
break
lnos
.
pop
(
0
)
lnl
=
lnn
if
ln
==
pln
+
1
:
s
=
"+ "
else
:
s
=
"
%
d "
%
ln
if
ln
!=
lnl
:
s
+=
"
%
d "
%
lnl
pln
=
lnl
else
:
pln
=
ln
if
cn
==
pcn
:
s
+=
"."
else
:
s
+=
"
%
d"
%
cn
pcn
=
cn
fdo
.
write
(
s
+
"
\n
"
)
if
__name__
==
"__main__"
:
optlist
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
"g:o:x:"
)
fo
=
sys
.
stdout
gcovprog
=
"gcov6"
for
f
,
v
in
optlist
:
if
f
==
'-o'
and
v
==
'-'
:
fo
=
sys
.
stdout
elif
f
==
'-o'
:
fo
=
open
(
v
,
"w"
)
elif
f
==
'-g'
:
gcovprog
=
v
elif
f
==
'-x'
:
exclude
.
append
(
v
)
else
:
assert
False
if
len
(
args
)
==
0
:
args
=
[
"."
]
for
dn
in
args
:
run_gcov
(
gcovprog
,
dn
)
produce_output
(
fo
)
optlist
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
"g:o:x:"
)
fo
=
sys
.
stdout
gcovprog
=
"gcov6"
for
f
,
v
in
optlist
:
if
f
==
'-o'
and
v
==
'-'
:
fo
=
sys
.
stdout
elif
f
==
'-o'
:
fo
=
open
(
v
,
"w"
)
elif
f
==
'-g'
:
gcovprog
=
v
elif
f
==
'-x'
:
exclude
.
append
(
v
)
else
:
assert
False
if
not
args
:
args
=
[
"."
]
for
dn
in
args
:
run_gcov
(
gcovprog
,
dn
)
produce_output
(
fo
)
tools/include_wash.py
View file @
83b41822
...
...
@@ -5,41 +5,39 @@ from __future__ import print_function
import
os
def
check
(
fn
):
l
=
[]
for
i
in
open
(
fn
):
i
=
i
.
strip
()
if
len
(
i
)
==
0
:
continue
if
i
[
0
]
!=
"#"
:
continue
if
i
.
find
(
"include"
)
==
-
1
:
continue
if
i
.
find
(
'"'
)
==
-
1
:
l
.
append
(
i
.
split
(
'<'
)[
1
]
.
split
(
'>'
)[
0
])
else
:
l
.
append
(
i
.
split
(
'"'
)[
1
])
if
"vrt.h"
in
l
:
vrt
=
l
.
index
(
"vrt.h"
)
if
not
"vdef.h"
in
l
:
print
(
fn
,
"vdef.h not included with vrt.h"
)
vdef
=
l
.
index
(
"vdef.h"
)
if
vdef
>
vrt
:
print
(
fn
,
"vdef.h included after vrt.h"
)
for
i
in
(
"stddef.h"
,
"stdint.h"
,
"cache/cache.h"
,
"cache.h"
):
if
i
in
l
:
print
(
fn
,
i
+
" included with vrt.h"
)
l
=
[]
for
i
in
open
(
fn
):
i
=
i
.
strip
()
if
not
i
:
continue
if
i
[
0
]
!=
"#"
:
continue
if
i
.
find
(
"include"
)
==
-
1
:
continue
if
i
.
find
(
'"'
)
==
-
1
:
l
.
append
(
i
.
split
(
'<'
)[
1
]
.
split
(
'>'
)[
0
])
else
:
l
.
append
(
i
.
split
(
'"'
)[
1
])
if
"vrt.h"
in
l
:
vrt
=
l
.
index
(
"vrt.h"
)
if
"vdef.h"
not
in
l
:
print
(
fn
,
"vdef.h not included with vrt.h"
)
vdef
=
l
.
index
(
"vdef.h"
)
if
vdef
>
vrt
:
print
(
fn
,
"vdef.h included after vrt.h"
)
for
i
in
(
"stddef.h"
,
"stdint.h"
,
"cache/cache.h"
,
"cache.h"
):
if
i
in
l
:
print
(
fn
,
i
+
" included with vrt.h"
)
for
i
in
(
"cache/cache.h"
,
"cache.h"
):
if
i
in
l
:
for
i
in
(
"stddef.h"
,
"stdint.h"
,
"vrt.h"
,
"math.h"
,
"pthread.h"
,
"stdarg.h"
,
"sys/types.h"
,
"vdef.h"
,
"miniobj.h"
,
"vas.h"
,
"vqueue.h"
,
):
if
i
in
l
:
print
(
fn
,
i
+
" included with cache.h"
)
for
i
in
(
"cache/cache.h"
,
"cache.h"
):
if
i
in
l
:
for
i
in
(
"stddef.h"
,
"stdint.h"
,
"vrt.h"
,
"math.h"
,
"pthread.h"
,
"stdarg.h"
,
"sys/types.h"
,
"vdef.h"
,
"miniobj.h"
,
"vas.h"
,
"vqueue.h"
):
if
i
in
l
:
print
(
fn
,
i
+
" included with cache.h"
)
for
(
dir
,
dns
,
fns
)
in
os
.
walk
(
"."
):
for
f
in
fns
:
if
f
[
-
2
:]
==
".c"
:
check
(
dir
+
"/"
+
f
)
for
f
in
fns
:
if
f
[
-
2
:]
==
".c"
:
check
(
dir
+
"/"
+
f
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment