示例#1
0
static char *
extract_identifier (char **expp, int is_parameter)
{
  char *result;
  char *p = *expp;
  unsigned int len;

  if (is_parameter && startswith (p, "..."))
    {
      /* Ok.  */
    }
  else
    {
      if (! *p || ! macro_is_identifier_nondigit (*p))
	return NULL;
      for (++p;
	   *p && (macro_is_identifier_nondigit (*p) || macro_is_digit (*p));
	   ++p)
	;
    }

  if (is_parameter && startswith (p, "..."))      
    p += 3;

  len = p - *expp;
  result = (char *) xmalloc (len + 1);
  memcpy (result, *expp, len);
  result[len] = '\0';
  *expp += len;
  return result;
}
示例#2
0
文件: macroexp.c 项目: 5kg/gdb
static int
get_pp_number (struct macro_buffer *tok, char *p, char *end)
{
  if (p < end
      && (macro_is_digit (*p)
          || (*p == '.'
	      && p + 2 <= end
	      && macro_is_digit (p[1]))))
    {
      char *tok_start = p;

      while (p < end)
        {
	  if (p + 2 <= end
	      && strchr ("eEpP", *p)
	      && (p[1] == '+' || p[1] == '-'))
            p += 2;
          else if (macro_is_digit (*p)
		   || macro_is_identifier_nondigit (*p)
		   || *p == '.')
            p++;
          else
            break;
        }

      set_token (tok, tok_start, p);
      return 1;
    }
  else
    return 0;
}
示例#3
0
文件: macroexp.c 项目: 5kg/gdb
static int
get_identifier (struct macro_buffer *tok, char *p, char *end)
{
  if (p < end
      && macro_is_identifier_nondigit (*p))
    {
      char *tok_start = p;

      while (p < end
             && (macro_is_identifier_nondigit (*p)
                 || macro_is_digit (*p)))
        p++;

      set_token (tok, tok_start, p);
      tok->is_identifier = 1;
      return 1;
    }
  else
    return 0;
}