Source/ThunderBeast/QuakeToon/game/q_shared.c
char *COM_Parse (char **data_p)
{
	int		c;
	int		len;
	char	*data;

	data = *data_p;
	len = 0;
	com_token[0] = 0;
	
	if (!data)
	{
		*data_p = NULL;
		return "";
	}
		
// skip whitespace
skipwhite:
	while ( (c = *data) <= ' ')
	{
		if (c == 0)
		{
			*data_p = NULL;
			return "";
		}
		data++;
	}
	
// skip // comments
	if (c=='/' && data[1] == '/')
	{
		while (*data && *data != '\n')
			data++;
		goto skipwhite;
	}

// handle quoted strings specially
	if (c == '\"')
	{
		data++;
		while (1)
		{
			c = *data++;
			if (c=='\"' || !c)
			{
				com_token[len] = 0;
				*data_p = data;
				return com_token;
			}
			if (len < MAX_TOKEN_CHARS)
			{
				com_token[len] = c;
				len++;
			}
		}
	}

// parse a regular word
	do
	{
		if (len < MAX_TOKEN_CHARS)
		{
			com_token[len] = c;
			len++;
		}
		data++;
		c = *data;
	} while (c>32);

	if (len == MAX_TOKEN_CHARS)
	{
//		Com_Printf ("Token exceeded %i chars, discarded.\n", MAX_TOKEN_CHARS);
		len = 0;
	}
	com_token[len] = 0;

	*data_p = data;
	return com_token;
}
/*
==============
COM_Parse

Parse a token out of a string
==============
*/
COM_Parse
Parse a token out of a string
COM_Parse Parse a token out of a string
char *COM_Parse (char **data_p)
{
	int		c;
	int		len;
	char	*data;
	data = *data_p;
	len = 0;
	com_token[0] = 0;
	if (!data)
	{
		*data_p = NULL;
		return "";
	}
skipwhite:
	while ( (c = *data) <= ' ')
	{
		if (c == 0)
		{
			*data_p = NULL;
			return "";
		}
		data++;
	}
	if (c=='/' && data[1] == '/')
	{
		while (*data && *data != '\n')
			data++;
		goto skipwhite;
	}
	if (c == '\"')
	{
		data++;
		while (1)
		{
			c = *data++;
			if (c=='\"' || !c)
			{
				com_token[len] = 0;
				*data_p = data;
				return com_token;
			}
			if (len < MAX_TOKEN_CHARS)
			{
				com_token[len] = c;
				len++;
			}
		}
	}
	do
	{
		if (len < MAX_TOKEN_CHARS)
		{
			com_token[len] = c;
			len++;
		}
		data++;
		c = *data;
	} while (c>32);
	if (len == MAX_TOKEN_CHARS)
	{
		len = 0;
	}
	com_token[len] = 0;
	*data_p = data;
	return com_token;
}
char * COM_Parse ( char * * data_p ) { int c ; int len ; char * data ; data = * data_p ; len = 0 ; com_token [ 0 ] = 0 ; if ( ! data ) { * data_p = NULL ; return " " ; } skipwhite : while ( ( c = * data ) <= ' ' ) { if ( c == 0 ) { * data_p = NULL ; return " " ; } data ++ ; } if ( c == ' ' && data [ 1 ] == ' ' ) { while ( * data && * data != ' \n ' ) data ++ ; goto skipwhite ; } if ( c == ' \" ' ) { data ++ ; while ( 1 ) { c = * data ++ ; if ( c == ' \" ' || ! c ) { com_token [ len ] = 0 ; * data_p = data ; return com_token ; } if ( len < MAX_TOKEN_CHARS ) { com_token [ len ] = c ; len ++ ; } } } do { if ( len < MAX_TOKEN_CHARS ) { com_token [ len ] = c ; len ++ ; } data ++ ; c = * data ; } while ( c > 32 ) ; if ( len == MAX_TOKEN_CHARS ) { len = 0 ; } com_token [ len ] = 0 ; * data_p = data ; return com_token ; }
COM_Parse
Parse a token out of a string
COM_Parse Parse a token out of a string
// skip whitespace // skip // comments // handle quoted strings specially // parse a regular word //		Com_Printf ("Token exceeded %i chars, discarded.\n", MAX_TOKEN_CHARS);