X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=sbr%2Fsmatch.c;h=5bee67ffc8b1d2ab035eec55d4ae27e0287594a0;hp=88a098b3a0e629678b3c386eb1f51e728aacf33f;hb=b6823062c9806496b39ff12bf1fbe43ae127c96c;hpb=5dd6771b28c257af405d7248639ed0e3bcdce38b diff --git a/sbr/smatch.c b/sbr/smatch.c index 88a098b..5bee67f 100644 --- a/sbr/smatch.c +++ b/sbr/smatch.c @@ -1,11 +1,10 @@ - /* - * smatch.c -- match a switch (option) - * - * 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. - */ +** smatch.c -- match a switch (option) +** +** 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 @@ -13,35 +12,35 @@ int smatch(char *string, struct swit *swp) { - char *sp, *tcp; - int firstone, len; - struct swit *tp; - - firstone = UNKWNSW; - - if (!string) - return firstone; - len = strlen(string); - - for (tp = swp; tp->sw; tp++) { - tcp = tp->sw; - if (len < abs(tp->minchars)) - continue; /* no match */ - for (sp = string; *sp == *tcp++;) { - if (*sp++ == '\0') - return (tp - swp); /* exact match */ - } - if (*sp) { - if (*sp != ' ') - continue; /* no match */ - if (*--tcp == '\0') - return (tp - swp); /* exact match */ + char *sp, *tcp; + int firstone, len; + struct swit *tp; + + firstone = UNKWNSW; + + if (!string) + return firstone; + len = strlen(string); + + for (tp = swp; tp->sw; tp++) { + tcp = tp->sw; + if (len < abs(tp->minchars)) + continue; /* no match */ + for (sp = string; *sp == *tcp++;) { + if (*sp++ == '\0') + return (tp - swp); /* exact match */ + } + if (*sp) { + if (*sp != ' ') + continue; /* no match */ + if (*--tcp == '\0') + return (tp - swp); /* exact match */ + } + if (firstone == UNKWNSW) + firstone = tp - swp; + else + firstone = AMBIGSW; } - if (firstone == UNKWNSW) - firstone = tp - swp; - else - firstone = AMBIGSW; - } - return (firstone); + return (firstone); }