]> diplodocus.org Git - nmh/blob - sbr/uprf.c
c17bdfe87e3b4eaef544b519061a805814b25632
[nmh] / sbr / uprf.c
1 /*
2 * uprf.c -- "unsigned" lexical prefix
3 *
4 * This code is Copyright (c) 2002, by the authors of nmh. See the
5 * COPYRIGHT file in the root directory of the nmh distribution for
6 * complete copyright information.
7 */
8
9 #include <h/mh.h>
10
11
12 /* uprf returns true if s starts with prefix, ignoring case.
13 * Otherwise false. If s or prefix are NULL then false results. */
14 int
15 uprf(const char *s, const char *prefix)
16 {
17 unsigned char *us, *up;
18
19 if (!s || !prefix)
20 return 0;
21 us = (unsigned char *)s;
22 up = (unsigned char *)prefix;
23
24 while (*us && tolower(*us) == tolower(*up)) {
25 us++;
26 up++;
27 }
28
29 return *up == '\0';
30 }