File klibc-readlink.patch of Package klibc

diff -Ndurp klibc/usr/utils/readlink.c klibc-readlink/usr/utils/readlink.c
--- klibc/usr/utils/readlink.c	2016-08-10 21:20:04.000000000 +0300
+++ klibc-readlink/usr/utils/readlink.c	2016-08-10 21:34:08.000000000 +0300
@@ -3,55 +3,42 @@
 #include <unistd.h>
 #include <sys/stat.h>
 
-const char *progname;
-
-static __noreturn usage(void)
-{
-	fprintf(stderr, "Usage: %s [-f] link...\n", progname);
-	exit(1);
-}
-
 int main(int argc, char *argv[])
 {
-	int c, f_flag = 0;
-	const char *name;
-	char link_name[PATH_MAX];
-	int rv;
-	int i;
-
-	progname = argv[0];
+	int f_flag;
 
-	do {
-		c = getopt(argc, argv, "f");
-		if (c == EOF)
+	for (f_flag = 0;;) {
+		switch (getopt(argc, argv, "f")) {
+		case EOF:
 			break;
-		switch (c) {
 		case 'f':
 			f_flag = 1;
-			break;
-
+			continue;
 		case '?':
-			fprintf(stderr, "%s: invalid option -%c\n",
-				progname, optopt);
-			usage();
+			goto usage;
 		}
-	} while (1);
+		break;
+	};
 
-	if (optind == argc)
-		usage();
+	if (optind == argc) {
+usage:
+		fprintf(stderr, "Usage: %s [-f] link...\n", argv[0]);
+		return 1;
+	}
 
 	argv += optind;
-	while ((name = *argv++)) {
-		if (f_flag)
-			rv = realpath(name, link_name) ? strlen(link_name) : -1;
-		else
-			rv = readlink(name, link_name, sizeof link_name - 1);
+	for (argv += optind + 1; *argv; argv++) {
+		char link_name[PATH_MAX];
+		const char *name = *argv;
+		int rv = f_flag
+			 ? (realpath(name, link_name) ? strlen(link_name) : -1)
+			 : readlink(name, link_name, sizeof(link_name) - 1);
 		if (rv < 0) {
 			perror(name);
-			exit(1);
+			return 1;
 		}
-		link_name[rv] = '\n';
-		_fwrite(link_name, rv+1, stdout);
+		link_name[rv] = '\0';
+		puts(link_name);
 	}
 
 	return 0;
openSUSE Build Service is sponsored by