Ejemplo n.º 1
0
static void	ft_switch(char **s, va_list args, size_t *size, char **p)
{
    t_format	*opt;
    int			x;
    int			d;

    x = 0;
    d = 0;
    if (**s == '%')
    {
        ++(*s);
        if (**s)
            if ((opt = get_format(s, args, 0)))
            {
                ft_add(p, ft_build(args, opt), size, 0);
                ft_memdel((void **)&opt);
            }
    }
    else if ((**s == '{' && *(*s + 1) == 'C') || **s == '}')
        ft_add(p, set_color(s), size, 2);
    else
    {
        ft_add(p, *s, size, 1);
        ++(*s);
    }
}
Ejemplo n.º 2
0
int main (int argc, char **argv)
{
	if (argc == 3)
	{
		char *arg1 = argv[1];
		char *arg2 = argv[2];
		char *result;
		bool neg1;
		bool neg2;

		ft_putstr(arg1);
		ft_putstr(arg2);
		if (arg1[0]=='-')
			neg1=true;
		else
			neg1=false;
		if (arg2[0]=='-')
			neg2=true;
		else
			neg2=false;
		if (!neg1 && !neg2)
		{
			int size1 = ft_strlen(arg1);
			int size2 = ft_strlen(arg2);
			int retenue = 0;
			int max = 0;
			if (size2 > size1)
			{
				// result = malloc(size2*sizeof(char)+1);
				// max = size2;
				// if (result == NULL)
				// 	exit(-1);
				// int loop = max;
				// while (loop != 0)
				// {
				// 	result[loop-1] = ft_itoa(ft_atoi(arg2[size2-1])+ft_atoi(arg1[size1-1]));
				// 	loop--;
				// 	size2--;
				// 	if (size1-2 < 0)
				// 		arg1[0]='0';
				// 	else
				// 		size1--;
				// }
				result = ft_add(arg1, arg2, size2);
			}
			else
			{
				result = ft_add(arg2, arg1, size1);
			}
		}
		else
		{

		}
		ft_putstr(result);
	}
	return (0);
}
Ejemplo n.º 3
0
int main (int argc, char **argv)
{
	if (argc == 3)
	{
		char *arg1 = argv[1];
		char *arg2 = argv[2];
		char *result;
		bool neg1;
		bool neg2;
    int neg = 2;

		ft_putstr(arg1);
		ft_putstr(arg2);
		int size1 = ft_strlen(arg1);
		int size2 = ft_strlen(arg2);
		if (arg1[0]=='-')
			neg1=true;
		else
			neg1=false;
		if (arg2[0]=='-')
			neg2=true;
		else
			neg2=false;
		if ((!neg1 && !neg2) || (neg1 && neg2))
		{
			int retenue = 0;
			int max = 0;
      if (neg1)
        neg=1;
      else
        neg=0;
			if (size2 > size1)
			{
				result = ft_add(arg1, arg2, size2, neg);
			}
			else
			{
				result = ft_add(arg2, arg1, size1, neg);
			}
		}
		else
		{

		}
    if (neg == 1)
      ft_putchar('-');
		ft_putstr(result);
	}
	return (0);
}
Ejemplo n.º 4
0
int			ft_up(t_game *g)
{
	int		i[4];

	i[2] = g->size * g->size;
	i[0] = 0;
	i[3] = 0;
	while (i[0] < i[2])
	{
		if (!ft_is_empty(g->map[i[0]]))
		{
			i[1] = i[0] + g->size;
			while (i[1] < i[2])
			{
				if (!ft_is_empty(g->map[i[1]]))
				{
					if (g->map[i[0]] == g->map[i[1]])
						ft_add(g, i);
					break ;
				}
				i[1] += g->size;
			}
		}
		i[0]++;
	}
	return (ft_move_up(g->map, g->size) + i[3]);
}
Ejemplo n.º 5
0
t_sq		*ft_back_co(t_tet *t, t_sq *sq, t_sq *fin, int nr)
{
	t_sq	*f;
	int		i;

	f = NULL;
	f = (t_sq*)malloc(sizeof(t_sq));
	if (f)
		ft_clone(f, sq, 13);
	i = 0;
	while (t[i].x != -1)
	{
		if (ft_is_taken(f, t[i]) == 0)
		{
			ft_add(f, t[i]);
			if (ft_back_co(t, f, fin, nr) == NULL)
				return (NULL);
			ft_clone(f, sq, 13);
		}
		i++;
	}
	if (nr == f->tot)
		fin = ft_min(fin, f);
	if (ft_end(fin->d, nr))
		return (NULL);
	return (f);
}
Ejemplo n.º 6
0
static void		list(t_lem *p, char *str, int flag)
{
    t_list	*list;

    list = ft_lstnew(str, flag);
    if (p->file == NULL)
        p->file = list;
    else
        ft_add(p->file, list);
}
Ejemplo n.º 7
0
static void	ft_scroll3(int	k, t_list *current)
{
	int		j;

	j = 0;
	while (current->content[j] && current->content[j] == g_e.buff[k + j])
		j++;
	while (current->content[j])
	{
		ft_add(g_e.buff, g_e.i++, current->content[j], &g_e.size);
		ft_putchar(current->content[j++]);
	}
}
Ejemplo n.º 8
0
void			exec_1(t_process **proc)
{
	if (PROC->op == LIVE)
		ft_live(proc);
	else if (PROC->op == LD)
		ft_ld(proc);
	else if (PROC->op == ST)
		ft_st(proc);
	else if (PROC->op == ADD)
		ft_add(proc);
	else if (PROC->op == SUB)
		ft_sub(proc);
	else if (PROC->op == AND)
		ft_and(proc);
	else if (PROC->op == OR)
		ft_or(proc);
	else if (PROC->op == XOR)
		ft_xor(proc);
}