File klibc-2.0.4-dirname.patch of Package klibc

diff -Nurp klibc-2.0.4/usr/utils/dirname.c klibc-2.0.4-dirname/usr/utils/dirname.c
--- klibc-2.0.4/usr/utils/dirname.c	1970-01-01 03:00:00.000000000 +0300
+++ klibc-2.0.4-dirname/usr/utils/dirname.c	2014-09-22 05:58:57.065374245 +0300
@@ -0,0 +1,35 @@
+#include <stdio.h>
+#include <string.h>
+
+static void trim_slashes(char s[])
+{
+	size_t l;
+
+	for (l = strlen(s) - 1; l && s[l] == '/'; l--);
+	s[l + 1] = '\0';
+}
+
+int main(int argc, char *argv[])
+{
+	int i;
+
+	if (argc < 2) {
+		fprintf(stderr, "%s: missing operand\n", argv[0]);
+		return 1;
+	}
+
+	for (i = 1; i < argc; i++) {
+		char *p;
+
+		trim_slashes(argv[i]);
+		p = strrchr(argv[i], '/');
+		if (p) {
+			*p = '\0';
+			trim_slashes(argv[i]);
+			puts(argv[i]);
+		} else
+			puts(".");
+	}
+
+	return 0;
+}
diff -Nurp klibc-2.0.4/usr/utils/Kbuild klibc-2.0.4-dirname/usr/utils/Kbuild
--- klibc-2.0.4/usr/utils/Kbuild	2014-07-26 03:15:07.000000000 +0300
+++ klibc-2.0.4-dirname/usr/utils/Kbuild	2014-09-22 06:00:35.821367564 +0300
@@ -4,6 +4,7 @@
 
 progs := chroot dd mkdir mkfifo mknod mount pivot_root umount
 progs += true false sleep ln mv nuke minips cat ls losetup
+progs += dirname
 progs += uname halt kill readlink cpio sync dmesg
 
 static-y := $(addprefix static/, $(progs))
@@ -14,6 +15,8 @@ static/chroot-y     := chroot.o
 shared/chroot-y     := chroot.o
 static/dd-y         := dd.o
 shared/dd-y         := dd.o
+static/dirname-y    := dirname.o
+shared/dirname-y    := dirname.o
 static/dmesg-y      := dmesg.o
 shared/dmesg-y      := dmesg.o
 static/mkdir-y      := mkdir.o file_mode.o
openSUSE Build Service is sponsored by