Fix log entry parser for values containing ":" (colons).

This commit is contained in:
Jonathan Moore Liles 2008-12-02 00:07:45 -06:00
parent a07d997397
commit b22a286fa8
1 changed files with 65 additions and 45 deletions

View File

@ -103,21 +103,24 @@ Log_Entry::parse_alist( const char *s )
int tl = strlen( s );
char **r = (char**)malloc( sizeof( char* ) * tl );
// const char *e = s + tl;
bool quote = false;
bool value = false;
const char *c = NULL;
int i = 0;
for ( ; ; s++ )
{
/* if ( *s == '\n' ) */
/* break; */
// if ( *s == ':' || s == e )
if ( *s == ':' || *s == '\0' )
switch ( *s )
{
if ( c )
case '\0':
case ' ':
if ( ! quote && c )
{
if ( ! value )
{
value = true;
break;
}
int l = s - c;
char *pair = (char*)malloc( l + 1 );
@ -152,13 +155,30 @@ Log_Entry::parse_alist( const char *s )
memmove( v, v + 1, strlen( v ) + 1 );
}
}
}
printf( "%s\n", v );
c = NULL;
}
break;
case ':': /* this is a key */
if ( ! quote && ! c )
{
c = s;
value = false;
}
break;
case '"':
quote = !quote;
break;
case '\\':
s++;
break;
}
if ( *s == '\0' )
break;
}
}
r[ i ] = NULL;