Browse Source

fixes: vars display with longer name than value, max fct in libft

master
narnaud 3 years ago
parent
commit
9dc9b4285e
  1. 2
      lexer.c
  2. 2
      libft/Makefile
  3. 1
      libft/libft.h
  4. 10
      libft/nbr/ft_max.c
  5. 4
      minishell.c

2
lexer.c

@ -105,7 +105,7 @@ int replace_var(char **line, char *tmp, int tmp_i)
while (i < len)
tmp[tmp_i++] = value[i++];
tmp[tmp_i] = 0;
*line += i;
*line += ft_max(ft_strlen(var_name) + 1, i);
return (tmp_i);
}

2
libft/Makefile

@ -17,7 +17,7 @@ SRCS += mem/ft_bzero.c mem/ft_memset.c mem/ft_memchr.c mem/ft_memcpy.c \
SRCS += put/ft_putchar_fd.c put/ft_putnbr_fd.c put/ft_putendl_fd.c \
put/ft_putstr_fd.c
SRCS += nbr/ft_nbrlen.c nbr/ft_croissant.c nbr/ft_decroissant.c
SRCS += nbr/ft_nbrlen.c nbr/ft_croissant.c nbr/ft_decroissant.c nbr/ft_max.c
SRCS += slist/ft_size.c slist/ft_new.c slist/ft_last.c \
slist/ft_add_back.c slist/ft_add_front.c slist/ft_delone.c \

1
libft/libft.h

@ -56,6 +56,7 @@ size_t ft_ulen(unsigned int nbr);
size_t ft_longbaselen(long nbr, size_t base);
int ft_croissant(int a, int b);
int ft_decroissant(int a, int b);
int ft_max(int a, int b);
void *ft_memset(void *b, int c, size_t len);
char *ft_strchr(const char *s, int c);

10
libft/nbr/ft_max.c

@ -0,0 +1,10 @@
#include "../libft.h"
int ft_max(int a, int b)
{
if (a > b)
return (a);
else
return(b);
}

4
minishell.c

@ -40,8 +40,8 @@ int caller(t_command *cmd)
if (cmd->next)
return (caller(cmd->next));
waitpid(pid, &status, 0);
if (WIFEXITED(status) && WEXITSTATUS(status))
write(1, "\n", 1);
//if (WIFEXITED(status) && WEXITSTATUS(status))
// write(1, "\n", 1);
if (WIFSIGNALED(status))
printf("QUIT: %d\n", WTERMSIG(status));
if (cmd->fd[0])

Loading…
Cancel
Save