Example #1
0
void	ft_print_map(t_tetr *ptr, int size)
{
	int		i;
	int		j;
	char	**tab;

	tab = ft_tabnew(size);
	ft_dot_filler(tab, size);
	while (ptr != NULL)
	{
		i = 0;
		while (i < 4)
		{
			j = 0;
			while (j < 4)
			{
				if (ptr->tetr[i][j] == '#')
				{
					tab[ptr->x + i][ptr->y + j] = ptr->nbr;
				}
				j++;
			}
			i++;
		}
		ptr = ptr->next;
	}
	ft_free_tab(tab, size);
}
Example #2
0
static void	sh_env(char **argv, char **env)
{
	char	**tab;

	if (argv[1] == NULL)
		print_env(env);
	else if (argv[1] != NULL && ft_strcmp(argv[1], "-i") == 0)
	{
		tab = (char**)ft_tabnew(2);
		tab[0] = NULL;
		tab[1] = NULL;
		exec_glob(argv + 2, tab);
		free_tab(tab);
	}
	else
		exec_glob(argv + 1, env);
}
Example #3
0
int				ft_env_check_opt_plus(char **cmd, t_opt *opt, int i)
{
	char		**table;
	int			k;

	while (ft_strchr(cmd[i], '='))
	{
		if ((table = ft_tabnew(ft_tablen(opt->extra) + 2)) == NULL)
			return (ft_env_error("malloc failed", 0));
		k = 0;
		while (opt->extra && opt->extra[k])
		{
			table[k] = opt->extra[k];
			k++;
		}
		table[k] = cmd[i];
		table[k + 1] = NULL;
		free(opt->extra);
		opt->extra = table;
		i++;
	}
	return (i);
}