* defines.h (PATH_ENV): name of PATH environment. [new].

* defines.h (ENV_IGNORECASE): define for case insensitive platforms
  to access environment variables.

* dln.c (dln_find_exe): use PATH_ENV instead of "PATH".

* hash.c (env_delete, rb_f_getenv, env_fetch, rb_env_path_tainted,
  env_aset): ditto.

* ruby.c (proc_options): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3966 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
usa 2003-06-20 06:22:50 +00:00
parent 068bc7e43a
commit 65ba3eba64
6 changed files with 55 additions and 23 deletions

View File

@ -1,3 +1,17 @@
Fri Jun 20 15:04:28 2003 NAKAMURA Usaku <usa@ruby-lang.org>
* defines.h (PATH_ENV): name of PATH environment. [new].
* defines.h (ENV_IGNORECASE): define for case insensitive platforms
to access environment variables.
* dln.c (dln_find_exe): use PATH_ENV instead of "PATH".
* hash.c (env_delete, rb_f_getenv, env_fetch, rb_env_path_tainted,
env_aset): ditto.
* ruby.c (proc_options): ditto.
Fri Jun 20 00:45:19 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org> Fri Jun 20 00:45:19 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
* lib/csv.rb: Import csv module. * lib/csv.rb: Import csv module.

View File

@ -165,6 +165,16 @@ flush_register_windows(void)
#endif #endif
#define PATH_SEP_CHAR PATH_SEP[0] #define PATH_SEP_CHAR PATH_SEP[0]
#if defined(__human68k__)
#define PATH_ENV "path"
#else
#define PATH_ENV "PATH"
#endif
#if defined(DOSISH) || !defined(__human68k__)
#define ENV_IGNORECASE
#endif
#if defined(__human68k__) #if defined(__human68k__)
#undef HAVE_RANDOM #undef HAVE_RANDOM
#undef HAVE_SETITIMER #undef HAVE_SETITIMER

6
dln.c
View File

