本文整理汇总了C++中PS_ReadWhiteSpace函数的典型用法代码示例。如果您正苦于以下问题:C++ PS_ReadWhiteSpace函数的具体用法?C++ PS_ReadWhiteSpace怎么用?C++ PS_ReadWhiteSpace使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PS_ReadWhiteSpace函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ScriptSkipTo
//============================================================================
//
// Parameter: -
// Returns: -
// Changes Globals: -
//============================================================================
int ScriptSkipTo(script_t *script, char *value)
{
int len;
char firstchar;
firstchar = *value;
len = strlen(value);
do
{
if(!PS_ReadWhiteSpace(script))
{
return 0;
}
if(*script->script_p == firstchar)
{
if(!strncmp(script->script_p, value, len))
{
return 1;
} //end if
} //end if
script->script_p++;
}
while(1);
} //end of the function ScriptSkipTo
开发者ID:Diskutant,项目名称:RTCW-SP,代码行数:33,代码来源:l_script.c
示例2: PS_ReadString
//============================================================================
// Reads C-like string. Escape characters are interpretted.
// Quotes are included with the string.
// Reads two strings with a white space between them as one string.
//
// Parameter: script : script to read from
// token : buffer to store the string
// Returns: qtrue when a string was read successfully
// Changes Globals: -
//============================================================================
int PS_ReadString(script_t *script, token_t *token, int quote)
{
int len, tmpline;
char *tmpscript_p;
if (quote == '\"') token->type = TT_STRING;
else token->type = TT_LITERAL;
len = 0;
//leading quote
token->string[len++] = *script->script_p++;
//
while(1)
{
//minus 2 because trailing double quote and zero have to be appended
if (len >= MAX_TOKEN - 2)
{
ScriptError(script, "string longer than MAX_TOKEN = %d", MAX_TOKEN);
return 0;
} //end if
//if there is an escape character and
//if escape characters inside a string are allowed
if (*script->script_p == '\\' && !(script->flags & SCFL_NOSTRINGESCAPECHARS))
{
if (!PS_ReadEscapeCharacter(script, &token->string[len]))
{
token->string[len] = 0;
return 0;
} //end if
len++;
} //end if
//if a trailing quote
else if (*script->script_p == quote)
{
//step over the double quote
script->script_p++;
//if white spaces in a string are not allowed
if (script->flags & SCFL_NOSTRINGWHITESPACES) break;
//
tmpscript_p = script->script_p;
tmpline = script->line;
//read unusefull stuff between possible two following strings
if (!PS_ReadWhiteSpace(script))
{
script->script_p = tmpscript_p;
script->line = tmpline;
break;
} //end if
//if there's no leading double qoute
if (*script->script_p != quote)
{
script->script_p = tmpscript_p;
script->line = tmpline;
break;
} //end if
//step over the new leading double quote
script->script_p++;
} //end if
else
{
if (*script->script_p == '\0')
{
token->string[len] = 0;
ScriptError(script, "missing trailing quote");
return 0;
} //end if
if (*script->script_p == '\n')
{
token->string[len] = 0;
ScriptError(script, "newline inside string %s", token->string);
return 0;
} //end if
token->string[len++] = *script->script_p++;
} //end else
} //end while
//trailing quote
token->string[len++] = quote;
//end string with a zero
token->string[len] = '\0';
//the sub type is the length of the string
token->subtype = len;
return 1;
} //end of the function PS_ReadString
开发者ID:0culus,项目名称:ioq3,代码行数:93,代码来源:l_script.c
注:本文中的PS_ReadWhiteSpace函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论