Пример #1
0
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
0
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
0
/*
 * 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
0
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
0
char           *skipdelim(
    char *cp)
{
    cp = skipwhite(cp);
    if (*cp == ',')
        cp = skipwhite(cp + 1);
    return cp;
}
Пример #6
0
/*
 * 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;
}
Пример #7
0
/*
 * ":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);
      }
    }
  }
}
Пример #8
0
/// 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;
    }
  }
}
Пример #9
0
/// 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;
    }
  }
}
Пример #10
0
/** 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;
}
Пример #11
0
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;
            }
        }
}
Пример #12
0
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;
}
Пример #13
0
char *
nwstrtail (char *str, char *pattern)
{
        for (;;) {
                skipwhite (&str);
                skipwhite (&pattern);

                if (*str != *pattern || !*str)
                        break;

                str++;
                pattern++;
        }

        return *pattern ? NULL : str;
}
Пример #14
0
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;
}
Пример #15
0
Файл: as6.c Проект: aap/pdp6
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;
}
Пример #16
0
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);
}
Пример #17
0
/*
   Positions file at line after section tag. Returns 0 if section found;
   -1 if not.
   */
static int findSection(void *fp, const char *section)
{
  static char line[INIFILE_MAX_LINELEN+2]; /* 1 for newline, 1 for NULL */
  static char bracketsection[INIFILE_MAX_LINELEN+2];
  char *nonwhite;

  /* check valid file */
  if (NULL == fp)
  {
    return -1;
  }

  /* start from beginning */

  rewind((FILE *)fp);

  /* if section is NULL, we're already positioned */
  if (NULL == section)
  {
    return 0;
  }

  /* wrap section in brackets, so it matches */

  sprintf(bracketsection,"[%s]",section);

  /* find [section], and position fp just after it */

  while (!feof((FILE *) fp))
  {

    if (NULL == fgets(line, INIFILE_MAX_LINELEN+1, (FILE *) fp))
    {
      /* got to end of file without finding it */
      return -1;
    }

    /* got a line-- check it for real data, not comment or blank line */
    if (NULL == (nonwhite = skipwhite(line)))
    {
      /* blank line-- skip it */
      continue;
    }

    /* not a blank line-- compare with section tag */
    if (0 != strncmp(bracketsection, nonwhite, strlen(bracketsection)))
    {
      /* not on this line */
      continue;
    }

    /* else it matches-- fp is now set up for search on tag */
    return 0;
  }

  /* didn't find it */
  return -1;
}
Пример #18
0
int read_viminfo_filemark(vir_T *virp, int force)
{
  char_u      *str;
  xfmark_T    *fm;
  int i;

  /* We only get here if line[0] == '\'' or '-'.
   * Illegal mark names are ignored (for future expansion). */
  str = virp->vir_line + 1;
  if (
    *str <= 127 &&
    ((*virp->vir_line == '\'' && (VIM_ISDIGIT(*str) || isupper(*str)))
     || (*virp->vir_line == '-' && *str == '\''))) {
    if (*str == '\'') {
      /* If the jumplist isn't full insert fmark as oldest entry */
      if (curwin->w_jumplistlen == JUMPLISTSIZE)
        fm = NULL;
      else {
        for (i = curwin->w_jumplistlen; i > 0; --i)
          curwin->w_jumplist[i] = curwin->w_jumplist[i - 1];
        ++curwin->w_jumplistidx;
        ++curwin->w_jumplistlen;
        fm = &curwin->w_jumplist[0];
        fm->fmark.mark.lnum = 0;
        fm->fname = NULL;
      }
    } else if (VIM_ISDIGIT(*str))
      fm = &namedfm[*str - '0' + NMARKS];
    else
      fm = &namedfm[*str - 'A'];
    if (fm != NULL && (fm->fmark.mark.lnum == 0 || force)) {
      str = skipwhite(str + 1);
      fm->fmark.mark.lnum = getdigits(&str);
      str = skipwhite(str);
      fm->fmark.mark.col = getdigits(&str);
      fm->fmark.mark.coladd = 0;
      fm->fmark.fnum = 0;
      str = skipwhite(str);
      vim_free(fm->fname);
      fm->fname = viminfo_readstring(virp, (int)(str - virp->vir_line),
          FALSE);
    }
  }
  return vim_fgets(virp->vir_line, LSIZE, virp->vir_fd);
}
Пример #19
0
/*
 * ":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;
  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))) {
    GA_DEEP_CLEAR(&menutrans_ga, menutrans_T, FREE_MENUTRANS);

    /* 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 {
      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);
        menutrans_T* tp = GA_APPEND_VIA_PTR(menutrans_T, &menutrans_ga);
        tp->from = from;
        tp->from_noamp = from_noamp;
        tp->to = to;
      } else {
        free(from);
        free(to);
      }
    }
  }
}
Пример #20
0
mixed *identify_next_number(string num,int base)
{
  switch(strlen(num=skipwhite(num)))
  {
  default:
    switch(num[0..4])
    {
    case "three": return ({base+3,num[5..1000]});
    case "seven": return ({base+7,num[5..1000]});
    case "eight": return ({base+8,num[5..1000]});
Пример #21
0
string_parse &string_parse::readword(std::string &text)
{
    text.clear();
    skipwhite();
    while (!std::isspace(static_cast<int>(*pos)) && !eos())
    {
        text += *pos++;
    }
    return *this;
}
Пример #22
0
static int exec_script(char * const argv[], char * fname)
{
    FILE * fp;
    char * newargs[NARG_MAX];
    char line[MAX_INPUT];
    size_t skip;

    memset(line, '\0', sizeof(line));
    fp = fopen(fname, "r");
    if (!fgets(line, sizeof(line), fp))
        return -ENOEXEC;
    fclose(fp);

    if (line[0] == '#' && line[1] == '!' && line[2] != '\0') {
        /* Parse shebang line */
        char * arg0 = skipwhite(line + 2);
        char * arg1;

        arg1 = arg0;
        while (arg1 < line + sizeof(line)) {
            if (*arg1 == '\0' || isspace(*arg1)) {
                *arg1 = '\0';
                break;
            }
            arg1++;
        }
        arg1++;
        if (arg1 < (line + sizeof(line)) && *arg1 != '\0') {
            newargs[0] = arg0;
            newargs[1] = arg1;
            newargs[2] = fname;
            skip = 3;
        } else {
            newargs[0] = arg0;
            newargs[1] = fname;
            skip = 2;
        }
    } else { /* Try fallback to sh */
        newargs[0] = "sh";
        newargs[1] = fname;
        skip = 1;
    }

    /* Handle args */
    for (size_t i = 1; (newargs[i + skip] = argv[i]); i++) {
        if (i >= NARG_MAX - 2) {
            errno = E2BIG;
            return -1;
        }
    }

    execve(_PATH_BSHELL, newargs, environ);

    return 0;
}
Пример #23
0
/*
 * ":sign define {name} ..." command
 */
    static void
