2 # Check is all errno definitions at errlist.h documented in the manual.
3 # Copyright (C) 2020 Free Software Foundation, Inc.
4 # This file is part of the GNU C Library.
6 # The GNU C Library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License, or (at your option) any later version.
11 # The GNU C Library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with the GNU C Library; if not, see
18 # <https://www.gnu.org/licenses/>.
24 RE_MANUAL
= re
.compile(
27 RE_ERRLIST
= re
.compile(
33 # Each manual entry is in the form:
35 # errno{EAGAIN, 35, Resource temporarily unavailable}
37 errlist
= [RE_MANUAL
.findall(s
) for s
in f
]
38 return map(lambda x
: x
[0], filter(None, errlist
))
40 # Each errlist entry is in the form:
42 # _S(ERR_MAP(EAGAIN), N_("Resource temporarily unavailable"))
44 errlist
= [RE_ERRLIST
.findall(s
) for s
in f
]
45 # Each element is '[]' or '['(EAGAIN)']'
46 return map(lambda s
: s
[0][s
[0].find('(')+1:s
[0].find(')')],
47 filter(None, errlist
))
49 def check_errno_definitions(manual_fname
, errlist_fname
):
50 with
open(manual_fname
, 'r') as mfile
, open(errlist_fname
, 'r') as efile
:
51 merr
= parse_manual(mfile
)
52 eerr
= parse_errlist(efile
)
53 diff
= set(eerr
).difference(merr
)
57 print("Failure: the following value(s) are not in manual:",
58 ", ".join(str(e
) for e
in diff
))
62 parser
= argparse
.ArgumentParser(description
='Generate errlist.h')
63 parser
.add_argument('-m', dest
='manual', metavar
='FILE',
64 help='manual errno texi file')
65 parser
.add_argument('-e', dest
='errlist', metavar
='FILE',
66 help='errlist with errno definitions')
67 args
= parser
.parse_args()
69 check_errno_definitions(args
.manual
, args
.errlist
)
72 if __name__
== '__main__':