Also patched leak that was happening in formatting.
SRCDIR = .
# SOURCES = $(addprefix $(SRCDIR)/, ft_putchar.c ft_putstr.c ft_strcmp.c ft_strlen.c ft_swap.c)
SOURCES = $(shell find $(SRCDIR) -maxdepth 1 -name "*.c")
-OBJECTS = $(SOURCES:.c=.o) libft.a
+OBJECTS = $(SOURCES:.c=.o)
NAME = libftprintf.a
all : $(NAME)
-$(NAME) : $(OBJECTS)
+$(NAME) : $(OBJECTS) libft.a
+ mv libft.a $(NAME)
$(AR) rcs $(NAME) $(OBJECTS)
libft.a :
/* By: ljiriste <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/09/05 11:30:56 by ljiriste #+# #+# */
-/* Updated: 2023/09/11 12:41:51 by ljiriste ### ########.fr */
+/* Updated: 2023/09/15 15:32:41 by ljiriste ### ########.fr */
/* */
/* ************************************************************************** */
return (1);
}
temp = base_str_constr(conv.type, args);
- to_print = formatting(temp, conv);
+ to_print = formatting(&temp, conv);
free(temp);
if (!valid_toprint(to_print))
return (-1);
/* By: ljiriste <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/09/05 11:28:21 by ljiriste #+# #+# */
-/* Updated: 2023/09/11 12:42:41 by ljiriste ### ########.fr */
+/* Updated: 2023/09/15 15:33:50 by ljiriste ### ########.fr */
/* */
/* ************************************************************************** */
return ;
}
-t_to_print formatting(char *str, t_conv conv)
+t_to_print formatting(char **str, t_conv conv)
{
t_to_print res;
- if ((conv.type == 'p' && ft_strncmp(str, "0", 2) == 0))
+ if ((conv.type == 'p' && ft_strncmp(*str, "0", 2) == 0))
{
- free (str);
- str = ft_strdup("(nil)");
+ free (*str);
+ *str = ft_strdup("(nil)");
}
- else if (conv.type == 's' && str == NULL)
- str = ft_strdup("(null)");
+ else if (conv.type == 's' && *str == NULL)
+ *str = ft_strdup("(null)");
init_printed(&res);
- create_main(str, &res, conv);
+ create_main(*str, &res, conv);
create_alt(&res, conv);
create_padding(&res, conv);
return (res);
/* By: ljiriste <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/09/05 12:00:16 by ljiriste #+# #+# */
-/* Updated: 2023/09/05 12:27:18 by ljiriste ### ########.fr */
+/* Updated: 2023/09/15 15:34:21 by ljiriste ### ########.fr */
/* */
/* ************************************************************************** */
int ft_printf(const char *format, ...);
int handle_conversion(const char **format, va_list *args);
-t_to_print formatting(char *str, t_conv conv);
+t_to_print formatting(char **str, t_conv conv);
t_conv parse_format(const char **format, va_list *args);
void create_padding(t_to_print *tp, t_conv conv);