File klibc-2.0.4-basename.patch of Package klibc

diff -Nurp klibc-2.0.4/usr/utils/basename.c klibc-2.0.4-basename/usr/utils/basename.c
--- klibc-2.0.4/usr/utils/basename.c	1970-01-01 03:00:00.000000000 +0300
+++ klibc-2.0.4-basename/usr/utils/basename.c	2014-09-22 05:58:49.306374770 +0300
@@ -0,0 +1,33 @@
+#include <stdio.h>
+#include <string.h>
+
+int main(int argc, char *argv[])
+{
+	char *p;
+	size_t l;
+
+	if (argc > 3) {
+		fprintf(stderr, "%s: extra operand '%s'\n", argv[0], argv[3]);
+		return 1;
+	}
+
+	if (argc < 2) {
+		fprintf(stderr, "%s: missing operand\n", argv[0]);
+		return 1;
+	}
+
+	for (l = strlen(argv[1]) - 1; l && argv[1][l] == '/'; l--);
+	l++;
+	argv[1][l] = '\0';
+
+	if (argc == 3) {
+		p = argv[1] + l - strlen(argv[2]);
+		if (!strcmp(p, argv[2]))
+			*p = '\0';
+	}
+
+	p = strrchr(argv[1], '/');
+	puts(p ? p + 1 : argv[1]);
+	return 0;
+}
+
diff -Nurp klibc-2.0.4/usr/utils/Kbuild klibc-2.0.4-basename/usr/utils/Kbuild
--- klibc-2.0.4/usr/utils/Kbuild	2014-07-26 03:15:07.000000000 +0300
+++ klibc-2.0.4-basename/usr/utils/Kbuild	2014-09-22 06:01:07.598365414 +0300
@@ -3,6 +3,7 @@
 #
 
 progs := chroot dd mkdir mkfifo mknod mount pivot_root umount
+progs += basename
 progs += true false sleep ln mv nuke minips cat ls losetup
 progs += uname halt kill readlink cpio sync dmesg
 
@@ -10,6 +11,8 @@ static-y := $(addprefix static/, $(progs
 shared-y := $(addprefix shared/, $(progs))
 
 # The binary is placed in a subdir, so we need to tell kbuild this
+static/basename-y   := basename.o
+shared/basename-y   := basename.o
 static/chroot-y     := chroot.o
 shared/chroot-y     := chroot.o
 static/dd-y         := dd.o
openSUSE Build Service is sponsored by