home *** CD-ROM | disk | FTP | other *** search
-
- /*
- * Copyright (C) 1990 Jay Konigsberg - see Makefile for details
- * This is Free Software, distrubited under the GNU Software Aggrement.
- */
-
- /*
- * position - locate the first occurence of substr in string and
- * return the subscript
- */
- #include "simped.h"
-
- int position(substr, string)
- char substr[];
- char string[];
- {
- int strinx, /* index for string */
- subinx, /* index for substr */
- sublen, /* length of substr */
- found=FALSE; /* boolean - is a match found? */
-
- sublen=strlen(substr);
- for(strinx=0; strinx < strlen(string); ++strinx)
- {
- for (subinx=0; subinx < sublen; ++subinx)
- {
- if (substr[subinx] == string[strinx+subinx])
- {
- found=TRUE;
- }
- else
- {
- found=FALSE;
- break;
- }
- }
- if (subinx == sublen && found)
- break;
- }
- if (! found)
- strinx = -1;
- return(strinx);
- }
-