From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eric Wong Newsgroups: gmane.comp.lang.ruby.kcar.general Subject: [PATCH] use rb_fstring from Ruby 2.1.0dev if available Date: Sat, 12 Oct 2013 03:18:36 +0000 Message-ID: <1381547916-7599-1-git-send-email-normalperson@yhbt.net> References: <1381547916-7599-1-git-send-email-normalperson@yhbt.net> Reply-To: kcar@librelist.org NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1381547933 21482 80.91.229.3 (12 Oct 2013 03:18:53 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 12 Oct 2013 03:18:53 +0000 (UTC) To: kcar@librelist.org Original-X-From: kcar@librelist.org Sat Oct 12 05:18:58 2013 Return-path: Envelope-to: gclrkg-kcar@m.gmane.org In-Reply-To: <1381547916-7599-1-git-send-email-normalperson@yhbt.net> List-Archive: List-Help: List-Id: kcar@librelist.org List-Post: List-Subscribe: List-Unsubscribe: Precedence: list Original-Sender: kcar@librelist.org Xref: news.gmane.org gmane.comp.lang.ruby.kcar.general:12 Archived-At: Received: from zedshaw2.xen.prgmr.com ([71.19.156.177]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VUpjE-0001wC-K1 for gclrkg-kcar@m.gmane.org; Sat, 12 Oct 2013 05:18:56 +0200 Received: from zedshaw2.xen.prgmr.com (unknown [IPv6:::1]) by zedshaw2.xen.prgmr.com (Postfix) with ESMTP id 3647375107 for ; Sat, 12 Oct 2013 03:19:28 +0000 (UTC) This should be safe after r43210 from ruby trunk --- ext/kcar/extconf.rb | 1 + ext/kcar/kcar.rl | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ext/kcar/extconf.rb b/ext/kcar/extconf.rb index 4f19c4a..1ac6847 100644 --- a/ext/kcar/extconf.rb +++ b/ext/kcar/extconf.rb @@ -7,6 +7,7 @@ have_macro("SIZEOF_OFF_T", "ruby.h") or check_sizeof("off_t", "sys/types.h") have_macro("SIZEOF_LONG", "ruby.h") or check_sizeof("long", "sys/types.h") have_func("rb_str_set_len", "ruby.h") have_func("rb_str_modify", "ruby.h") +have_func("rb_fstring", "ruby.h") # -fPIC is needed for Rubinius, MRI already uses it regardless with_cflags($CFLAGS + " -fPIC ") do diff --git a/ext/kcar/kcar.rl b/ext/kcar/kcar.rl index e812279..7d3f9ae 100644 --- a/ext/kcar/kcar.rl +++ b/ext/kcar/kcar.rl @@ -192,6 +192,16 @@ static void write_cont_value(struct http_parser *hp, rb_str_buf_cat(hp->cont, vptr, end + 1); } +#ifndef HAVE_RB_FSTRING +static VALUE my_fstring(VALUE str) +{ + OBJ_FREEZE(str); + + return str; +} +#define rb_fstring(str) my_fstring((str)) +#endif /* !HAVE_RB_FSTRING */ + static void write_value(VALUE hdr, struct http_parser *hp, const char *buffer, const char *p) { @@ -273,7 +283,7 @@ static void write_value(VALUE hdr, struct http_parser *hp, if (NIL_P(e)) { /* new value, freeze it since it speeds up MRI slightly */ - OBJ_FREEZE(f); + f = rb_fstring(f); if (hclass == rb_cHash) rb_hash_aset(hdr, f, v); -- 1.8.4