当前位置: 首页>>代码示例>>C++>>正文


C++ skip_spaces函数代码示例

本文整理汇总了C++中skip_spaces函数的典型用法代码示例。如果您正苦于以下问题:C++ skip_spaces函数的具体用法?C++ skip_spaces怎么用?C++ skip_spaces使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了skip_spaces函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: skip_spaces

//--------------------------------------------------------------------------
bool groupman_t::parse_nodeset(
      psupergroup_t sg,
      char *grpstr)
{
  // Find node group bounds
  for ( /*init*/ char *p_group_start = NULL, *p_group_end = NULL;
        /* cond*/(p_group_start = strchr(grpstr, '(')) != NULL
             && (p_group_start = skip_spaces(p_group_start+1), (p_group_end = strchr(p_group_start, ')')) != NULL);
        /*incr*/)
  {
    // Terminate the string with the closing parenthesis
    *p_group_end = '\0';

    // Advance to next group
    grpstr = skip_spaces(p_group_end + 1);

    // Add a new group
    pnodegroup_t ng = sg->add_nodegroup();

    for (/*init*/ char *saved_ptr, 
                  *p = p_group_start, 
                  *token = qstrtok(p, ",", &saved_ptr);
         /*cond*/ p != NULL;
         /*incr*/ p = qstrtok(NULL, ",", &saved_ptr))
    {
      p = skip_spaces(p);

      int nid;
      ea_t start = 0, end = 0;
      if (qsscanf(p, "%d : %a : %a", &nid, &start, &end) <= 0)
        continue;

      // Create an ND
      nodedef_t *nd = ng->add_node();
      nd->nid = nid;
      nd->start = start;
      nd->end = end;

      // Map this node
      map_nodedef(nid, nd);
    }
  }
  return true;
}
开发者ID:lallousx86,项目名称:GraphSlick,代码行数:45,代码来源:groupman.cpp

示例2: perform_net_load

void
perform_net_load(struct descriptor_data *d, char *arg)
{
    int skill_num, percent;
    long int cost;

    skip_spaces(&arg);
    if (!*arg) {
        d_printf(d, "Usage: load <program>\r\n");
        return;
    }

    skill_num = find_skill_num(arg);
    if (skill_num < 1) {
        d_printf(d, "Error: program '%s' not found\r\n", arg);
        return;
    }

    if ((SPELL_GEN(skill_num, CLASS_CYBORG) > 0
            && GET_CLASS(d->creature) != CLASS_CYBORG)
        || (GET_REMORT_GEN(d->creature) < SPELL_GEN(skill_num, CLASS_CYBORG))
        || (GET_LEVEL(d->creature) < SPELL_LEVEL(skill_num, CLASS_CYBORG))) {
        d_printf(d, "Error: resources unavailable to load '%s'\r\n", arg);
        return;
    }

    if (GET_SKILL(d->creature, skill_num) >= LEARNED(d->creature)) {
        d_printf(d, "Program fully installed on local system.\r\n");
        return;
    }

    cost = GET_SKILL_COST(d->creature, skill_num);
    d_printf(d, "Program cost: %10ld  Account balance; %'" PRId64 "\r\n",
        cost, d->account->bank_future);

    if (d->account->bank_future < cost) {
        d_printf(d, "Error: insufficient funds in your account\r\n");
        return;
    }

    withdraw_future_bank(d->account, cost);
    percent = MIN(MAXGAIN(d->creature),
        MAX(MINGAIN(d->creature), GET_INT(d->creature) * 2));
    percent = MIN(LEARNED(d->creature) -
        GET_SKILL(d->creature, skill_num), percent);
    SET_SKILL(d->creature, skill_num, GET_SKILL(d->creature,
            skill_num) + percent);
    d_printf(d,
        "Program download: %s terminating, %d percent transfer.\r\n",
        spell_to_str(skill_num), percent);
    if (GET_SKILL(d->creature, skill_num) >= LEARNED(d->creature))
        d_printf(d, "Program fully installed on local system.\r\n");
    else
        d_printf(d, "Program %d%% installed on local system.\r\n",
            GET_SKILL(d->creature, skill_num));
}
开发者ID:TempusMUD,项目名称:Tempuscode,代码行数:56,代码来源:gnetsys.c

示例3: skip_spaces

void config_file::init(const string& filename, istream& is)
{
  string cur_sect;

  int lineno = 1;
  for (string line; getline(is, line); ++lineno) {
    const char* p = line.c_str();
    const char* st = p;
    p = skip_spaces(p);

    if (*p=='\0') continue;
    if (*p==';') continue;

    if (*p=='[') {
      const char* q = strchr(p, ']');
      if (q == NULL)
        throw parse_error(filename, lineno, line.length(), "']' missing");
      cur_sect = string(p+1, q);
      q = skip_spaces(q+1);
      if (*q != '\0') 
        throw parse_error(filename, lineno, q-st, "invalid character");

      (void)dat[cur_sect];

      continue;
    }

    const char* q = strchr(p, '=');
    if (q == NULL)
      throw parse_error(filename, lineno, line.length(), "'=' missing");

    string key(trim(string(p, q)));
    string val(trim(q+1));

    if (val.length() >= 2) {
      if (val[0] == '"' &&
          val[val.length()-1] == '"')
        val.assign(val, 1, val.length()-2);
    }

    dat[cur_sect][key] = val;
  }
}
开发者ID:b-xiang,项目名称:pficommon,代码行数:43,代码来源:config_file.cpp

