Module Name: src
Committed By: rillig
Date: Tue Sep 8 19:11:30 UTC 2020
Modified Files:
src/distrib/sets: fmt-list
Log Message:
distrib/sets/fmt-list: add no-action mode
This is useful for finding parse errors only. Inspired by some entries
that are obsolete and have more than the "obsolete" flag. There are
only few of these entries though, and they don't seem worth fixing.
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/distrib/sets/fmt-list
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/distrib/sets/fmt-list
diff -u src/distrib/sets/fmt-list:1.1 src/distrib/sets/fmt-list:1.2
--- src/distrib/sets/fmt-list:1.1 Sat Sep 5 11:13:07 2020
+++ src/distrib/sets/fmt-list Tue Sep 8 19:11:30 2020
@@ -1,5 +1,5 @@
#! /usr/bin/lua
--- $NetBSD: fmt-list,v 1.1 2020/09/05 11:13:07 rillig Exp $
+-- $NetBSD: fmt-list,v 1.2 2020/09/08 19:11:30 rillig Exp $
--[[
@@ -8,7 +8,7 @@ have the other fields at the same indent
Sort the lines and remove duplicate lines.
-usage: ./fmt-list */*/{mi,ad.*,md.*}
+usage: ./fmt-list [-n] */*/{mi,ad.*,md.*}
]]
@@ -405,7 +405,7 @@ end
-- Load a file list, normalize it and write it back to disk.
-local function format_list(fname)
+local function format_list(fname, write_back)
local head, entries, errors = read_list(fname)
if #errors > 0 then
for _, err in ipairs(errors) do
@@ -415,10 +415,22 @@ local function format_list(fname)
end
normalize(entries)
- write_list(fname, head, entries)
+
+ if write_back then
+ write_list(fname, head, entries)
+ end
end
-for _, fname in ipairs(arg) do
- format_list(fname)
+local function main(arg)
+ local write_back = true
+ for _, fname in ipairs(arg) do
+ if fname == "-n" then
+ write_back = false
+ else
+ format_list(fname, write_back)
+ end
+ end
end
+
+main(arg)