From 3f2ef05278d42233f0a9ee9652e152824a7103e4 Mon Sep 17 00:00:00 2001 From: Charles Date: Sun, 10 Nov 2019 10:37:51 +0100 Subject: ft_printf write to buffer instead of instant write --- printer.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'printer.c') diff --git a/printer.c b/printer.c index d349276..f4f80a0 100644 --- a/printer.c +++ b/printer.c @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/10/28 23:19:24 by cacharle #+# #+# */ -/* Updated: 2019/11/05 23:40:12 by cacharle ### ########.fr */ +/* Updated: 2019/11/09 01:00:20 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -43,22 +43,24 @@ char *convert_specifier(va_list ap, t_pformat *pformat) { if (pformat->specifier == 'c') return (convert_char(ap, pformat)); - else if (pformat->specifier == 's') + if (pformat->specifier == 's') return (convert_str(ap, pformat)); - else if (pformat->specifier == 'p') + if (pformat->specifier == 'p') return (convert_ptr(ap, pformat)); - else if (pformat->specifier == 'd' || pformat->specifier == 'i') + if (pformat->specifier == 'd' || pformat->specifier == 'i') return (convert_int(ap, pformat)); - else if (pformat->specifier == 'u') + if (pformat->specifier == 'u') return (convert_uint(ap, pformat)); - else if (pformat->specifier == 'x') + if (pformat->specifier == 'x') return (convert_hex(ap, pformat)); - else if (pformat->specifier == 'X') + if (pformat->specifier == 'X') return (convert_hex(ap, pformat)); - else if (pformat->specifier == '%') + if (pformat->specifier == '%') return (convert_percent(ap, pformat)); - else if (pformat->specifier == 'n') + if (pformat->specifier == 'n') return (convert_written(ap, pformat)); + if (pformat->specifier == 'f') + return (convert_double(ap, pformat)); else return (convert_none(ap, pformat)); return (NULL); @@ -98,7 +100,7 @@ char *handle_precision(t_pformat *pformat, char *str) int len; char *tmp; - if (ft_strchr("diuxX", pformat->specifier) && pformat->precision > 0) + if (ft_strchr("diuxX", pformat->specifier) && pformat->precision >= 0) pformat->flags &= ~FLAG_ZERO; len = ft_strlen(str); if (pformat->precision == 0 && str[0] == '0') -- cgit