From 736e7342c441e533f7482883a8e0b30a1a076bc4 Mon Sep 17 00:00:00 2001 From: Masahiro Sakai Date: Sun, 10 Nov 2024 20:20:28 +0900 Subject: [PATCH] improve misc/collect-min-version-macro.rb --- misc/collect-min-version-macro.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/misc/collect-min-version-macro.rb b/misc/collect-min-version-macro.rb index 267c4578..1e24fe54 100644 --- a/misc/collect-min-version-macro.rb +++ b/misc/collect-min-version-macro.rb @@ -2,18 +2,21 @@ base = ARGV[0] || "." -a = [] +h = {} Dir.glob("**/*.hs", base: base){|fname| File.open(fname, encoding: "utf-8"){|f| f.each_line{|l| if /MIN_VERSION_\w+\(\d+,\d+,\d+\)/ =~ l - a << $~[0] + (h[$~[0]] ||= []) << fname end } } } -a.sort.uniq.each{|l| - puts l +h.keys.sort.each {|k| + puts k + h[k].each {|fname| + puts " #{fname}" + } }