示例#1
0
static	BOOL	check(t_get *link, t_header *head, char *line)
{
  line = link->line;
  if (NMATCH(NAME_CMD_STRING, line + hempty(line)))
    head->name =  get(NAME_CMD_STRING, line, 0, link->no);
  else if (NMATCH(COMMENT_CMD_STRING, line + hempty(line)))
    head->comment = get(COMMENT_CMD_STRING, line, 1, link->no);
  else
    {
      if (nempty(line, my_strilen(line, COMMENT_CHAR)))
	return (ERROR);
      else if (nempty(line, my_strilen(line, SCOMMENT_CHAR)))
	return (ERROR);
      if (IN(line, COMMENT_CHAR))
	{
	  link->line = my_strndup(line, my_strilen(line, COMMENT_CHAR));
	  free(line);
	}
      line = link->line;
      if (IN(line, SCOMMENT_CHAR))
	{
	  link->line = my_strndup(line, my_strilen(line, SCOMMENT_CHAR));
	  free(line);
	}
      return (CLEAN);
    }
  return (ERROR);
}
示例#2
0
文件: scan.c 项目: Colliotv/42.sh
void	scan_export(t_alias **alias)
{
  int		no;
  BOOL		c;
  char		*s;
  FD		file;

  c = TRUE;
  no = 0;
  if ((file = open_it()) == -1)
    return ;
  while ((s = get_next_line(file)) != NULL && c)
    {
      if (NMATCH("export", s))
	c = export_env(s + my_strlen("export")
		       + hempty(s + my_strlen("export")), no);
      else if (NMATCH("alias", s))
	c = export_alias(s + my_strlen("export")
			 + hempty(s + my_strlen("export")),
			 alias, no);
      else if (!nempty(s, my_strilen(s, '#')))
	return ;
      no++;
    }
}
示例#3
0
static char	*get(char *type, char *line, int itype, int n)
{
  int		l;

  l = hempty(line) + my_strlen(type) +
    hempty(line + hempty(line) + my_strlen(type));
  if (line[l] != '"')
    lerror(INVALID(itype), n);
  if (!IN(line + l + 1, '"'))
    lerror(INVALID(itype), n);
  return (my_strndup(line + l + 1, my_strilen(line + l + 1, '"')));
}
示例#4
0
文件: subdiv.c 项目: Colliotv/42.sh
t_get	*subdivide(char *s, t_get *prev, char **bad_sintax)
{
  size_t l;
  t_get *link;

  if (empty(s))
    return (prev);
  if (s[0] == '\\' && prev)
    if ((!S_IN(prev->word, "\"'|;<>()`")))
      return (echappment(s, prev, bad_sintax, 0));
  if ((link = xmalloc(sizeof(*prev))) == NULL)
    return (NULL);
  link->word = (void*)(link->next = NULL);
  link->prev = prev;
  if (prev)
    prev->next = link;
  s += hempty(s);
  if (s[(link->inter = 0)] == '\\')
    return (echappment(s, link, bad_sintax, 1));
  l = subdiv(s, bad_sintax);
  if (*bad_sintax)
    return (nullify_link(link, 0, 1));
  if ((link->word = my_strndup(s, l)) == NULL)
    return (nullify_link(link, 0, 1));
  if (subdivide(s + my_strlen(link->word), link, bad_sintax) == NULL)
    return (nullify_link(link, 1, 1));
  return (link);
}
示例#5
0
static BOOL check_fd(char *s, FD xml, FLAG i, char **r)
{
  while (s && NMATCH(OPEN_COMMENT, s += hempty(s)))
    s = move_to_end_comment(s, xml);
  *r = s;
  if (i == INIT && MATCH("<scene>", s + hempty(s)))
    return (TRUE);
  else if (i == INIT)
    return (FALSE);
  if ((s = (*r = get_next_line(xml))) == NULL)
    (void)lerror("no </scene> close");
  if (i == END && MATCH("</scene>", s + hempty(s)))
    return (FALSE);
  else if (i == END)
    return (TRUE);
  return (FALSE);
}
示例#6
0
static void	scan_line(CLASS_DISPLAY *d, FD xml, char *s)
{
  size_t	i;

  i = 0;
  while (((d->scan)[i]).call)
    {
      if (NMATCH(((d->scan)[i]).div, s + hempty(s)))
	{
	  (((d->scan)[i]).call)(d, xml, s);
	  return ;
	}
      i++;
    }
  fprintf(stderr, "error :%s not recognized", s);
  exit(-1);
}