summaryrefslogtreecommitdiffstats
path: root/Modules/sre_lib.h
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-06-10 16:38:05 (GMT)
committerGitHub <noreply@github.com>2020-06-10 16:38:05 (GMT)
commitd36cf5f1d20ce9f111a8fc997104785086e8eee6 (patch)
treef452121f147dece783aa9a278f6ce80b012ca0bd /Modules/sre_lib.h
parent24b8bad6d30ae4fb37ee686a073adfa5308659f9 (diff)
downloadcpython-d36cf5f1d20ce9f111a8fc997104785086e8eee6.zip
cpython-d36cf5f1d20ce9f111a8fc997104785086e8eee6.tar.gz
cpython-d36cf5f1d20ce9f111a8fc997104785086e8eee6.tar.bz2
bpo-40943: Replace PY_FORMAT_SIZE_T with "z" (GH-20781)
The PEP 353, written in 2005, introduced PY_FORMAT_SIZE_T. Python no longer supports macOS 10.4 and Visual Studio 2010, but requires more recent macOS and Visual Studio versions. In 2020 with Python 3.10, it is now safe to use directly "%zu" to format size_t and "%zi" to format Py_ssize_t.
Diffstat (limited to 'Modules/sre_lib.h')
-rw-r--r--Modules/sre_lib.h29
1 files changed, 12 insertions, 17 deletions
diff --git a/Modules/sre_lib.h b/Modules/sre_lib.h
index 2657d8d..cfe0a4a 100644
--- a/Modules/sre_lib.h
+++ b/Modules/sre_lib.h
@@ -323,12 +323,12 @@ SRE(count)(SRE_STATE* state, const SRE_CODE* pattern, Py_ssize_t maxcount)
if (!i)
break;
}
- TRACE(("|%p|%p|COUNT %" PY_FORMAT_SIZE_T "d\n", pattern, ptr,
+ TRACE(("|%p|%p|COUNT %zd\n", pattern, ptr,
(SRE_CHAR*) state->ptr - ptr));
return (SRE_CHAR*) state->ptr - ptr;
}
- TRACE(("|%p|%p|COUNT %" PY_FORMAT_SIZE_T "d\n", pattern, ptr,
+ TRACE(("|%p|%p|COUNT %zd\n", pattern, ptr,
ptr - (SRE_CHAR*) state->ptr));
return ptr - (SRE_CHAR*) state->ptr;
}
@@ -414,8 +414,7 @@ SRE(info)(SRE_STATE* state, const SRE_CODE* pattern)
#define DATA_STACK_ALLOC(state, type, ptr) \
do { \
alloc_pos = state->data_stack_base; \
- TRACE(("allocating %s in %" PY_FORMAT_SIZE_T "d " \
- "(%" PY_FORMAT_SIZE_T "d)\n", \
+ TRACE(("allocating %s in %zd (%zd)\n", \
Py_STRINGIFY(type), alloc_pos, sizeof(type))); \
if (sizeof(type) > state->data_stack_size - alloc_pos) { \
int j = data_stack_grow(state, sizeof(type)); \
@@ -429,14 +428,13 @@ do { \
#define DATA_STACK_LOOKUP_AT(state, type, ptr, pos) \
do { \
- TRACE(("looking up %s at %" PY_FORMAT_SIZE_T "d\n", Py_STRINGIFY(type), pos)); \
+ TRACE(("looking up %s at %zd\n", Py_STRINGIFY(type), pos)); \
ptr = (type*)(state->data_stack+pos); \
} while (0)
#define DATA_STACK_PUSH(state, data, size) \
do { \
- TRACE(("copy data in %p to %" PY_FORMAT_SIZE_T "d " \
- "(%" PY_FORMAT_SIZE_T "d)\n", \
+ TRACE(("copy data in %p to %zd (%zd)\n", \
data, state->data_stack_base, size)); \
if (size > state->data_stack_size - state->data_stack_base) { \
int j = data_stack_grow(state, size); \
@@ -453,8 +451,7 @@ do { \
safely casted to `void*`, see bpo-39943 for details. */
#define DATA_STACK_POP(state, data, size, discard) \
do { \
- TRACE(("copy data to %p from %" PY_FORMAT_SIZE_T "d " \
- "(%" PY_FORMAT_SIZE_T "d)\n", \
+ TRACE(("copy data to %p from %zd (%zd)\n", \
data, state->data_stack_base-size, size)); \
memcpy((void*) data, state->data_stack+state->data_stack_base-size, size); \
if (discard) \
@@ -463,8 +460,7 @@ do { \
#define DATA_STACK_POP_DISCARD(state, size) \
do { \
- TRACE(("discard data from %" PY_FORMAT_SIZE_T "d " \
- "(%" PY_FORMAT_SIZE_T "d)\n", \
+ TRACE(("discard data from %zd (%zd)\n", \
state->data_stack_base-size, size)); \
state->data_stack_base -= size; \
} while(0)
@@ -577,8 +573,7 @@ entrance:
/* optimization info block */
/* <INFO> <1=skip> <2=flags> <3=min> ... */
if (ctx->pattern[3] && (uintptr_t)(end - ctx->ptr) < ctx->pattern[3]) {
- TRACE(("reject (got %" PY_FORMAT_SIZE_T "d chars, "
- "need %" PY_FORMAT_SIZE_T "d)\n",
+ TRACE(("reject (got %zd chars, need %zd)\n",
end - ctx->ptr, (Py_ssize_t) ctx->pattern[3]));
RETURN_FAILURE;
}
@@ -1028,7 +1023,7 @@ entrance:
ctx->count = ctx->u.rep->count+1;
- TRACE(("|%p|%p|MAX_UNTIL %" PY_FORMAT_SIZE_T "d\n", ctx->pattern,
+ TRACE(("|%p|%p|MAX_UNTIL %zd\n", ctx->pattern,
ctx->ptr, ctx->count));
if (ctx->count < (Py_ssize_t) ctx->u.rep->pattern[1]) {
@@ -1091,7 +1086,7 @@ entrance:
ctx->count = ctx->u.rep->count+1;
- TRACE(("|%p|%p|MIN_UNTIL %" PY_FORMAT_SIZE_T "d %p\n", ctx->pattern,
+ TRACE(("|%p|%p|MIN_UNTIL %zd %p\n", ctx->pattern,
ctx->ptr, ctx->count, ctx->u.rep->pattern));
if (ctx->count < (Py_ssize_t) ctx->u.rep->pattern[1]) {
@@ -1358,7 +1353,7 @@ exit:
TRACE(("|%p|%p|JUMP_ASSERT_NOT\n", ctx->pattern, ctx->ptr));
goto jump_assert_not;
case JUMP_NONE:
- TRACE(("|%p|%p|RETURN %" PY_FORMAT_SIZE_T "d\n", ctx->pattern,
+ TRACE(("|%p|%p|RETURN %zd\n", ctx->pattern,
ctx->ptr, ret));
break;
}
@@ -1420,7 +1415,7 @@ SRE(search)(SRE_STATE* state, SRE_CODE* pattern)
pattern += 1 + pattern[1];
}
- TRACE(("prefix = %p %" PY_FORMAT_SIZE_T "d %" PY_FORMAT_SIZE_T "d\n",
+ TRACE(("prefix = %p %zd %zd\n",
prefix, prefix_len, prefix_skip));
TRACE(("charset = %p\n", charset));