diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2013-05-14 06:49:41 -0700 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2013-05-14 06:49:41 -0700 |
| commit | 7cc66cf819beb5398d6fd40711373f9cfe79b77a (patch) | |
| tree | 1692d5e02a6c4584b5e7cd95696ddebad5bc88fe | |
| parent | 17f10b05f2bb1c70dbc9fee06e16336ed264b098 (diff) | |
| parent | 87eb57b663fd564d81d59a3d79bae0bcf8ad43e0 (diff) | |
| download | mruby-7cc66cf819beb5398d6fd40711373f9cfe79b77a.tar.gz mruby-7cc66cf819beb5398d6fd40711373f9cfe79b77a.zip | |
Merge pull request #1252 from carsonmcdonald/fixfilenames
Fix for issue 1243
| -rw-r--r-- | build_config.rb | 5 | ||||
| -rw-r--r-- | src/codegen.c | 8 | ||||
| -rw-r--r-- | src/load.c | 3 | ||||
| -rw-r--r-- | src/state.c | 1 | ||||
| -rw-r--r-- | tasks/mruby_build_commands.rake | 2 |
5 files changed, 15 insertions, 4 deletions
diff --git a/build_config.rb b/build_config.rb index a6502ac86..75c3520ea 100644 --- a/build_config.rb +++ b/build_config.rb @@ -25,6 +25,11 @@ MRuby::Build.new do |conf| # cc.compile_options = "%{flags} -MMD -o %{outfile} -c %{infile}" # end + # mrbc settings + # conf.mrbc do |mrbc| + # mrbc.compile_options = "-g -B%{funcname} -o- -" # The -g option is required for line numbers + # end + # Linker settings # conf.linker do |linker| # linker.command = ENV['LD'] || 'gcc' diff --git a/src/codegen.c b/src/codegen.c index 38328c669..f4617a570 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -2403,6 +2403,8 @@ scope_finish(codegen_scope *s) { mrb_state *mrb = s->mrb; mrb_irep *irep = s->irep; + size_t fname_len; + char *fname; irep->flags = 0; if (s->iseq) { @@ -2418,7 +2420,11 @@ scope_finish(codegen_scope *s) irep->pool = (mrb_value *)codegen_realloc(s, irep->pool, sizeof(mrb_value)*irep->plen); irep->syms = (mrb_sym *)codegen_realloc(s, irep->syms, sizeof(mrb_sym)*irep->slen); if (s->filename) { - irep->filename = s->filename; + fname_len = strlen(s->filename); + fname = codegen_malloc(s, fname_len + 1); + memcpy(fname, s->filename, fname_len); + fname[fname_len] = '\0'; + irep->filename = fname; } irep->nlocals = s->nlocals; diff --git a/src/load.c b/src/load.c index b3f13a8ef..81d47858a 100644 --- a/src/load.c +++ b/src/load.c @@ -267,9 +267,6 @@ read_rite_lineno_record(mrb_state *mrb, const uint8_t *bin, size_t irepno, uint3 mrb->irep[irepno]->lines = lines; error_exit: - if (fname) { - mrb_free(mrb, fname); - } return ret; } diff --git a/src/state.c b/src/state.c index 9bf051c1a..b34fbd025 100644 --- a/src/state.c +++ b/src/state.c @@ -101,6 +101,7 @@ mrb_irep_free(mrb_state *mrb, struct mrb_irep *irep) mrb_free(mrb, irep->iseq); mrb_free(mrb, irep->pool); mrb_free(mrb, irep->syms); + mrb_free(mrb, (void *)irep->filename); mrb_free(mrb, irep->lines); mrb_free(mrb, irep); } diff --git a/tasks/mruby_build_commands.rake b/tasks/mruby_build_commands.rake index a47633c51..7b61b2dee 100644 --- a/tasks/mruby_build_commands.rake +++ b/tasks/mruby_build_commands.rake @@ -236,6 +236,8 @@ module MRuby end class Command::Mrbc < Command + attr_accessor :compile_options + def initialize(build) super @command = nil |
