From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2201) id 03DCC38376DA; Sat, 12 Nov 2022 14:12:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 03DCC38376DA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1668262335; bh=7doGw4ddCRBvvmojvBgRFEqxUks2SlhoyDLGfj43TME=; h=From:To:Subject:Date:From; b=ZvTFamYKl0x+fG49lTIc5h2SazbQMyRtW6NodVulPTiWJww9t4snX5q0PTnNozeD4 XkR3XSd6J0x4Tl4kg+nwZpfAjgvsWk0KMBvv7C8D3LnpaXK/01BbVvP3xSb7Iid35d IEI6i7S88bJdohPDToF1Max22TFuViXBSpyZY5d8= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Jon TURNEY To: newlib-cvs@sourceware.org Subject: [newlib-cygwin] makedocbook: Use raw strings for regexes X-Act-Checkin: newlib-cygwin X-Git-Author: Jon Turney X-Git-Refname: refs/heads/master X-Git-Oldrev: bd4bed1254672ac51ca0af0e7720f98c60626d56 X-Git-Newrev: 2432d77099345ee3a4649d002750622d5db79c1b Message-Id: <20221112141215.03DCC38376DA@sourceware.org> Date: Sat, 12 Nov 2022 14:12:12 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D2432d770993= 45ee3a4649d002750622d5db79c1b commit 2432d77099345ee3a4649d002750622d5db79c1b Author: Jon Turney Date: Tue Nov 1 11:15:25 2022 +0000 makedocbook: Use raw strings for regexes =20 Use raw strings for regexes. This is best practice, and fixes a number of "W605 invalid escape sequence" flakes. Diff: --- newlib/doc/makedocbook.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/newlib/doc/makedocbook.py b/newlib/doc/makedocbook.py index 4e83ab63a..5e46082df 100755 --- a/newlib/doc/makedocbook.py +++ b/newlib/doc/makedocbook.py @@ -107,7 +107,7 @@ def remove_noncomments(src): =20 # A command is a single word of at least 3 characters, all uppercase, and = alone on a line def iscommand(l): - if re.match('^[A-Z_]{3,}\s*$', l): + if re.match(r'^[A-Z_]{3,}\s*$', l): =20 return True return False @@ -198,7 +198,7 @@ def function(c, l): descr =3D line_markup_convert(', '.join(descrlist)) =20 # fpclassify includes an 'and' we need to discard - namelist =3D map(lambda v: re.sub('^and ', '', v.strip(), 1), namelist) + namelist =3D map(lambda v: re.sub(r'^and ', r'', v.strip(), 1), nameli= st) # strip off << >> surrounding name namelist =3D map(lambda v: v.strip().lstrip('<').rstrip('>'), namelist) # instantiate list to make it subscriptable @@ -297,11 +297,11 @@ def synopsis(c, t): =20 s =3D '' for l in t.splitlines(): - if re.match('\s*(#|\[|struct)', l): + if re.match(r'\s*(#|\[|struct)', l): # preprocessor # directives, structs, comments in square brack= ets funcsynopsisinfo =3D lxml.etree.SubElement(funcsynopsis, 'func= synopsisinfo') funcsynopsisinfo.text =3D l.strip() + '\n' - elif re.match('[Ll]ink with', l): + elif re.match(r'[Ll]ink with', l): pass else: s =3D s + l @@ -348,7 +348,7 @@ def synopsis_for_prototype(funcsynopsis, s): void =3D lxml.etree.SubElement(funcprototype, 'void') else: # Split parameters on ',' except if it is inside () - for p in re.split(',(?![^()]*\))', match.group(3)): + for p in re.split(r',(?![^()]*\))', match.group(3)): p =3D p.strip() =20 if verbose: @@ -361,7 +361,7 @@ def synopsis_for_prototype(funcsynopsis, s): parameter =3D lxml.etree.SubElement(paramdef, 'par= ameter') =20 # <[ ]> enclose the parameter name - match2 =3D re.match('(.*)<\[(.*)\]>(.*)', p) + match2 =3D re.match(r'(.*)<\[(.*)\]>(.*)', p) =20 if verbose: print(match2.groups(), file=3Dsys.stderr) @@ -472,16 +472,16 @@ def line_markup_convert(p): =20 # also convert some simple texinfo markup # convert @emph{foo} to foo - s =3D re.sub('@emph{(.*?)}', '\\1', s) + s =3D re.sub(r'@emph{(.*?)}', r'\1', s) # convert @strong{foo} to foo - s =3D re.sub('@strong{(.*?)}', '\\1', s) + s =3D re.sub(r'@strong{(.*?)}', r'\1', s) # convert @minus{} to U+2212 MINUS SIGN s =3D s.replace('@minus{}', '−') # convert @dots{} to U+2026 HORIZONTAL ELLIPSIS s =3D s.replace('@dots{}', '…') =20 # convert xref and pxref - s =3D re.sub('@xref{(.*?)}', "See ", s) + s =3D re.sub(r'@xref{(.*?)}', r"See ", s) =20 # very hacky way of dealing with @* to force a newline s =3D s.replace('@*', '') @@ -562,7 +562,7 @@ def t_TABLEEND(t): =20 def t_ITEM(t): r'o\s.*\n' - t.value =3D re.sub('o\s', '', lexer.lexmatch.group(0), 1) + t.value =3D re.sub(r'o\s', r'', lexer.lexmatch.group(0), 1) t.value =3D line_markup_convert(t.value) return t =20 @@ -828,7 +828,7 @@ def main(file): print(s) =20 # warn about texinfo commands which didn't get processed - match =3D re.search('@[a-z*]+', s) + match =3D re.search(r'@[a-z*]+', s) if match: print('texinfo command %s remains in output' % match.group(), file= =3Dsys.stderr)