ruby-changes:29546
From: charliesome <ko1@a...>
Date: Mon, 24 Jun 2013 22:03:46 +0900 (JST)
Subject: [ruby-changes:29546] charliesome:r41598 (trunk): * eval_error.c (warn_printf): use rb_vsprintf instead so ruby specific
charliesome 2013-06-24 22:03:35 +0900 (Mon, 24 Jun 2013) New Revision: 41598 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=41598 Log: * eval_error.c (warn_printf): use rb_vsprintf instead so ruby specific extensions like PRIsVALUE can be used in format strings * eval_error.c (error_print): use warn_print_str (alias for rb_write_error_str) to print a string value instead of using RSTRING_PTR and RSTRING_LEN manually * eval.c (setup_exception): use PRIsVALUE instead of %s and RSTRING_PTR Modified files: trunk/ChangeLog trunk/eval.c trunk/eval_error.c Index: ChangeLog =================================================================== --- ChangeLog (revision 41597) +++ ChangeLog (revision 41598) @@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Mon Jun 24 22:04:00 2013 Charlie Somerville <charliesome@r...> + + * eval_error.c (warn_printf): use rb_vsprintf instead so ruby specific + extensions like PRIsVALUE can be used in format strings + * eval_error.c (error_print): use warn_print_str (alias for + rb_write_error_str) to print a string value instead of using + RSTRING_PTR and RSTRING_LEN manually + * eval.c (setup_exception): use PRIsVALUE instead of %s and RSTRING_PTR + Mon Jun 24 20:31:00 2013 Charlie Somerville <charliesome@r...> * compile.c (make_name_for_block): use PRIsVALUE in format string Index: eval_error.c =================================================================== --- eval_error.c (revision 41597) +++ eval_error.c (revision 41598) @@ -6,17 +6,18 @@ https://github.com/ruby/ruby/blob/trunk/eval_error.c#L6 static void warn_printf(const char *fmt, ...) { - char buf[BUFSIZ]; + VALUE str; va_list args; va_init_list(args, fmt); - vsnprintf(buf, BUFSIZ, fmt, args); + str = rb_vsprintf(fmt, args); va_end(args); - rb_write_error(buf); + rb_write_error_str(str); } #define warn_print(x) rb_write_error(x) #define warn_print2(x,l) rb_write_error2((x),(l)) +#define warn_print_str(x) rb_write_error_str(x) static void error_pos(void) @@ -122,7 +123,7 @@ error_print(void) https://github.com/ruby/ruby/blob/trunk/eval_error.c#L123 if (NIL_P(mesg)) error_pos(); else { - warn_print2(RSTRING_PTR(mesg), RSTRING_LEN(mesg)); + warn_print_str(mesg); } } @@ -147,7 +148,7 @@ error_print(void) https://github.com/ruby/ruby/blob/trunk/eval_error.c#L148 epath = rb_class_name(eclass); if (elen == 0) { warn_print(": "); - warn_print2(RSTRING_PTR(epath), RSTRING_LEN(epath)); + warn_print_str(epath); warn_print("\n"); } else { @@ -164,7 +165,7 @@ error_print(void) https://github.com/ruby/ruby/blob/trunk/eval_error.c#L165 warn_print2(einfo, len); if (epath) { warn_print(" ("); - warn_print2(RSTRING_PTR(epath), RSTRING_LEN(epath)); + warn_print_str(epath); warn_print(")\n"); } if (tail) { @@ -186,7 +187,7 @@ error_print(void) https://github.com/ruby/ruby/blob/trunk/eval_error.c#L187 for (i = 1; i < len; i++) { VALUE line = RARRAY_AREF(errat, i); if (RB_TYPE_P(line, T_STRING)) { - warn_printf("\tfrom %s\n", RSTRING_PTR(line)); + warn_printf("\tfrom %"PRIsVALUE"\n", line); } if (skip && i == TRACE_HEAD && len > TRACE_MAX) { warn_printf("\t ... %ld levels...\n", Index: eval.c =================================================================== --- eval.c (revision 41597) +++ eval.c (revision 41598) @@ -479,19 +479,16 @@ setup_exception(rb_thread_t *th, int tag https://github.com/ruby/ruby/blob/trunk/eval.c#L479 if ((status = EXEC_TAG()) == 0) { RB_GC_GUARD(e) = rb_obj_as_string(e); if (file && line) { - warn_printf("Exception `%s' at %s:%d - %s\n", - rb_obj_classname(th->errinfo), - file, line, RSTRING_PTR(e)); + warn_printf("Exception `%s' at %s:%d - %"PRIsVALUE"\n", + rb_obj_classname(th->errinfo), file, line, e); } else if (file) { - warn_printf("Exception `%s' at %s - %s\n", - rb_obj_classname(th->errinfo), - file, RSTRING_PTR(e)); + warn_printf("Exception `%s' at %s - %"PRIsVALUE"\n", + rb_obj_classname(th->errinfo), file, e); } else { - warn_printf("Exception `%s' - %s\n", - rb_obj_classname(th->errinfo), - RSTRING_PTR(e)); + warn_printf("Exception `%s' - %"PRIsVALUE"\n", + rb_obj_classname(th->errinfo), e); } } POP_TAG(); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/