Ejemplo n.º 1
0
/*
** Write the header of the file (minus the prog size)
** init the linked lists storing label definition and reference
** Read every line of the file fd_champ,
** split them into a word tab and send them
** to process_line
** Then launch late_operation
** if any error is encountered during these operations,
** return -1, else return 0
*/
int		my_parsefile(int fd_champ, int fd_binary)
{
  char		*line;
  char		**lexed_line;
  int		j;
  int		fileoffset;
  t_lateinfo	info;

  my_init_info(&info);
  if ((fileoffset = write_header(fd_champ, fd_binary)) == -1)
    return (-1);
  j = 1;
  while ((line = get_next_line(fd_champ)) != NULL)
    {
      if (line[0] != COMMENT_CHAR && line[0] != '.' && line[0] && line[0])
	{
	  if ((lexed_line = my_epur(all_in_tab(line))) == NULL
	      || process_line(lexed_line, fd_binary, &fileoffset, &info) == -1)
	    {
	      my_fprintf(2, "at line %i : \"%s\" ", j, line);
	      return (-1);
	    }
	}
      free(line);
      ++j;
    }
  return (late_operation(fd_binary, fileoffset, &info));
}
Ejemplo n.º 2
0
int	make(int ac, char **av)
{
  int	nb_col;
  int	nb_line;
  char	**tab;
  int	mem;
  int	mem_i;
  int	mem_j;

  nb_col = nb_colonne(av[1], 0, 0);
  nb_line = nb_ligne(av[1]);
  tab = malloc_tab(nb_col, nb_line);
  all_in_tab(tab, nb_line, nb_col, av[1]);
  one_or_zero(tab);
  replace_number(tab, nb_col);
  mem = check_bigger(tab, av, nb_col);
  mem_i = check_i(tab, mem, av, nb_col);
  mem_j = check_j(tab, mem, av, nb_col);
  replace_square(tab, mem, mem_i, mem_j);
  replace_all(tab, av, nb_col, nb_line);
  show_double_tab(tab);
}