[PATCH 1/3] Make the stat command ignore lines that it is not looking for.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Steve Dickson <steved@xxxxxxxxxx>
---
 general/stat.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/general/stat.c b/general/stat.c
index c4e4fc0..2ce604e 100644
--- a/general/stat.c
+++ b/general/stat.c
@@ -30,7 +30,7 @@ main(argc, argv)
 {
 	FILE	*fp;
 	int	i, n;
-	char	c, *fmt;
+	char	c, *fmt, buf[BUFSIZ];
 	int	attfmt = 0;	/* set if using att time format */
 
 	Prog = argv[0];
@@ -45,6 +45,7 @@ main(argc, argv)
 			Prog, File);
 		exit(1);
 	}
+getnewch:
 	if ((i = fgetc(fp)) == EOF) {
 		fprintf(stderr, "%s: %s is empty\n",
 			Prog, File);
@@ -53,8 +54,12 @@ main(argc, argv)
 	c = i & 0x7f;
 	if (c == '\n' || c == '\r' || c == 'r')
 		attfmt = 1;
-	else
+	else if (isdigit(c))
 		fmt = "%lf %*s %lf %*s %lf %*s";	/* BSD fmt */
+	else { /* skip the line */
+		fgets(buf, BUFSIZ, fp);
+		goto getnewch;
+	}
 	if (ungetc(c, fp) == EOF) {
 		fprintf(stderr, "%s: can't push char back to %s\n",
 			Prog, File);
-- 
1.7.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux