Logo Search packages:      
Sourcecode: bibclean version File versions

strist.c

/* -*-C-*- strist.c */
/*-->strist*/
/**********************************************************************/
/****************************** strist ********************************/
/**********************************************************************/

#include <config.h>
#include "xctype.h"
#include "xstring.h"

RCSID("$Id: strist.c,v 1.1 1995/10/07 15:50:28 beebe Exp beebe $")


/* Return pointer to location of sub[] in s[], ignoring letter case,
else (char*)NULL.  This is a simple implementation; a library version
should use a more sophisticated version (e.g. Boyer-Moore,
Knuth-Morris-Pratt, hardware search). */

char*
#if defined(HAVE_STDC)
stristr(
const char  *s,
const char  *sub
)
#else /* NOT defined(HAVE_STDC) */
stristr(s,sub)
const char  *s;
const char  *sub;
#endif /* defined(HAVE_STDC) */
{
    size_t length;

    length = (size_t)strlen(sub);
    if (s == (const char*)NULL)
      return ((char*)NULL);
    if ((sub == (char*)NULL) || (*sub == '\0'))
      return ((char*)s); /* NULL substring always found at start */
    for (;*s;)
    {
      if (strnicmp(s,sub,length) == 0)
          return ((char*)s);
      ++s;
    }
    return ((char*)NULL);
}

Generated by  Doxygen 1.6.0   Back to index