summaryrefslogtreecommitdiffstats
path: root/Parser
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2021-06-12 13:11:59 (GMT)
committerGitHub <noreply@github.com>2021-06-12 13:11:59 (GMT)
commitbe8b631b7a587aa781245e14c8cca32970e1be5b (patch)
treee754599e2e72d6e327667f1b8788f2d34d6fda36 /Parser
parent9f1c5f6e8af6ba3f659b2aea1e221ac9695828ba (diff)
downloadcpython-be8b631b7a587aa781245e14c8cca32970e1be5b.zip
cpython-be8b631b7a587aa781245e14c8cca32970e1be5b.tar.gz
cpython-be8b631b7a587aa781245e14c8cca32970e1be5b.tar.bz2
Add more const modifiers. (GH-26691)
Diffstat (limited to 'Parser')
-rw-r--r--Parser/pegen.c14
-rw-r--r--Parser/pegen.h6
-rw-r--r--Parser/string_parser.c10
3 files changed, 15 insertions, 15 deletions
diff --git a/Parser/pegen.c b/Parser/pegen.c
index 82f840c..1941244 100644
--- a/Parser/pegen.c
+++ b/Parser/pegen.c
@@ -7,7 +7,7 @@
#include "string_parser.h"
PyObject *
-_PyPegen_new_type_comment(Parser *p, char *s)
+_PyPegen_new_type_comment(Parser *p, const char *s)
{
PyObject *res = PyUnicode_DecodeUTF8(s, strlen(s), NULL);
if (res == NULL) {
@@ -26,7 +26,7 @@ _PyPegen_add_type_comment_to_arg(Parser *p, arg_ty a, Token *tc)
if (tc == NULL) {
return a;
}
- char *bytes = PyBytes_AsString(tc->bytes);
+ const char *bytes = PyBytes_AsString(tc->bytes);
if (bytes == NULL) {
return NULL;
}
@@ -66,7 +66,7 @@ _PyPegen_check_barry_as_flufl(Parser *p, Token* t) {
assert(t->bytes != NULL);
assert(t->type == NOTEQUAL);
- char* tok_str = PyBytes_AS_STRING(t->bytes);
+ const char* tok_str = PyBytes_AS_STRING(t->bytes);
if (p->flags & PyPARSE_BARRY_AS_BDFL && strcmp(tok_str, "<>") != 0) {
RAISE_SYNTAX_ERROR("with Barry as BDFL, use '<>' instead of '!='");
return -1;
@@ -78,7 +78,7 @@ _PyPegen_check_barry_as_flufl(Parser *p, Token* t) {
}
PyObject *
-_PyPegen_new_identifier(Parser *p, char *n)
+_PyPegen_new_identifier(Parser *p, const char *n)
{
PyObject *id = PyUnicode_DecodeUTF8(n, strlen(n), NULL);
if (!id) {
@@ -911,7 +911,7 @@ _PyPegen_expect_soft_keyword(Parser *p, const char *keyword)
if (t->type != NAME) {
return NULL;
}
- char *s = PyBytes_AsString(t->bytes);
+ const char *s = PyBytes_AsString(t->bytes);
if (!s) {
p->error_indicator = 1;
return NULL;
@@ -942,7 +942,7 @@ _PyPegen_name_from_token(Parser *p, Token* t)
if (t == NULL) {
return NULL;
}
- char* s = PyBytes_AsString(t->bytes);
+ const char *s = PyBytes_AsString(t->bytes);
if (!s) {
p->error_indicator = 1;
return NULL;
@@ -1068,7 +1068,7 @@ _PyPegen_number_token(Parser *p)
return NULL;
}
- char *num_raw = PyBytes_AsString(t->bytes);
+ const char *num_raw = PyBytes_AsString(t->bytes);
if (num_raw == NULL) {
p->error_indicator = 1;
return NULL;
diff --git a/Parser/pegen.h b/Parser/pegen.h
index 1540da0..161a498 100644
--- a/Parser/pegen.h
+++ b/Parser/pegen.h
@@ -202,7 +202,7 @@ CHECK_CALL_NULL_ALLOWED(Parser *p, void *result)
#define CHECK(type, result) ((type) CHECK_CALL(p, result))
#define CHECK_NULL_ALLOWED(type, result) ((type) CHECK_CALL_NULL_ALLOWED(p, result))
-PyObject *_PyPegen_new_type_comment(Parser *, char *);
+PyObject *_PyPegen_new_type_comment(Parser *, const char *);
Py_LOCAL_INLINE(PyObject *)
NEW_TYPE_COMMENT(Parser *p, Token *tc)
@@ -210,7 +210,7 @@ NEW_TYPE_COMMENT(Parser *p, Token *tc)
if (tc == NULL) {
return NULL;
}
- char *bytes = PyBytes_AsString(tc->bytes);
+ const char *bytes = PyBytes_AsString(tc->bytes);
if (bytes == NULL) {
goto error;
}
@@ -242,7 +242,7 @@ INVALID_VERSION_CHECK(Parser *p, int version, char *msg, void *node)
#define CHECK_VERSION(type, version, msg, node) ((type) INVALID_VERSION_CHECK(p, version, msg, node))
arg_ty _PyPegen_add_type_comment_to_arg(Parser *, arg_ty, Token *);
-PyObject *_PyPegen_new_identifier(Parser *, char *);
+PyObject *_PyPegen_new_identifier(Parser *, const char *);
Parser *_PyPegen_Parser_New(struct tok_state *, int, int, int, int *, PyArena *);
void _PyPegen_Parser_Free(Parser *);
mod_ty _PyPegen_run_parser_from_file_pointer(FILE *, int, PyObject *, const char *,
diff --git a/Parser/string_parser.c b/Parser/string_parser.c
index fa41a36..66405b2 100644
--- a/Parser/string_parser.c
+++ b/Parser/string_parser.c
@@ -87,7 +87,7 @@ decode_unicode_with_escapes(Parser *parser, const char *s, size_t len, Token *t)
if (*s & 0x80) {
PyObject *w;
int kind;
- void *data;
+ const void *data;
Py_ssize_t w_len;
Py_ssize_t i;
w = decode_utf8(&s, end);
@@ -288,17 +288,17 @@ fstring_find_expr_location(Token *parent, char *expr_str, int *p_lines, int *p_c
*p_lines = 0;
*p_cols = 0;
if (parent && parent->bytes) {
- char *parent_str = PyBytes_AsString(parent->bytes);
+ const char *parent_str = PyBytes_AsString(parent->bytes);
if (!parent_str) {
return false;
}
- char *substr = strstr(parent_str, expr_str);
+ const char *substr = strstr(parent_str, expr_str);
if (substr) {
// The following is needed, in order to correctly shift the column
// offset, in the case that (disregarding any whitespace) a newline
// immediately follows the opening curly brace of the fstring expression.
bool newline_after_brace = 1;
- char *start = substr + 1;
+ const char *start = substr + 1;
while (start && *start != '}' && *start != '\n') {
if (*start != ' ' && *start != '\t' && *start != '\f') {
newline_after_brace = 0;
@@ -318,7 +318,7 @@ fstring_find_expr_location(Token *parent, char *expr_str, int *p_lines, int *p_c
}
/* adjust the start based on the number of newlines encountered
before the f-string expression */
- for (char* p = parent_str; p < substr; p++) {
+ for (const char *p = parent_str; p < substr; p++) {
if (*p == '\n') {
(*p_lines)++;
}