SUSv2 specifies that if the extension is identical to the basename, it
authorEric Andersen <andersen@codepoet.org>
Mon, 3 Sep 2001 19:37:15 +0000 (19:37 -0000)
committerEric Andersen <andersen@codepoet.org>
Mon, 3 Sep 2001 19:37:15 +0000 (19:37 -0000)
should not be removed.  Patch backport from Matt Kraai

busybox/basename.c
busybox/coreutils/basename.c

index b83f387c29c70725fb69b22efee4e9a38d6133b7..c15afd53328aee8c9131a169efd78aa19a320ba9 100644 (file)
@@ -44,7 +44,7 @@ extern int basename_main(int argc, char **argv)
                argv++;
                n = strlen(*argv);
                m = strlen(s);
-               if (m>=n && strncmp(s+m-n, *argv, n)==0)
+               if (m>n && strncmp(s+m-n, *argv, n)==0)
                        s[m-n] = '\0';
        }
        puts(s);
index b83f387c29c70725fb69b22efee4e9a38d6133b7..c15afd53328aee8c9131a169efd78aa19a320ba9 100644 (file)
@@ -44,7 +44,7 @@ extern int basename_main(int argc, char **argv)
                argv++;
                n = strlen(*argv);
                m = strlen(s);
-               if (m>=n && strncmp(s+m-n, *argv, n)==0)
+               if (m>n && strncmp(s+m-n, *argv, n)==0)
                        s[m-n] = '\0';
        }
        puts(s);