From 042e5013a3bc42a3637aa1646e9fc002436b852f Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 3 Aug 2013 00:31:02 +0000 Subject: struct.c: rb_struct_define_under * struct.c (rb_struct_define_under): new function to define Struct under the given namespace, not under Struct. [Feature #8264] * ext/etc/etc.c: use rb_struct_define_under. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42348 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/etc/etc.c | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) (limited to 'ext/etc') diff --git a/ext/etc/etc.c b/ext/etc/etc.c index 474f3ebde0..3f14669748 100644 --- a/ext/etc/etc.c +++ b/ext/etc/etc.c @@ -672,37 +672,38 @@ Init_etc(void) rb_define_module_function(mEtc, "sysconfdir", etc_sysconfdir, 0); rb_define_module_function(mEtc, "systmpdir", etc_systmpdir, 0); - sPasswd = rb_struct_define(NULL, - "name", + sPasswd = rb_struct_define_under(mEtc, "Passwd", + "name", #ifdef HAVE_STRUCT_PASSWD_PW_PASSWD - "passwd", + "passwd", #endif - "uid", - "gid", + "uid", + "gid", #ifdef HAVE_STRUCT_PASSWD_PW_GECOS - "gecos", + "gecos", #endif - "dir", - "shell", + "dir", + "shell", #ifdef HAVE_STRUCT_PASSWD_PW_CHANGE - "change", + "change", #endif #ifdef HAVE_STRUCT_PASSWD_PW_QUOTA - "quota", + "quota", #endif #ifdef HAVE_STRUCT_PASSWD_PW_AGE - "age", + "age", #endif #ifdef HAVE_STRUCT_PASSWD_PW_CLASS - "uclass", + "uclass", #endif #ifdef HAVE_STRUCT_PASSWD_PW_COMMENT - "comment", + "comment", #endif #ifdef HAVE_STRUCT_PASSWD_PW_EXPIRE - "expire", + "expire", #endif - NULL); + NULL); +#if 0 /* Define-const: Passwd * * Passwd is a Struct that contains the following members: @@ -743,18 +744,19 @@ Init_etc(void) * account expiration time(integer) must be compiled with +HAVE_STRUCT_PASSWD_PW_EXPIRE+ */ rb_define_const(mEtc, "Passwd", sPasswd); - rb_set_class_path(sPasswd, mEtc, "Passwd"); +#endif rb_define_const(rb_cStruct, "Passwd", sPasswd); /* deprecated name */ rb_extend_object(sPasswd, rb_mEnumerable); rb_define_singleton_method(sPasswd, "each", etc_each_passwd, 0); #ifdef HAVE_GETGRENT - sGroup = rb_struct_define(NULL, "name", + sGroup = rb_struct_define_under(mEtc, "Group", "name", #ifdef HAVE_STRUCT_GROUP_GR_PASSWD - "passwd", + "passwd", #endif - "gid", "mem", NULL); + "gid", "mem", NULL); +#if 0 /* Define-const: Group * * Group is a Struct that is only available when compiled with +HAVE_GETGRENT+. @@ -777,7 +779,7 @@ Init_etc(void) * members of the group. */ rb_define_const(mEtc, "Group", sGroup); - rb_set_class_path(sGroup, mEtc, "Group"); +#endif rb_define_const(rb_cStruct, "Group", sGroup); /* deprecated name */ rb_extend_object(sGroup, rb_mEnumerable); rb_define_singleton_method(sGroup, "each", etc_each_group, 0); -- cgit v1.2.3