++ed by:
ABRAXXA ADAMJS ALEXBIO ANDREFS ARJONES

117 PAUSE user(s)
93 non-PAUSE user(s).

Ricardo SIGNES

Miscellaneous Functions

Analyses the string in order to make fast searches on it using fbm_instr() -- the Boyer-Moore algorithm.

Returns the location of the SV in the string delimited by big and bigend. It returns NULL if the string can't be found. The sv does not have to be fbm_compiled, but the search will not be as fast then.

Returns true if the leading len bytes of the strings s1 and s2 are the same case-insensitively; false otherwise. Uppercase and lowercase ASCII range bytes match themselves and their opposite case counterparts. Non-cased and non-ASCII range bytes match only themselves.

Returns true if the leading len bytes of the strings s1 and s2 are the same case-insensitively in the current locale; false otherwise.

Memory Management

Perl's version of strdup(). Returns a pointer to a newly allocated string which is a duplicate of pv. The size of the string is determined by strlen(). The memory allocated for the new string can be freed with the Safefree() function.

Perl's version of what strndup() would be if it existed. Returns a pointer to a newly allocated string which is a duplicate of the first len bytes from pv, plus a trailing NUL byte. The memory allocated for the new string can be freed with the Safefree() function.

A version of savepv() which allocates the duplicate string in memory which is shared between threads.

A version of savepvn() which allocates the duplicate string in memory which is shared between threads. (With the specific difference that a NULL pointer is not acceptable)

A version of savepv()/savepvn() which gets the string to duplicate from the passed in SV using SvPV()

A version of savesharedpv() which allocates the duplicate string in memory which is shared between threads.

Miscellaneous Functions =for apidoc form

Takes a sprintf-style format pattern and conventional (non-SV) arguments and returns the formatted string.

    (char *) Perl_form(pTHX_ const char* pat, ...)

can be used any place a string (char *) is required:

    char * s = Perl_form("%d.%d",major,minor);

Uses a single private buffer so if you want to format several strings you must explicitly copy the earlier strings away (and free the copies when you are done).

Take a sprintf-style format pattern and argument list. These are used to generate a string message. If the message does not end with a newline, then it will be extended with some indication of the current location in the code, as described for "mess_sv".

Normally, the resulting message is returned in a new mortal SV. During global destruction a single SV may be shared between uses of this function.

Expands a message, intended for the user, to include an indication of the current location in the code, if the message does not already appear to be complete.

basemsg is the initial message or object. If it is a reference, it will be used as-is and will be the result of this function. Otherwise it is used as a string, and if it already ends with a newline, it is taken to be complete, and the result of this function will be the same string. If the message does not end with a newline, then a segment such as at foo.pl line 37 will be appended, and possibly other clauses indicating the current state of execution. The resulting message will end with a dot and a newline.

Normally, the resulting message is returned in a new mortal SV. During global destruction a single SV may be shared between uses of this function. If consume is true, then the function is permitted (but not required) to modify and return basemsg instead of allocating a new SV.

pat and args are a sprintf-style format pattern and encapsulated argument list. These are used to generate a string message. If the message does not end with a newline, then it will be extended with some indication of the current location in the code, as described for "mess_sv".

Normally, the resulting message is returned in a new mortal SV. During global destruction a single SV may be shared between uses of this function.

Warning and Dieing */

/* Common code used in dieing and warning */

STATIC SV * S_with_queued_errors(pTHX_ SV *ex) { PERL_ARGS_ASSERT_WITH_QUEUED_ERRORS; if (PL_errors && SvCUR(PL_errors) && !SvROK(ex)) { sv_catsv(PL_errors, ex); ex = sv_mortalcopy(PL_errors); SvCUR_set(PL_errors, 0); } return ex; }

