summaryrefslogtreecommitdiff
path: root/pod/perlreapi.pod
diff options
context:
space:
mode:
authorKarl Williamson <public@khwilliamson.com>2012-10-09 11:07:18 -0600
committerKarl Williamson <public@khwilliamson.com>2012-10-09 11:16:06 -0600
commit5a2b28cee560cf253bd6a196081dfbe2ac9bb22a (patch)
tree08a144964e695612c317fdc201049cb35feb87d0 /pod/perlreapi.pod
parent5400f398f5599ed8cebbb1b983a820138f7ec643 (diff)
downloadperl-5a2b28cee560cf253bd6a196081dfbe2ac9bb22a.tar.gz
perlreapi.pod: grammar and other nits
Diffstat (limited to 'pod/perlreapi.pod')
-rw-r--r--pod/perlreapi.pod144
1 files changed, 72 insertions, 72 deletions
diff --git a/pod/perlreapi.pod b/pod/perlreapi.pod
index 60b81ff413..6d34185cfb 100644
--- a/pod/perlreapi.pod
+++ b/pod/perlreapi.pod
@@ -1,11 +1,11 @@
=head1 NAME
-perlreapi - perl regular expression plugin interface
+perlreapi - Perl regular expression plugin interface
=head1 DESCRIPTION
-As of Perl 5.9.5 there is a new interface for plugging and using other
-regular expression engines than the default one.
+As of Perl 5.9.5 there is a new interface for plugging and using
+regular expression engines other than the default one.
Each engine is supposed to provide access to a constant structure of the
following format:
@@ -32,7 +32,7 @@ following format:
void (*numbered_buff_STORE) (pTHX_
REGEXP * const rx,
const I32 paren,
- SV const * const value);
+ SV const * const value);
I32 (*numbered_buff_LENGTH) (pTHX_
REGEXP * const rx,
const SV * const sv,
@@ -60,10 +60,10 @@ the right routines to do so.
In order to install a new regexp handler, C<$^H{regcomp}> is set
to an integer which (when casted appropriately) resolves to one of these
structures. When compiling, the C<comp> method is executed, and the
-resulting regexp structure's engine field is expected to point back at
+resulting C<regexp> structure's engine field is expected to point back at
the same structure.
-The pTHX_ symbol in the definition is a macro used by perl under threading
+The pTHX_ symbol in the definition is a macro used by Perl under threading
to provide an extra argument to the routine holding a pointer back to
the interpreter that is executing the regexp. So under threading all
routines get an extra argument.
@@ -80,39 +80,39 @@ the match. See L</The REGEXP structure> below for an explanation of
the individual fields in the REGEXP struct.
The C<pattern> parameter is the scalar that was used as the
-pattern. previous versions of perl would pass two C<char*> indicating
-the start and end of the stringified pattern, the following snippet can
+pattern. Previous versions of Perl would pass two C<char*> indicating
+the start and end of the stringified pattern; the following snippet can
be used to get the old parameters:
STRLEN plen;
char* exp = SvPV(pattern, plen);
char* xend = exp + plen;
-Since any scalar can be passed as a pattern it's possible to implement
+Since any scalar can be passed as a pattern, it's possible to implement
an engine that does something with an array (C<< "ook" =~ [ qw/ eek
hlagh / ] >>) or with the non-stringified form of a compiled regular
-expression (C<< "ook" =~ qr/eek/ >>). perl's own engine will always
-stringify everything using the snippet above but that doesn't mean
+expression (C<< "ook" =~ qr/eek/ >>). Perl's own engine will always
+stringify everything using the snippet above, but that doesn't mean
other engines have to.
The C<flags> parameter is a bitfield which indicates which of the
C<msixp> flags the regex was compiled with. It also contains
-additional info such as whether C<use locale> is in effect.
+additional info, such as if C<use locale> is in effect.
The C<eogc> flags are stripped out before being passed to the comp
-routine. The regex engine does not need to know whether any of these
-are set as those flags should only affect what perl does with the
+routine. The regex engine does not need to know if any of these
+are set, as those flags should only affect what Perl does with the
pattern and its match variables, not how it gets compiled and
executed.
By the time the comp callback is called, some of these flags have
already had effect (noted below where applicable). However most of
-their effect occurs after the comp callback has run in routines that
+their effect occurs after the comp callback has run, in routines that
read the C<< rx->extflags >> field which it populates.
In general the flags should be preserved in C<< rx->extflags >> after
compilation, although the regex engine might want to add or delete
-some of them to invoke or disable some special behavior in perl. The
+some of them to invoke or disable some special behavior in Perl. The
flags along with any special behavior they cause are documented below:
The pattern modifiers:
@@ -131,7 +131,7 @@ as a multi-line string.
=item C</x> - RXf_PMf_EXTENDED
-If present on a regex C<#> comments will be handled differently by the
+If present on a regex, C<"#"> comments will be handled differently by the
tokenizer in some cases.
TODO: Document those cases.
@@ -163,9 +163,9 @@ Additional flags:
=item RXf_SPLIT
If C<split> is invoked as C<split ' '> or with no arguments (which
-really means C<split(' ', $_)>, see L<split|perlfunc/split>), perl will
+really means C<split(' ', $_)>, see L<split|perlfunc/split>), Perl will
set this flag. The regex engine can then check for it and set the
-SKIPWHITE and WHITE extflags. To do this the perl engine does:
+SKIPWHITE and WHITE extflags. To do this, the Perl engine does:
if (flags & RXf_SPLIT && r->prelen == 1 && r->precomp[0] == ' ')
r->extflags |= (RXf_SKIPWHITE|RXf_WHITE);
@@ -181,11 +181,11 @@ the C<split> operator.
If the flag is present in C<< rx->extflags >> C<split> will delete
whitespace from the start of the subject string before it's operated
-on. What is considered whitespace depends on whether the subject is a
-UTF-8 string and whether the C<RXf_PMf_LOCALE> flag is set.
+on. What is considered whitespace depends on if the subject is a
+UTF-8 string and if the C<RXf_PMf_LOCALE> flag is set.
-If RXf_WHITE is set in addition to this flag C<split> will behave like
-C<split " "> under the perl engine.
+If RXf_WHITE is set in addition to this flag, C<split> will behave like
+C<split " "> under the Perl engine.
=item RXf_START_ONLY
@@ -193,7 +193,7 @@ Tells the split operator to split the target string on newlines
(C<\n>) without invoking the regex engine.
Perl's engine sets this if the pattern is C</^/> (C<plen == 1 && *exp
-== '^'>), even under C</^/s>, see L<split|perlfunc>. Of course a
+== '^'>), even under C</^/s>; see L<split|perlfunc>. Of course a
different regex engine might want to use the same optimizations
with a different syntax.
@@ -201,15 +201,15 @@ with a different syntax.
Tells the split operator to split the target string on whitespace
without invoking the regex engine. The definition of whitespace varies
-depending on whether the target string is a UTF-8 string and on
-whether RXf_PMf_LOCALE is set.
+depending on if the target string is a UTF-8 string and on
+if RXf_PMf_LOCALE is set.
Perl's engine sets this flag if the pattern is C<\s+>.
=item RXf_NULL
Tells the split operator to split the target string on
-characters. The definition of character varies depending on whether
+characters. The definition of character varies depending on if
the target string is a UTF-8 string.
Perl's engine sets this flag on empty patterns, this optimization
@@ -246,7 +246,7 @@ Pointer to the physical start of the string.
=item strend
Pointer to the character following the physical end of the string (i.e.
-the \0).
+the C<\0>).
=item stringarg
@@ -276,9 +276,9 @@ Optimisation flags; subject to change.
const U32 flags, struct re_scream_pos_data_s *data);
Find the start position where a regex match should be attempted,
-or possibly whether the regex engine should not be run because the
-pattern can't match. This is called as appropriate by the core
-depending on the values of the extflags member of the regexp
+or possibly if the regex engine should not be run because the
+pattern can't match. This is called, as appropriate, by the core,
+depending on the values of the C<extflags> member of the C<regexp>
structure.
=head2 checkstr
@@ -292,10 +292,10 @@ by C<split> for optimising matches.
void free(pTHX_ REGEXP * const rx);
-Called by perl when it is freeing a regexp pattern so that the engine
+Called by Perl when it is freeing a regexp pattern so that the engine
can release any resources pointed to by the C<pprivate> member of the
-regexp structure. This is only responsible for freeing private data;
-perl will handle releasing anything else contained in the regexp structure.
+C<regexp> structure. This is only responsible for freeing private data;
+Perl will handle releasing anything else contained in the C<regexp> structure.
=head2 Numbered capture callbacks
@@ -313,7 +313,7 @@ forth, and have these symbolic values for the special variables:
$' RX_BUFF_IDX_POSTMATCH
$& RX_BUFF_IDX_FULLMATCH
-Note that in perl 5.17.3 and earlier, the last three constants were also
+Note that in Perl 5.17.3 and earlier, the last three constants were also
used for the caret variants of the variables.
@@ -329,12 +329,12 @@ implemented via magic.
Fetch a specified numbered capture. C<sv> should be set to the scalar
to return, the scalar is passed as an argument rather than being
-returned from the function because when it's called perl already has a
+returned from the function because when it's called Perl already has a
scalar to store the value, creating another one would be
redundant. The scalar can be set with C<sv_setsv>, C<sv_setpvn> and
friends, see L<perlapi>.
-This callback is where perl untaints its own capture variables under
+This callback is where Perl untaints its own capture variables under
taint mode (see L<perlsec>). See the C<Perl_reg_numbered_buff_fetch>
function in F<regcomp.c> for how to untaint capture variables if
that's something you'd like your engine to do as well.
@@ -375,9 +375,9 @@ variables, to do this in another engine use the following callback
Perl_croak(aTHX_ PL_no_modify);
}
-Actually perl will not I<always> croak in a statement that looks
+Actually Perl will not I<always> croak in a statement that looks
like it would modify a numbered capture variable. This is because the
-STORE callback will not be called if perl can determine that it
+STORE callback will not be called if Perl can determine that it
doesn't have to modify the value. This is exactly how tied variables
behave in the same situation:
@@ -393,10 +393,10 @@ behave in the same situation:
tie my $sv => "CaptureVar";
$sv =~ y/a/b/;
-Because C<$sv> is C<undef> when the C<y///> operator is applied to it
+Because C<$sv> is C<undef> when the C<y///> operator is applied to it,
the transliteration won't actually execute and the program won't
C<die>. This is different to how 5.8 and earlier versions behaved
-since the capture variables were READONLY variables then, now they'll
+since the capture variables were READONLY variables then; now they'll
just die when assigned to in the default engine.
=head3 numbered_buff_LENGTH
@@ -407,9 +407,9 @@ just die when assigned to in the default engine.
const I32 paren);
Get the C<length> of a capture variable. There's a special callback
-for this so that perl doesn't have to do a FETCH and run C<length> on
-the result, since the length is (in perl's case) known from an offset
-stored in C<< rx->offs >> this is much more efficient:
+for this so that Perl doesn't have to do a FETCH and run C<length> on
+the result, since the length is (in Perl's case) known from an offset
+stored in C<< rx->offs >>, this is much more efficient:
I32 s1 = rx->offs[paren].start;
I32 s2 = rx->offs[paren].end;
@@ -421,7 +421,7 @@ L<is_utf8_string_loclen|perlapi/is_utf8_string_loclen>.
=head2 Named capture callbacks
-Called to get/set the value of C<%+> and C<%-> as well as by some
+Called to get/set the value of C<%+> and C<%->, as well as by some
utility functions in L<re>.
There are two callbacks, C<named_buff> is called in all the cases the
@@ -430,7 +430,7 @@ would be on changes to C<%+> and C<%-> and C<named_buff_iter> in the
same cases as FIRSTKEY and NEXTKEY.
The C<flags> parameter can be used to determine which of these
-operations the callbacks should respond to, the following flags are
+operations the callbacks should respond to. The following flags are
currently defined:
Which L<Tie::Hash> operation is being performed from the Perl level on
@@ -445,12 +445,12 @@ C<%+> or C<%+>, if any:
RXapif_FIRSTKEY
RXapif_NEXTKEY
-Whether C<%+> or C<%-> is being operated on, if any.
+If C<%+> or C<%-> is being operated on, if any.
RXapif_ONE /* %+ */
RXapif_ALL /* %- */
-Whether this is being called as C<re::regname>, C<re::regnames> or
+If this is being called as C<re::regname>, C<re::regnames> or
C<re::regnames_count>, if any. The first two will be combined with
C<RXapif_ONE> or C<RXapif_ALL>.
@@ -483,7 +483,7 @@ releases. For instance this might be implemented by magic instead
The package the qr// magic object is blessed into (as seen by C<ref
qr//>). It is recommended that engines change this to their package
-name for identification regardless of whether they implement methods
+name for identification regardless of if they implement methods
on the object.
The package this method returns should also have the internal
@@ -521,10 +521,10 @@ Functions>.
On threaded builds a regexp may need to be duplicated so that the pattern
can be used by multiple threads. This routine is expected to handle the
duplication of any private data pointed to by the C<pprivate> member of
-the regexp structure. It will be called with the preconstructed new
-regexp structure as an argument, the C<pprivate> member will point at
+the C<regexp> structure. It will be called with the preconstructed new
+C<regexp> structure as an argument, the C<pprivate> member will point at
the B<old> private structure, and it is this routine's responsibility to
-construct a copy and return a pointer to it (which perl will then use to
+construct a copy and return a pointer to it (which Perl will then use to
overwrite the field as passed to this routine.)
This allows the engine to dupe its private data but also if necessary
@@ -534,7 +534,7 @@ On unthreaded builds this field doesn't exist.
=head2 op_comp
-This is private to the perl core and subject to change. Should be left
+This is private to the Perl core and subject to change. Should be left
null.
=head1 The REGEXP structure
@@ -542,19 +542,19 @@ null.
The REGEXP struct is defined in F<regexp.h>. All regex engines must be able to
correctly build such a structure in their L</comp> routine.
-The REGEXP structure contains all the data that perl needs to be aware of
+The REGEXP structure contains all the data that Perl needs to be aware of
to properly work with the regular expression. It includes data about
-optimisations that perl can use to determine if the regex engine should
+optimisations that Perl can use to determine if the regex engine should
really be used, and various other control info that is needed to properly
-execute patterns in various contexts such as is the pattern anchored in
-some way, or what flags were used during the compile, or whether the
-program contains special constructs that perl needs to be aware of.
+execute patterns in various contexts, such as if the pattern anchored in
+some way, or what flags were used during the compile, or if the
+program contains special constructs that Perl needs to be aware of.
In addition it contains two fields that are intended for the private
use of the regex engine that compiled the pattern. These are the
C<intflags> and C<pprivate> members. C<pprivate> is a void pointer to
-an arbitrary structure whose use and management is the responsibility
-of the compiling engine. perl will never modify either of these
+an arbitrary structure, whose use and management is the responsibility
+of the compiling engine. Perl will never modify either of these
values.
typedef struct regexp {
@@ -564,7 +564,7 @@ values.
/* what re is this a lightweight copy of? */
struct regexp* mother_re;
- /* Information about the match that the perl core uses to manage
+ /* Information about the match that the Perl core uses to manage
* things */
U32 extflags; /* Flags used both externally and internally */
I32 minlen; /* mininum possible number of chars in */
@@ -618,13 +618,13 @@ The fields are discussed in more detail below:
=head2 C<engine>
-This field points at a regexp_engine structure which contains pointers
+This field points at a C<regexp_engine> structure which contains pointers
to the subroutines that are to be used for performing a match. It
is the compiling routine's responsibility to populate this field before
returning the regexp object.
Internally this is set to C<NULL> unless a custom engine is specified in
-C<$^H{regcomp}>, perl's own set of callbacks can be accessed in the struct
+C<$^H{regcomp}>, Perl's own set of callbacks can be accessed in the struct
pointed to by C<RE_ENGINE_PTR>.
=head2 C<mother_re>
@@ -633,7 +633,7 @@ TODO, see L<http://www.mail-archive.com/perl5-changes@perl.org/msg17328.html>
=head2 C<extflags>
-This will be used by perl to see what flags the regexp was compiled
+This will be used by Perl to see what flags the regexp was compiled
with, this will normally be set to the value of the flags parameter by
the L<comp|/comp> callback. See the L<comp|/comp> documentation for
valid flags.
@@ -658,8 +658,8 @@ following pattern:
where the C<minlen> would be 3 but C<minlenret> would only be 2 as the \d is
required to match but is not actually included in the matched content. This
distinction is particularly important as the substitution logic uses the
-C<minlenret> to tell whether it can do in-place substitution which can result in
-considerable speedup.
+C<minlenret> to tell if it can do in-place substitutions (these can
+result in considerable speed-up).
=head2 C<gofs>
@@ -668,7 +668,7 @@ Left offset from pos() to start match at.
=head2 C<substrs>
Substring data about strings that must appear in the final match. This
-is currently only used internally by perl's engine for but might be
+is currently only used internally by Perl's engine, but might be
used in the future for all engines for optimisations.
=head2 C<nparens>, C<lastparen>, and C<lastcloseparen>
@@ -684,13 +684,13 @@ this is the same as C<extflags> unless the engine chose to modify one of them.
=head2 C<pprivate>
-A void* pointing to an engine-defined data structure. The perl engine uses the
+A void* pointing to an engine-defined data structure. The Perl engine uses the
C<regexp_internal> structure (see L<perlreguts/Base Structures>) but a custom
engine should use something else.
=head2 C<swap>
-Unused. Left in for compatibility with perl 5.10.0.
+Unused. Left in for compatibility with Perl 5.10.0.
=head2 C<offs>
@@ -713,7 +713,7 @@ C<$paren >= 1>.
Used for optimisations. C<precomp> holds a copy of the pattern that
was compiled and C<prelen> its length. When a new pattern is to be
compiled (such as inside a loop) the internal C<regcomp> operator
-checks whether the last compiled C<REGEXP>'s C<precomp> and C<prelen>
+checks if the last compiled C<REGEXP>'s C<precomp> and C<prelen>
are equivalent to the new one, and if so uses the old pattern instead
of compiling a new one.
@@ -760,7 +760,7 @@ which work in characters, not bytes.
=head2 C<wrapped> C<wraplen>
-Stores the string C<qr//> stringifies to. The perl engine for example
+Stores the string C<qr//> stringifies to. The Perl engine for example
stores C<(?^:eek)> in the case of C<qr/eek/>.
When using a custom engine that doesn't support the C<(?:)> construct
@@ -782,7 +782,7 @@ purposes when embedding compiled regexes into larger patterns with C<qr//>.
=head2 C<refcnt>
-The number of times the structure is referenced. When this falls to 0 the
+The number of times the structure is referenced. When this falls to 0, the
regexp is automatically freed by a call to pregfree. This should be set to 1 in
each engine's L</comp> routine.