示例4: check_newline

static int check_newline(struct dsa *dsa)
{     if (skip_spaces(dsa, 0)) return 1;
      if (!(dsa->c == EOF || dsa->c == '\n'))
      {  xprintf("%s:%d: extra symbols detected\n", dsa->fname,
            dsa->seqn);
         return 1;
      }
      if (get_char(dsa)) return 1;
      return 0;
}
开发者ID:BohanHsu,项目名称:developer,代码行数:10,代码来源:glptsp.c

示例5: check_colon

static int check_colon(struct dsa *dsa)
{     if (skip_spaces(dsa, 0)) return 1;
      if (dsa->c != ':')
      {  xprintf("%s:%d: missing colon after `%s'\n", dsa->fname,
            dsa->seqn, dsa->token);
         return 1;
      }
      if (get_char(dsa)) return 1;
      return 0;
}
开发者ID:BohanHsu,项目名称:developer,代码行数:10,代码来源:glptsp.c

示例6: fs_cmd_user

static int fs_cmd_user(struct fs_info *session) {
	/* Usage: user <user-name> */
	int ret;
	char *tmp, *arg_username, *password;

	if (!session->is_connected) {
		fprintf(stderr, "Not connected.\n");
		return FTP_RET_FAIL;
	}

	/* Get args */
	tmp = &session->cmd_buff[0];
	skip_spaces(tmp); skip_word(tmp); skip_spaces(tmp);
	arg_username = tmp;

	split_word(arg_username);

	if (*arg_username == '\0') {
		fprintf(stderr, "User name is not specified.\n");
		errno = EINVAL;
		return FTP_RET_ERROR;
	}
	/* --- END OF Get args --- */

	ret = fs_execute(session, "USER %s\r\n", arg_username);
	if (ret != FTP_RET_OK) {
		return ret;
	}

	password = getpass("Password: ");
	if (password == NULL) {
		fprintf(stderr, "Cant get password for %s.\n", arg_username);
		errno = EINVAL;
		return FTP_RET_ERROR;
	}

	ret = fs_execute(session, "PASS %s\r\n", password);
	if (ret != FTP_RET_OK) {
		return ret;
	}

	return FTP_RET_OK;
}
开发者ID:AleksandraButrova,项目名称:embox,代码行数:43,代码来源:ftp.c

示例7: createToken

Token *ScannerImp::nextToken() {
	if(skip_spaces())return NULL;
	runMachines();
	TType typ = manager->getType();
	skip_comment(&typ);
	int wortlaenge = manager->getLexemLength();
	int wrongChars = manager->ungetCtr();
	buffer->ungetChar(wrongChars);
	return createToken(typ,wortlaenge,x,y);
}
开发者ID:fble,项目名称:hochschule,代码行数:10,代码来源:ScannerImp.cpp

示例8: simple_strtoul

char *spk_s2uchar(char *start, char *dest)
{
	int val;

	/* Do not replace with kstrtoul: here we need start to be updated */
	val = simple_strtoul(skip_spaces(start), &start, 10);
	if (*start == ',')
		start++;
	*dest = (u_char)val;
	return start;
}
开发者ID:Anjali05,项目名称:linux,代码行数:11,代码来源:varhandlers.c

示例9: empty_elsed

static inline int empty_elsed(const char *in)
{
	in = skip_spaces(in);
	in += LEN("#elsed");
	while (*in == ' ' || *in == '\t')
		in++;
	if (*in == '\n')
		return 1;
	else
		return 0;
}
开发者ID:initng,项目名称:initng-scripts,代码行数:11,代码来源:install_service_file.c

示例10: parse

	void parse(const char* json, JsonObject& object)
	{
		CE_ASSERT_NOT_NULL(json);

		json = skip_spaces(json);

		if (*json == '{')
			parse_object(json, object);
		else
			parse_root_object(json, object);
	}
开发者ID:MAnyKey,项目名称:crown,代码行数:11,代码来源:sjson.cpp

示例11: while

void ScannerImp::skip_comment(TType *typ) {
	if(*typ == CommentBegin) {
		while (*typ != CommentEnd || skip_spaces()) {
			runMachines();
			*typ = manager->getType();
		}
		buffer->ungetChar(1);
		runMachines();
		*typ = manager->getType();
	}
}
开发者ID:fble,项目名称:hochschule,代码行数:11,代码来源:ScannerImp.cpp

示例12: parse

	void parse(const char* json, JsonObject& object)
	{
		CE_ENSURE(NULL != json);

		json = skip_spaces(json);

		if (*json == '{')
			parse_object(json, object);
		else
			parse_root_object(json, object);
	}
