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

rb_source_loc -> rb_source_location_cstr

* vm.c (rb_source_loc): rename to rb_source_location_cstr()
  to make behavior clear compare with rb_source_location().

* error.c (warning_string): use rb_source_location_cstr() directly.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60792 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2017-11-16 05:52:19 +00:00
parent 15abb96177
commit 360b78e4dc
5 changed files with 10 additions and 12 deletions

10
error.c
View file

@ -229,11 +229,9 @@ static VALUE
warning_string(rb_encoding *enc, const char *fmt, va_list args) warning_string(rb_encoding *enc, const char *fmt, va_list args)
{ {
int line; int line;
VALUE file = rb_source_location(&line); const char *file = rb_source_location_cstr(&line);
return warn_vsprintf(enc, return warn_vsprintf(enc,
NIL_P(file) ? NULL : RSTRING_PTR(file), line, RSTRING_PTR(file), line, fmt, args);
fmt, args);
} }
#define with_warning_string(mesg, enc, fmt) \ #define with_warning_string(mesg, enc, fmt) \
@ -533,7 +531,7 @@ rb_bug(const char *fmt, ...)
int line = 0; int line = 0;
if (GET_EC()) { if (GET_EC()) {
file = rb_source_loc(&line); file = rb_source_location_cstr(&line);
} }
report_bug(file, line, fmt, NULL); report_bug(file, line, fmt, NULL);
@ -548,7 +546,7 @@ rb_bug_context(const void *ctx, const char *fmt, ...)
int line = 0; int line = 0;
if (GET_EC()) { if (GET_EC()) {
file = rb_source_loc(&line); file = rb_source_location_cstr(&line);
} }
report_bug(file, line, fmt, ctx); report_bug(file, line, fmt, ctx);

2
eval.c
View file

@ -504,7 +504,7 @@ setup_exception(rb_execution_context_t *ec, int tag, volatile VALUE mesg, VALUE
const char *file = 0; const char *file = 0;
int line; int line;
file = rb_source_loc(&line); file = rb_source_location_cstr(&line);
if ((file && !NIL_P(mesg)) || (cause != Qundef)) { if ((file && !NIL_P(mesg)) || (cause != Qundef)) {
volatile int state = 0; volatile int state = 0;

2
gc.c
View file

@ -1874,7 +1874,7 @@ newobj_init(VALUE klass, VALUE flags, VALUE v1, VALUE v2, VALUE v3, int wb_prote
#endif #endif
#if GC_DEBUG #if GC_DEBUG
RANY(obj)->file = rb_source_loc(&RANY(obj)->line); RANY(obj)->file = rb_source_location_cstr(&RANY(obj)->line);
GC_ASSERT(!SPECIAL_CONST_P(obj)); /* check alignment */ GC_ASSERT(!SPECIAL_CONST_P(obj)); /* check alignment */
#endif #endif

View file

@ -1767,7 +1767,7 @@ void rb_vm_change_state(void);
void rb_vm_inc_const_missing_count(void); void rb_vm_inc_const_missing_count(void);
const void **rb_vm_get_insns_address_table(void); const void **rb_vm_get_insns_address_table(void);
VALUE rb_source_location(int *pline); VALUE rb_source_location(int *pline);
const char *rb_source_loc(int *pline); const char *rb_source_location_cstr(int *pline);
void rb_vm_pop_cfunc_frame(void); void rb_vm_pop_cfunc_frame(void);
int rb_vm_add_root_module(ID id, VALUE module); int rb_vm_add_root_module(ID id, VALUE module);
void rb_vm_check_redefinition_by_prepend(VALUE klass); void rb_vm_check_redefinition_by_prepend(VALUE klass);
@ -1944,7 +1944,7 @@ RUBY_SYMBOL_EXPORT_END
do { \ do { \
if (UNLIKELY(RUBY_DTRACE_##name##_ENABLED())) { \ if (UNLIKELY(RUBY_DTRACE_##name##_ENABLED())) { \
int dtrace_line; \ int dtrace_line; \
const char *dtrace_file = rb_source_loc(&dtrace_line); \ const char *dtrace_file = rb_source_location_cstr(&dtrace_line); \
if (!dtrace_file) dtrace_file = ""; \ if (!dtrace_file) dtrace_file = ""; \
RUBY_DTRACE_##name(arg, dtrace_file, dtrace_line); \ RUBY_DTRACE_##name(arg, dtrace_file, dtrace_line); \
} \ } \

4
vm.c
View file

@ -356,7 +356,7 @@ rb_dtrace_setup(rb_execution_context_t *ec, VALUE klass, ID id,
VALUE name = rb_class_path_no_cache(klass); VALUE name = rb_class_path_no_cache(klass);
const char *classname, *filename; const char *classname, *filename;
const char *methodname = rb_id2name(id); const char *methodname = rb_id2name(id);
if (methodname && (filename = rb_source_loc(&args->line_no)) != 0) { if (methodname && (filename = rb_source_location_cstr(&args->line_no)) != 0) {
if (NIL_P(name) || !(classname = StringValuePtr(name))) if (NIL_P(name) || !(classname = StringValuePtr(name)))
classname = "<unknown>"; classname = "<unknown>";
args->classname = classname; args->classname = classname;
@ -1298,7 +1298,7 @@ rb_source_location(int *pline)
} }
const char * const char *
rb_source_loc(int *pline) rb_source_location_cstr(int *pline)
{ {
VALUE path = rb_source_location(pline); VALUE path = rb_source_location(pline);
if (NIL_P(path)) return NULL; if (NIL_P(path)) return NULL;