ext/etc/etc.c in etc-1.0.1 vs ext/etc/etc.c in etc-1.1.0
- old
+ new
@@ -50,10 +50,12 @@
#ifndef _WIN32
char *getenv();
#endif
char *getlogin();
+#define RUBY_ETC_VERSION "1.1.0"
+
#include "constdefs.h"
/* call-seq:
* getlogin -> String
*
@@ -96,11 +98,11 @@
#if defined(HAVE_GETPWENT) || defined(HAVE_GETGRENT)
static VALUE
safe_setup_str(const char *str)
{
if (str == 0) str = "";
- return rb_tainted_str_new2(str);
+ return rb_str_new2(str);
}
static VALUE
safe_setup_locale_str(const char *str)
{
@@ -215,11 +217,10 @@
{
#ifdef HAVE_GETPWENT
struct passwd *pwd;
const char *p = StringValueCStr(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;
@@ -227,19 +228,19 @@
}
#ifdef HAVE_GETPWENT
static int passwd_blocking = 0;
static VALUE
-passwd_ensure(void)
+passwd_ensure(VALUE _)
{
endpwent();
passwd_blocking = (int)Qfalse;
return Qnil;
}
static VALUE
-passwd_iterate(void)
+passwd_iterate(VALUE _)
{
struct passwd *pw;
setpwent();
while ((pw = getpwent()) != 0) {
@@ -459,11 +460,10 @@
{
#ifdef HAVE_GETGRENT
struct group *grp;
const char *p = StringValueCStr(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;
@@ -471,20 +471,20 @@
}
#ifdef HAVE_GETGRENT
static int group_blocking = 0;
static VALUE
-group_ensure(void)
+group_ensure(VALUE _)
{
endgrent();
group_blocking = (int)Qfalse;
return Qnil;
}
static VALUE
-group_iterate(void)
+group_iterate(VALUE _)
{
struct group *pw;
setgrent();
while ((pw = getgrent()) != 0) {
@@ -643,11 +643,11 @@
/*
* Returns system temporary directory; typically "/tmp".
*/
static VALUE
-etc_systmpdir(void)
+etc_systmpdir(VALUE _)
{
VALUE tmpdir;
#ifdef _WIN32
WCHAR path[_MAX_PATH];
UINT len = rb_w32_system_tmpdir(path, numberof(path));
@@ -675,11 +675,14 @@
if (!tmpstr) {
confstr(_CS_DARWIN_USER_TEMP_DIR, RSTRING_PTR(tmpdir), len);
}
# endif
#endif
+#ifndef RB_PASS_KEYWORDS
+ /* untaint on Ruby < 2.7 */
FL_UNSET(tmpdir, FL_TAINT);
+#endif
return tmpdir;
}
#ifdef HAVE_UNAME
/*
@@ -752,13 +755,10 @@
rb_hash_aset(result, ID2SYM(rb_intern("nodename")), nodename);
# ifndef PROCESSOR_ARCHITECTURE_AMD64
# define PROCESSOR_ARCHITECTURE_AMD64 9
# endif
-# ifndef PROCESSOR_ARCHITECTURE_IA64
-# define PROCESSOR_ARCHITECTURE_IA64 6
-# endif
# ifndef PROCESSOR_ARCHITECTURE_INTEL
# define PROCESSOR_ARCHITECTURE_INTEL 0
# endif
GetSystemInfo(&s);
switch (s.wProcessorArchitecture) {
@@ -766,13 +766,10 @@
mach = "x64";
break;
case PROCESSOR_ARCHITECTURE_ARM:
mach = "ARM";
break;
- case PROCESSOR_ARCHITECTURE_IA64:
- mach = "IA64";
- break;
case PROCESSOR_ARCHITECTURE_INTEL:
mach = "x86";
break;
default:
mach = "unknown";
@@ -1066,9 +1063,10 @@
Init_etc(void)
{
VALUE mEtc;
mEtc = rb_define_module("Etc");
+ rb_define_const(mEtc, "VERSION", rb_str_new_cstr(RUBY_ETC_VERSION));
init_constants(mEtc);
rb_define_module_function(mEtc, "getlogin", etc_getlogin, 0);
rb_define_module_function(mEtc, "getpwuid", etc_getpwuid, -1);