summaryrefslogtreecommitdiff
path: root/ext/strscan/strscan.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/strscan/strscan.c')
-rw-r--r--ext/strscan/strscan.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/ext/strscan/strscan.c b/ext/strscan/strscan.c
index 177cfdd..a62616c 100644
--- a/ext/strscan/strscan.c
+++ b/ext/strscan/strscan.c
@@ -1186,20 +1186,20 @@ strscan_inspect(VALUE self)
static VALUE
inspect1(struct strscanner *p)
{
- char buf[BUFSIZE];
- char *bp = buf;
+ VALUE str;
long len;
if (p->curr == 0) return rb_str_new2("");
if (p->curr > INSPECT_LENGTH) {
- strcpy(bp, "..."); bp += 3;
- len = INSPECT_LENGTH;
+ str = rb_str_new_cstr("...");
+ len = INSPECT_LENGTH;
}
else {
- len = p->curr;
+ str = rb_str_new(0, 0);
+ len = p->curr;
}
- memcpy(bp, CURPTR(p) - len, len); bp += len;
- return rb_str_dump(rb_str_new(buf, bp - buf));
+ rb_str_cat2(str, CURPTR(p) - len, len);
+ return rb_str_dump(str);
}
static VALUE