Skip to content

Commit bd66bdc

Browse files
committed
parse_ident: Add const to two parameters
This function doesn't change anything in the string delimitted by these parameters, and future commits will call it with const strings that otherwise would have to cast away const
1 parent 735e7cc commit bd66bdc

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

embed.fnc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6176,8 +6176,8 @@ So |SV * |new_constant |NULLOK const char *s \
61766176
|NULLOK const char *type \
61776177
|STRLEN typelen \
61786178
|NULLOK const char **error_msg
6179-
S |char * |parse_ident |SPTR char *s \
6180-
|EPTRQ char * const s_end \
6179+
S |char * |parse_ident |SPTR const char *s \
6180+
|EPTRQ const char * const s_end \
61816181
|SPTR char **d \
61826182
|EPTR char * const e \
61836183
|bool is_utf8 \

proto.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

toke.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10539,7 +10539,7 @@ S_new_constant(pTHX_ const char *s, STRLEN len, const char *key, STRLEN keylen,
1053910539
}
1054010540

1054110541
STATIC char *
10542-
S_parse_ident(pTHX_ char *s, char * const s_end,
10542+
S_parse_ident(pTHX_ const char *s, const char * const s_end,
1054310543
char **d, char * const e,
1054410544
bool is_utf8, U32 flags)
1054510545
{
@@ -10591,7 +10591,7 @@ S_parse_ident(pTHX_ char *s, char * const s_end,
1059110591

1059210592
/* Find the end of the identifier by accumulating characters until
1059310593
* find a non-identifier character */
10594-
char *t = s + advance;
10594+
const char *t = s + advance;
1059510595
while ((advance = isIDCONT_utf8_safe((const U8*) t,
1059610596
(const U8*) s_end)))
1059710597
{
@@ -10638,7 +10638,11 @@ S_parse_ident(pTHX_ char *s, char * const s_end,
1063810638
identifier*/
1063910639
break;
1064010640
}
10641-
return s;
10641+
10642+
/* Cast away const, because many of our callers don't have it; this
10643+
* function declares it as const so as to indicate that it doesn't change
10644+
* it, and it can be called using a const parameter */
10645+
return (char *) s;
1064210646
}
1064310647

1064410648
char *

0 commit comments

Comments
 (0)