From 220534453eecc2c07ad710d72268aafd20b83138 Mon Sep 17 00:00:00 2001 From: joe Date: Fri, 8 May 2015 23:07:47 -0400 Subject: initial commit --- byte_chr.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 byte_chr.c (limited to 'byte_chr.c') 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 @@ +/* Public domain. */ + +#include "byte.h" + +unsigned int byte_chr(s,n,c) +char *s; +register unsigned int n; +int c; +{ + register char ch; + register char *t; + + ch = c; + t = s; + for (;;) { + if (!n) break; if (*t == ch) break; ++t; --n; + if (!n) break; if (*t == ch) break; ++t; --n; + if (!n) break; if (*t == ch) break; ++t; --n; + if (!n) break; if (*t == ch) break; ++t; --n; + } + return t - s; +} -- cgit v1.2.3