本文整理汇总了C++中skip_whitespace函数的典型用法代码示例。如果您正苦于以下问题:C++ skip_whitespace函数的具体用法?C++ skip_whitespace怎么用?C++ skip_whitespace使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了skip_whitespace函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: parse_rgba
static gboolean
parse_rgba (ClutterColor *color,
gchar *str,
gboolean has_alpha)
{
skip_whitespace (&str);
if (*str != '(')
return FALSE;
str += 1;
/* red */
parse_rgb_value (str, &color->red, &str);
skip_whitespace (&str);
if (*str != ',')
return FALSE;
str += 1;
/* green */
parse_rgb_value (str, &color->green, &str);
skip_whitespace (&str);
if (*str != ',')
return FALSE;
str += 1;
/* blue */
parse_rgb_value (str, &color->blue, &str);
skip_whitespace (&str);
/* alpha (optional); since the alpha channel value can only
* be between 0 and 1 we don't use the parse_rgb_value()
* function
*/
if (has_alpha)
{
gdouble number;
if (*str != ',')
return FALSE;
str += 1;
skip_whitespace (&str);
number = g_ascii_strtod (str, &str);
color->alpha = CLAMP (number * 255.0, 0, 255);
}
else
color->alpha = 255;
skip_whitespace (&str);
if (*str != ')')
return FALSE;
return TRUE;
}
开发者ID:GNOME,项目名称:clutter,代码行数:59,代码来源:clutter-color.c
示例2: process_title
//-------------------------------------------------------------------
static void process_title(const char *title)
{
register const char *ptr = title;
register int i=0;
ptr = skip_whitespace(ptr);
while (i<(sizeof(script_title)-1) && ptr[i] && ptr[i]!='\r' && ptr[i]!='\n')
{
script_title[i]=ptr[i];
++i;
}
script_title[i]=0;
}
开发者ID:DIYBookScanner,项目名称:chdk,代码行数:14,代码来源:gui_script.c
示例3: execute
/**
* Execute the BASIC command in 's'.
*/
void execute(char *s) {
unsigned char command;
char * args;
reset_interrupted();
s = skip_whitespace(s);
args = find_args(s);
command = find_keyword(s);
if (command != CMD_UNKNOWN) {
command_functions[command](args);
} else {
lcd_puts("Unknown command!\n");
}
}
开发者ID:punkofnewsociety,项目名称:homecomputer-6502,代码行数:16,代码来源:basic.c
示例4: check_param
//-------------------------------------------------------------------
// Process one entry "@param VAR TITLE" to check if it exists
// param = ptr right after descriptor (should point to var)
// RETURN VALUE: 0 if not found, 1..26 = id of var
// Used to ensure that a param loaded from an old saved paramset does
// not overwrite defaults from script
//-------------------------------------------------------------------
static int check_param(const char *param)
{
register const char *ptr = param;
register int n=0, l;
ptr = skip_whitespace(ptr);
if (ptr[0] && (ptr[0]>='a' && ptr[0]<='a'+SCRIPT_NUM_PARAMS) && (ptr[1]==' ' || ptr[1]=='\t'))
{
n = ptr[0]-'a'; // VAR
ptr = skip_whitespace(ptr+2); // skip to TITLE
l = skip_toeol(ptr) - ptr; // get length of TITLE
if (l > MAX_PARAM_NAME_LEN)
l = MAX_PARAM_NAME_LEN;
if (l != strlen(script_params[n])) // Check length matches existing TITLE length
n = 0;
else if (strncmp(ptr,script_params[n],l) != 0) // Check that TITLE matches existing TITLE
n = 0;
else
n++;
}
return n; // n=1 if '@param a' was processed, n=2 for 'b' ... n=26 for 'z'. n=0 if failed.
}
开发者ID:DIYBookScanner,项目名称:chdk,代码行数:29,代码来源:gui_script.c
示例5: process_range
//-------------------------------------------------------------------
// Process one entry "@range VAR MIN MAX"
// param = ptr right after descriptor (should point to var)
//-------------------------------------------------------------------
static void process_range(const char *param)
{
register const char *ptr = param;
register int n;
ptr = skip_whitespace(ptr);
if (ptr[0] && (ptr[0]>='a' && ptr[0]<='a'+SCRIPT_NUM_PARAMS) && (ptr[1]==' ' || ptr[1]=='\t'))
{
n = ptr[0]-'a';
ptr = skip_whitespace(ptr+2);
int min = strtol(ptr,NULL,0);
ptr = skip_whitespace(skip_token(ptr));
int max = strtol(ptr,NULL,0);
script_range_values[n] = MENU_MINMAX(min,max);
if ((min == 0) && (max == 1))
script_range_types[n] = MENUITEM_BOOL;
else if ((min >= 0) && (max >= 0))
script_range_types[n] = MENUITEM_INT|MENUITEM_F_MINMAX|MENUITEM_F_UNSIGNED;
else
script_range_types[n] = MENUITEM_INT|MENUITEM_F_MINMAX;
} // ??? else produce error message
}
开发者ID:DIYBookScanner,项目名称:chdk,代码行数:26,代码来源:gui_script.c
示例6: read_map
static void read_map(JSONSource* self, rich_Sink* to) {
Input* in = self->in;
call(to, sink, RICH_MAP, NULL);
bool first = true;
for (;;) {
int ch = skip_whitespace(in);
if (ch == '}') break;
if (first) {
first = false;
} else {
if (ch != ',') RAISE(MALFORMED);
ch = skip_whitespace(in);
}
if (ch != '"') RAISE(MALFORMED);
read_string(self);
call(to, sink, RICH_KEY, &self->sval);
ch = skip_whitespace(in);
if (ch != ':') RAISE(MALFORMED);
read_value(self, to);
}
call(to, sink, RICH_ENDMAP, NULL);
}
开发者ID:vaughan0,项目名称:vlib,代码行数:22,代码来源:rich_json.c
示例7: ensure
void streamtools_object::test<1>()
{
char arr[255];
std::string str;
std::string expected_result;
std::string actual_result;
std::istringstream is;
is.str(str = "");
ensure("skip_whitespace: empty string", (false == skip_whitespace(is)));
is.clear();
is.str(str = " SecondLife is a 3D World");
skip_whitespace(is);
is.get(arr, 255, '\0');
expected_result = "SecondLife is a 3D World";
ensure_equals("skip_whitespace: space", arr, expected_result);
is.clear();
is.str(str = "\t \tSecondLife is a 3D World");
skip_whitespace(is);
is.get(arr, 255, '\0');
expected_result = "SecondLife is a 3D World";
ensure_equals("skip_whitespace: space and tabs", arr, expected_result);
is.clear();
is.str(str = "\t \tSecondLife is a 3D World ");
skip_whitespace(is);
is.get(arr, 255, '\0');
expected_result = "SecondLife is a 3D World ";
ensure_equals("skip_whitespace: space at end", arr, expected_result);
is.clear();
is.str(str = "\t \r\nSecondLife is a 3D World");
skip_whitespace(is);
is.get(arr, 255, '\0');
expected_result = "\r\nSecondLife is a 3D World";
ensure_equals("skip_whitespace: space at end", arr, expected_result);
}
开发者ID:Nora28,项目名称:imprudence,代码行数:39,代码来源:llstreamtools_tut.cpp
示例8: line_has_word
bool line_has_word (char *ptr, const char *word, int word_len) {
ptr = skip_whitespace(ptr);
//make sure the file doesn't end before the end of the word + required whitespace,
// then see if the word's found on the line
if (strnlen (ptr, word_len) == word_len && !strncasecmp (ptr, word, word_len)) {
//then make sure it isn't just the start of another word
ptr += word_len;
//if (isspace (*ptr) || is_end_of_code_line (ptr))
return true;
}
return false;
}
开发者ID:RickyXwang,项目名称:transf-badapple,代码行数:13,代码来源:utils.cpp
示例9: parse_fa_id_line
/* Each line in the file consists of up to four whitespace separated fields:
* id [description] [x_name] [y_name]
*/
static bool parse_fa_id_line(const char **line, bool seen[])
{
int id;
bool ok =
parse_int(line, &id) &&
TEST_OK_(0 <= id && (uint32_t) id < id_list_length,
"FA id %d out of range", id) &&
TEST_OK_(!seen[id], "FA id %u repeated", id);
if (ok)
{
seen[id] = true;
struct fa_id_list *entry = &fa_id_list[id];
IGNORE(
skip_whitespace(line) &&
maybe_parse_word(line, &entry->description) &&
skip_whitespace(line) &&
maybe_parse_word(line, &entry->x_name) &&
skip_whitespace(line) &&
maybe_parse_word(line, &entry->y_name));
}
return ok;
}
开发者ID:Araneidae,项目名称:fa-archiver,代码行数:25,代码来源:mask.c
示例10: process_memstate
void process_memstate ( void )
{
char *p;
if ( ! slurpfile( "/proc/meminfo" ) ){
return;
}
p = strstr( buffer, "MemFree:" );
p = skip_token(p);
p = skip_whitespace(p);
now.mem_free = strtod( p, (char **)NULL);
p = strstr( buffer, "MemShared:" );
p = skip_token(p);
p = skip_whitespace(p);
now.mem_shared = strtod( p, (char **)NULL);
p = strstr( buffer, "Buffers:" );
p = skip_token(p);
p = skip_whitespace(p);
now.mem_buffers = strtod( p, (char **)NULL);
p = strstr( buffer, "Cached:" );
p = skip_token(p);
p = skip_whitespace(p);
now.mem_cached = strtod( p, (char **)NULL);
p = strstr( buffer, "SwapFree:" );
p = skip_token(p);
p = skip_whitespace(p);
now.swap_free = strtod( p, (char **)NULL );
}
开发者ID:satterly,项目名称:ganglia-1.0,代码行数:39,代码来源:dendrite.c
示例11: http_request_parse_method_line
/**
* Parses first line of request
*/
uint8_t* ICACHE_FLASH_ATTR http_request_parse_method_line( http_request_object_type* request, uint8_t* data )
{
uint8_t* w, v, *end, ev;
char hpost[ 5 ] = "POST", hget[ 4 ] = "GET";
ev = *( end = get_line_ending( data ));
( *end ) = '\0';
request->method = HTTP_METHOD_NONE;
data = skip_whitespace( data );
v = *( w = skip_to_whitespace( data ) );
( *w ) = '\0';
if( strcmp( hget, ( char* ) data ) == 0 ) request->method = HTTP_METHOD_GET;
if( strcmp( hpost, ( char* ) data ) == 0 ) request->method = HTTP_METHOD_POST;
( *w ) = v;
data = skip_whitespace( w );
v = *( w = skip_to_whitespace( data ) );
( *w ) = '\0';
url_parse_path( request->location, data );
( *w ) = v;
( *end ) = ev;
return skip_line_ending( end );
}
开发者ID:cristidbr,项目名称:aircore,代码行数:26,代码来源:esp_http.c
示例12: parse_pair
// Parses a pair, assuming the opening left parenthesis has already been read.
static struct ParseResult parse_pair(const char *text) {
struct ParseResult result;
result.err_type = -1;
const char *s = text;
s += skip_whitespace(s);
if (*s == ')') {
s++;
result.expr = new_null();
goto chars_read;
}
struct ParseResult first = parse(s);
s += first.chars_read;
if (first.err_type != -1) {
result.err_type = first.err_type;
goto chars_read;
}
if (*s == '.') {
s++;
struct ParseResult second = parse(s);
s += second.chars_read;
if (second.err_type != -1) {
result.err_type = second.err_type;
release_expression(first.expr);
goto chars_read;
}
if (*s != ')') {
result.err_type = *s ? ERR_EXPECTED_RPAREN : ERR_UNEXPECTED_EOI;
release_expression(first.expr);
goto chars_read;
}
s++;
result.expr = new_pair(first.expr, second.expr);
} else {
struct ParseResult rest = parse_pair(s);
s += rest.chars_read;
if (rest.err_type != -1) {
result.err_type = rest.err_type;
release_expression(first.expr);
goto chars_read;
}
result.expr = new_pair(first.expr, rest.expr);
}
chars_read:
result.chars_read = (size_t)(s - text);
return result;
}
开发者ID:mk12,项目名称:eva,代码行数:51,代码来源:parse.c
示例13: hfp_context_close_container
bool hfp_context_close_container(struct hfp_context *context)
{
skip_whitespace(context);
/* The list shall be followed by a right parenthesis (")" V250 5.7.3.1*/
if (context->data[context->offset] != ')')
return false;
context->offset++;
next_field(context);
return true;
}
开发者ID:AlanApter,项目名称:steamlink-sdk,代码行数:14,代码来源:hfp.c
示例14: get_name
// Extract name up to maxlen, find or create sc_param based on name
// Return pointer past name.
// Sets *sp to sc_param entry, or 0 if not found
const char* get_name(const char *p, int maxlen, sc_param **sp, int create)
{
char str[MAX_PARAM_NAME_LEN+1];
*sp = 0;
p = skip_whitespace(p);
if (p[0] && isalpha(p[0]))
{
p = get_token(p, str, maxlen);
*sp = find_param(str);
if ((*sp == 0) && create)
*sp = new_param(str);
}
return p;
}
开发者ID:c10ud,项目名称:CHDK,代码行数:17,代码来源:gui_script.c
示例15: cmd_layerdef
static int cmd_layerdef(const char *p)
{
int fn, n, ret = ERR_INVALID_ARGS;
unsigned char fn_combo = 0;
p = skip_whitespace(p);
for (p = skip_whitespace(p); *p; p = skip_token(p)) {
fn = parse_function_n(p);
if (fn == INVALID_NUMBER) break;
fn_combo |= (unsigned char)(1 << (fn - 1));
}
if (!fn_combo) goto ret;
/* layer id */
n = parse_int(p, 1, 255);
if (n == INVALID_NUMBER) goto ret;
pair_list_push(LAYERDEF_LIST, fn_combo, (unsigned char)n);
ret = 0;
ret:
return ret;
}
开发者ID:thentenaar,项目名称:sctools,代码行数:23,代码来源:scas.c
示例16: process_param
//-------------------------------------------------------------------
// Process one entry "@param VAR TITLE"
// RESULT: params[VAR].desc - parameter title
// RETURN VALUE: 0 if err, 1 if ok
//-------------------------------------------------------------------
static void process_param(const char *ptr)
{
sc_param *p;
ptr = get_name(ptr, MAX_PARAM_NAME_LEN, &p, 1);
if (p)
{
ptr = skip_whitespace(ptr);
int l = skip_toeol(ptr) - ptr;
if (l > MAX_PARAM_NAME_LEN) l = MAX_PARAM_NAME_LEN;
p->desc = malloc(l+1);
strncpy(p->desc, ptr, l);
p->desc[l] = 0;
}
}
开发者ID:c10ud,项目名称:CHDK,代码行数:19,代码来源:gui_script.c
示例17: failure
/* Read and record the parameters, if any, of a function-like macro
definition. Destroys pfile->out.cur.
Returns true on success, false on failure (syntax error or a
duplicate parameter). On success, CUR (pfile->context) is just
past the closing parenthesis. */
static bool
scan_parameters (cpp_reader *pfile, cpp_macro *macro)
{
const uchar *cur = CUR (pfile->context) + 1;
bool ok;
for (;;)
{
cur = skip_whitespace (pfile, cur, true /* skip_comments */);
if (is_idstart (*cur))
{
ok = false;
if (_cpp_save_parameter (pfile, macro, lex_identifier (pfile, cur)))
break;
cur = skip_whitespace (pfile, CUR (pfile->context),
true /* skip_comments */);
if (*cur == ',')
{
cur++;
continue;
}
ok = (*cur == ')');
break;
}
ok = (*cur == ')' && macro->paramc == 0);
break;
}
if (!ok)
cpp_error (pfile, CPP_DL_ERROR, "syntax error in macro parameter list");
CUR (pfile->context) = cur + (*cur == ')');
return ok;
}
开发者ID:Fokycnuk,项目名称:gcc,代码行数:43,代码来源:cpptrad.c
示例18: parse_choices
static char * parse_choices(struct kconfig * choice_kcfg, char * pnt)
{
struct kconfig * kcfg;
int index = 1;
/*
* Choices appear in pairs of strings. The parse is fairly trivial.
*/
while(1)
{
pnt = skip_whitespace(pnt);
if(*pnt == '\0') break;
kcfg = (struct kconfig *) malloc(sizeof(struct kconfig));
memset(kcfg, 0, sizeof(struct kconfig));
kcfg->tok = tok_choice;
if( clast != NULL )
{
clast->next = kcfg;
clast = kcfg;
}
else
{
clast = config = kcfg;
}
pnt = get_string(pnt, &kcfg->label);
pnt = skip_whitespace(pnt);
pnt = get_string(pnt, &kcfg->optionname);
kcfg->choice_label = choice_kcfg;
kcfg->choice_value = index++;
if( strcmp(kcfg->label, choice_kcfg->value) == 0 )
choice_kcfg->choice_value = kcfg->choice_value;
}
return pnt;
}
开发者ID:xinpianyu72,项目名称:nemo,代码行数:37,代码来源:tkparse.c
示例19: command
/*
* Parse non-option commands: getopts, (short)usage, or end.
* The return code indicates whether the end directive was observed.
*/
static int
command(pmOptions *opts, char *buffer)
{
char *start, *finish;
start = skip_whitespace(buffer);
if (strncasecmp(start, "getopt", sizeof("getopt")-1) == 0) {
start = skip_whitespace(skip_nonwhitespace(start));
finish = skip_nonwhitespace(start);
*finish = '\0';
if (pmDebug & DBG_TRACE_DESPERATE)
fprintf(stderr, "%s: getopt command: '%s'\n", pmProgname, start);
if ((opts->short_options = strdup(start)) == NULL)
__pmNoMem("short_options", strlen(start), PM_FATAL_ERR);
return 0;
}
if (strncasecmp(start, "usage", sizeof("usage")-1) == 0) {
start = skip_whitespace(skip_nonwhitespace(start));
if (pmDebug & DBG_TRACE_DESPERATE)
fprintf(stderr, "%s: usage command: '%s'\n", pmProgname, start);
if ((opts->short_usage = strdup(start)) == NULL)
__pmNoMem("short_usage", strlen(start), PM_FATAL_ERR);
return 0;
}
if (strncasecmp(start, "end", sizeof("end")-1) == 0) {
if (pmDebug & DBG_TRACE_DESPERATE)
fprintf(stderr, "%s: end command\n", pmProgname);
return 1;
}
fprintf(stderr, "%s: unrecognized command: '%s'\n", pmProgname, buffer);
return 0;
}
开发者ID:Aconex,项目名称:pcp,代码行数:40,代码来源:pmgetopt.c
示例20: string_to_kcg_real
int string_to_kcg_real(const char* str, void* pValue, const char** endptr)
{
skip_whitespace(str);
if (pSimDoubleVTable != NULL
&& pSimDoubleVTable->m_pfnGetConvInfo(SptNone, SptString) == 1) {
return string_to_VTable(str, pSimDoubleVTable, pValue, endptr);
}
{
double nTemp = 0;
int nRet = pConverter->m_pfnStringToReal(str, &nTemp, endptr);
if (nRet != 0 && pValue != NULL)
*(kcg_real*)pValue = (kcg_real)nTemp;
return nRet;
}
}
开发者ID:fogacalu,项目名称:scade-integration-example-1,代码行数:15,代码来源:project2_newtype.c
注:本文中的skip_whitespace函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论