runit

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

byte_chr.c (397B)


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