X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=sbr%2Fseq_nameok.c;h=f9ed1b0e4cbcde0bace709252e0df4632dad9ce0;hb=8041c8a4001e576d7600efaaf6628a791263490d;hp=66319b5ef4368ffcb8701416f1d1a13722192d59;hpb=1691e80890e5d8ba258c51c214a3e91880e1db2b;p=mmh diff --git a/sbr/seq_nameok.c b/sbr/seq_nameok.c index 66319b5..f9ed1b0 100644 --- a/sbr/seq_nameok.c +++ b/sbr/seq_nameok.c @@ -1,54 +1,55 @@ - /* - * seq_nameok.c -- check if a sequence name is ok - * - * $Id$ - */ +** seq_nameok.c -- check if a sequence name is ok +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include int -seq_nameok (char *s) +seq_nameok(unsigned char *s) { - char *pp; - - if (s == NULL || *s == '\0') { - advise (NULL, "empty sequence name"); - return 0; - } - - /* - * Make sure sequence name doesn't clash with one - * of the `reserved' sequence names. - */ - if (!(strcmp (s, "new") && - strcmp (s, "all") && - strcmp (s, "first") && - strcmp (s, "last") && - strcmp (s, "prev") && - strcmp (s, "next"))) { - advise (NULL, "illegal sequence name: %s", s); - return 0; - } - - /* - * First character in a sequence name must be - * an alphabetic character ... - */ - if (!isalpha (*s)) { - advise (NULL, "illegal sequence name: %s", s); - return 0; - } - - /* - * and can be followed by zero or more alphanumeric characters - */ - for (pp = s + 1; *pp; pp++) - if (!isalnum (*pp)) { - advise (NULL, "illegal sequence name: %s", s); - return 0; + unsigned char *pp; + + if (s == NULL || *s == '\0') { + advise(NULL, "empty sequence name"); + return 0; + } + + /* + ** Make sure sequence name doesn't clash with one + ** of the `reserved' sequence names. + */ + if (!(strcmp(s, "new") && + strcmp(s, "all") && + strcmp(s, "first") && + strcmp(s, "last") && + strcmp(s, "prev") && + strcmp(s, "next"))) { + advise(NULL, "illegal sequence name: %s", s); + return 0; } - return 1; + /* + ** First character in a sequence name must be + ** an alphabetic character ... + */ + if (!isalpha(*s)) { + advise(NULL, "illegal sequence name: %s", s); + return 0; + } + + /* + ** and can be followed by zero or more alphanumeric characters + */ + for (pp = s + 1; *pp; pp++) + if (!isalnum(*pp)) { + advise(NULL, "illegal sequence name: %s", s); + return 0; + } + + return 1; }