sign_define_cmd(char_u *sign_name, char_u *cmdline)
{
    char_u	*arg;
    char_u	*p = cmdline;
    char_u	*icon = NULL;
    char_u	*text = NULL;
    char_u	*linehl = NULL;
    char_u	*texthl = NULL;
    int failed = FALSE;

    // set values for a defined sign.
    for (;;)
    {
	arg = skipwhite(p);
	if (*arg == NUL)
	    break;
	p = skiptowhite_esc(arg);
	if (STRNCMP(arg, "icon=", 5) == 0)
	{
	    arg += 5;
	    icon = vim_strnsave(arg, (int)(p - arg));
	}
	else if (STRNCMP(arg, "text=", 5) == 0)
	{
	    arg += 5;
	    text = vim_strnsave(arg, (int)(p - arg));
	}
	else if (STRNCMP(arg, "linehl=", 7) == 0)
	{
	    arg += 7;
	    linehl = vim_strnsave(arg, (int)(p - arg));
	}
	else if (STRNCMP(arg, "texthl=", 7) == 0)
	{
	    arg += 7;
	    texthl = vim_strnsave(arg, (int)(p - arg));
	}
	else
	{
	    semsg(_(e_invarg2), arg);
	    failed = TRUE;
	    break;
	}
    }

    if (!failed)
	sign_define_by_name(sign_name, icon, linehl, text, texthl);

    vim_free(icon);
    vim_free(text);
    vim_free(linehl);
    vim_free(texthl);
}
Пример #24
0
static void ParseCharMetrics(FILE *file,struct temp_font *tf, char *line, char *pt) {
    int cnt,i;

    cnt = strtol(skipwhite(pt),NULL,10);
    for ( i=0; i<cnt && fgets(line,400,file)!=NULL; ++i ) {
	int len = strlen(line);
	if ( line[len-1]=='\n' ) line[--len]='\0';
	if ( line[len-1]=='\r' ) line[--len]='\0';
	parse_CharMetric_line(tf,line);
    }
}
Пример #25
0
void
skipword (char **s)
{
        if (!*s)
                return;

        skipwhite (s);

        while (!isspace(**s))
                (*s)++;
}
Пример #26
0
static void split(char *cmd) {
	cmd = skipwhite(cmd);
	char* next = strchr(cmd, ' ');
	int i = 0;
	
	while (next != NULL) {
		next[0] = '\0';
		args[i] = cmd;
		++i;
		cmd = skipwhite(next + 1);
		next = strchr(cmd, ' ');
	}
	
	if (cmd[0] != '\0') {
		args[i] = cmd;
		next = strchr(cmd, '\n');
		next[0] = '\0';
		++i;
	}
	
	args[i] = NULL;
}
static fz_error parsehexstring(fz_obj **obj, char **sp)
{
	fz_error error;
	char buf[512];
	char *s = *sp;
	char *p = buf;
	int a, b;

	s ++;		/* skip '<' */

	while (*s && p < buf + sizeof buf)
	{
		skipwhite(&s);
		if (*s == '>') {
			s ++;
			break;
		}
		a = *s++;

		if (*s == '\0')
			break;

		skipwhite(&s);
		if (*s == '>') {
			s ++;
			break;
		}
		b = *s++;

		*p++ = fromhex(a) * 16 + fromhex(b);
	}

	*sp = s;
	error = fz_newstring(obj, buf, p - buf);
	if (error)
		return fz_rethrow(error, "cannot create string");
	return fz_okay;
}
uint8_t LanguageIdentifier::guessCountryFromUserAgent(char *ua) {
	if(!ua) return(0);
	uint8_t country = 0;
	while(*ua) {
		if(!(ua = skipwhite(ua)))
			return(0);
		if(s_isLangTag(ua) &&
				(country = s_getCountryFromSpec(ua)) != 0)
				return(country);
		if(!(ua = skipword(ua)))
			return(0);
	}
	return(0);
}
uint8_t LanguageIdentifier::guessLanguageFromUserAgent(char *str) {
	// Mozilla/5.0 (X11; U; Linux i686;
	// en-US; rv:1.8.1.4) Gecko/20070531 Firefox/2.0.0.4
	uint8_t lang = langUnknown;
	while(*str) {
		if(!(str = skipwhite(str)))
			return(langUnknown);
		if((lang = getLanguageFromUserAgent(str)) != langUnknown)
				return(lang);
		if(!(str = skipword(str)))
			return(langUnknown);
	}
	return(langUnknown);
}
Пример #30
0
/** find second argument, modifies string */
static int
find_arg2(SSL* ssl, char* arg, char** arg2)
{
	char* as = strchr(arg, ' ');
	char* at = strchr(arg, '\t');
	if(as && at) {
		if(at < as)
			as = at;
		as[0]=0;
		*arg2 = skipwhite(as+1);
	} else if(as) {
		as[0]=0;
		*arg2 = skipwhite(as+1);
	} else if(at) {
		at[0]=0;
		*arg2 = skipwhite(at+1);
	} else {
		ssl_printf(ssl, "error could not find next argument "
			"after %s\n", arg);
		return 0;
	}
	return 1;
}