summaryrefslogtreecommitdiff
path: root/byte_chr.c
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2015-05-08 23:07:47 -0400
committerjoe <joe@jerkface.net>2015-05-08 23:07:47 -0400
commit220534453eecc2c07ad710d72268aafd20b83138 (patch)
tree469bd5db135e31b7ea908152aa3389b9b1e06d5b /byte_chr.c
initial commit
Diffstat (limited to 'byte_chr.c')
-rw-r--r--byte_chr.c22
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
5unsigned int byte_chr(s,n,c)
6char *s;
7register unsigned int n;
8int 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}