1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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/branches/ruby_1_6@2166 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2002-03-07 11:19:37 +00:00
parent 1fa55abe2c
commit cffe9928c4
7 changed files with 82 additions and 8 deletions

View file

@ -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.

2
eval.c
View file

@ -1221,7 +1221,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;

48
gc.c
View file

@ -368,6 +368,48 @@ is_pointer_to_heap(ptr)
return Qfalse;
}
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
mark_locations_array(x, n)
register VALUE *x;
@ -465,6 +507,7 @@ rb_gc_mark(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:
@ -708,6 +751,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;
@ -1353,4 +1399,6 @@ Init_GC()
rb_global_variable(&finalizers);
rb_gc_unregister_address(&rb_mObSpace);
finalizers = rb_ary_new();
source_filenames = st_init_strtable();
}

View file

@ -193,6 +193,7 @@ void rb_gc_mark_maybe();
void rb_gc_mark();
void rb_gc_force_recycle _((VALUE));
void rb_gc _((void));
char *rb_source_filename _((const char *));
void rb_gc_call_finalizer_at_exit _((void));
/* hash.c */
VALUE rb_hash _((VALUE));

View file

@ -1972,7 +1972,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;

8
ruby.c
View file

@ -714,7 +714,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);
@ -822,7 +822,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);
}
@ -939,7 +939,7 @@ ruby_script(name)
{
if (name) {
rb_progname = rb_tainted_str_new2(name);
ruby_sourcefile = name;
ruby_sourcefile = rb_source_filename(name);
}
}
@ -978,7 +978,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);

View file

@ -1,4 +1,4 @@
#define RUBY_VERSION "1.6.7"
#define RUBY_RELEASE_DATE "2002-03-06"
#define RUBY_RELEASE_DATE "2002-03-07"
#define RUBY_VERSION_CODE 167
#define RUBY_RELEASE_CODE 20020306
#define RUBY_RELEASE_CODE 20020307