runit

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

byte_rchr.c (455B)


      1 /* Public domain. */
      2 
      3 #include "byte.h"
      4 
      5 unsigned int byte_rchr(s,n,c)
      6 char *s;
      7 register unsigned int n;
      8 int c;
      9 {
     10   register char ch;
     11   register char *t;
     12   register char *u;
     13 
     14   ch = c;
     15   t = s;
     16   u = 0;
     17   for (;;) {
     18     if (!n) break; if (*t == ch) u = t; ++t; --n;
     19     if (!n) break; if (*t == ch) u = t; ++t; --n;
     20     if (!n) break; if (*t == ch) u = t; ++t; --n;
     21     if (!n) break; if (*t == ch) u = t; ++t; --n;
     22   }
     23   if (!u) u = t;
     24   return u - s;
     25 }