From c027dcfde2bf40c45dfb0fe1b79f97b8827d89f3 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 27 Dec 2023 18:04:04 +0900 Subject: [ruby/etc] [DOC] Add minimal documents for constants https://github.com/ruby/etc/commit/97a4f798d4 --- ext/etc/.document | 1 + ext/etc/mkconstants.rb | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) (limited to 'ext/etc') diff --git a/ext/etc/.document b/ext/etc/.document index 2b0d7eb5c9..9bbea23b92 100644 --- a/ext/etc/.document +++ b/ext/etc/.document @@ -1 +1,2 @@ etc.c +constdefs.h diff --git a/ext/etc/mkconstants.rb b/ext/etc/mkconstants.rb index a752d64519..c8ebb67767 100644 --- a/ext/etc/mkconstants.rb +++ b/ext/etc/mkconstants.rb @@ -35,6 +35,12 @@ opt.def_option('-H FILE', 'specify output header file') {|filename| opt.parse! +CONST_PREFIXES = { + 'SC' => 'for Etc.sysconf; See man sysconf', + 'CS' => 'for Etc.confstr; See man constr', + 'PC' => 'for IO#pathconf; See man fpathconf', +} + h = {} COMMENTS = {} @@ -49,6 +55,13 @@ DATA.each_line {|s| next end h[name] = default_value + if additional = CONST_PREFIXES[name[/\A_([A-Z]+)_/, 1]] + if comment&.match(/\w\z/) + comment << " " << additional + else + (comment ||= String.new) << " " << additional.sub(/\A\w/) {$&.upcase} + end + end COMMENTS[name] = comment if comment } DEFS = h.to_a @@ -123,6 +136,9 @@ result = erb_new.call(<<'EOS', nil, '%').result(binding) static void init_constants(VALUE mod) { +#if 0 + mod = rb_define_module("Etc"); +#endif <%= gen_const_defs %> } EOS -- cgit v1.2.3