Annotation of 43BSD/contrib/mh/sbr/smatch.c, revision 1.1.1.1

1.1       root        1: /* smatch.c - match a switch */
                      2: 
                      3: #include "../h/mh.h"
                      4: 
                      5: 
                      6: #define abs(i) (i < 0 ? -i : i)
                      7: 
                      8: 
                      9: smatch(string, swp)
                     10: register char *string;
                     11: register struct swit *swp;
                     12: {
                     13:     register char  *sp,
                     14:                    *tcp;
                     15:     struct swit *tp;
                     16:     int     firstone,
                     17:             stringlen;
                     18: 
                     19:     firstone = UNKWNSW;
                     20: 
                     21:     for (stringlen = strlen (string), tp = swp; tcp = tp -> sw; tp++) {
                     22:        if (stringlen < abs (tp -> minchars))
                     23:            continue;           /* no match */
                     24:        for (sp = string; *sp == *tcp++;) {
                     25:            if (*sp++ == 0)
                     26:                return (tp - swp);/* exact match */
                     27:        }
                     28:        if (*sp != 0) {
                     29:            if (*sp != ' ')
                     30:                continue;       /* no match */
                     31:            if (*--tcp == 0)
                     32:                return (tp - swp);/* exact match */
                     33:        }
                     34:        if (firstone == UNKWNSW)
                     35:            firstone = tp - swp;
                     36:        else
                     37:            firstone = AMBIGSW;
                     38:     }
                     39: 
                     40:     return (firstone);
                     41: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.