STATIC bool S_invoke_exception_hook(pTHX_ SV *ex, bool warn) { dVAR; HV *stash; GV *gv; CV *cv; SV **const hook = warn ? &PL_warnhook : &PL_diehook; /* sv_2cv might call Perl_croak() or Perl_warner() */ SV * const oldhook = *hook;

    if (!oldhook)
        return FALSE;

    ENTER;
    SAVESPTR(*hook);
    *hook = NULL;
    cv = sv_2cv(oldhook, &stash, &gv, 0);
    LEAVE;
    if (cv && !CvDEPTH(cv) && (CvROOT(cv) || CvXSUB(cv))) {
        dSP;
        SV *exarg;

        ENTER;
        save_re_context();
        if (warn) {
            SAVESPTR(*hook);
            *hook = NULL;
        }
        exarg = newSVsv(ex);
        SvREADONLY_on(exarg);
        SAVEFREESV(exarg);

        PUSHSTACKi(warn ? PERLSI_WARNHOOK : PERLSI_DIEHOOK);
        PUSHMARK(SP);
        XPUSHs(exarg);
        PUTBACK;
        call_sv(MUTABLE_SV(cv), G_DISCARD);
        POPSTACK;
        LEAVE;
        return TRUE;
    }
    return FALSE;
}

/* =for apidoc Am|OP *|die_sv|SV *baseex

Behaves the same as "croak_sv", except for the return type. It should be used only where the OP * return type is required. The function never actually returns.

Behaves the same as "croak", except for the return type. It should be used only where the OP * return type is required. The function never actually returns.

This is an XS interface to Perl's die function.

baseex is the error message or object. If it is a reference, it will be used as-is. Otherwise it is used as a string, and if it does not end with a newline then it will be extended with some indication of the current location in the code, as described for "mess_sv".

The error message or object will be used as an exception, by default returning control to the nearest enclosing eval, but subject to modification by a $SIG{__DIE__} handler. In any case, the croak_sv function never returns normally.

To die with a simple string message, the "croak" function may be more convenient.

This is an XS interface to Perl's die function.

pat and args are a sprintf-style format pattern and encapsulated argument list. These are used to generate a string message. If the message does not end with a newline, then it will be extended with some indication of the current location in the code, as described for "mess_sv".

The error message will be used as an exception, by default returning control to the nearest enclosing eval, but subject to modification by a $SIG{__DIE__} handler. In any case, the croak function never returns normally.

For historical reasons, if pat is null then the contents of ERRSV ($@) will be used as an error message or object instead of building an error message from arguments. If you want to throw a non-string object, or build an error message in an SV yourself, it is preferable to use the "croak_sv" function, which does not involve clobbering ERRSV.

This is an XS interface to Perl's die function.

Take a sprintf-style format pattern and argument list. These are used to generate a string message. If the message does not end with a newline, then it will be extended with some indication of the current location in the code, as described for "mess_sv".

The error message will be used as an exception, by default returning control to the nearest enclosing eval, but subject to modification by a $SIG{__DIE__} handler. In any case, the croak function never returns normally.

For historical reasons, if pat is null then the contents of ERRSV ($@) will be used as an error message or object instead of building an error message from arguments. If you want to throw a non-string object, or build an error message in an SV yourself, it is preferable to use the "croak_sv" function, which does not involve clobbering ERRSV.

Exactly equivalent to Perl_croak(aTHX_ "%s", PL_no_modify), but generates terser object code than using Perl_croak. Less code used on exception code paths reduces CPU cache pressure.

This is an XS interface to Perl's warn function.

baseex is the error message or object. If it is a reference, it will be used as-is. Otherwise it is used as a string, and if it does not end with a newline then it will be extended with some indication of the current location in the code, as described for "mess_sv".

The error message or object will by default be written to standard error, but this is subject to modification by a $SIG{__WARN__} handler.

To warn with a simple string message, the "warn" function may be more convenient.

This is an XS interface to Perl's warn function.

pat and args are a sprintf-style format pattern and encapsulated argument list. These are used to generate a string message. If the message does not end with a newline, then it will be extended with some indication of the current location in the code, as described for "mess_sv".

The error message or object will by default be written to standard error, but this is subject to modification by a $SIG{__WARN__} handler.

Unlike with "vcroak", pat is not permitted to be null.

This is an XS interface to Perl's warn function.

Take a sprintf-style format pattern and argument list. These are used to generate a string message. If the message does not end with a newline, then it will be extended with some indication of the current location in the code, as described for "mess_sv".

The error message or object will by default be written to standard error, but this is subject to modification by a $SIG{__WARN__} handler.

Unlike with "croak", pat is not permitted to be null.

Miscellaneous Functions

Fill the sv with current working directory

Validate that a given string can be parsed as a version object, but doesn't actually perform the parsing. Can use either strict or lax validation rules. Can optionally set a number of hint variables to save the parsing code some time when tokenizing.

Returns a pointer to the next character after the parsed version string, as well as upgrading the passed in SV to an RV.

Function must be called with an already existing SV like

    sv = newSV(0);
    s = scan_version(s, SV *sv, bool qv);

Performs some preprocessing to the string to ensure that it has the correct characteristics of a version. Flags the object if it contains an underscore (which denotes this is an alpha version). The boolean qv denotes that the version should be interpreted as if it had multiple decimals, even if it doesn't.

Returns a new version object based on the passed in SV:

    SV *sv = new_version(SV *ver);

Does not alter the passed in ver SV. See "upg_version" if you want to upgrade the SV.

In-place upgrade of the supplied SV to a version object.

    SV *sv = upg_version(SV *sv, bool qv);

Returns a pointer to the upgraded SV. Set the boolean qv if you want to force this SV to be interpreted as an "extended" version.

Validates that the SV contains valid internal structure for a version object. It may be passed either the version object (RV) or the hash itself (HV). If the structure is valid, it returns the HV. If the structure is invalid, it returns NULL.

    SV *hv = vverify(sv);

Note that it only confirms the bare minimum structure (so as not to get confused by derived classes which may contain additional hash entries):

  • The SV is an HV or a reference to an HV

  • The hash contains a "version" key

  • The "version" key has a reference to an AV as its value

Accepts a version object and returns the normalized floating point representation. Call like:

    sv = vnumify(rv);

NOTE: you can pass either the object directly or the SV contained within the RV.

The SV returned has a refcount of 1.

Accepts a version object and returns the normalized string representation. Call like:

    sv = vnormal(rv);

NOTE: you can pass either the object directly or the SV contained within the RV.

The SV returned has a refcount of 1.

In order to maintain maximum compatibility with earlier versions of Perl, this function will return either the floating point notation or the multiple dotted notation, depending on whether the original version contained 1 or more dots, respectively.

The SV returned has a refcount of 1.

Version object aware cmp. Both operands must already have been converted into version objects.

Dummy routine which "shares" an SV when there is no sharing module present. Or "locks" it. Or "unlocks" it. In other words, ignores its single SV argument. Exists to avoid test for a NULL function pointer and because it could potentially warn under some level of strict-ness.

Dummy routine which reports that object can be destroyed when there is no sharing module present. It ignores its single SV argument, and returns 'true'. Exists to avoid test for a NULL function pointer and because it could potentially warn under some level of strict-ness.

The C library sprintf, wrapped if necessary, to ensure that it will return the length of the string written to the buffer. Only rare pre-ANSI systems need the wrapper function - usually this is a direct call to sprintf.

The C library snprintf functionality, if available and standards-compliant (uses vsnprintf, actually). However, if the vsnprintf is not available, will unfortunately use the unsafe vsprintf which can overrun the buffer (there is an overrun check, but that may be too late). Consider using sv_vcatpvf instead, or getting vsnprintf.

The C library vsnprintf if available and standards-compliant. However, if if the vsnprintf is not available, will unfortunately use the unsafe vsprintf which can overrun the buffer (there is an overrun check, but that may be too late). Consider using sv_vcatpvf instead, or getting vsnprintf.




Hosting generously
sponsored by Bytemark