summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog15
-rw-r--r--eval.c3
-rw-r--r--intern.h2
-rw-r--r--io.c48
-rw-r--r--regex.c2
-rw-r--r--string.c12
-rw-r--r--variable.c43
-rw-r--r--version.h2
8 files changed, 80 insertions, 47 deletions
diff --git a/ChangeLog b/ChangeLog
index 4debc6953da..9a70f640ea6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/eval.c b/eval.c
index 837fe1c706e..3de2f57f03e 100644
--- a/eval.c
+++ b/eval.c
@@ -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;
diff --git a/intern.h b/intern.h
index 6369cace440..b37c4dcea7a 100644
--- a/intern.h
+++ b/intern.h
@@ -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*, ...));
diff --git a/io.c b/io.c
index 9f03c09a96e..bbbe04bec72 100644
--- a/io.c
+++ b/io.c
@@ -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>
@@ -2245,6 +2253,18 @@ prep_stdio(f, mode, klass)
}
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;
VALUE *argv;
@@ -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;
diff --git a/regex.c b/regex.c
index f5a27c3d0c1..fbb0aaab9ee 100644
--- a/regex.c
+++ b/regex.c
@@ -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
diff --git a/string.c b/string.c
index b9399c2fd1b..01f3f03d15c 100644
--- a/string.c
+++ b/string.c
@@ -2754,6 +2754,18 @@ rb_str_center(str, w)
}
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()
{
rb_cString = rb_define_class("String", rb_cObject);
diff --git a/variable.c b/variable.c
index 36882a30633..3885693d9a8 100644
--- a/variable.c
+++ b/variable.c
@@ -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
@@ -1324,18 +1325,6 @@ rb_define_global_const(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;
ID id;
@@ -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)) {
diff --git a/version.h b/version.h
index e646222a5c2..dd2a9807917 100644
--- a/version.h
+++ b/version.h
@@ -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