Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ext/etc/.document
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
etc.c
constdefs.h
16 changes: 16 additions & 0 deletions ext/etc/mkconstants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ def c_str(str)

opt.parse!

CONST_PREFIXES = {
'SC' => 'for Etc.sysconf; See <tt>man sysconf</tt>',
'CS' => 'for Etc.confstr; See <tt>man constr</tt>',
'PC' => 'for IO#pathconf; See <tt>man fpathconf</tt>',
}

h = {}
COMMENTS = {}

Expand All @@ -49,6 +55,13 @@ def c_str(str)
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
Expand Down Expand Up @@ -123,6 +136,9 @@ def each_name(pat)
static void
init_constants(VALUE mod)
{
#if 0
mod = rb_define_module("Etc");
#endif
<%= gen_const_defs %>
}
EOS
Expand Down