X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=sbr%2Fsmatch.c;h=b22df66b958d2af4ea3e46e4abe5e512b467e02b;hp=88a098b3a0e629678b3c386eb1f51e728aacf33f;hb=a485ed478abbd599d8c9aab48934e7a26733ecb1;hpb=f480c03187724e54e5391ee61b810827da319a6c diff --git a/sbr/smatch.c b/sbr/smatch.c index 88a098b..b22df66 100644 --- a/sbr/smatch.c +++ b/sbr/smatch.c @@ -1,4 +1,3 @@ - /* * smatch.c -- match a switch (option) * @@ -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); }