X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=gzip.c;h=cfc4fe3a2a7ff70ea28662cd52aef87c4b9257d7;hb=621b71dc5a3e523d4663d9021a9bbcc29c19690d;hp=09a16503aa75f812940a8e63e562396cc0e46911;hpb=79f88bd1e54d6042fbe50c212f836920fa208e56;p=debian%2Fgzip diff --git a/gzip.c b/gzip.c index 09a1650..cfc4fe3 100644 --- a/gzip.c +++ b/gzip.c @@ -77,6 +77,7 @@ static char const *const license_msg[] = { #include "ignore-value.h" #include "stat-time.h" #include "version.h" +#include "xalloc.h" #include "yesno.h" /* configuration */ @@ -1180,9 +1181,12 @@ local char *get_suffix(name) break; } } + + char *z_lower = xstrdup(z_suffix); + strlwr(z_lower); known_suffixes[suffix_of_builtin ? sizeof known_suffixes / sizeof *known_suffixes - 2 - : 0] = z_suffix; + : 0] = z_lower; suf = known_suffixes + suffix_of_builtin; nlen = strlen(name); @@ -1193,15 +1197,18 @@ local char *get_suffix(name) } strlwr(suffix); slen = strlen(suffix); + char *match = NULL; do { int s = strlen(*suf); if (slen > s && ! ISSLASH (suffix[slen - s - 1]) && strequ(suffix + slen - s, *suf)) { - return name+nlen-s; + match = name+nlen-s; + break; } } while (*++suf != NULL); + free(z_lower); - return NULL; + return match; }