[libdispatch-dev] [PATCH] testing/summarize.c on Linux

Mario Schwalbe schwalbe at inf.tu-dresden.de
Mon Nov 16 06:43:13 PST 2009


Hi,

convert from fgetln (not available on Linux) to fgets.
(this patch also removes whitespace on empty lines. sorry.)

ciao,
Mario

Index: testing/summarize.c
===================================================================
--- testing/summarize.c	(Revision 165)
+++ testing/summarize.c	(Arbeitskopie)
@@ -43,7 +43,7 @@
 		fprintf(stderr, "%s: usage: summarize\n", argv[0]);
 		exit(1);
 	}
-	
+
 	/*
 	FILE* f = fopen(argv[1], "w");
 	if (f == NULL) {
@@ -56,8 +56,8 @@
 	fprintf(f, "\n==================================================\n");
 	fprintf(f, "[SUMMARY] Test Summary\n");
 	fprintf(f, "==================================================\n\n");
-	
-	size_t len;
+
+	char buf[1024];
 	char* ln;
 	long total = 0;
 	long pass = 0;
@@ -66,8 +66,8 @@
 	long total_pass = 0;
 	long total_fail = 0;
 	for(;;) {
-		ln = fgetln(stdin, &len);
-		//if (ln) fprintf(stdout, "%.*s", (int)len, ln);
+		ln = fgets(buf, sizeof(buf), stdin);
+
 		if (ln == NULL || has_prefix(ln, "[TEST]")) {
 			if (total) {
 				print_summary(f, total, pass, fail);
@@ -79,7 +79,7 @@
 			pass = 0;
 			fail = 0;
 			if (ln) {
-				fprintf(f, "%.*s", (int)len, ln);
+				fprintf(f, "%s", ln);
 			} else {
 				fprintf(f, "[TOTAL]\n");
 				print_summary(f, total_total, total_pass, total_fail);
@@ -93,6 +93,6 @@
 			++fail;
 		}
 	}
-	
+
 	return (total_fail ? EXIT_FAILURE : EXIT_SUCCESS);
 }




More information about the libdispatch-dev mailing list