3 # run from trunk/ and > errors.py
10 errors_h
= open("headers/os/support/Errors.h", "r")
16 match
= re
.match(r
'#\s?define\s+(?P<define>\w+)\s+(?P<expr>.+)', line
)
18 define
= match
.groupdict().get("define")
19 expr
= match
.groupdict().get("expr")
21 #print "==== %s ==== %s" % (define, expr)
27 if expr
== "((int)0)":
31 m
= re
.match(r
"B_TO_POSIX_ERROR\((?P<expr>.*)\)", expr
)
34 expr
= m
.group("expr")
37 m
= re
.match(r
"B_FROM_POSIX_ERROR\((?P<expr>.*)\)", expr
)
40 expr
= m
.group("expr")
43 m
= re
.match(r
"\((?P<expr>.*)\)", expr
)
46 expr
= m
.group("expr")
49 m
= re
.match(r
"(?P<expr>\w+)$", expr
)
52 token
= m
.group("expr")
54 value
= errors
[token
]["value"]
55 #print "%s -> %s = %s" % (define, token, value)
57 m
= re
.match(r
"(?P<base>.*_BASE)\s*\+\s*(?P<offset>\w+)$", expr
)
59 base
= m
.group("base")
63 o
= int(m
.group("offset"), 0)
65 #print "value: %x + %x = %x = %d" % (b, o, value, value)
68 print "Value unknown for %s" % (define
)
71 if re
.match(r
".*_BASE", define
):
72 #print "base: %s=%s" % (define, value)
76 #print "%s=%s :%s" % (define, expr, value)
77 errors
[define
] = {"expr": expr
, "value": value
, "str": ""}
84 #print errors['EILSEQ']
88 strerror_c
= open("src/system/libroot/posix/string/strerror.c", "r")
92 for line
in strerror_c
:
94 match
= re
.match(r
'\t*case (?P<define>\w+):', line
)
96 define
= match
.groupdict().get("define")
97 defines
.append(define
)
98 match
= re
.match(r
'\t*//\s+(?P<define>\w+):*$', line
)
100 define
= match
.groupdict().get("define")
101 defines
.append(define
)
103 match
= re
.match(r
'\t*return "(?P<str>.+)";', line
)
105 str = match
.groupdict().get("str")
110 #print errors[d]#['str']
111 errors
[d
]['str'] = str
113 print "not found: %s" % (d
)
116 #errors[define] = "plop"
121 errors
['B_OK']['str'] = "No Error"
122 errors
['B_NO_ERROR']['str'] = "No Error"
123 errors
['B_DONT_DO_THAT']['str'] = "Don't do that!"
128 print "'%s': %s," % (e
, errors
[e
])