diff options
Diffstat (limited to 'byte_chr.c')
-rw-r--r-- | byte_chr.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/byte_chr.c b/byte_chr.c new file mode 100644 index 0000000..fd56056 --- /dev/null +++ b/byte_chr.c | |||
@@ -0,0 +1,22 @@ | |||
1 | /* Public domain. */ | ||
2 | |||
3 | #include "byte.h" | ||
4 | |||
5 | unsigned int byte_chr(s,n,c) | ||
6 | char *s; | ||
7 | register unsigned int n; | ||
8 | int c; | ||
9 | { | ||
10 | register char ch; | ||
11 | register char *t; | ||
12 | |||
13 | ch = c; | ||
14 | t = s; | ||
15 | for (;;) { | ||
16 | if (!n) break; if (*t == ch) break; ++t; --n; | ||
17 | if (!n) break; if (*t == ch) break; ++t; --n; | ||
18 | if (!n) break; if (*t == ch) break; ++t; --n; | ||
19 | if (!n) break; if (*t == ch) break; ++t; --n; | ||
20 | } | ||
21 | return t - s; | ||
22 | } | ||