From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from re-prd-fep-041.btinternet.com (mailomta18-re.btinternet.com [213.120.69.111]) by sourceware.org (Postfix) with ESMTPS id 0D831385841E for ; Fri, 4 Nov 2022 13:50:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0D831385841E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=dronecode.org.uk Authentication-Results: sourceware.org; spf=none smtp.mailfrom=dronecode.org.uk Received: from re-prd-rgout-001.btmx-prd.synchronoss.net ([10.2.54.4]) by re-prd-fep-041.btinternet.com with ESMTP id <20221104135007.ZIOA9588.re-prd-fep-041.btinternet.com@re-prd-rgout-001.btmx-prd.synchronoss.net>; Fri, 4 Nov 2022 13:50:07 +0000 Authentication-Results: btinternet.com; none X-SNCR-Rigid: 613A8CC341042740 X-Originating-IP: [81.153.98.206] X-OWM-Source-IP: 81.153.98.206 (GB) X-OWM-Env-Sender: jonturney@btinternet.com X-VadeSecure-score: verdict=clean score=0/300, class=clean X-RazorGate-Vade: gggruggvucftvghtrhhoucdtuddrgedvgedrvddugdehgecutefuodetggdotefrodftvfcurfhrohhfihhlvgemuceutffkvffkuffjvffgnffgvefqofdpqfgfvfenuceurghilhhouhhtmecufedtudenucenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeflohhnucfvuhhrnhgvhicuoehjohhnrdhtuhhrnhgvhiesughrohhnvggtohguvgdrohhrghdruhhkqeenucggtffrrghtthgvrhhnpeejheegvdefkeekteduudekvdegffduueeggeejveelhfehleduvedvgeektdehffenucffohhmrghinheplhgvgihmrghttghhrdhgrhhouhhpnecukfhppeekuddrudehfedrleekrddvtdeinecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehhvghloheplhhotggrlhhhohhsthdrlhhotggrlhguohhmrghinhdpihhnvghtpeekuddrudehfedrleekrddvtdeipdhmrghilhhfrhhomhepjhhonhdrthhurhhnvgihsegurhhonhgvtghouggvrdhorhhgrdhukhdpnhgspghrtghpthhtohepvddprhgtphhtthhopehjohhnrdhtuhhrnhgvhiesughrohhnvggtohguvgdrohhrghdruhhkpdhrtghpthhtohepnhgvfihlihgssehsohhurhgtvgifrghrvgdrohhrgh X-RazorGate-Vade-Verdict: clean 0 X-RazorGate-Vade-Classification: clean Received: from localhost.localdomain (81.153.98.206) by re-prd-rgout-001.btmx-prd.synchronoss.net (5.8.716.04) (authenticated as jonturney@btinternet.com) id 613A8CC341042740; Fri, 4 Nov 2022 13:50:07 +0000 From: Jon Turney To: newlib@sourceware.org Cc: Jon Turney Subject: [PATCH 1/5] makedocbook: Use raw strings for regexes Date: Fri, 4 Nov 2022 13:49:42 +0000 Message-Id: <20221104134946.13443-2-jon.turney@dronecode.org.uk> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221104134946.13443-1-jon.turney@dronecode.org.uk> References: <20221104134946.13443-1-jon.turney@dronecode.org.uk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1196.8 required=5.0 tests=BAYES_00,FORGED_SPF_HELO,GIT_PATCH_0,KAM_DMARC_STATUS,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_BARRACUDACENTRAL,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Use raw strings for regexes. This is best practice, and fixes a number of "W605 invalid escape sequence" flakes. --- 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): # 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): return True return False @@ -198,7 +198,7 @@ def function(c, l): descr = line_markup_convert(', '.join(descrlist)) # fpclassify includes an 'and' we need to discard - namelist = map(lambda v: re.sub('^and ', '', v.strip(), 1), namelist) + namelist = map(lambda v: re.sub(r'^and ', r'', v.strip(), 1), namelist) # strip off << >> surrounding name namelist = map(lambda v: v.strip().lstrip('<').rstrip('>'), namelist) # instantiate list to make it subscriptable @@ -297,11 +297,11 @@ def synopsis(c, t): s = '' for l in t.splitlines(): - if re.match('\s*(#|\[|struct)', l): + if re.match(r'\s*(#|\[|struct)', l): # preprocessor # directives, structs, comments in square brackets funcsynopsisinfo = lxml.etree.SubElement(funcsynopsis, 'funcsynopsisinfo') funcsynopsisinfo.text = l.strip() + '\n' - elif re.match('[Ll]ink with', l): + elif re.match(r'[Ll]ink with', l): pass else: s = s + l @@ -348,7 +348,7 @@ def synopsis_for_prototype(funcsynopsis, s): void = 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 = p.strip() if verbose: @@ -361,7 +361,7 @@ def synopsis_for_prototype(funcsynopsis, s): parameter = lxml.etree.SubElement(paramdef, 'parameter') # <[ ]> enclose the parameter name - match2 = re.match('(.*)<\[(.*)\]>(.*)', p) + match2 = re.match(r'(.*)<\[(.*)\]>(.*)', p) if verbose: print(match2.groups(), file=sys.stderr) @@ -472,16 +472,16 @@ def line_markup_convert(p): # also convert some simple texinfo markup # convert @emph{foo} to foo - s = re.sub('@emph{(.*?)}', '\\1', s) + s = re.sub(r'@emph{(.*?)}', r'\1', s) # convert @strong{foo} to foo - s = re.sub('@strong{(.*?)}', '\\1', s) + s = re.sub(r'@strong{(.*?)}', r'\1', s) # convert @minus{} to U+2212 MINUS SIGN s = s.replace('@minus{}', '−') # convert @dots{} to U+2026 HORIZONTAL ELLIPSIS s = s.replace('@dots{}', '…') # convert xref and pxref - s = re.sub('@xref{(.*?)}', "See ", s) + s = re.sub(r'@xref{(.*?)}', r"See ", s) # very hacky way of dealing with @* to force a newline s = s.replace('@*', '') @@ -562,7 +562,7 @@ def t_TABLEEND(t): def t_ITEM(t): r'o\s.*\n' - t.value = re.sub('o\s', '', lexer.lexmatch.group(0), 1) + t.value = re.sub(r'o\s', r'', lexer.lexmatch.group(0), 1) t.value = line_markup_convert(t.value) return t @@ -828,7 +828,7 @@ def main(file): print(s) # warn about texinfo commands which didn't get processed - match = re.search('@[a-z*]+', s) + match = re.search(r'@[a-z*]+', s) if match: print('texinfo command %s remains in output' % match.group(), file=sys.stderr) -- 2.38.1