Module Name: src
Committed By: rillig
Date: Mon Feb 15 23:00:03 UTC 2021
Modified Files:
src/distrib/sets: fmt-list
Log Message:
distrib/sets/list-fmt: sort commented entries like regular entries
Seen in lists/modules/ad.aarch64, among others. These lines are not
intended as comments but as regular entries that just happen to be
commented out.
This is the same as how pkglint treats commented variable assignments,
which take part in aligning blocks of variable assignments even though
they are syntactically comments.
To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 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.3 src/distrib/sets/fmt-list:1.4
--- src/distrib/sets/fmt-list:1.3 Mon Nov 2 20:14:01 2020
+++ src/distrib/sets/fmt-list Mon Feb 15 23:00:03 2021
@@ -1,5 +1,5 @@
#! /usr/bin/lua
--- $NetBSD: fmt-list,v 1.3 2020/11/02 20:14:01 rillig Exp $
+-- $NetBSD: fmt-list,v 1.4 2021/02/15 23:00:03 rillig Exp $
--[[
@@ -106,10 +106,10 @@ end)
local function parse_entry(line)
local category_align, prefix, fullname, flags_align, category, flags =
- line:match("^((%-?)(%.%S*)%s+)((%S+)%s+)(%S+)$")
+ line:match("^(([#%-]?)(%.%S*)%s+)((%S+)%s+)(%S+)$")
if fullname == nil then
category_align, prefix, fullname, category =
- line:match("^((%-?)(%.%S*)%s+)(%S+)$")
+ line:match("^(([#%-]?)(%.%S*)%s+)(%S+)$")
end
if fullname == nil then
prefix, fullname = line:match("^(%-)(%.%S*)$")
@@ -153,6 +153,16 @@ test(function()
assert_equals(entry.category, "category")
assert_equals(entry.flags_col, 16)
assert_equals(entry.flags, "flags")
+
+ entry = parse_entry("#./dirname/filename\tcat\tflags")
+ assert_equals(entry.prefix, "#")
+ assert_equals(entry.fullname, "./dirname/filename")
+ assert_equals(entry.dirname, "./dirname")
+ assert_equals(entry.basename, "filename")
+ assert_equals(entry.category_col, 24)
+ assert_equals(entry.category, "cat")
+ assert_equals(entry.flags_col, 8)
+ assert_equals(entry.flags, "flags")
end)
@@ -397,6 +407,8 @@ local function write_list(fname, head, e
if line ~= prev_line then
prev_line = line
f:write(line, "\n")
+ else
+ --print(string.format("%s: duplicate entry: %s", fname, line))
end
end