1
0
Fork 0
mirror of git://git.psyc.eu/libpsyc synced 2024-08-15 03:19:02 +00:00

now parsing the number manually. Needs testing

This commit is contained in:
Mathias L. Baumann 2011-04-16 12:37:33 +02:00
parent c688bab1f8
commit d4b0f33d7b

View file

@ -262,27 +262,29 @@ inline int PSYC_parse(
} }
}else if(state->inHeader == 0 && method==0 && state->buffer.ptr[state->cursor] == ' ') // oi, its a binary var! }else if(state->inHeader == 0 && method==0 && state->buffer.ptr[state->cursor] == ' ') // oi, its a binary var!
{ // after SP the length follows. { // after SP the length follows.
const uint8_t * bin_length_str = state->buffer.ptr + state->cursor+1; unsigned int binLength= 0;
int strln = 0;
do if(state->buffer.length<=++(state->cursor)) // incremented cursor inside lenght?
{ {
state->cursor=startc; // set to start value
return 1; // return insufficient
}
while(isNumeric(state->buffer.ptr[state->cursor]));
{
binLength = 10 * binLength + state->buffer.ptr[state->cursor] - '0';
if(state->buffer.length<=++(state->cursor)) // incremented cursor inside lenght? if(state->buffer.length<=++(state->cursor)) // incremented cursor inside lenght?
{ {
state->cursor=startc; // set to start value state->cursor=startc; // set to start value
return 1; // return insufficient return 1; // return insufficient
} }
++strln;
} }
while(isNumeric(state->buffer.ptr[state->cursor]));
// after the length a TAB follows // after the length a TAB follows
if (state->buffer.ptr[state->cursor] != '\t') if (state->buffer.ptr[state->cursor] != '\t')
return -8; return -8;
// now we have the length. convert it to int // is the length still in this buffer?
int binLength = atoi(bin_length_str);
// is that still in this buffer?
if(state->buffer.length <= state->cursor+binLength+1 ) if(state->buffer.length <= state->cursor+binLength+1 )
{ {
state->cursor=startc; state->cursor=startc;
@ -292,7 +294,8 @@ inline int PSYC_parse(
value->ptr = state->buffer.ptr + state->cursor+1; value->ptr = state->buffer.ptr + state->cursor+1;
value->length=binLength; value->length=binLength;
state->cursor += binLength+1; state->cursor += binLength+1;
}else }
else
return -8; return -8;