X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=uip%2Fmhl.c;h=76d23358588480cd0c6b24ee2b8b83355176a0bc;hb=c89293b617b20e1bdceeed290941c45acc457b15;hp=2987c0d2a6a9b89d3d3dbdbd64a8184353bbc604;hpb=de6974ed610ffbfaff335021ea7e359e85c27cfa;p=mmh diff --git a/uip/mhl.c b/uip/mhl.c index 2987c0d..76d2335 100644 --- a/uip/mhl.c +++ b/uip/mhl.c @@ -598,6 +598,34 @@ process(char *fname, int ofilen, int ofilec) c1->c_flags &= ~HDROUTPUT; } +static boolean +simplematch(char *pattern, char *b) +{ + char *match = strrchr(pattern, '*'); + char repl; + boolean ret; + + /* check if pattern ends with a * and is not escaped witch a \ */ + if (!match || match[1] || (match > pattern && match[-1] == '\\')) { + if (!match || match[1]) { + return mh_strcasecmp(pattern, b) == 0; + } + match[0] = '\0'; + match[-1] = '*'; + ret = mh_strcasecmp(pattern, b)==0; + match[-1] = '\\'; + match[0] = '*'; + return ret; + } + + repl = b[match-pattern]; + b[match-pattern] = '\0'; + *match = '\0'; + ret = (mh_strcasecmp(pattern, b) == 0); + b[match-pattern] = repl; + *match = '*'; + return ret; +} static void mhlfile(FILE *fp, char *mname, int ofilen, int ofilec) @@ -626,7 +654,7 @@ mhlfile(FILE *fp, char *mname, int ofilen, int ofilec) switch (state = m_getfld2(state, &f, fp)) { case FLD2: for (ip = ignores; *ip; ip++) - if (mh_strcasecmp(f.name, *ip)==0) { + if (simplematch(*ip, f.name)) { break; } if (*ip) { @@ -981,7 +1009,7 @@ putcomp(struct mcomp *c1, struct mcomp *c2, int flag) count += c1->c_offset; if ((cp = oneline(c2->c_text, c1->c_flags))) { - putstr((c1->c_flags & RTRIM) ? rtrim(cp) : cp); + putstr((c1->c_flags & RTRIM) ? rtrim(cp) : cp); } if (term == '\n') putstr("\n");