Skip to content

Commit

Permalink
Fix bad escape sequences in Python strings (#137)
Browse files Browse the repository at this point in the history
- Some of the Python scripts contain strings with ill-formed
  escape sequences, which generate errors in newer versions
  of the Python interpreter. This CL addresses the issue.

Signed-off-by: Derek Foster <justffoulkes@gmail.com>
  • Loading branch information
ffoulkes authored Dec 12, 2024
1 parent e809b2b commit 595b74d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
4 changes: 2 additions & 2 deletions build-aux/extract-ofp-actions
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ def extract_ofp_actions(fn, definitions):
if line.startswith('/*') or not line or line.isspace():
fatal("unexpected syntax within action")
comment += ' %s' % line.lstrip('* \t').rstrip(' \t\r\n')
comment = re.sub('\[[^]]*\]', '', comment)
comment = re.sub(r'\[[^]]*\]', '', comment)
comment = comment[:-2].rstrip()

m = re.match('([^:]+):\s+(.*)$', comment)
m = re.match(r'([^:]+):\s+(.*)$', comment)
if not m:
fatal("unexpected syntax between actions")

Expand Down
8 changes: 4 additions & 4 deletions build-aux/extract-ofp-errors
Original file line number Diff line number Diff line change
Expand Up @@ -241,19 +241,19 @@ def extract_ofp_errors(fn):
comment += ' %s' % line.lstrip('* \t').rstrip(' \t\r\n')
comment = comment[:-2].rstrip()

m = re.match('Expected: (.*)\.$', comment)
m = re.match(r'Expected: (.*)\.$', comment)
if m:
expected_errors[m.group(1)] = (fileName, lineNumber)
continue

m = re.match('((?:.(?!\. ))+.)\.\s+(.*)$', comment)
m = re.match(r'((?:.(?!\. ))+.)\.\s+(.*)$', comment)
if not m:
fatal("unexpected syntax between errors")

dsts, comment = m.groups()

getLine()
m = re.match('\s+(?:OFPERR_([A-Z0-9_]+))(\s*=\s*OFPERR_OFS)?,',
m = re.match(r'\s+(?:OFPERR_([A-Z0-9_]+))(\s*=\s*OFPERR_OFS)?,',
line)
if not m:
fatal("syntax error expecting OFPERR_ enum value")
Expand All @@ -262,7 +262,7 @@ def extract_ofp_errors(fn):
if enum in names:
fatal("%s specified twice" % enum)

comments.append(re.sub('\[[^]]*\]', '', comment))
comments.append(re.sub(r'\[[^]]*\]', '', comment))
names.append(enum)

for dst in dsts.split(', '):
Expand Down
10 changes: 5 additions & 5 deletions build-aux/extract-ofp-fields
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,9 @@ def group_xml_to_nroff(group_node, fields):
'.SS "Summary:"\n',
".TS\n",
"tab(;);\n",
"l l l l l l l.\n",
"l l l l l l.\n",
"Name;Bytes;Mask;RW?;Prereqs;NXM/OXM Support\n",
"\_;\_;\_;\_;\_;\_\n",
r"\_;\_;\_;\_;\_;\_\n",
]
content += summary
content += [".TE\n"]
Expand All @@ -332,7 +332,7 @@ def make_oxm_classes_xml(document):
s = """tab(;);
l l l.
Prefix;Vendor;Class
\_;\_;\_
\\_;\\_;\\_
"""
for key in sorted(OXM_CLASSES, key=OXM_CLASSES.get):
vendor, class_, class_type = OXM_CLASSES.get(key)
Expand Down Expand Up @@ -374,7 +374,7 @@ def make_ovs_fields(meta_flow_h, meta_flow_xml):
"""\
'\\" tp
.\\" -*- mode: troff; coding: utf-8 -*-
.TH "ovs\-fields" 7 "%s" "Open vSwitch" "Open vSwitch Manual"
.TH "ovs\\-fields" 7 "%s" "Open vSwitch" "Open vSwitch Manual"
.fp 5 L CR \\" Make fixed-width font available as \\fL.
.de ST
. PP
Expand Down Expand Up @@ -404,7 +404,7 @@ def make_ovs_fields(meta_flow_h, meta_flow_xml):
..
.if \\n[.g] .mso www.tmac
.SH NAME
ovs\-fields \- protocol header fields in OpenFlow and Open vSwitch
ovs\\-fields \\- protocol header fields in OpenFlow and Open vSwitch
.
.PP
"""
Expand Down
2 changes: 1 addition & 1 deletion build-aux/extract-ofp-msgs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def extract_ofp_msgs(output_file_name):
number = int(number)

get_line()
m = re.match('\s+(?:OFPRAW_%s)(\d*)_([A-Z0-9_]+),?$' % type_,
m = re.match(r'\s+(?:OFPRAW_%s)(\d*)_([A-Z0-9_]+),?$' % type_,
line)
if not m:
fatal("syntax error expecting OFPRAW_ enum")
Expand Down
3 changes: 2 additions & 1 deletion ovsdb/ovsdb-doc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/python3

# Copyright (c) 2010, 2011, 2012, 2013, 2014, 2015, 2020 Nicira, Inc.
# Copyright (c) 2024 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -239,7 +240,7 @@ Purpose
if erFile:
s += """
.\\" check if in troff mode (TTY)
.if t \{
.if t \\{
.bp
.SH "TABLE RELATIONSHIPS"
.PP
Expand Down

0 comments on commit 595b74d

Please sign in to comment.