1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@903 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2000-08-25 08:26:06 +00:00
parent d68d1d1584
commit df9d49d088
8 changed files with 80 additions and 47 deletions

View file

@ -1,3 +1,18 @@
Fri Aug 25 15:24:39 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
* variable.c (rb_cvar_get): should not follow __attached__.
* variable.c (mod_av_set): second class variable assignment at the
toplevel shoule not give warning.
Fri Aug 25 01:18:36 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
* io.c (next_argv): prepare path for open file.
* string.c (rb_str_setter): moved from io.c.
* io.c (next_argv): filename should be "-" for refreshed ARGF.
Thu Aug 24 15:27:39 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
* ext/socket/socketport.h: use `extern int h_errno' if needed.

3
eval.c
View file

@ -3590,6 +3590,9 @@ assign(self, lhs, val, check)
break;
case NODE_CVDECL:
rb_cvar_declare(ruby_cbase, lhs->nd_vid, val);
break;
case NODE_CVASGN:
rb_cvar_set(ruby_cbase, lhs->nd_vid, val);
break;

View file

@ -204,7 +204,6 @@ VALUE rb_io_eof _((VALUE));
VALUE rb_io_binmode _((VALUE));
VALUE rb_file_open _((const char*, const char*));
VALUE rb_gets _((void));
void rb_str_setter _((VALUE, ID, VALUE*));
/* numeric.c */
void rb_num_zerodiv _((void));
VALUE rb_num_coerce_bin _((VALUE, VALUE));
@ -320,6 +319,7 @@ VALUE rb_str_upto _((VALUE, VALUE, int));
VALUE rb_str_inspect _((VALUE));
VALUE rb_str_split _((VALUE, const char*));
void rb_str_associate _((VALUE, VALUE));
void rb_str_setter _((VALUE, ID, VALUE*));
/* struct.c */
VALUE rb_struct_new __((VALUE, ...));
VALUE rb_struct_define __((const char*, ...));

48
io.c
View file

@ -19,6 +19,14 @@
#include <ctype.h>
#include <errno.h>
#if defined(MSDOS) || defined(__BOW__) || defined(__CYGWIN__) || defined(NT) || defined(__human68k__) || defined(__EMX__)
# define NO_SAFE_RENAME
#endif
#if defined(MSDOS) || defined(__CYGWIN__) || defined(NT)
# define NO_LONG_FNAME
#endif
#include <sys/types.h>
#if !defined(DJGPP) && !defined(NT) && !defined(__human68k__)
#include <sys/ioctl.h>
@ -2244,6 +2252,18 @@ prep_stdio(f, mode, klass)
return (VALUE)io;
}
static VALUE
prep_path(io, path)
VALUE io;
char *path;
{
OpenFile *fptr;
GetOpenFile(io, fptr);
if (fptr->path) rb_bug("illegal prep_path() call");
fptr->path = strdup(path);
}
static VALUE
rb_io_s_new(argc, argv, klass)
int argc;
@ -2360,6 +2380,7 @@ next_argv()
else {
next_p = -1;
current_file = rb_stdin;
filename = rb_str_new2("-");
}
init_p = 1;
first_p = 0;
@ -2375,6 +2396,7 @@ next_argv()
if (strlen(fn) == 1 && fn[0] == '-') {
current_file = rb_stdin;
if (ruby_inplace_mode) {
rb_warn("Can't do inplace edit for stdio");
rb_defout = rb_stdout;
}
}
@ -2392,12 +2414,12 @@ next_argv()
fstat(fileno(fr), &st);
if (*ruby_inplace_mode) {
str = rb_str_new2(fn);
#if defined(MSDOS) || defined(__CYGWIN__) || defined(NT)
#ifdef NO_LONG_FNAME
ruby_add_suffix(str, ruby_inplace_mode);
#else
rb_str_cat2(str, ruby_inplace_mode);
#endif
#if defined(MSDOS) || defined(__BOW__) || defined(__CYGWIN__) || defined(NT) || defined(__human68k__) || defined(__EMX__)
#ifdef NO_SAFE_RENAME
(void)fclose(fr);
(void)unlink(RSTRING(str)->ptr);
(void)rename(fn, RSTRING(str)->ptr);
@ -2412,19 +2434,19 @@ next_argv()
#endif
}
else {
#if !defined(MSDOS) && !defined(__BOW__) && !defined(__CYGWIN__) && !defined(NT) && !defined(__human68k__)
#ifdef NO_SAFE_RENAME
rb_fatal("Can't do inplace edit without backup");
#else
if (unlink(fn) < 0) {
rb_warn("Can't remove %s: %s, skipping file",
fn, strerror(errno));
fclose(fr);
goto retry;
}
#else
rb_fatal("Can't do inplace edit without backup");
#endif
}
fw = rb_fopen(fn, "w");
#if !defined(MSDOS) && !defined(__CYGWIN__) && !(NT) && !defined(__human68k__) && !defined(__BEOS__) && !defined(__EMX__)
#ifndef NO_SAFE_RENAME
fstat(fileno(fw), &st2);
fchmod(fileno(fw), st.st_mode);
if (st.st_uid!=st2.st_uid || st.st_gid!=st2.st_gid) {
@ -2432,8 +2454,10 @@ next_argv()
}
#endif
rb_defout = prep_stdio(fw, FMODE_WRITABLE, rb_cFile);
prep_path(rb_defout, fn);
}
current_file = prep_stdio(fr, FMODE_READABLE, rb_cFile);
prep_path(current_file, fn);
}
if (binmode) rb_io_binmode(current_file);
}
@ -2557,18 +2581,6 @@ rb_f_readlines(argc, argv)
return ary;
}
void
rb_str_setter(val, id, var)
VALUE val;
ID id;
VALUE *var;
{
if (!NIL_P(val) && TYPE(val) != T_STRING) {
rb_raise(rb_eTypeError, "value of %s must be String", rb_id2name(id));
}
*var = val;
}
static VALUE
rb_f_backquote(obj, str)
VALUE obj, str;

View file

@ -3550,7 +3550,7 @@ re_match(bufp, string_arg, size, pos, regs)
stacke = &stackb[MAX_NUM_FAILURE_ITEMS * NFAILURES];
#ifdef DEBUG_REGEX
fprintf(stderr, "Entering re_match(%s%s)\n", string1_arg, string2_arg);
fprintf(stderr, "Entering re_match(%s)\n", string_arg);
#endif
/* Initialize subexpression text positions to -1 to mark ones that no

View file

@ -2753,6 +2753,18 @@ rb_str_center(str, w)
return res;
}
void
rb_str_setter(val, id, var)
VALUE val;
ID id;
VALUE *var;
{
if (!NIL_P(val) && TYPE(val) != T_STRING) {
rb_raise(rb_eTypeError, "value of %s must be String", rb_id2name(id));
}
*var = val;
}
void
Init_String()
{

View file

@ -1228,11 +1228,12 @@ rb_const_defined(klass, id)
}
static void
rb_mod_av_set(klass, id, val, dest)
mod_av_set(klass, id, val, dest, once)
VALUE klass;
ID id;
VALUE val;
char *dest;
int once;
{
if (!OBJ_TAINTED(klass) && rb_safe_level() >= 4)
rb_raise(rb_eSecurityError, "Insecure: can't set %s", dest);
@ -1240,7 +1241,7 @@ rb_mod_av_set(klass, id, val, dest)
if (!RCLASS(klass)->iv_tbl) {
RCLASS(klass)->iv_tbl = st_init_numtable();
}
else if (st_lookup(RCLASS(klass)->iv_tbl, id, 0)) {
else if (once && st_lookup(RCLASS(klass)->iv_tbl, id, 0)) {
rb_warn("already initialized %s %s", dest, rb_id2name(id));
}
@ -1253,7 +1254,7 @@ rb_const_set(klass, id, val)
ID id;
VALUE val;
{
rb_mod_av_set(klass, id, val, "constant");
mod_av_set(klass, id, val, "constant", Qtrue);
}
void
@ -1323,18 +1324,6 @@ rb_define_global_const(name, val)
rb_define_const(rb_cObject, name, val);
}
void
rb_cvar_declare(klass, id, val)
VALUE klass;
ID id;
VALUE val;
{
if (FL_TEST(klass, FL_SINGLETON)) {
klass = rb_iv_get(klass, "__attached__");
}
rb_mod_av_set(klass, id, val, "class variable");
}
void
rb_cvar_set(klass, id, val)
VALUE klass;
@ -1345,9 +1334,6 @@ rb_cvar_set(klass, id, val)
if (!OBJ_TAINTED(klass) && rb_safe_level() >= 4)
rb_raise(rb_eSecurityError, "Insecure: can't modify class variable");
if (FL_TEST(klass, FL_SINGLETON)) {
klass = rb_iv_get(klass, "__attached__");
}
tmp = klass;
while (tmp) {
if (RCLASS(tmp)->iv_tbl && st_lookup(RCLASS(tmp)->iv_tbl,id,0)) {
@ -1357,7 +1343,17 @@ rb_cvar_set(klass, id, val)
tmp = RCLASS(tmp)->super;
}
rb_raise(rb_eNameError,"uninitialized class variable %s",rb_id2name(id));
rb_raise(rb_eNameError,"uninitialized class variable %s in %s",
rb_id2name(id), rb_class2name(klass));
}
void
rb_cvar_declare(klass, id, val)
VALUE klass;
ID id;
VALUE val;
{
mod_av_set(klass, id, val, "class variable", Qfalse);
}
VALUE
@ -1368,9 +1364,6 @@ rb_cvar_get(klass, id)
VALUE value;
VALUE tmp;
if (FL_TEST(klass, FL_SINGLETON)) {
klass = rb_iv_get(klass, "__attached__");
}
tmp = klass;
while (tmp) {
if (RCLASS(tmp)->iv_tbl && st_lookup(RCLASS(tmp)->iv_tbl,id,&value)) {
@ -1379,7 +1372,8 @@ rb_cvar_get(klass, id)
tmp = RCLASS(tmp)->super;
}
rb_raise(rb_eNameError,"uninitialized class variable %s",rb_id2name(id));
rb_raise(rb_eNameError,"uninitialized class variable %s in %s",
rb_id2name(id), rb_class2name(klass));
return Qnil; /* not reached */
}
@ -1390,9 +1384,6 @@ rb_cvar_defined(klass, id)
{
VALUE tmp;
if (FL_TEST(klass, FL_SINGLETON)) {
klass = rb_iv_get(klass, "__attached__");
}
tmp = klass;
while (tmp) {
if (RCLASS(tmp)->iv_tbl && st_lookup(RCLASS(tmp)->iv_tbl,id,0)) {

View file

@ -1,4 +1,4 @@
#define RUBY_VERSION "1.5.5"
#define RUBY_VERSION "1.6.0"
#define RUBY_RELEASE_DATE "2000-08-24"
#define RUBY_VERSION_CODE 155
#define RUBY_RELEASE_CODE 20000824