Skip to content

Commit 0a7924e

Browse files
committed
utf8n_to_uvchr_msgs: Change formal parameter
This makes the beginning of the string to examine totally const, and then initializes the pointer to the position in the string being parsed to this constant s0. Making it totally const enforces that the function doesn't try to change it; and this makes the next commit trivial.
1 parent 3aedd04 commit 0a7924e

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

embed.fnc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3639,7 +3639,7 @@ AMTdp |UV |utf8n_to_uvchr_error \
36393639
|const U32 flags \
36403640
|NULLOK U32 *errors
36413641
ATdip |UV |utf8n_to_uvchr_msgs \
3642-
|NN const U8 *s \
3642+
|NN const U8 * const s0 \
36433643
|STRLEN curlen \
36443644
|NULLOK STRLEN *retlen \
36453645
|const U32 flags \

inline.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2976,7 +2976,7 @@ Perl_is_utf8_fixed_width_buf_loclen_flags(const U8 * const s,
29762976
}
29772977

29782978
PERL_STATIC_INLINE UV
2979-
Perl_utf8n_to_uvchr_msgs(const U8 *s,
2979+
Perl_utf8n_to_uvchr_msgs(const U8 * const s0,
29802980
STRLEN curlen,
29812981
STRLEN *retlen,
29822982
const U32 flags,
@@ -2999,7 +2999,6 @@ Perl_utf8n_to_uvchr_msgs(const U8 *s,
29992999
*msgs = NULL;
30003000
}
30013001

3002-
const U8 * s0;
30033002

30043003
/* No calls from core pass in an empty string; non-core need a check */
30053004
#ifdef PERL_CORE
@@ -3012,16 +3011,16 @@ Perl_utf8n_to_uvchr_msgs(const U8 *s,
30123011
/* UTF-8 invariants are returned unchanged. The code below is quite
30133012
* capable of handling this, but this shortcuts this very common case
30143013
* */
3015-
if (UTF8_IS_INVARIANT(*s)) {
3014+
if (UTF8_IS_INVARIANT(*s0)) {
30163015
if (retlen) {
30173016
*retlen = 1;
30183017
}
30193018

3020-
return *s;
3019+
return *s0;
30213020
}
30223021

3022+
const U8 * s = s0;
30233023
const U8 * send = s + curlen;
3024-
s0 = s;
30253024

30263025
/* This dfa is fast. If it accepts the input, it was for a
30273026
* well-formed, non-problematic code point, which can be returned

proto.h

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)