summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-03-07 11:19:37 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-03-07 11:19:37 +0000
commiteffd8230ea7f34fac60cca80d4a50c7975bd9f22 (patch)
treef61b7e2710f6e94657630069b9a4c7232eea0141
parent6dc931e59f7f0099909a077dfbd6be5e4326ae09 (diff)
* gc.c (rb_source_filename): added. holds unique strings for file
names with GC space. * gc.c (rb_gc_mark): mark source file name. * gc.c (gc_sweep): ditto. * gc.c (Init_GC): initialize source file name table. * intern.h (rb_source_filename): added. * eval.c (rb_eval_string): use rb_source_filename(). * parse.y (yycompile): ditto. * ruby.c (proc_options): ditto. * ruby.c (load_file): ditto. * ruby.c (ruby_script): ditto. * ruby.c (ruby_prog_init): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2166 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog25
-rw-r--r--eval.c2
-rw-r--r--gc.c48
-rw-r--r--intern.h1
-rw-r--r--parse.y2
-rw-r--r--ruby.c8
-rw-r--r--version.h4
7 files changed, 82 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index c211d86aea..1bf6292b3a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+Thu Mar 7 20:08:25 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * gc.c (rb_source_filename): added. holds unique strings for file
+ names with GC space.
+
+ * gc.c (rb_gc_mark): mark source file name.
+
+ * gc.c (gc_sweep): ditto.
+
+ * gc.c (Init_GC): initialize source file name table.
+
+ * intern.h (rb_source_filename): added.
+
+ * eval.c (rb_eval_string): use rb_source_filename().
+
+ * parse.y (yycompile): ditto.
+
+ * ruby.c (proc_options): ditto.
+
+ * ruby.c (load_file): ditto.
+
+ * ruby.c (ruby_script): ditto.
+
+ * ruby.c (ruby_prog_init): ditto.
+
Wed Mar 6 17:58:08 2002 WATANABE Hirofumi <eban@ruby-lang.org>
* dln.c (dln_load): use LoadLibrary instead of LoadLibraryEx.
diff --git a/eval.c b/eval.c
index 7c6343fa41..759e041802 100644
--- a/eval.c
+++ b/eval.c
@@ -1248,7 +1248,7 @@ rb_eval_string(str)
VALUE v;
char *oldsrc = ruby_sourcefile;
- ruby_sourcefile = "(eval)";
+ ruby_sourcefile = rb_source_filename("(eval)");
v = eval(ruby_top_self, rb_str_new2(str), Qnil, 0, 0);
ruby_sourcefile = oldsrc;
diff --git a/gc.c b/gc.c
index b6115abb93..e95f38e6b3 100644
--- a/gc.c
+++ b/gc.c
@@ -428,6 +428,48 @@ init_mark_stack()
static void rb_gc_mark_children(VALUE ptr);
+static st_table *source_filenames;
+
+char *
+rb_source_filename(f)
+ const char *f;
+{
+ char *name;
+
+ if (!st_lookup(source_filenames, f, &name)) {
+ long len = strlen(f) + 1;
+ char *ptr = name = ALLOC_N(char, len + 1);
+ *ptr++ = 0;
+ MEMCPY(ptr, f, char, len);
+ st_add_direct(source_filenames, ptr, name);
+ return ptr;
+ }
+ return name + 1;
+}
+
+static void
+mark_source_filename(f)
+ char *f;
+{
+ if (f) {
+ f[-1] = 1;
+ }
+}
+
+static enum st_retval
+sweep_source_filename(key, value)
+ char *key, *value;
+{
+ if (*value) {
+ *value = 0;
+ return ST_CONTINUE;
+ }
+ else {
+ free(value);
+ return ST_DELETE;
+ }
+}
+
static void
gc_mark_all()
{
@@ -604,6 +646,7 @@ rb_gc_mark_children(ptr)
break;
case T_NODE:
+ mark_source_filename(obj->as.node.nd_file);
switch (nd_type(obj)) {
case NODE_IF: /* 1,2,3 */
case NODE_FOR:
@@ -846,6 +889,9 @@ gc_sweep()
}
}
+ mark_source_filename(ruby_sourcefile);
+ st_foreach(source_filenames, sweep_source_filename, 0);
+
freelist = 0;
final_list = deferred_final_list;
deferred_final_list = 0;
@@ -1510,4 +1556,6 @@ Init_GC()
rb_global_variable(&finalizers);
rb_gc_unregister_address(&rb_mObSpace);
finalizers = rb_ary_new();
+
+ source_filenames = st_init_strtable();
}
diff --git a/intern.h b/intern.h
index 36998df00d..5310f1c03d 100644
--- a/intern.h
+++ b/intern.h
@@ -198,6 +198,7 @@ VALUE rb_find_file _((VALUE));
/* gc.c */
int ruby_stack_check _((void));
int ruby_stack_length _((VALUE**));
+char *rb_source_filename _((const char *));
void rb_gc_mark_locations _((VALUE*, VALUE*));
void rb_mark_tbl _((struct st_table*));
void rb_mark_hash _((struct st_table*));
diff --git a/parse.y b/parse.y
index 7845433ce0..ee36daf7ae 100644
--- a/parse.y
+++ b/parse.y
@@ -2123,7 +2123,7 @@ yycompile(f, line)
ruby__end__seen = 0;
ruby_eval_tree = 0;
heredoc_end = 0;
- ruby_sourcefile = strdup(f);
+ ruby_sourcefile = rb_source_filename(f);
ruby_in_compile = 1;
n = yyparse();
ruby_debug_lines = 0;
diff --git a/ruby.c b/ruby.c
index bd7d599ac0..155a6fa0ad 100644
--- a/ruby.c
+++ b/ruby.c
@@ -717,7 +717,7 @@ proc_options(argc, argv)
process_sflag();
ruby_init_loadpath();
- ruby_sourcefile = argv0;
+ ruby_sourcefile = rb_source_filename(argv0);
if (e_script) {
require_libraries();
rb_compile_string(script, e_script, 1);
@@ -825,7 +825,7 @@ load_file(fname, script)
argv[0] = path;
execv(path, argv);
- ruby_sourcefile = fname;
+ ruby_sourcefile = rb_source_filename(fname);
ruby_sourceline = 1;
rb_fatal("Can't exec %s", path);
}
@@ -951,7 +951,7 @@ ruby_script(name)
{
if (name) {
rb_progname = rb_tainted_str_new2(name);
- ruby_sourcefile = name;
+ ruby_sourcefile = rb_source_filename(name);
}
}
@@ -990,7 +990,7 @@ ruby_prog_init()
{
init_ids();
- ruby_sourcefile = "ruby";
+ ruby_sourcefile = rb_source_filename("ruby");
rb_define_variable("$VERBOSE", &ruby_verbose);
rb_define_variable("$-v", &ruby_verbose);
rb_define_variable("$-w", &ruby_verbose);
diff --git a/version.h b/version.h
index 6483098e8c..733f1838c2 100644
--- a/version.h
+++ b/version.h
@@ -1,4 +1,4 @@
#define RUBY_VERSION "1.7.2"
-#define RUBY_RELEASE_DATE "2002-03-06"
+#define RUBY_RELEASE_DATE "2002-03-07"
#define RUBY_VERSION_CODE 172
-#define RUBY_RELEASE_CODE 20020306
+#define RUBY_RELEASE_CODE 20020307