File mg-fgetln.patch of Package mg

--- cscope.c.orig	2016-01-10 19:17:28.633910612 +0100
+++ cscope.c	2016-01-10 20:10:12.432902124 +0100
@@ -222,8 +222,7 @@
 	addline(bp, title);
 	addline(bp, "");
 	/* All lines are NUL terminated */
-	while ((line = fgetln(fpipe, &len)) != NULL) {
-		line[len - 1] = '\0';
+	while ((getline(&line, &len, fpipe)) != -1) {
 		addline(bp, line);
 	}
 	pclose(fpipe);
@@ -448,8 +447,7 @@
 	addline(bp, "");
 	addline(bp, "-------------------------------------------------------------------------------");
 	/* All lines are NUL terminated */
-	while ((buf = fgetln(fpipe, &len)) != NULL) {
-		buf[len - 1] = '\0';
+	while ((getline(&buf, &len, fpipe)) != -1) {
 		if (addentry(bp, buf) != TRUE)
 			return (FALSE);
 		nores = 1;
--- grep.c.orig	2016-01-10 19:21:03.947362638 +0100
+++ grep.c	2016-01-10 20:10:20.728011537 +0100
@@ -213,10 +213,9 @@
 	/*
 	 * We know that our commands are nice and the last line will end with
 	 * a \n, so we don't need to try to deal with the last line problem
-	 * in fgetln.
+	 * in fgetln/getline.
 	 */
-	while ((buf = fgetln(fpipe, &len)) != NULL) {
-		buf[len - 1] = '\0';
+	while ((getline(&buf, &len, fpipe)) != -1) {
 		addline(bp, buf);
 	}
 	ret = pclose(fpipe);
openSUSE Build Service is sponsored by