diff ringtools/fc-pwt-comp.c @ 885:16e259bff02b

fc-pwt-comp: explicitly reject empty input
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 03 Apr 2022 03:55:02 +0000
parents 8eb1f60f6676
children
line wrap: on
line diff
--- a/ringtools/fc-pwt-comp.c	Sun Apr 03 03:49:48 2022 +0000
+++ b/ringtools/fc-pwt-comp.c	Sun Apr 03 03:55:02 2022 +0000
@@ -163,6 +163,8 @@
 main(argc, argv)
 	char **argv;
 {
+	int nonempty;
+
 	if (argc != 3) {
 		fprintf(stderr, "usage: %s src-file bin-file\n", argv[0]);
 		exit(1);
@@ -185,6 +187,7 @@
 		exit(1);
 	}
 
+	nonempty = 0;
 	for (lineno = 1; fgets(linebuf, sizeof linebuf, inf); lineno++) {
 		parse_line_into_fields();
 		if (!nfields)
@@ -198,6 +201,12 @@
 				infname, lineno);
 			exit(1);
 		}
+		nonempty = 1;
 	}
-	exit(0);
+	if (nonempty)
+		exit(0);
+	else {
+		fprintf(stderr, "error: %s is empty\n", infname);
+		exit(1);
+	}
 }