@ -1591,11 +1591,7 @@ dln_find_exe(fname, path)
const char *path; const char *path;
{ {
if (!path) { if (!path) {
#if defined(__human68k__) path = getenv(PATH_ENV);
path = getenv("path");
#else
path = getenv("PATH");
#endif
} }
if (!path) { if (!path) {

40
hash.c
View File

@ -1017,10 +1017,10 @@ env_delete(obj, name)
VALUE value = env_str_new2(val); VALUE value = env_str_new2(val);
ruby_setenv(nam, 0); ruby_setenv(nam, 0);
#ifdef DOSISH #ifdef ENV_IGNORECASE
if (strcasecmp(nam, "PATH") == 0) { if (strcasecmp(nam, PATH_ENV) == 0) {
#else #else
if (strcmp(nam, "PATH") == 0) { if (strcmp(nam, PATH_ENV) == 0) {
#endif #endif
path_tainted = 0; path_tainted = 0;
} }
@ -1053,10 +1053,10 @@ rb_f_getenv(obj, name)
} }
env = getenv(nam); env = getenv(nam);
if (env) { if (env) {
#ifdef DOSISH #ifdef ENV_IGNORECASE
if (strcasecmp(nam, "PATH") == 0 && !rb_env_path_tainted()) if (strcasecmp(nam, PATH_ENV) == 0 && !rb_env_path_tainted())
#else #else
if (strcmp(nam, "PATH") == 0 && !rb_env_path_tainted()) if (strcmp(nam, PATH_ENV) == 0 && !rb_env_path_tainted())
#endif #endif
{ {
VALUE str = rb_str_new2(env); VALUE str = rb_str_new2(env);
@ -1096,10 +1096,10 @@ env_fetch(argc, argv)
} }
return if_none; return if_none;
} }
#ifdef DOSISH #ifdef ENV_IGNORECASE
if (strcasecmp(nam, "PATH") == 0 && !rb_env_path_tainted()) if (strcasecmp(nam, PATH_ENV) == 0 && !rb_env_path_tainted())
#else #else
if (strcmp(nam, "PATH") == 0 && !rb_env_path_tainted()) if (strcmp(nam, PATH_ENV) == 0 && !rb_env_path_tainted())
#endif #endif
return rb_str_new2(env); return rb_str_new2(env);
return env_str_new2(env); return env_str_new2(env);
@ -1116,7 +1116,7 @@ int
rb_env_path_tainted() rb_env_path_tainted()
{ {
if (path_tainted < 0) { if (path_tainted < 0) {
path_tainted_p(getenv("PATH")); path_tainted_p(getenv(PATH_ENV));
} }
return path_tainted; return path_tainted;
} }
@ -1131,8 +1131,8 @@ envix(nam)
env = GET_ENVIRON(environ); env = GET_ENVIRON(environ);
for (i = 0; env[i]; i++) { for (i = 0; env[i]; i++) {
if ( if (
#ifdef WIN32 #ifdef ENV_IGNORECASE
strnicmp(env[i],nam,len) == 0 strncasecmp(env[i],nam,len) == 0
#else #else
memcmp(env[i],nam,len) == 0 memcmp(env[i],nam,len) == 0
#endif #endif
@ -1148,7 +1148,7 @@ ruby_setenv(name, value)
const char *name; const char *name;
const char *value; const char *value;
{ {
#if defined(WIN32) && !defined(__CYGWIN32__) #if defined(_WIN32)
/* The sane way to deal with the environment. /* The sane way to deal with the environment.
* Has these advantages over putenv() & co.: * Has these advantages over putenv() & co.:
* * enables us to store a truly empty value in the * * enables us to store a truly empty value in the
@ -1259,7 +1259,11 @@ env_aset(obj, nm, val)
rb_raise(rb_eArgError, "bad environment variable value"); rb_raise(rb_eArgError, "bad environment variable value");
ruby_setenv(name, value); ruby_setenv(name, value);
if (strcmp(name, "PATH") == 0) { #ifdef ENV_IGNORECASE
if (strcasecmp(name, PATH_ENV) == 0) {
#else
if (strcmp(name, PATH_ENV) == 0) {
#endif
if (OBJ_TAINTED(val)) { if (OBJ_TAINTED(val)) {
/* already tainted, no check */ /* already tainted, no check */
path_tainted = 1; path_tainted = 1;
@ -1580,7 +1584,11 @@ env_has_value(dmy, value)
while (*env) { while (*env) {
char *s = strchr(*env, '=')+1; char *s = strchr(*env, '=')+1;
if (s) { if (s) {
#ifdef ENV_IGNORECASE
if (strncasecmp(s, RSTRING(value)->ptr, strlen(s)) == 0) {
#else
if (strncmp(s, RSTRING(value)->ptr, strlen(s)) == 0) { if (strncmp(s, RSTRING(value)->ptr, strlen(s)) == 0) {
#endif
FREE_ENVIRON(environ); FREE_ENVIRON(environ);
return Qtrue; return Qtrue;
} }
@ -1603,7 +1611,11 @@ env_index(dmy, value)
while (*env) { while (*env) {
char *s = strchr(*env, '=')+1; char *s = strchr(*env, '=')+1;
if (s) { if (s) {
#ifdef ENV_IGNORECASE
if (strncasecmp(s, RSTRING(value)->ptr, strlen(s)) == 0) {
#else
if (strncmp(s, RSTRING(value)->ptr, strlen(s)) == 0) { if (strncmp(s, RSTRING(value)->ptr, strlen(s)) == 0) {
#endif
str = env_str_new(*env, s-*env-1); str = env_str_new(*env, s-*env-1);
FREE_ENVIRON(environ); FREE_ENVIRON(environ);
return str; return str;

2
ruby.c
View File

@ -726,7 +726,7 @@ proc_options(argc, argv)
script = dln_find_file(argv[0], path); script = dln_find_file(argv[0], path);
} }
if (!script) { if (!script) {
script = dln_find_file(argv[0], getenv("PATH")); script = dln_find_file(argv[0], getenv(PATH_ENV));
} }
if (!script) script = argv[0]; if (!script) script = argv[0];
} }

View File

@ -1,11 +1,11 @@
#define RUBY_VERSION "1.8.0" #define RUBY_VERSION "1.8.0"
#define RUBY_RELEASE_DATE "2003-06-19" #define RUBY_RELEASE_DATE "2003-06-20"
#define RUBY_VERSION_CODE 180 #define RUBY_VERSION_CODE 180
#define RUBY_RELEASE_CODE 20030619 #define RUBY_RELEASE_CODE 20030620
#define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 8 #define RUBY_VERSION_MINOR 8
#define RUBY_VERSION_TEENY 0 #define RUBY_VERSION_TEENY 0
#define RUBY_RELEASE_YEAR 2003 #define RUBY_RELEASE_YEAR 2003
#define RUBY_RELEASE_MONTH 6 #define RUBY_RELEASE_MONTH 6
#define RUBY_RELEASE_DAY 19 #define RUBY_RELEASE_DAY 20