Commit 8da6c6c1 authored by Pekka Pessi's avatar Pekka Pessi

sofia-sip/bnf.h, torture_bnf.c: fixed span_lws() and skip_lws().

Previously skipped *(SP / HT / CR / LF).
Correct bnf is LWS

darcs-hash:20060817184540-65a35-8a86271394c053144a21946218c6f0a904773d8c.gz
parent 85716db2
......@@ -171,12 +171,18 @@ SOFIAPUBVAR unsigned char const _bnf_table[256];
/** Get number of characters before linear whitespace */
#define span_non_lws(s) strcspn(s, LWS)
/** Calculate span of a linear whitespace characters. */
/** Calculate span of a linear whitespace.
* LWS = [*WSP CRLF] 1*WSP
*/
static inline int span_lws(char const *s)
{
char const *e = s;
while (IS_LWS(*e))
e++;
char const *e = s;
int i = 0;
e += strspn(s, WS);
if (e[i] == '\r') i++;
if (e[i] == '\n') i++;
if (IS_WS(e[i]))
e += i + strspn(e + i, WS);
return e - s;
}
......
......@@ -65,9 +65,13 @@ int bnf_test(void)
BEGIN();
TEST_1(IS_TOKEN('a'));
TEST_1(IS_TOKEN('b'));
TEST(span_lws(" \r\n \r\nLoppuu"), 7);
TEST(span_lws(" \r\r\nLoppuu"), 5);
TEST(span_lws(" \n\r\nLoppuu"), 5);
/* Fixed for 1.12.2: lws = [*wsp crlf] 1*wsp */
TEST(span_lws(" \r\n \r\nLoppuu"), 5);
TEST(span_lws(" \r\r \nLoppuu"), 2);
TEST(span_lws(" \n\r \nLoppuu"), 2);
TEST(span_lws(" \r \nLoppuu"), 4);
TEST(span_lws(" \n\t \nLoppuu"), 5);
TEST(span_lws(" \r\n\t \nLoppuu"), 6);
TEST(span_token(SIP_TOKEN), strlen(SIP_TOKEN));
TEST(count_bnf(bnf_token), strlen(SIP_TOKEN "$"));
#define SIP_PARAM SIP_TOKEN "[:]/"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment