diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-10-06 12:03:10 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-10-06 13:32:07 -0700 |
commit | 2ca88db578a4b9143a5dfaa66ce38b9463e7e166 (patch) | |
tree | 42d02488cc054be06f8227b4fedc3580ab4b4f26 | |
parent | c4eca8765e9aaf0d2736e764770d72f407affc16 (diff) | |
download | clogger-2ca88db578a4b9143a5dfaa66ce38b9463e7e166.tar.gz |
Rack will be relaxing the spec to allow subclasses of String objects. Just in case they're not compatible, we'll convert them to strings.
-rw-r--r-- | ext/clogger_ext/clogger.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/ext/clogger_ext/clogger.c b/ext/clogger_ext/clogger.c index f935c11..26d1ec6 100644 --- a/ext/clogger_ext/clogger.c +++ b/ext/clogger_ext/clogger.c @@ -124,7 +124,7 @@ static inline int need_escape(unsigned c) } /* we are encoding-agnostic, clients can send us all sorts of junk */ -static VALUE byte_xs(VALUE from) +static VALUE byte_xs_str(VALUE from) { static const char esc[] = "0123456789ABCDEF"; unsigned char *new_ptr; @@ -164,6 +164,11 @@ static VALUE byte_xs(VALUE from) return rv; } +static VALUE byte_xs(VALUE from) +{ + return byte_xs_str(rb_obj_as_string(from)); +} + static void clogger_mark(void *ptr) { struct clogger *c = ptr; @@ -459,7 +464,7 @@ static void append_request_env(struct clogger *c, VALUE key) { VALUE tmp = rb_hash_aref(c->env, key); - tmp = NIL_P(tmp) ? g_dash : byte_xs(rb_obj_as_string(tmp)); + tmp = NIL_P(tmp) ? g_dash : byte_xs(tmp); rb_str_buf_append(c->log_buf, tmp); } @@ -470,7 +475,7 @@ static void append_response(struct clogger *c, VALUE key) assert(rb_obj_class(c->headers) == cHeaderHash); v = rb_funcall(c->headers, sq_brace_id, 1, key); - v = NIL_P(v) ? g_dash : byte_xs(rb_obj_as_string(v)); + v = NIL_P(v) ? g_dash : byte_xs(v); rb_str_buf_append(c->log_buf, v); } |