summaryrefslogtreecommitdiff
path: root/toke.c
diff options
context:
space:
mode:
authorZefram <zefram@fysh.org>2010-09-11 19:36:10 +0100
committerFlorian Ragwitz <rafl@debian.org>2010-09-28 21:35:02 +0200
commit9dcc53ea14d7a502bb5ac0877765bde14f8cc721 (patch)
treee04fbefccc4e81298835b1e4fb69e8db347ff810 /toke.c
parentdccfc75d21f1ac6a97926d5bac2e89d3cd22eafa (diff)
downloadperl-9dcc53ea14d7a502bb5ac0877765bde14f8cc721.tar.gz
systematically provide pv/pvn/pvs/sv quartets
Anywhere an API function takes a string in pvn form, ensure that there are corresponding pv, pvs, and sv APIs.
Diffstat (limited to 'toke.c')
-rw-r--r--toke.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/toke.c b/toke.c
index 961866bba0..dd49c3cdba 100644
--- a/toke.c
+++ b/toke.c
@@ -923,7 +923,7 @@ at I<pv>. These octets are interpreted as either UTF-8 or Latin-1,
according to whether the C<LEX_STUFF_UTF8> flag is set in I<flags>.
The characters are recoded for the lexer buffer, according to how the
buffer is currently being interpreted (L</lex_bufutf8>). If a string
-to be interpreted is available as a Perl scalar, the L</lex_stuff_sv>
+to be inserted is available as a Perl scalar, the L</lex_stuff_sv>
function is more convenient.
=cut
@@ -1015,6 +1015,35 @@ Perl_lex_stuff_pvn(pTHX_ const char *pv, STRLEN len, U32 flags)
}
/*
+=for apidoc Amx|void|lex_stuff_pv|const char *pv|U32 flags
+
+Insert characters into the lexer buffer (L</PL_parser-E<gt>linestr>),
+immediately after the current lexing point (L</PL_parser-E<gt>bufptr>),
+reallocating the buffer if necessary. This means that lexing code that
+runs later will see the characters as if they had appeared in the input.
+It is not recommended to do this as part of normal parsing, and most
+uses of this facility run the risk of the inserted characters being
+interpreted in an unintended manner.
+
+The string to be inserted is represented by octets starting at I<pv>
+and continuing to the first nul. These octets are interpreted as either
+UTF-8 or Latin-1, according to whether the C<LEX_STUFF_UTF8> flag is set
+in I<flags>. The characters are recoded for the lexer buffer, according
+to how the buffer is currently being interpreted (L</lex_bufutf8>).
+If it is not convenient to nul-terminate a string to be inserted, the
+L</lex_stuff_pvn> function is more appropriate.
+
+=cut
+*/
+
+void
+Perl_lex_stuff_pv(pTHX_ const char *pv, U32 flags)
+{
+ PERL_ARGS_ASSERT_LEX_STUFF_PV;
+ lex_stuff_pvn(pv, strlen(pv), flags);
+}
+
+/*
=for apidoc Amx|void|lex_stuff_sv|SV *sv|U32 flags
Insert characters into the lexer buffer (L</PL_parser-E<gt>linestr>),
@@ -1027,7 +1056,7 @@ interpreted in an unintended manner.
The string to be inserted is the string value of I<sv>. The characters
are recoded for the lexer buffer, according to how the buffer is currently
-being interpreted (L</lex_bufutf8>). If a string to be interpreted is
+being interpreted (L</lex_bufutf8>). If a string to be inserted is
not already a Perl scalar, the L</lex_stuff_pvn> function avoids the
need to construct a scalar.