mirror of
git://git.psyc.eu/libpsyc
synced 2024-08-15 03:19:02 +00:00
added parsing of empty variables
This commit is contained in:
parent
0b012a091f
commit
7f3acf9770
2 changed files with 33 additions and 26 deletions
58
src/parser.c
58
src/parser.c
|
@ -245,8 +245,9 @@ inline int PSYC_parseElement(
|
||||||
* so checking for \n too here
|
* so checking for \n too here
|
||||||
|
|
||||||
* We dont check if cursor inside length, because
|
* We dont check if cursor inside length, because
|
||||||
* the last loop iteration did that already. */
|
* the last loop iteration did that already.
|
||||||
if(data[*cursor] == '\t' || (data[*cursor] == '\n' && method==1))
|
*/
|
||||||
|
if(data[*cursor] == '\t' || data[*cursor] == '\n') // && method==1))
|
||||||
{
|
{
|
||||||
/* after the \t the arg-data follows, which is
|
/* after the \t the arg-data follows, which is
|
||||||
* anything but \n. arg-data can be of length 0
|
* anything but \n. arg-data can be of length 0
|
||||||
|
@ -259,38 +260,43 @@ inline int PSYC_parseElement(
|
||||||
* to the first potential arg-data byte.
|
* to the first potential arg-data byte.
|
||||||
* If there is no arg-data, we still have
|
* If there is no arg-data, we still have
|
||||||
* the length attribute on 0. */
|
* the length attribute on 0. */
|
||||||
*value=data+*cursor+1;
|
if(method == 0 && data[*cursor] == '\n') // emptyvar
|
||||||
*vlength=0;
|
|
||||||
|
|
||||||
while(1)
|
|
||||||
{
|
{
|
||||||
if(dlength<=++(*cursor)) // incremented cursor inside lenght?
|
*value=data+*cursor;
|
||||||
|
*vlength=0;
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
*value=data+*cursor+1;
|
||||||
|
*vlength=0;
|
||||||
|
while(1)
|
||||||
{
|
{
|
||||||
*cursor=startc; // set to start value
|
if(dlength<=++(*cursor)) // incremented cursor inside lenght?
|
||||||
return 1; // return insufficient
|
|
||||||
}
|
|
||||||
|
|
||||||
if(1 != method && data[*cursor] == '\n')
|
|
||||||
break;
|
|
||||||
|
|
||||||
if(1 == method && data[*cursor] == '|')
|
|
||||||
{
|
|
||||||
if(dlength<++(*cursor)) // incremented cursor inside lenght?
|
|
||||||
{
|
{
|
||||||
*cursor=startc; // set to start value
|
*cursor=startc; // set to start value
|
||||||
return 1; // return insufficient
|
return 1; // return insufficient
|
||||||
}
|
}
|
||||||
|
|
||||||
/* packet finishes here */
|
if(0 == method && data[*cursor] == '\n')
|
||||||
if(data[*cursor] == '\n')
|
break;
|
||||||
{
|
|
||||||
*cursor+=1;
|
|
||||||
return 3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
++(*vlength);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if(1 == method && data[*cursor] == '|')
|
||||||
|
{
|
||||||
|
if(dlength<++(*cursor)) // incremented cursor inside lenght?
|
||||||
|
{
|
||||||
|
*cursor=startc; // set to start value
|
||||||
|
return 1; // return insufficient
|
||||||
|
}
|
||||||
|
|
||||||
|
/* packet finishes here */
|
||||||
|
if(data[*cursor] == '\n')
|
||||||
|
{
|
||||||
|
*cursor+=1;
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
++(*vlength);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ _request_context_enter
|
||||||
:_target psyc://p5B084547.dip.t-dialin.net/@test
|
:_target psyc://p5B084547.dip.t-dialin.net/@test
|
||||||
|
|
||||||
:_more vars
|
:_more vars
|
||||||
|
:_nocontent
|
||||||
:_entity variablevalue
|
:_entity variablevalue
|
||||||
_notice_context_leave
|
_notice_context_leave
|
||||||
|
|
|
|
||||||
|
|
Loading…
Reference in a new issue