Skip to content

Commit aabfead

Browse files
committed
Make a few parse fcns accessible to B::Hooks::Parser
This module had made copies of three functions from toke.c many releases ago, and they stagnated. Most outside code has no business calling them, but the least worst choice I believe is to make them accessible, but hide that fact. This commit makes them accessible to modules that have defined PERL_EXT. It does not document their API's, and marks them as subject to change, so they aren't even listed as available in the docs. In other words, you'd have to really go digging to find out you could use them. And the API of two of the three had changed since the code was originally stolen. So that "subject to change" actually has happened. We should feel free to change the API as needed, and B::Hooks::Parser will have to be updated. Thanks to Tony Cook for advising me on this area unfamiliar to me.
1 parent 2ec4590 commit aabfead

File tree

4 files changed

+28
-28
lines changed

4 files changed

+28
-28
lines changed

embed.fnc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2744,6 +2744,12 @@ EXpR |SV* |get_and_check_backslash_N_name|NN const char* s \
27442744
|const bool is_utf8 \
27452745
|NN const char** error_msg
27462746

2747+
EXpMR |char* |scan_str |NN char *start|int keep_quoted \
2748+
|int keep_delims|int re_reparse \
2749+
|NULLOK char **delimp
2750+
EXpM |char* |scan_word |NN char *s|NN char *dest|STRLEN destlen \
2751+
|int allow_package|NN STRLEN *slp
2752+
EXpMR |char* |skipspace_flags|NN char *s|U32 flags
27472753
#if defined(PERL_IN_TOKE_C)
27482754
s |void |check_uni
27492755
s |void |force_next |I32 type
@@ -2761,16 +2767,10 @@ s |char* |scan_ident |NN char *s|NN char *dest \
27612767
|STRLEN destlen|I32 ck_uni
27622768
sR |char* |scan_inputsymbol|NN char *start
27632769
sR |char* |scan_pat |NN char *start|I32 type
2764-
sR |char* |scan_str |NN char *start|int keep_quoted \
2765-
|int keep_delims|int re_reparse \
2766-
|NULLOK char **delimp
27672770
sR |char* |scan_subst |NN char *start
27682771
sR |char* |scan_trans |NN char *start
2769-
s |char* |scan_word |NN char *s|NN char *dest|STRLEN destlen \
2770-
|int allow_package|NN STRLEN *slp
27712772
s |void |update_debugger_info|NULLOK SV *orig_sv \
27722773
|NULLOK const char *const buf|STRLEN len
2773-
sR |char* |skipspace_flags|NN char *s|U32 flags
27742774
sR |char* |swallow_bom |NN U8 *s
27752775
#ifndef PERL_NO_UTF16_FILTER
27762776
s |I32 |utf16_textfilter|int idx|NN SV *sv|int maxlen

embed.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,6 +1101,9 @@
11011101
#define reg_qr_package(a) Perl_reg_qr_package(aTHX_ a)
11021102
#define reg_temp_copy(a,b) Perl_reg_temp_copy(aTHX_ a,b)
11031103
#define report_uninit(a) Perl_report_uninit(aTHX_ a)
1104+
#define scan_str(a,b,c,d,e) Perl_scan_str(aTHX_ a,b,c,d,e)
1105+
#define scan_word(a,b,c,d,e) Perl_scan_word(aTHX_ a,b,c,d,e)
1106+
#define skipspace_flags(a,b) Perl_skipspace_flags(aTHX_ a,b)
11041107
#define sv_magicext_mglob(a) Perl_sv_magicext_mglob(aTHX_ a)
11051108
#define sv_only_taint_gmagic S_sv_only_taint_gmagic
11061109
#define swash_fetch(a,b,c) Perl_swash_fetch(aTHX_ a,b,c)
@@ -2046,11 +2049,8 @@
20462049
#define scan_ident(a,b,c,d) S_scan_ident(aTHX_ a,b,c,d)
20472050
#define scan_inputsymbol(a) S_scan_inputsymbol(aTHX_ a)
20482051
#define scan_pat(a,b) S_scan_pat(aTHX_ a,b)
2049-
#define scan_str(a,b,c,d,e) S_scan_str(aTHX_ a,b,c,d,e)
20502052
#define scan_subst(a) S_scan_subst(aTHX_ a)
20512053
#define scan_trans(a) S_scan_trans(aTHX_ a)
2052-
#define scan_word(a,b,c,d,e) S_scan_word(aTHX_ a,b,c,d,e)
2053-
#define skipspace_flags(a,b) S_skipspace_flags(aTHX_ a,b)
20542054
#define sublex_done() S_sublex_done(aTHX)
20552055
#define sublex_push() S_sublex_push(aTHX)
20562056
#define sublex_start() S_sublex_start(aTHX)

