From 9171f6863a8346c69944387d993d5e58f95c33a3 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 27 Jun 2006 02:37:01 +0000 Subject: * ext/etc/etc.c (setup_passwd, setup_group): allow bignum uid, gid and so on. [ruby-talk:199102] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@10408 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/etc/etc.c | 12 ++++++------ ext/etc/extconf.rb | 15 ++++++++++++++- 2 files changed, 20 insertions(+), 7 deletions(-) (limited to 'ext') diff --git a/ext/etc/etc.c b/ext/etc/etc.c index ac95735549..c79640d02a 100644 --- a/ext/etc/etc.c +++ b/ext/etc/etc.c @@ -79,18 +79,18 @@ setup_passwd(pwd) #ifdef HAVE_ST_PW_PASSWD safe_setup_str(pwd->pw_passwd), #endif - INT2FIX(pwd->pw_uid), - INT2FIX(pwd->pw_gid), + PW_UID2VAL(pwd->pw_uid), + PW_GID2VAL(pwd->pw_gid), #ifdef HAVE_ST_PW_GECOS safe_setup_str(pwd->pw_gecos), #endif safe_setup_str(pwd->pw_dir), safe_setup_str(pwd->pw_shell), #ifdef HAVE_ST_PW_CHANGE - INT2FIX(pwd->pw_change), + INT2NUM(pwd->pw_change), #endif #ifdef HAVE_ST_PW_QUOTA - INT2FIX(pwd->pw_quota), + INT2NUM(pwd->pw_quota), #endif #ifdef HAVE_ST_PW_AGE PW_AGE2VAL(pwd->pw_age), @@ -102,7 +102,7 @@ setup_passwd(pwd) safe_setup_str(pwd->pw_comment), #endif #ifdef HAVE_ST_PW_EXPIRE - INT2FIX(pwd->pw_expire), + INT2NUM(pwd->pw_expire), #endif 0 /*dummy*/ ); @@ -313,7 +313,7 @@ setup_group(grp) #ifdef HAVE_ST_GR_PASSWD safe_setup_str(grp->gr_passwd), #endif - INT2FIX(grp->gr_gid), + PW_GID2VAL(grp->gr_gid), mem); } #endif diff --git a/ext/etc/extconf.rb b/ext/etc/extconf.rb index 0dc8e7ddac..5cdb824fda 100644 --- a/ext/etc/extconf.rb +++ b/ext/etc/extconf.rb @@ -24,6 +24,19 @@ if a or b or c have_struct_member('struct passwd', 'pw_expire', 'pwd.h') have_struct_member('struct passwd', 'pw_passwd', 'pwd.h') have_struct_member('struct group', 'gr_passwd', 'grp.h') - have_type("uid_t"); + [%w"uid_t pwd.h", %w"gid_t grp.h"].each do |t, *h| + h << "sys/types.h" + if have_type(t, h) + if try_static_assert("sizeof(#{t}) > sizeof(long)", h) + f = "LL2NUM" + else + f = "INT2NUM" + end + if try_static_assert("(#{t})-1 > 0", h) + f = "U#{f}" + end + $defs.push("-DPW_#{t.chomp('_t').upcase}2VAL=#{f}") + end + end create_makefile("etc") end -- cgit v1.2.3