ext/etc/etc.c in etc-0.2.1 vs ext/etc/etc.c in etc-1.0.0

- old
+ new

@@ -213,13 +213,14 @@ static VALUE etc_getpwnam(VALUE obj, VALUE nam) { #ifdef HAVE_GETPWENT struct passwd *pwd; + const char *p = StringValueCStr(nam); - SafeStringValue(nam); - pwd = getpwnam(RSTRING_PTR(nam)); + rb_check_safe_obj(nam); + pwd = getpwnam(p); if (pwd == 0) rb_raise(rb_eArgError, "can't find user for %"PRIsVALUE, nam); return setup_passwd(pwd); #else return Qnil; #endif @@ -456,13 +457,14 @@ static VALUE etc_getgrnam(VALUE obj, VALUE nam) { #ifdef HAVE_GETGRENT struct group *grp; + const char *p = StringValueCStr(nam); - SafeStringValue(nam); - grp = getgrnam(RSTRING_PTR(nam)); + rb_check_safe_obj(nam); + grp = getgrnam(p); if (grp == 0) rb_raise(rb_eArgError, "can't find group for %"PRIsVALUE, nam); return setup_group(grp); #else return Qnil; #endif @@ -623,12 +625,13 @@ /* * Returns system configuration directory. * * This is typically "/etc", but is modified by the prefix used when Ruby was - * compiled. For example, if Ruby is built and installed in /usr/local, returns - * "/usr/local/etc". + * compiled. For example, if Ruby is built and installed in /usr/local, + * returns "/usr/local/etc" on other platforms than Windows. + * On Windows, this always returns the directory provided by the system. */ static VALUE etc_sysconfdir(VALUE obj) { #ifdef _WIN32 @@ -1010,10 +1013,10 @@ #if defined(HAVE_SCHED_GETAFFINITY) && defined(CPU_ALLOC) int ncpus; ncpus = etc_nprocessors_affin(); if (ncpus != -1) { - return INT2NUM(ncpus); + return INT2NUM(ncpus); } /* fallback to _SC_NPROCESSORS_ONLN */ #endif errno = 0;