tests/unpack-valid: port to printf that do not grok hex
[debian/gzip] / util.c
diff --git a/util.c b/util.c
index f84dfc951716f811a2db068e248bb06b60f269a9..8e0f35f24284e261a1719ba6a4dfcc40324a6ae7 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1,6 +1,6 @@
 /* util.c -- utility functions for gzip support
 
-   Copyright (C) 1997-1999, 2001-2002, 2006, 2009-2015 Free Software
+   Copyright (C) 1997-1999, 2001-2002, 2006, 2009-2017 Free Software
    Foundation, Inc.
    Copyright (C) 1992-1993 Jean-loup Gailly
 
 #include <config.h>
 #include <ctype.h>
 #include <errno.h>
-
-#include "tailor.h"
-
 #include <limits.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <stdlib.h>
 #include <errno.h>
 
+#include "tailor.h"
 #include "gzip.h"
+#include <dirname.h>
 #include <xalloc.h>
 
 #ifndef CHAR_BIT
@@ -301,18 +300,7 @@ char *
 gzip_base_name (fname)
     char *fname;
 {
-    char *p;
-
-    if ((p = strrchr(fname, PATH_SEP))  != NULL) fname = p+1;
-#ifdef PATH_SEP2
-    if ((p = strrchr(fname, PATH_SEP2)) != NULL) fname = p+1;
-#endif
-#ifdef PATH_SEP3
-    if ((p = strrchr(fname, PATH_SEP3)) != NULL) fname = p+1;
-#endif
-#ifdef SUFFIX_SEP
-    if ((p = strrchr(fname, SUFFIX_SEP)) != NULL) *p = '\0';
-#endif
+    fname = last_component (fname);
     if (casemap('A') == 'a') strlwr(fname);
     return fname;
 }