Renamed all standard sequences (e.g. cur->c) and made them globally changeable
[mmh] / sbr / seq_nameok.c
index f9ed1b0..a61dd9c 100644 (file)
@@ -1,5 +1,5 @@
 /*
-** seq_nameok.c -- check if a sequence name is ok
+** seq_nameok.c -- check if a name is ok for a user-defined sequence
 **
 ** This code is Copyright (c) 2002, by the authors of nmh.  See the
 ** COPYRIGHT file in the root directory of the nmh distribution for
@@ -9,6 +9,9 @@
 #include <h/mh.h>
 
 
+/*
+** returns true if it is a valid name for a user-defined sequence
+*/
 int
 seq_nameok(unsigned char *s)
 {
@@ -22,14 +25,12 @@ seq_nameok(unsigned char *s)
        /*
        ** Make sure sequence name doesn't clash with one
        ** of the `reserved' sequence names.
+       ** Note: Accept `cur' here! But why is it treated special? --meillo
        */
-       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);
+       if (strcmp(s, seq_first)==0 || strcmp(s, seq_last)==0 ||
+                       strcmp(s, seq_prev)==0 || strcmp(s, seq_next)==0 ||
+                       strcmp(s, seq_all)==0 || strcmp(s, seq_beyond)==0) {
+               advise(NULL, "collision with reserved sequence name: `%s'", s);
                return 0;
        }
 
@@ -38,18 +39,20 @@ seq_nameok(unsigned char *s)
        ** an alphabetic character ...
        */
        if (!isalpha(*s)) {
-               advise(NULL, "illegal sequence name: %s", s);
+               advise(NULL, "sequence name must start with a letter: %s", s);
                return 0;
        }
 
        /*
        ** and can be followed by zero or more alphanumeric characters
        */
-       for (pp = s + 1; *pp; pp++)
+       for (pp = s+1; *pp; pp++) {
                if (!isalnum(*pp)) {
-                       advise(NULL, "illegal sequence name: %s", s);
+                       advise(NULL, "sequence name must only contain "
+                                       "letters and digits: %s", s);
                        return 0;
                }
+       }
 
        return 1;
 }