本文整理汇总了C++中skip_ws函数的典型用法代码示例。如果您正苦于以下问题:C++ skip_ws函数的具体用法?C++ skip_ws怎么用?C++ skip_ws使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了skip_ws函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: step_predicate_parser
static void step_predicate_parser(parser_context *context)
{
enter_state(context, ST_PREDICATE);
skip_ws(context);
if('[' == get_char(context))
{
consume_char(context);
if(!look_for(context, "]"))
{
context->result.code = ERR_UNBALANCED_PRED_DELIM;
return;
}
skip_ws(context);
if(']' == get_char(context))
{
context->result.code = ERR_EMPTY_PREDICATE;
return;
}
try_predicate_parser(wildcard_predicate);
try_predicate_parser(subscript_predicate);
try_predicate_parser(slice_predicate);
if(JSONPATH_SUCCESS != context->result.code && ERR_PARSER_OUT_OF_MEMORY != context->result.code)
{
context->result.code = ERR_UNSUPPORTED_PRED_TYPE;
}
}
else
{
unexpected_value(context, '[');
}
}
示例2: parse_shop
/*
* shop = addop << addop
* | addop >> addop
* | addop
*/
int
parse_shop(char **p)
{
int val1, val2;
int done = 0;
skip_ws(p);
val1 = parse_addop(p);
do {
skip_ws(p);
if (*(*p) == '>' && *(*p+1) == '>') {
(*p) += 2; /* skip >> */
val2 = parse_addop(p);
if (val2 < 0)
error("negative shift count");
val1 = val1 >> val2;
} else if (*(*p) == '<' && *(*p+1) == '<') {
(*p) += 2; /* skip >> */
val2 = parse_addop(p);
if (val2 < 0)
error("negative shift count");
val1 = val1 << val2;
} else
done = 1;
} while (!done);
示例3: bibtex_tag
static char *
bibtex_tag( char *p, newstr *tag )
{
p = newstr_cpytodelim( tag, skip_ws( p ), "= \t\r\n", 0 );
if ( newstr_memerr( tag ) ) return NULL;
return skip_ws( p );
}
示例4: medin_medlinedate
/* <MedlineDate>2003 Jan-Feb</MedlineDate> */
static int
medin_medlinedate( fields *info, char *p, int level )
{
int fstatus;
newstr tmp;
newstr_init( &tmp );
p = newstr_cpytodelim( &tmp, skip_ws( p ), " \t\n\r", 0 );
if ( newstr_memerr( &tmp ) ) return BIBL_ERR_MEMERR;
if ( tmp.len > 0 ) {
fstatus = fields_add( info, "PARTYEAR", tmp.data, level );
if ( fstatus!=FIELDS_OK ) return BIBL_ERR_MEMERR;
}
p = newstr_cpytodelim( &tmp, skip_ws( p ), " \t\n\r", 0 );
if ( newstr_memerr( &tmp ) ) return BIBL_ERR_MEMERR;
if ( tmp.len > 0 ) {
newstr_findreplace( &tmp, "-", "/" );
fstatus = fields_add( info, "PARTMONTH", tmp.data, level );
if ( fstatus!=FIELDS_OK ) return BIBL_ERR_MEMERR;
}
p = newstr_cpytodelim( &tmp, skip_ws( p ), " \t\n\r", 0 );
if ( newstr_memerr( &tmp ) ) return BIBL_ERR_MEMERR;
if ( tmp.len > 0 ) {
fstatus = fields_add( info, "PARTDAY", tmp.data, level );
if ( fstatus!=FIELDS_OK ) return BIBL_ERR_MEMERR;
}
newstr_free( &tmp );
return BIBL_OK;
}
示例5: parse_comp
static int
parse_comp(const char *s, int strict,
VALUE *num)
{
char *buf, *b;
VALUE tmp;
int ret = 1;
buf = ALLOCV_N(char, tmp, strlen(s) + 1);
b = buf;
skip_ws(&s);
if (!read_comp(&s, strict, num, &b)) {
ret = 0;
}
else {
skip_ws(&s);
if (strict)
if (*s != '\0')
ret = 0;
}
ALLOCV_END(tmp);
return ret;
}
示例6: while
static char *get_value(char **pos, config_file_t *cf, char *skipped)
{
char *p = *pos;
char *q;
char *start;
*skipped = '\0';
if (*p == '"')
{
p++;
start = p;
q = p;
while (*p != '\0' && *p != '\r' && *p != '\n' && *p != '"')
{
if (*p == '\\' && (p[1] == '"' || p[1] == '\\'))
p++;
*q++ = *p++;
}
if (*p == '\0')
{
config_file_error(cf, "File ends inside quoted string");
return NULL;
}
if (*p == '\r' || *p == '\n')
{
config_file_error(cf, "Newline inside quoted string");
return NULL;
}
if (*p != '"')
{
config_file_error(cf, "Weird character terminating quoted string (BUG)");
return NULL;
}
p++;
*q = '\0';
*pos = p;
skip_ws(pos, cf);
return start;
}
else
{
start = p;
while (*p != '\0' && *p != '\t' && *p != '\r' && *p != '\n' &&
*p != ' ' && *p != '/' && *p != '#' &&
*p != ';' && *p != '{' && *p != '}')
p++;
if (p == start)
return NULL;
*pos = p;
skip_ws(pos, cf);
if (p == *pos)
*skipped = *p;
*p = '\0';
if (p == *pos)
(*pos)++;
return start;
}
}
示例7: read_reg
static const gchar* read_reg(const gchar *s, guint8 *r, int *line, GError **error)
{
guint num = 0;
s = skip_ws(s, line);
if (!s || !*s) {
g_set_error(error, ROBOT_ERROR, ROBOT_ERROR_SYNTAX, "Waiting for register name at line %d", *line);
return NULL;
}
/* Special case: const */
if (g_ascii_isxdigit(*s) && g_ascii_isxdigit(s[1]) && (s[2] == 0 || g_ascii_isspace(s[2]))) {
num = g_ascii_xdigit_value(s[0]) * 16 + g_ascii_xdigit_value(s[1]);
*r = num;
s += 2;
return skip_ws(s, line);
}
if (*s != 'r' && *s != 'R') {
g_set_error(error, ROBOT_ERROR, ROBOT_ERROR_SYNTAX, "Waiting for register name at line %d", *line);
return NULL;
}
++s;
if (!g_ascii_isdigit(*s)) {
g_set_error(error, ROBOT_ERROR, ROBOT_ERROR_SYNTAX, "Waiting for register name at line %d", *line);
return NULL;
}
num = g_ascii_digit_value(*s);
++s;
if (g_ascii_isdigit(*s)) {
num = num * 10 + g_ascii_digit_value(*s);
++s;
if (!*s || g_ascii_isspace(*s)) {
*r = num;
if (num > 31) {
g_set_error(error, ROBOT_ERROR, ROBOT_ERROR_SYNTAX, "We've got only 32 registers (at line %d)", *line);
return NULL;
}
return skip_ws(s, line);
} else {
g_set_error(error, ROBOT_ERROR, ROBOT_ERROR_SYNTAX, "Waiting for register name at line %d", *line);
return NULL;
}
} else if (!*s || g_ascii_isspace(*s)) {
*r = num;
return skip_ws(s, line);
} else {
g_set_error(error, ROBOT_ERROR, ROBOT_ERROR_SYNTAX, "Waiting for register name at line %d", *line);
return NULL;
}
return NULL;
}
示例8: next_id
/** suche den beginn des nächsten wortes
*/
int next_id( int line, int *p)
{
if( skip_ws(line,p) ) return -1;
while( *p < m_len(line) )
{
if( isspace( CHAR(line,*p)) ) return skip_ws(line,p);
(*p)++;
}
return -1;
}
示例9: parse_header_line
static int parse_header_line( char* line, char** pkey, char** pvalue )
{
char* s;
char* end;
char* key_end;
char c;
s = prepare_line( line, &end );
if( *s == '\0' )
{
return 1;
}
*pkey = s;
while( ( c = *s ) != '=' && c != ' ' && c != '\t' )
{
if( c == '\0' )
{
fprintf( stderr, "kum error: invalid header format.\n" );
exit( 1 );
}
++s;
}
key_end = s;
s = (char*) skip_ws( s );
if( key_end == *pkey || *s != '=' )
{
fprintf( stderr, "kum error: invalid header format.\n" );
exit( 1 );
}
*key_end = '\0';
++s;
s = (char*) skip_ws( s );
if( *s != '\"' && *s != '\'' )
{
*pvalue = s;
}
else
{
/* Removing quotes */
*pvalue = s + 1;
if( end > *pvalue && *(end - 1) == *s )
{
*--end = '\0';
}
}
return 1;
}
示例10: parse_mulop
/*
* mulop = unop * unop
* | unop / unop
* | unop % unop
* | unop
*/
int
parse_mulop(char **p)
{
int val1, val2;
int done = 0;
skip_ws(p);
val1 = parse_unop(p);
do {
skip_ws(p);
switch (**p) {
case '*':
(*p)++; /* skip * */
val2 = parse_unop(p);
val1 = val1 * val2;
break;
case '/':
(*p)++; /* skip / */
val2 = parse_unop(p);
if (val2 == 0) {
if (g_pass == 2)
error("division by zero");
done = 1;
break;
}
val1 = val1 / val2;
break;
case '%':
(*p)++; /* skip / */
val2 = parse_unop(p);
if (val2 == 0) {
if (g_pass == 2)
error("modulus of zero");
done = 1;
break;
}
val1 = val1 % val2;
break;
default:
done = 1;
break;
}
} while (!done);
return val1;
}
示例11: seta_assignment
static BOOL
seta_assignment ( LPCTSTR* p_, INT* result )
{
LPCTSTR p = *p_;
LPTSTR ident;
TCHAR op = 0;
INT identlen, exprval;
PARSE_IDENT(ident,identlen,p);
if ( identlen )
{
p = skip_ws(p);
if ( *p == _T('=') )
op = *p, p = skip_ws(p+1);
else if ( _tcschr ( _T("*/%+-&^|"), *p ) && p[1] == _T('=') )
op = *p, p = skip_ws(p+2);
else if ( _tcschr ( _T("<>"), *p ) && *p == p[1] && p[2] == _T('=') )
op = *p, p = skip_ws(p+3);
}
/* allow to chain multiple assignments, such as: a=b=1 */
if ( ident && op )
{
INT identval;
LPTSTR buf;
if ( !seta_assignment ( &p, &exprval ) )
return FALSE;
if ( !seta_identval ( ident, &identval ) )
identval = 0;
switch ( op )
{
case '=':
identval = exprval;
break;
case '<':
identval <<= exprval;
break;
case '>':
identval >>= exprval;
break;
default:
if ( !calc ( &identval, op, exprval ) )
return FALSE;
}
buf = (LPTSTR)alloca ( 32 * sizeof(TCHAR) );
_sntprintf ( buf, 32, _T("%i"), identval );
SetEnvironmentVariable ( ident, buf ); // TODO FIXME - check return value
exprval = identval;
}
示例12: read_data
static const gchar* read_data(const gchar *s, GByteArray *data, int *line, GError **error)
{
unsigned char c;
const gchar *p;
++s;
while (*s) {
s = skip_ws(s, line);
if (*s == '}') {
++s;
return s;
}
if (!g_ascii_isxdigit(*s)) {
g_set_error(error, ROBOT_ERROR, ROBOT_ERROR_SYNTAX, "Invalid symbol at line %d `%16s'", *line, s);
return NULL;
}
c = g_ascii_xdigit_value(*s) * 16;
++s;
if (!g_ascii_isxdigit(*s)) {
g_set_error(error, ROBOT_ERROR, ROBOT_ERROR_SYNTAX, "Invalid symbol at line %d `%16s'", *line, s);
return NULL;
}
c += g_ascii_xdigit_value(*s);
++s;
g_byte_array_append(data, &c, 1);
p = skip_ws(s, line);
if (p == s && *s != '}') {
g_set_error(error, ROBOT_ERROR, ROBOT_ERROR_SYNTAX, "Invalid symbol at line %d `%16s'", *line, s);
return NULL;
}
s = p;
}
c = 0;
while (data->len % 4 != 0)
g_byte_array_append(data, &c, 1);
return NULL;
}
示例13: seta_bitAndTerm
static BOOL
seta_bitAndTerm ( LPCTSTR* p_, INT* result )
{
LPCTSTR p = *p_;
INT lval;
if ( !seta_logShiftTerm ( &p, &lval ) )
return FALSE;
while ( *p && _tcschr(_T("<>"),*p) && p[0] == p[1] )
{
INT rval;
TCHAR op = *p;
p = skip_ws ( p+2 );
if ( !seta_logShiftTerm ( &p, &rval ) )
return FALSE;
switch ( op )
{
case '<':
lval <<= rval;
break;
case '>':
lval >>= rval;
break;
default:
ConErrResPuts ( STRING_INVALID_OPERAND );
return FALSE;
}
}
*result = lval;
*p_ = p;
return TRUE;
}
示例14: seta_ltorTerm
static BOOL
seta_ltorTerm ( LPCTSTR* p_, INT* result, LPCTSTR ops, BOOL (*subTerm)(LPCTSTR*,INT*) )
{
LPCTSTR p = *p_;
INT lval;
if ( !subTerm ( &p, &lval ) )
return FALSE;
while ( *p && _tcschr(ops,*p) )
{
INT rval;
TCHAR op = *p;
p = skip_ws ( p+1 );
if ( !subTerm ( &p, &rval ) )
return FALSE;
if ( !calc ( &lval, op, rval ) )
return FALSE;
}
*result = lval;
*p_ = p;
return TRUE;
}
示例15: seta_mulTerm
static BOOL
seta_mulTerm ( LPCTSTR* p_, INT* result )
{
LPCTSTR p = *p_;
TCHAR op = 0;
INT rval;
if ( _tcschr(_T("!~-"),*p) )
{
op = *p;
p = skip_ws ( p + 1 );
}
if ( !seta_unaryTerm ( &p, &rval ) )
return FALSE;
switch ( op )
{
case '!':
rval = !rval;
break;
case '~':
rval = ~rval;
break;
case '-':
rval = -rval;
break;
}
*result = rval;
*p_ = p;
return TRUE;
}