1: /*
   2:  * Copyright (c) 1980 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  *
   6:  *	@(#)rindex_.c	5.2	6/7/85
   7:  *
   8:  * find last occurrence of substring in string
   9:  *
  10:  * calling sequence:
  11:  *	character*(*) substr, string
  12:  *	indx = rindex (string, substr)
  13:  * where:
  14:  *	indx will be the index of the first character of the last occurence
  15:  *	of substr in string, or zero if not found.
  16:  */
  17: 
  18: long rindex_(str, substr, slen, sublen)
  19: char *str, *substr; long slen, sublen;
  20: {
  21:     register char   *p = str + (slen - sublen);
  22:     register char   *p1, *p2;
  23:     register int    len;
  24: 
  25:     if (sublen == 0)
  26:         return(0L);
  27:     while (p >= str) {
  28:         p1 = p;
  29:         p2 = substr;
  30:         len = sublen;
  31:         while ( *p1++ == *p2++ && --len > 0) ;
  32:         if ( len <= 0 )
  33:             return((long)(++p - str));
  34:         p--;
  35:     }
  36:     return(0L);
  37: }

Defined functions

rindex_ defined in line 18; never used
Last modified: 1987-02-18
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1203
Valid CSS Valid XHTML 1.0 Strict