Skip to content

Commit

Permalink
Merge branch 'master' into armv8-a
Browse files Browse the repository at this point in the history
  • Loading branch information
volyrique authored May 24, 2019
2 parents c04a8f7 + 81fe3d9 commit 2355e5f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 20 deletions.
1 change: 0 additions & 1 deletion .gitattributes

This file was deleted.

37 changes: 20 additions & 17 deletions picohttpparser.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@
#endif
#include "picohttpparser.h"

/* $Id$ */

#if __GNUC__ >= 3
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
Expand Down Expand Up @@ -169,9 +167,9 @@ static const char *findchar_nonprintable_fast(const char *buf, const char *buf_e

return buf;
#else
static const char ALIGNED(16) ranges2[] = "\000\040\177\177";
static const char ALIGNED(16) ranges2[16] = "\000\040\177\177";

return findchar_fast(buf, buf_end, ranges2, sizeof(ranges2) - 1, found);
return findchar_fast(buf, buf_end, ranges2, 4, found);
#endif
}

Expand All @@ -180,15 +178,11 @@ static const char *get_token_to_eol(const char *buf, const char *buf_end, const
const char *token_start = buf;

#ifdef __SSE4_2__
static const char ranges1[] = "\0\010"
/* allow HT */
"\012\037"
/* allow SP and up to but not including DEL */
"\177\177"
/* allow chars w. MSB set */
;
static const char ALIGNED(16) ranges1[16] = "\0\010" /* allow HT */
"\012\037" /* allow SP and up to but not including DEL */
"\177\177"; /* allow chars w. MSB set */
int found;
buf = findchar_fast(buf, buf_end, ranges1, sizeof(ranges1) - 1, &found);
buf = findchar_fast(buf, buf_end, ranges1, 6, &found);
if (found)
goto FOUND_CTL;
#elif defined(__ARM_64BIT_STATE) && defined(__ARM_FEATURE_UNALIGNED) && !defined(__ARM_BIG_ENDIAN)
Expand Down Expand Up @@ -433,9 +427,13 @@ static const char *parse_request(const char *buf, const char *buf_end, const cha

/* parse request line */
ADVANCE_TOKEN(*method, *method_len);
++buf;
do {
++buf;
} while (*buf == ' ');
ADVANCE_TOKEN(*path, *path_len);
++buf;
do {
++buf;
} while (*buf == ' ');
if (*method_len == 0 || *path_len == 0) {
*ret = -1;
return NULL;
Expand Down Expand Up @@ -492,10 +490,13 @@ static const char *parse_response(const char *buf, const char *buf_end, int *min
return NULL;
}
/* skip space */
if (*buf++ != ' ') {
if (*buf != ' ') {
*ret = -1;
return NULL;
}
do {
++buf;
} while (*buf == ' ');
/* parse status code, we want at least [:digit:][:digit:][:digit:]<other char> to try to parse */
if (buf_end - buf < 4) {
*ret = -2;
Expand All @@ -511,8 +512,10 @@ static const char *parse_response(const char *buf, const char *buf_end, int *min
/* ok */
} else if (**msg == ' ') {
/* remove preceding space */
++*msg;
--*msg_len;
do {
++*msg;
--*msg_len;
} while (**msg == ' ');
} else {
/* garbage found after status code */
*ret = -1;
Expand Down
2 changes: 0 additions & 2 deletions picohttpparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
#define ssize_t intptr_t
#endif

/* $Id$ */

#ifdef __cplusplus
extern "C" {
#endif
Expand Down
4 changes: 4 additions & 0 deletions test.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ static void test_request(void)
PARSE("GET / HTTP/1.0\r\nfoo: a \t \r\n\r\n", 0, 0, "exclude leading and trailing spaces in header value");
ok(bufis(headers[0].value, headers[0].value_len, "a"));

PARSE("GET / HTTP/1.0\r\n\r\n", 0, 0, "accept multiple spaces between tokens");

#undef PARSE
}

Expand Down Expand Up @@ -245,6 +247,8 @@ static void test_response(void)
PARSE("HTTP/1.1 200 OK\r\nbar: \t b\t \t\r\n\r\n", 0, 0, "exclude leading and trailing spaces in header value");
ok(bufis(headers[0].value, headers[0].value_len, "b"));

PARSE("HTTP/1.1 200 OK\r\n\r\n", 0, 0, "accept multiple spaces between tokens");

#undef PARSE
}

Expand Down

0 comments on commit 2355e5f

Please sign in to comment.