On 05/22/2014 03:28 AM, Jim Meyering wrote:
q> Nice. Thanks!
> What do you think about using e.g.,
>
> grep -vE '^0x(....|........)$'
>
> instead of that latter sed invocation?
> Then any offending hex string would be printed.
Well the previous did actually print the offending hex strings (since they
start with 0x),
however your technique of just using an anchored grep expression is better.
Though now, regex golf! I'm now using the following to also flag lower case hex,
which also give false positives with `make src/fs-magic-compare`:
grep -Ev '^0x([0-9A-F]{4}){1,2}$
I'll push the attached later.
thanks!
Pádraig.
>From 695a0b5502a623e5a9a6d149500c4898102d2dd8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <[email protected]>
Date: Thu, 22 May 2014 02:16:14 +0100
Subject: [PATCH] maint: enforce consistent width and case of file system
constants
* src/stat.c (human_fstype): Adjust a couple of existing constants
to be a consistent width and capitalization so that the
src/fs-magic-compare target works without reporting false positives.
* cfg.mk (sc_fs-magic-compare): A new syntax check to enforce this.
Improved by: Jim Meyering
---
cfg.mk | 8 ++++++++
src/stat.c | 6 +++---
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index 66aa55d..1e884cd 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -577,6 +577,14 @@ sc_marked_devdiagnostics:
halt='found marked developer diagnostic(s)' \
$(_sc_search_regexp)
+# Ensure we keep hex constants as 4 or 8 bytes for consistency
+# and so that make src/fs-magic-compare works consistently
+sc_fs-magic-compare:
+ @sed -n 's|.*/\* \(0x[0-9A-Fa-f]\{1,\}\) .*\*/|\1|p' \
+ $(srcdir)/src/stat.c | grep -Ev '^0x([0-9A-F]{4}){1,2}$$' \
+ && { echo '$(ME): Constants in src/stat.c should be 4 or 8' \
+ 'upper-case chars' 1>&2; exit 1; } || :
+
# Override the default Cc: used in generating an announcement.
announcement_Cc_ = $(translation_project_), \
[email protected], [email protected]
diff --git a/src/stat.c b/src/stat.c
index 7d43eb5..148ff49 100644
--- a/src/stat.c
+++ b/src/stat.c
@@ -316,7 +316,7 @@ human_fstype (STRUCT_STATVFS const *statfsbuf)
return "fusectl";
case S_MAGIC_FUTEXFS: /* 0x0BAD1DEA local */
return "futexfs";
- case S_MAGIC_GFS: /* 0x1161970 remote */
+ case S_MAGIC_GFS: /* 0x01161970 remote */
return "gfs/gfs2";
case S_MAGIC_GPFS: /* 0x47504653 remote */
return "gpfs";
@@ -326,7 +326,7 @@ human_fstype (STRUCT_STATVFS const *statfsbuf)
return "hfs+";
case S_MAGIC_HFS_X: /* 0x4858 local */
return "hfsx";
- case S_MAGIC_HOSTFS: /* 0xC0FFEE local */
+ case S_MAGIC_HOSTFS: /* 0x00C0FFEE local */
return "hostfs";
case S_MAGIC_HPFS: /* 0xF995E849 local */
return "hpfs";
@@ -378,7 +378,7 @@ human_fstype (STRUCT_STATVFS const *statfsbuf)
return "ntfs";
case S_MAGIC_OPENPROM: /* 0x9FA1 local */
return "openprom";
- case S_MAGIC_OCFS2: /* 0x7461636f remote */
+ case S_MAGIC_OCFS2: /* 0x7461636F remote */
return "ocfs2";
case S_MAGIC_PANFS: /* 0xAAD7AAEA remote */
return "panfs";
--
1.7.7.6