Back to index

lightning-sunbird  0.9+nobinonly
Functions
strstr.c File Reference
#include "plstr.h"
#include <string.h>

Go to the source code of this file.

Functions

 PL_strstr (const char *big, const char *little)
 PL_strrstr (const char *big, const char *little)
 PL_strnstr (const char *big, const char *little, PRUint32 max)
 PL_strnrstr (const char *big, const char *little, PRUint32 max)

Function Documentation

PL_strnrstr ( const char *  big,
const char *  little,
PRUint32  max 
)

Definition at line 95 of file strstr.c.

{
    const char *p;
    size_t ll;

    if( ((const char *)0 == big) || ((const char *)0 == little) ) return (char *)0;
    if( ((char)0 == *big) || ((char)0 == *little) ) return (char *)0;

    ll = strlen(little);

    for( p = big; max && *p; p++, max-- )
        ;

    p -= ll;
    if( p < big ) return (char *)0;

    for( ; p >= big; p-- )
        if( *little == *p )
            if( 0 == strncmp(p, little, ll) )
                return (char *)p;

    return (char *)0;
}

Here is the caller graph for this function:

PL_strnstr ( const char *  big,
const char *  little,
PRUint32  max 
)

Definition at line 74 of file strstr.c.

{
    size_t ll;

    if( ((const char *)0 == big) || ((const char *)0 == little) ) return (char *)0;
    if( ((char)0 == *big) || ((char)0 == *little) ) return (char *)0;

    ll = strlen(little);
    if( ll > (size_t)max ) return (char *)0;
    max -= (PRUint32)ll;
    max++;

    for( ; max && *big; big++, max-- )
        if( *little == *big )
            if( 0 == strncmp(big, little, ll) )
                return (char *)big;

    return (char *)0;
}

Here is the caller graph for this function:

PL_strrstr ( const char *  big,
const char *  little 
)

Definition at line 51 of file strstr.c.

{
    const char *p;
    size_t ll;
    size_t bl;

    if( ((const char *)0 == big) || ((const char *)0 == little) ) return (char *)0;
    if( ((char)0 == *big) || ((char)0 == *little) ) return (char *)0;

    ll = strlen(little);
    bl = strlen(big);
    if( bl < ll ) return (char *)0;
    p = &big[ bl - ll ];

    for( ; p >= big; p-- )
        if( *little == *p )
            if( 0 == strncmp(p, little, ll) )
                return (char *)p;

    return (char *)0;
}

Here is the caller graph for this function:

PL_strstr ( const char *  big,
const char *  little 
)

Definition at line 42 of file strstr.c.

{
    if( ((const char *)0 == big) || ((const char *)0 == little) ) return (char *)0;
    if( ((char)0 == *big) || ((char)0 == *little) ) return (char *)0;

    return strstr(big, little);
}

Here is the caller graph for this function: