本文整理汇总了C++中skipwhite函数的典型用法代码示例。如果您正苦于以下问题:C++ skipwhite函数的具体用法?C++ skipwhite怎么用?C++ skipwhite使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了skipwhite函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: skipwhite
SYMBOL *get_op(
char *cp,
char **endp)
{
int local;
char *label;
SYMBOL *op;
cp = skipwhite(cp);
if (EOL(*cp))
return NULL;
label = get_symbol(cp, &cp, &local);
if (label == NULL)
return NULL; /* No operation code. */
cp = skipwhite(cp);
if (*cp == ':') { /* A label definition? */
cp++;
if (*cp == ':')
cp++; /* Skip it */
free(label);
label = get_symbol(cp, &cp, NULL);
if (label == NULL)
return NULL;
}
op = lookup_sym(label, &system_st);
free(label);
if (endp)
*endp = cp;
return op;
}
示例2: split
static void
split(char cmd[])
{
cmd = skipwhite(cmd);
char *next = strchr(cmd, ' ');
size_t i = 0;
while (next)
{
*next = '\0';
g_args[i] = cmd;
++i;
cmd = skipwhite(next + 1);
next = strchr(cmd, ' ');
}
if (*cmd)
{
g_args[i] = cmd;
next = strchr(cmd, '\0');
*next = '\0';
++i;
}
g_args[i] = NULL;
}
示例3: string2blob
/*
* Convert a string variable, in the format of blob2string(), to a blob.
* Return NULL when conversion failed.
*/
blob_T *
string2blob(char_u *str)
{
blob_T *blob = blob_alloc();
char_u *s = str;
if (*s != '[')
goto failed;
s = skipwhite(s + 1);
while (*s != ']')
{
if (s[0] != '0' || s[1] != 'x'
|| !vim_isxdigit(s[2]) || !vim_isxdigit(s[3]))
goto failed;
ga_append(&blob->bv_ga, (hex2nr(s[2]) << 4) + hex2nr(s[3]));
s += 4;
if (*s == ',')
s = skipwhite(s + 1);
else if (*s != ']')
goto failed;
}
s = skipwhite(s + 1);
if (*s != NUL)
goto failed; // text after final ']'
++blob->bv_refcount;
return blob;
failed:
blob_free(blob);
return NULL;
}
示例4: msgheadline
void
msgheadline(Biobuf *bin, int n, Biobuf *bout)
{
char *p, *q;
char *date;
char *from;
char *subject;
date = nil;
from = nil;
subject = nil;
while(p = Brdline(bin, '\n')){
p[Blinelen(bin)-1] = '\0';
if((q = strchr(p, ':')) == nil)
continue;
*q++ = '\0';
if(cistrcmp(p, "from")==0)
from = fixfrom(skipwhite(q));
else if(cistrcmp(p, "subject")==0)
subject = estrdup(skipwhite(q));
else if(cistrcmp(p, "date")==0)
date = fixdate(skipwhite(q));
}
Bprint(bout, "%d/\t%s", n, from ? from : "");
if(date)
Bprint(bout, "\t%s", date);
if(subject)
Bprint(bout, "\n\t%s", subject);
Bprint(bout, "\n");
free(date);
free(from);
free(subject);
}
示例5: get_list_tv
/*
* Allocate a variable for a List and fill it from "*arg".
* Return OK or FAIL.
*/
int
get_list_tv(char_u **arg, typval_T *rettv, int evaluate)
{
list_T *l = NULL;
typval_T tv;
listitem_T *item;
if (evaluate)
{
l = list_alloc();
if (l == NULL)
return FAIL;
}
*arg = skipwhite(*arg + 1);
while (**arg != ']' && **arg != NUL)
{
if (eval1(arg, &tv, evaluate) == FAIL) /* recursive! */
goto failret;
if (evaluate)
{
item = listitem_alloc();
if (item != NULL)
{
item->li_tv = tv;
item->li_tv.v_lock = 0;
list_append(l, item);
}
else
clear_tv(&tv);
}
if (**arg == ']')
break;
if (**arg != ',')
{
EMSG2(_("E696: Missing comma in List: %s"), *arg);
goto failret;
}
*arg = skipwhite(*arg + 1);
}
if (**arg != ']')
{
EMSG2(_("E697: Missing end of List ']': %s"), *arg);
failret:
if (evaluate)
list_free(l);
return FAIL;
}
*arg = skipwhite(*arg + 1);
if (evaluate)
rettv_list_set(rettv, l);
return OK;
}
示例6: ex_menutranslate
/*
* ":menutrans".
* This function is also defined without the +multi_lang feature, in which
* case the commands are ignored.
*/
void ex_menutranslate(exarg_T *eap)
{
char_u *arg = eap->arg;
menutrans_T *tp;
char_u *from, *from_noamp, *to;
if (menutrans_ga.ga_itemsize == 0)
ga_init(&menutrans_ga, (int)sizeof(menutrans_T), 5);
/*
* ":menutrans clear": clear all translations.
*/
if (STRNCMP(arg, "clear", 5) == 0 && ends_excmd(*skipwhite(arg + 5))) {
tp = (menutrans_T *)menutrans_ga.ga_data;
for (int i = 0; i < menutrans_ga.ga_len; ++i) {
free(tp[i].from);
free(tp[i].from_noamp);
free(tp[i].to);
}
ga_clear(&menutrans_ga);
/* Delete all "menutrans_" global variables. */
del_menutrans_vars();
} else {
/* ":menutrans from to": add translation */
from = arg;
arg = menu_skip_part(arg);
to = skipwhite(arg);
*arg = NUL;
arg = menu_skip_part(to);
if (arg == to)
EMSG(_(e_invarg));
else {
ga_grow(&menutrans_ga, 1);
tp = (menutrans_T *)menutrans_ga.ga_data;
from = vim_strsave(from);
from_noamp = menu_text(from, NULL, NULL);
to = vim_strnsave(to, (int)(arg - to));
if (from_noamp != NULL) {
menu_translate_tab_and_shift(from);
menu_translate_tab_and_shift(to);
menu_unescape_name(from);
menu_unescape_name(to);
tp[menutrans_ga.ga_len].from = from;
tp[menutrans_ga.ga_len].from_noamp = from_noamp;
tp[menutrans_ga.ga_len].to = to;
++menutrans_ga.ga_len;
} else {
free(from);
free(from_noamp);
free(to);
}
}
}
}
示例7: putdigraph
/// Add the digraphs in the argument to the digraph table.
/// format: {c1}{c2} char {c1}{c2} char ...
///
/// @param str
void putdigraph(char_u *str)
{
int char1, char2, n;
int i;
digr_T *dp;
while (*str != NUL) {
str = skipwhite(str);
if (*str == NUL) {
return;
}
char1 = *str++;
char2 = *str++;
if (char2 == 0) {
EMSG(_(e_invarg));
return;
}
if ((char1 == ESC) || (char2 == ESC)) {
EMSG(_("E104: Escape not allowed in digraph"));
return;
}
str = skipwhite(str);
if (!VIM_ISDIGIT(*str)) {
EMSG(_(e_number_exp));
return;
}
n = getdigits(&str);
// If the digraph already exists, replace the result.
dp = (digr_T *)user_digraphs.ga_data;
for (i = 0; i < user_digraphs.ga_len; ++i) {
if (((int)dp->char1 == char1) && ((int)dp->char2 == char2)) {
dp->result = n;
break;
}
++dp;
}
// Add a new digraph to the table.
if (i == user_digraphs.ga_len) {
ga_grow(&user_digraphs, 1);
dp = (digr_T *)user_digraphs.ga_data + user_digraphs.ga_len;
dp->char1 = char1;
dp->char2 = char2;
dp->result = n;
++user_digraphs.ga_len;
}
}
}
示例8: putdigraph
/// Add the digraphs in the argument to the digraph table.
/// format: {c1}{c2} char {c1}{c2} char ...
///
/// @param str
void putdigraph(char_u *str)
{
char_u char1, char2;
digr_T *dp;
while (*str != NUL) {
str = skipwhite(str);
if (*str == NUL) {
return;
}
char1 = *str++;
char2 = *str++;
if (char2 == 0) {
EMSG(_(e_invarg));
return;
}
if ((char1 == ESC) || (char2 == ESC)) {
EMSG(_("E104: Escape not allowed in digraph"));
return;
}
str = skipwhite(str);
if (!ascii_isdigit(*str)) {
EMSG(_(e_number_exp));
return;
}
int n = getdigits_int(&str);
// If the digraph already exists, replace the result.
dp = (digr_T *)user_digraphs.ga_data;
int i;
for (i = 0; i < user_digraphs.ga_len; ++i) {
if (((int)dp->char1 == char1) && ((int)dp->char2 == char2)) {
dp->result = n;
break;
}
++dp;
}
// Add a new digraph to the table.
if (i == user_digraphs.ga_len) {
dp = GA_APPEND_VIA_PTR(digr_T, &user_digraphs);
dp->char1 = char1;
dp->char2 = char2;
dp->result = n;
}
}
}
示例9: parse_delegpt
/** parse args into delegpt */
static struct delegpt*
parse_delegpt(SSL* ssl, struct regional* region, char* args, uint8_t* root)
{
/* parse args and add in */
char* p = args;
char* todo;
struct delegpt* dp = delegpt_create(region);
struct sockaddr_storage addr;
socklen_t addrlen;
if(!dp || !delegpt_set_name(dp, region, root)) {
(void)ssl_printf(ssl, "error out of memory\n");
return NULL;
}
while(p) {
todo = p;
p = strchr(p, ' '); /* find next spot, if any */
if(p) {
*p++ = 0; /* end this spot */
p = skipwhite(p); /* position at next spot */
}
/* parse address */
if(!extstrtoaddr(todo, &addr, &addrlen)) {
(void)ssl_printf(ssl, "error cannot parse"
" IP address '%s'\n", todo);
return NULL;
}
/* add address */
if(!delegpt_add_addr(dp, region, &addr, addrlen, 0, 0, 1)) {
(void)ssl_printf(ssl, "error out of memory\n");
return NULL;
}
}
return dp;
}
示例10: expandIncludes
void expandIncludes(FILE *in,FILE *out)
{
FILE *inc;
char incName[30],*p,*p2;
ibool expanding = false;
while (fgets(line,sizeof(line),in)) {
if (expanding) {
if (strnicmp(line,ASM_INC,ASM_INC_LEN) == 0) {
p = skipwhite(line+ASM_INC_LEN)+1;
p2 = incName;
while (*p != '\"')
*p2++ = *p++;
*p2 = '\0';
inc = openfile(incName,"r");
fprintf(out,";---- BEGIN INCLUDED FILE %s ----\n",incName);
fprintf(out,";%s",line);
expandIncludes(inc,out);
fprintf(out,";---- END INCLUDED FILE %s ----\n",incName);
fclose(inc);
}
else fputs(line,out);
if (strnicmp(line,END_STR,END_LEN) == 0)
if (strnicmp(line,END_FULL_STR,END_FULL_LEN) == 0)
expanding = false;
}
else {
fputs(line,out);
if (strnicmp(line,BEGIN_STR,BEGIN_LEN) == 0)
if (strnicmp(line,BEGIN_FULL_STR,BEGIN_FULL_LEN) == 0)
expanding = true;
}
}
}
示例11: processline
void processline(bc *bc, char *line)
{
char token[64], *lp;
struct cmd *cmd;
lp=line;
gettoken(token, sizeof(token), &lp);
skipwhite(&lp);
cmd=commandlist;
while(cmd->name)
{
if(!strncmp(token, cmd->name, strlen(token)))
{
cmd->func(bc, lp);
return;
}
++cmd;
}
if(line[0]>='0' && line[0]<='9') // line number
{
bc->flags |= BF_NOPROMPT;
lp=line;
while(*lp>='0' && *lp<='9') ++lp;
if(*lp)
addline(bc, line);
else
deleteline(bc, atoi(line));
} else if(*line)
{
parseline(bc, line);
} else
bc->flags |= BF_NOPROMPT;
}
示例12: nwstrtail
char *
nwstrtail (char *str, char *pattern)
{
for (;;) {
skipwhite (&str);
skipwhite (&pattern);
if (*str != *pattern || !*str)
break;
str++;
pattern++;
}
return *pattern ? NULL : str;
}
示例13: par_open
void par_open(char *filename)
{
FILE *fp;
char line[MAXLEN];
char *block_name, *cp;
Block *bp = NULL;
if (now_open) ath_error("Parameter file %s still open\n",now_filename);
if (now_filename) free(now_filename);
fp = fopen(filename,"r");
if (fp == NULL)
ath_error("Parameter file %s could not be opened, try -i PARFILE\n"
,filename);
if (debug) fprintf(stdout,"Opening \"%s\" for parameter access\n",filename);
now_open = 1;
now_filename = my_strdup(filename);
while (fgets(line,MAXLEN,fp)) { /* dumb approach: one line per command */
cp = skipwhite(line); /* skip whitespace first */
if (*cp == '\0') continue; /* blank line */
if (*cp == '#') continue; /* skip comments */
if (strncmp(cp,"<par_end>",9) == 0) break; /* end of parameter file */
if (*cp == '<') { /* a new Block */
block_name = line_block_name(cp); /* extract name from <name> */
bp = add_block(block_name); /* find or add a block with this name */
continue;
}
add_par_line(bp,cp); /* add par to this block */
}
fclose(fp);
return;
}
示例14: token
Token
token(void)
{
Token t;
char tok[100];
char *p;
if(peekt.type != Unused){
t = peekt;
peekt.type = Unused;
return t;
}
skipwhite();
p = tok;
while(*lp)
switch(ctab[*lp]){
case Letter:
case Digit:
while(*lp && !isspace(*lp) && israd50(*lp))
*p++ = *lp++;
*p = '\0';
t = symnum(tok);
return t;
case ';':
while(*lp)
lp++;
t.type = Eol;
return t;
case '^':
lp++;
if(*lp == 'D')
t.type = Radix10;
else if(*lp == 'O')
t.type = Radix8;
else if(*lp == 'B')
t.type = Radix2;
else{
err(1, "error: unknown Radix ^%c\n", *lp);
t.type = Radix8;
}
lp++;
return t;
case Unused:
err(0, "warning: unknown char %c", *lp);
/* fallthrough */
case Ignore:
lp++;
break;
default:
t.type = ctab[*lp++];
return t;
}
t.type = Eol;
return t;
}
示例15: add_par_line
static void add_par_line(Block *bp, char *line)
{
char *cp;
char *name, *equal=NULL, *value=NULL, *hash=NULL, *comment=NULL, *nul;
if(bp == NULL)
ath_error("[add_par_line]: (no block name) while parsing line \n%s\n",line);
name = skipwhite(line); /* name */
for(cp = name; *cp != '\0'; cp++){/* Find the first '=' and '#' */
if(*cp == '='){
if(equal == NULL){
equal = cp; /* store the equals sign location */
value = skipwhite(cp + 1); /* value */
}
}
if(*cp == '#'){
hash = cp; /* store the hash sign location */
comment = skipwhite(cp + 1); /* comment */
break;
}
}
while(*cp != '\0') cp++; /* Find the NUL terminator */
nul = cp;
if(equal == NULL)
ath_error("No '=' found in line \"%s\"\n",line);
str_term(equal); /* Terminate the name string */
if(hash == NULL){
str_term(nul); /* Terminate the value string */
}
else{
str_term(hash); /* Terminate the value string */
if(*comment == '\0')
comment = NULL; /* Comment field is empty */
else
str_term(nul); /* Terminate the comment string */
}
add_par(bp,name,value,comment);
}