From: Eric Wong <e@80x24.org>
To: kcar-public@bogomips.org
Subject: [PATCH 6/7] filter_body: rename variables to be like memcpy(3)
Date: Wed, 19 Apr 2017 22:30:24 +0000 [thread overview]
Message-ID: <20170419223025.8093-7-e@80x24.org> (raw)
In-Reply-To: <20170419223025.8093-1-e@80x24.org>
This makes the naming more consistent with terminology used for
memcpy, since this method is intended to act like memcpy(3)
No actual functionality change.
---
ext/kcar/kcar.rl | 46 +++++++++++++++++++++++-----------------------
1 file changed, 23 insertions(+), 23 deletions(-)
diff --git a/ext/kcar/kcar.rl b/ext/kcar/kcar.rl
index 3d21e28..42eed9d 100644
--- a/ext/kcar/kcar.rl
+++ b/ext/kcar/kcar.rl
@@ -995,55 +995,55 @@ static VALUE keepalive(VALUE self)
/**
* call-seq:
- * parser.filter_body(buf, data) => nil/data
+ * parser.filter_body(dst, src) => nil/dst
*
- * Takes a String of +data+, will modify data if dechunking is done.
- * Returns +nil+ if there is more data left to process. Returns
- * +data+ if body processing is complete. When returning +data+,
- * it may modify +data+ so the start of the string points to where
+ * Takes a String of +src+, will modify src if dechunking is done.
+ * Returns +nil+ if there is more +src+ left to process. Returns
+ * +dst+ if body processing is complete. When returning +dst+,
+ * it may modify +src+ so the start of the string points to where
* the body ended so that trailer processing can begin.
*
* Raises ParserError if there are dechunking errors.
- * Basically this is a glorified memcpy(3) that copies +data+
- * into +buf+ while filtering it through the dechunker.
+ * Basically this is a glorified memcpy(3) that copies +src+
+ * into +dst+ while filtering it through the dechunker.
*/
-static VALUE filter_body(VALUE self, VALUE buf, VALUE data)
+static VALUE filter_body(VALUE self, VALUE dst, VALUE src)
{
struct http_parser *hp = data_get(self);
- char *dptr;
- long dlen;
+ char *sptr;
+ long slen;
- dptr = RSTRING_PTR(data);
- dlen = RSTRING_LEN(data);
- check_buffer_size(dlen);
+ sptr = RSTRING_PTR(src);
+ slen = RSTRING_LEN(src);
+ check_buffer_size(slen);
- StringValue(buf);
- rb_str_modify(buf);
- rb_str_resize(buf, dlen); /* we can never copy more than dlen bytes */
- OBJ_TAINT(buf); /* keep weirdo $SAFE users happy */
+ StringValue(dst);
+ rb_str_modify(dst);
+ rb_str_resize(dst, slen); /* we can never copy more than slen bytes */
+ OBJ_TAINT(dst); /* keep weirdo $SAFE users happy */
if (!hp->chunked)
rb_raise(rb_eRuntimeError, "filter_body is only for chunked bodies");
if (!chunked_eof(hp)) {
hp->s.dest_offset = 0;
- http_parser_execute(hp, buf, dptr, dlen);
+ http_parser_execute(hp, dst, sptr, slen);
if (hp->cs == http_parser_error)
rb_raise(eParserError, "Invalid HTTP format, parsing fails.");
assert(hp->s.dest_offset <= hp->offset &&
"destination buffer overflow");
- advance_str(data, hp->offset);
- rb_str_set_len(buf, hp->s.dest_offset);
+ advance_str(src, hp->offset);
+ rb_str_set_len(dst, hp->s.dest_offset);
- if (RSTRING_LEN(buf) == 0 && chunked_eof(hp)) {
+ if (RSTRING_LEN(dst) == 0 && chunked_eof(hp)) {
assert(hp->len.chunk == 0 && "chunk at EOF but more to parse");
} else {
- data = Qnil;
+ dst = Qnil;
}
}
hp->offset = 0; /* for trailer parsing */
- return data;
+ return dst;
}
void Init_kcar_ext(void)
--
EW
next prev parent reply other threads:[~2017-04-19 22:30 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-19 22:30 [PATCH 0/7] request parsing bits Eric Wong
2017-04-19 22:30 ` [PATCH 1/7] introduce new str_new_dd_freeze internal function Eric Wong
2017-04-19 22:30 ` [PATCH 2/7] begin implementing request parsing Eric Wong
2017-04-27 18:00 ` Eric Wong
2017-04-19 22:30 ` [PATCH 3/7] favor bitfields instead flags + macros Eric Wong
2017-04-19 22:30 ` [PATCH 4/7] implement request parsing with tests Eric Wong
2017-04-19 22:30 ` [PATCH 5/7] pkg.mk: enable warnings by default for tests Eric Wong
2017-04-19 22:30 ` Eric Wong [this message]
2017-04-19 22:30 ` [PATCH 7/7] flesh out filter_body for request parsing Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://yhbt.net/kcar/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170419223025.8093-7-e@80x24.org \
--to=e@80x24.org \
--cc=kcar-public@bogomips.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhbt.net/kcar.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).