1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-02 08:42:48 +00:00

Fix suffix matching.

Restore historical behaviour when the first argument is an empty string.

Submitted by:	Alexander N. Kabaev <ak03@gte.com>
Pointed out by:	bde
This commit is contained in:
Dag-Erling Smørgrav 2000-10-12 16:22:15 +00:00
parent 00d8d16417
commit 83d213303c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=67024

View File

@ -71,10 +71,15 @@ main(argc, argv)
if (argc != 1 && argc != 2)
usage();
if (!*argv[0]) {
printf("\n");
exit(0);
}
if ((p = basename(argv[0])) == NULL)
err(1, "%s", argv[0]);
if (*++argv && (q = strstr(p, *argv)) && strcmp(q, *argv) == 0)
*q = '\0';
if (*++argv && (q = strchr(p, '\0') - strlen(*argv)) > p &&
strcmp(*argv, q) == 0)
*q = '\0';
(void)printf("%s\n", p);
exit(0);
}