glapi: disable python escape sequences in strings that use invalid ones

We use invalid escape sequences in a few string.
r'...' disables escape sequences. This fixes validator errors:

/home/marek/dev/mesa/src/mapi/mapi_abi.py:45: SyntaxWarning: invalid escape sequence '\w'
  '^(?P<type>[\w\s*]+?)(?P<name>\w+)(\[(?P<array>\d+)\])?$')
/home/marek/dev/mesa/src/mapi/glapi/gen/api_exec_init.py:43: SyntaxWarning: invalid escape sequence '\p'
  header = """/**
/home/marek/dev/mesa/src/mapi/glapi/gen/gl_enums.py:64: SyntaxWarning: invalid escape sequence '\c'
  print("""

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33634>
This commit is contained in:
Marek Olšák 2025-02-20 23:55:26 -05:00 committed by Marge Bot
parent 1f75715dae
commit 72db4a1e50
3 changed files with 5 additions and 5 deletions

View file

@ -40,8 +40,8 @@ exec_flavor_map = {
}
header = """/**
* \\file api_exec_init.c
header = r"""/**
* \file api_exec_init.c
* Initialize dispatch table.
*/

View file

@ -61,7 +61,7 @@ class PrintGlEnums(gl_XML.gl_print_base):
return
def print_code(self):
print("""
print(r"""
typedef int (*cfunc)(const void *, const void *);
/**
@ -102,7 +102,7 @@ _mesa_enum_to_string(int nr)
else {
/* this is not re-entrant safe, no big deal here */
snprintf(token_tmp, sizeof(token_tmp) - 1, "0x%x", nr);
token_tmp[sizeof(token_tmp) - 1] = '\\0';
token_tmp[sizeof(token_tmp) - 1] = '\0';
return token_tmp;
}
}

View file

@ -42,7 +42,7 @@ class ABIEntry(object):
"""Represent an ABI entry."""
_match_c_param = re.compile(
'^(?P<type>[\w\s*]+?)(?P<name>\w+)(\[(?P<array>\d+)\])?$')
r'^(?P<type>[\w\s*]+?)(?P<name>\w+)(\[(?P<array>\d+)\])?$')
def __init__(self, cols, attrs, xml_data = None):
self._parse(cols)