开发者ID:neuroradiology,项目名称:crown,代码行数:11,代码来源:sjson.cpp

示例13: get_number_or_range

int
get_number_or_range (struct get_number_or_range_state *state)
{
  if (*state->string != '-')
    {
      /* Default case: state->string is pointing either to a solo
	 number, or to the first number of a range.  */
      state->last_retval = get_number_trailer (&state->string, '-');
      if (*state->string == '-')
	{
	  char **temp;

	  /* This is the start of a range (<number1> - <number2>).
	     Skip the '-', parse and remember the second number,
	     and also remember the end of the final token.  */

	  temp = &state->end_ptr; 
	  state->end_ptr = skip_spaces (state->string + 1);
	  state->end_value = get_number (temp);
	  if (state->end_value < state->last_retval) 
	    {
	      error (_("inverted range"));
	    }
	  else if (state->end_value == state->last_retval)
	    {
	      /* Degenerate range (number1 == number2).  Advance the
		 token pointer so that the range will be treated as a
		 single number.  */ 
	      state->string = state->end_ptr;
	    }
	  else
	    state->in_range = 1;
	}
    }
  else if (! state->in_range)
    error (_("negative value"));
  else
    {
      /* state->string points to the '-' that betokens a range.  All
	 number-parsing has already been done.  Return the next
	 integer value (one greater than the saved previous value).
	 Do not advance the token pointer until the end of range
	 is reached.  */

      if (++state->last_retval == state->end_value)
	{
	  /* End of range reached; advance token pointer.  */
	  state->string = state->end_ptr;
	  state->in_range = 0;
	}
    }
  state->finished = *state->string == '\0';
  return state->last_retval;
}
开发者ID:5kg,项目名称:gdb,代码行数:54,代码来源:cli-utils.c

示例14: dm_substitute_devices

static void __init dm_substitute_devices(char *str, size_t str_len)
{
	char *candidate = str;
	char *candidate_end = str;
	char old_char;
	size_t len = 0;
	dev_t dev;

	if (str_len < 3)
		return;

	while (str && *str) {
		candidate = strchr(str, '/');
		if (!candidate)
			break;

		/* Avoid embedded slashes */
		if (candidate != str && *(candidate - 1) != DM_FIELD_SEP) {
			str = strchr(candidate, DM_FIELD_SEP);
			continue;
		}

		len = get_dm_option(candidate, &candidate_end, DM_FIELD_SEP);
		str = skip_spaces(candidate_end);
		if (len < 3 || len > 37)  /* name_to_dev_t max; maj:mix min */
			continue;

		/* Temporarily terminate with a nul */
		candidate_end--;
		old_char = *candidate_end;
		*candidate_end = '\0';

		DMDEBUG("converting candidate device '%s' to dev_t", candidate);
		/* Use the boot-time specific device naming */
		dev = name_to_dev_t(candidate);
		*candidate_end = old_char;

		DMDEBUG(" -> %u", dev);
		/* No suitable replacement found */
		if (!dev)
			continue;

		/* Rewrite the /dev/path as a major:minor */
		len = snprintf(candidate, len, "%u:%u", MAJOR(dev), MINOR(dev));
		if (!len) {
			DMERR("error substituting device major/minor.");
			break;
		}
		candidate += len;
		/* Pad out with spaces (fixing our nul) */
		while (candidate < candidate_end)
			*(candidate++) = DM_FIELD_SEP;
	}
}
开发者ID:jiaming77,项目名称:DORIMANX_LG_STOCK_LP_KERNEL,代码行数:54,代码来源:do_mounts_dm.c

示例15: skip_code

static int skip_code(parser_ctx_t *ctx, BOOL exec_else)
{
    int if_depth = 1;
    const WCHAR *ptr;

    while(1) {
        ptr = strchrW(ctx->ptr, '@');
        if(!ptr) {
            WARN("No @end\n");
            return lex_error(ctx, JS_E_EXPECTED_CCEND);
        }
        ctx->ptr = ptr+1;

        if(!check_keyword(ctx, endW, NULL)) {
            if(--if_depth)
                continue;
            return 0;
        }

        if(exec_else && !check_keyword(ctx, elifW, NULL)) {
            if(if_depth > 1)
                continue;

            if(!skip_spaces(ctx) || *ctx->ptr != '(')
                return lex_error(ctx, JS_E_MISSING_LBRACKET);

            if(!parse_cc_expr(ctx))
                return -1;

            if(!get_ccbool(ctx->ccval))
                continue; /* skip block of code */

            /* continue parsing */
            ctx->cc_if_depth++;
            return 0;
        }

        if(exec_else && !check_keyword(ctx, elseW, NULL)) {
            if(if_depth > 1)
                continue;

            /* parse else block */
            ctx->cc_if_depth++;
            return 0;
        }

        if(!check_keyword(ctx, ifW, NULL)) {
            if_depth++;
            continue;
        }

        ctx->ptr++;
    }
}
开发者ID:oneminot,项目名称:reactos,代码行数:54,代码来源:lex.c


注:本文中的skip_spaces函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。