diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-01-30 03:49:07 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-01-30 03:49:07 +0000 |
commit | 299d89bdbd6382eff5435535ac87af0c66b83eaf (patch) | |
tree | 4af7e24aec0a352b4c158b095023ea0d28f26d2b /ext/syslog | |
parent | 30d7be39da512f70c9d61754b3e2e4035f426d2e (diff) |
merge revision(s) 44570:44572,44581:
r44570 | nobu | 2014-01-12 17:11:32 +0900 (Sun, 12 Jan 2014) | 4 lines
tcltklib.c: create_ip_exc format argument
* ext/tk/tcltklib.c (create_ip_exc): format argument must not be a
dynamic string, not to contain unescaped %.
------------------------------------------------------------------------
r44571 | nobu | 2014-01-12 17:11:34 +0900 (Sun, 12 Jan 2014) | 5 lines
stubs.c: library name strings
* ext/tk/stubs.c (ruby_open_tcl_dll, ruby_open_tk_dll): make library
names by string literal concatenation at compilation time, not by
sprintf() at runtime.
------------------------------------------------------------------------
r44572 | nobu | 2014-01-12 17:11:36 +0900 (Sun, 12 Jan 2014) | 1 line
ext: use rb_sprintf() and rb_vsprintf() with PRIsVALUE
* ext/bigdecimal/bigdecimal.c (CLASS_NAME): macro to wrap
depending on PRIsVALUE for 1.9. [Backport #9406]
* ext/bigdecimal/bigdecimal.c (DECIMAL_SIZE_OF_BITS): fallback
definition for 2.1 or older. [ruby-core:59750] [Backport #9406]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@44754 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/syslog')
-rw-r--r-- | ext/syslog/syslog.c | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/ext/syslog/syslog.c b/ext/syslog/syslog.c index d1f75101e4..28cee3de28 100644 --- a/ext/syslog/syslog.c +++ b/ext/syslog/syslog.c @@ -12,6 +12,15 @@ #include "ruby/util.h" #include <syslog.h> +#ifdef PRIsVALUE +# define RB_OBJ_CLASSNAME(obj) rb_obj_class(obj) +# define RB_OBJ_STRING(obj) (obj) +#else +# define PRIsVALUE "s" +# define RB_OBJ_CLASSNAME(obj) rb_obj_classname(obj) +# define RB_OBJ_STRING(obj) StringValueCStr(obj) +#endif + /* Syslog class */ static VALUE mSyslog, mSyslogConstants; static const char *syslog_ident = NULL; @@ -301,7 +310,7 @@ static VALUE mSyslog_log(int argc, VALUE *argv, VALUE self) pri = *argv++; if (!FIXNUM_P(pri)) { - rb_raise(rb_eTypeError, "type mismatch: %s given", rb_class2name(CLASS_OF(pri))); + rb_raise(rb_eTypeError, "type mismatch: %"PRIsVALUE" given", RB_OBJ_CLASSNAME(pri)); } syslog_write(FIX2INT(pri), argc, argv); @@ -313,24 +322,17 @@ static VALUE mSyslog_log(int argc, VALUE *argv, VALUE self) */ static VALUE mSyslog_inspect(VALUE self) { - char buf[1024]; - Check_Type(self, T_MODULE); - if (syslog_opened) { - snprintf(buf, sizeof(buf), - "<#%s: opened=true, ident=\"%s\", options=%d, facility=%d, mask=%d>", - rb_class2name(self), - syslog_ident, - syslog_options, - syslog_facility, - syslog_mask); - } else { - snprintf(buf, sizeof(buf), - "<#%s: opened=false>", rb_class2name(self)); - } + if (!syslog_opened) + return rb_sprintf("<#%s: opened=false>", rb_class2name(self)); - return rb_str_new2(buf); + return rb_sprintf("<#%s: opened=true, ident=\"%s\", options=%d, facility=%d, mask=%d>", + rb_class2name(self), + syslog_ident, + syslog_options, + syslog_facility, + syslog_mask); } /* Returns self, for backward compatibility. |