ftp.nice.ch/pub/next/unix/developer/plplot.3.0.s.tar.gz#/plplot/src/strpos.c

This is strpos.c in view mode; [Download] [Up]

#include "plplot.h"
#include <ctype.h>
#ifdef PLSTDC
#include <string.h>
#else
extern char *strchr();
#endif

/* Searches string str for first occurence of character chr.  If found */
/* the position of the character in the string is returned (the first  */
/* character has position 0).  If the character is not found a -1 is   */
/* returned. */
int strpos(str,chr)
char *str;
int chr;
{
    char *temp;

    if (temp = strchr(str,chr))
        return((int)(temp - str));
    else
        return((int)-1);
}

int stindex(str1,str2)
char *str1,*str2;
{
    int base;
    int str1ind;
    int str2ind;

    for(base=0; *(str1+base)!='\0'; base++) {
        for(str1ind=base, str2ind=0; *(str2+str2ind)!='\0' &&
            *(str2+str2ind) == *(str1+str1ind); str1ind++, str2ind++)
            ;   /* no body */

        if(*(str2+str2ind) == '\0')
            return((int)base);
    }
    return((int)-1);    /* search failed */
}

/* Searches string str for character chr (case insensitive) */
int stsearch(str,chr)
char *str;
int chr;
{
    if (strchr(str,chr))
        return((int)1);
    else if(strchr(str,toupper(chr)))
        return((int)1);
    else
        return((int)0);
}

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.