proto.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3108,12 +3108,20 @@ PERL_CALLCONV char* Perl_scan_num(pTHX_ const char* s, YYSTYPE *lvalp);
31083108
PERL_CALLCONV NV Perl_scan_oct(pTHX_ const char* start, STRLEN len, STRLEN* retlen);
31093109
#define PERL_ARGS_ASSERT_SCAN_OCT \
31103110
assert(start); assert(retlen)
3111+
PERL_CALLCONV char* Perl_scan_str(pTHX_ char *start, int keep_quoted, int keep_delims, int re_reparse, char **delimp)
3112+
__attribute__warn_unused_result__;
3113+
#define PERL_ARGS_ASSERT_SCAN_STR \
3114+
assert(start)
3115+
31113116
PERL_CALLCONV const char* Perl_scan_version(pTHX_ const char *s, SV *rv, bool qv);
31123117
#define PERL_ARGS_ASSERT_SCAN_VERSION \
31133118
assert(s); assert(rv)
31143119
PERL_CALLCONV char* Perl_scan_vstring(pTHX_ const char *s, const char *const e, SV *sv);
31153120
#define PERL_ARGS_ASSERT_SCAN_VSTRING \
31163121
assert(s); assert(e); assert(sv)
3122+
PERL_CALLCONV char* Perl_scan_word(pTHX_ char *s, char *dest, STRLEN destlen, int allow_package, STRLEN *slp);
3123+
#define PERL_ARGS_ASSERT_SCAN_WORD \
3124+
assert(s); assert(dest); assert(slp)
31173125
PERL_CALLCONV U32 Perl_seed(pTHX);
31183126
PERL_CALLCONV void Perl_set_caret_X(pTHX);
31193127
PERL_CALLCONV void Perl_set_context(void *t);
@@ -3132,6 +3140,11 @@ PERL_CALLCONV void Perl_setfd_inhexec_for_sysfd(pTHX_ int fd);
31323140
PERL_CALLCONV HEK* Perl_share_hek(pTHX_ const char* str, SSize_t len, U32 hash);
31333141
#define PERL_ARGS_ASSERT_SHARE_HEK \
31343142
assert(str)
3143+
PERL_CALLCONV char* Perl_skipspace_flags(pTHX_ char *s, U32 flags)
3144+
__attribute__warn_unused_result__;
3145+
#define PERL_ARGS_ASSERT_SKIPSPACE_FLAGS \
3146+
assert(s)
3147+
31353148
PERL_CALLCONV void Perl_sortsv(pTHX_ SV** array, size_t num_elts, SVCOMPARE_t cmp);
31363149
#define PERL_ARGS_ASSERT_SORTSV \
31373150
assert(cmp)
@@ -6117,11 +6130,6 @@ STATIC char* S_scan_pat(pTHX_ char *start, I32 type)
61176130
#define PERL_ARGS_ASSERT_SCAN_PAT \
61186131
assert(start)
61196132

6120-
STATIC char* S_scan_str(pTHX_ char *start, int keep_quoted, int keep_delims, int re_reparse, char **delimp)
6121-
__attribute__warn_unused_result__;
6122-
#define PERL_ARGS_ASSERT_SCAN_STR \
6123-
assert(start)
6124-
61256133
STATIC char* S_scan_subst(pTHX_ char *start)
61266134
__attribute__warn_unused_result__;
61276135
#define PERL_ARGS_ASSERT_SCAN_SUBST \
@@ -6132,14 +6140,6 @@ STATIC char* S_scan_trans(pTHX_ char *start)
61326140
#define PERL_ARGS_ASSERT_SCAN_TRANS \
61336141
assert(start)
61346142

6135-
STATIC char* S_scan_word(pTHX_ char *s, char *dest, STRLEN destlen, int allow_package, STRLEN *slp);
6136-
#define PERL_ARGS_ASSERT_SCAN_WORD \
6137-
assert(s); assert(dest); assert(slp)
6138-
STATIC char* S_skipspace_flags(pTHX_ char *s, U32 flags)
6139-
__attribute__warn_unused_result__;
6140-
#define PERL_ARGS_ASSERT_SKIPSPACE_FLAGS \
6141-
assert(s)
6142-
61436143
STATIC I32 S_sublex_done(pTHX)
61446144
__attribute__warn_unused_result__;
61456145

toke.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1885,8 +1885,8 @@ S_update_debugger_info(pTHX_ SV *orig_sv, const char *const buf, STRLEN len)
18851885
#define skipspace(s) skipspace_flags(s, 0)
18861886
#define peekspace(s) skipspace_flags(s, LEX_NO_INCLINE)
18871887

1888-
STATIC char *
1889-
S_skipspace_flags(pTHX_ char *s, U32 flags)
1888+
char *
1889+
Perl_skipspace_flags(pTHX_ char *s, U32 flags)
18901890
{
18911891
PERL_ARGS_ASSERT_SKIPSPACE_FLAGS;
18921892
if (PL_lex_formbrack && PL_lex_brackets <= PL_lex_formbrack) {
@@ -9434,8 +9434,8 @@ S_parse_ident(pTHX_ char **s, char **d, char * const e, int allow_package,
94349434
/* Returns a NUL terminated string, with the length of the string written to
94359435
*slp
94369436
*/
9437-
STATIC char *
9438-
S_scan_word(pTHX_ char *s, char *dest, STRLEN destlen, int allow_package, STRLEN *slp)
9437+
char *
9438+
Perl_scan_word(pTHX_ char *s, char *dest, STRLEN destlen, int allow_package, STRLEN *slp)
94399439
{
94409440
char *d = dest;
94419441
char * const e = d + destlen - 3; /* two-character token, ending NUL */
@@ -10664,8 +10664,8 @@ S_scan_inputsymbol(pTHX_ char *start)
1066410664
SvIVX of the SV.
1066510665
*/
1066610666

10667-
STATIC char *
10668-
S_scan_str(pTHX_ char *start, int keep_bracketed_quoted, int keep_delims, int re_reparse,
10667+
char *
10668+
Perl_scan_str(pTHX_ char *start, int keep_bracketed_quoted, int keep_delims, int re_reparse,
1066910669
char **delimp
1067010670
)
1067110671
{

0 commit comments

Comments
 (0)