From 68bc772a26dbb79c39a8bd06758418941da07037 Mon Sep 17 00:00:00 2001 From: Jack Halford Date: Sun, 22 Jan 2017 18:22:16 +0100 Subject: [PATCH] printf minus for i conversions --- libft/includes/libft.h | 6 +++--- libft/src/ft_printf/ft_conversion.c | 5 ++--- libft/src/ft_printf/ft_printf.c | 2 +- libft/src/math/ft_itoa_base.c | 2 +- libft/src/math/ft_lltoa_base.c | 10 +++++----- libft/src/str/ft_strappend.c | 2 +- libft/src/str/ft_strjoin.c | 2 +- libft/src/str/ft_strlen.c | 2 +- 8 files changed, 15 insertions(+), 16 deletions(-) diff --git a/libft/includes/libft.h b/libft/includes/libft.h index 64dfaa0a..def12d1d 100644 --- a/libft/includes/libft.h +++ b/libft/includes/libft.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/07 13:49:04 by jhalford #+# #+# */ -/* Updated: 2017/01/12 13:55:40 by jhalford ### ########.fr */ +/* Updated: 2017/01/22 16:31:25 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -40,8 +40,8 @@ # define FT_WS(x) (x == ' ' || x == '\t' || x == '\n') # define FT_ABS(x) (((x) < 0) ? -(x) : (x)) -# define FT_NEG(x) (((x) < 0) ? 1 : 0) -# define FT_POS(x) (((x) > 0) ? 1 : 0) +# define FT_NEG(x) ((x) < 0) +# define FT_POS(x) ((x) > 0) # define FT_MIN(a, b) ((a) < (b) ? (a) : (b)) # define FT_MAX(a, b) ((a) > (b) ? (a) : (b)) # define FT_DIST(a, b) (FT_ABS((a) - (b))) diff --git a/libft/src/ft_printf/ft_conversion.c b/libft/src/ft_printf/ft_conversion.c index a0bef932..0727b438 100644 --- a/libft/src/ft_printf/ft_conversion.c +++ b/libft/src/ft_printf/ft_conversion.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/07 13:31:48 by jhalford #+# #+# */ -/* Updated: 2016/12/09 18:00:52 by jhalford ### ########.fr */ +/* Updated: 2017/01/22 16:28:55 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,11 +14,10 @@ char *ft_signed_conversion(t_fmt *fmt, va_list ap) { - char base10[11]; + char base10[] = "0123456789"; long long arg; arg = va_arg(ap, int); - ft_strcpy(base10, "0123456789"); (void)fmt; return (ft_lltoa_base(arg, base10, fmt->flags)); } diff --git a/libft/src/ft_printf/ft_printf.c b/libft/src/ft_printf/ft_printf.c index 07e65e14..5713e276 100644 --- a/libft/src/ft_printf/ft_printf.c +++ b/libft/src/ft_printf/ft_printf.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/07 13:33:27 by jhalford #+# #+# */ -/* Updated: 2016/12/15 15:26:48 by jhalford ### ########.fr */ +/* Updated: 2017/01/22 16:38:58 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/libft/src/math/ft_itoa_base.c b/libft/src/math/ft_itoa_base.c index 05a4158d..edc60b46 100644 --- a/libft/src/math/ft_itoa_base.c +++ b/libft/src/math/ft_itoa_base.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/07 13:52:51 by jhalford #+# #+# */ -/* Updated: 2016/11/07 14:45:15 by jhalford ### ########.fr */ +/* Updated: 2017/01/22 16:38:53 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/libft/src/math/ft_lltoa_base.c b/libft/src/math/ft_lltoa_base.c index 0b2c6131..905dadef 100644 --- a/libft/src/math/ft_lltoa_base.c +++ b/libft/src/math/ft_lltoa_base.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/07 13:10:42 by jhalford #+# #+# */ -/* Updated: 2016/11/07 16:30:42 by jhalford ### ########.fr */ +/* Updated: 2017/01/22 16:39:08 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,11 +15,11 @@ static char *ft_flags(char *str, int *i, char *flags, int neg) { if (neg) - str[*i++] = '-'; + str[(*i)++] = '-'; else if (ft_strchr(flags, '+')) - str[*i++] = '+'; + str[(*i)++] = '+'; else if (ft_strchr(flags, ' ')) - str[*i++] = ' '; + str[(*i)++] = ' '; return (str); } @@ -46,7 +46,7 @@ char *ft_lltoa_base(long long nbr, char *base, char *flags) nbr = nbr / base_size; } str = ft_flags(str, &i, flags, neg); - str[i] = '\0'; + str[i] = 0; ft_strrev(str); return (str); } diff --git a/libft/src/str/ft_strappend.c b/libft/src/str/ft_strappend.c index 493f2ec0..222c95c9 100644 --- a/libft/src/str/ft_strappend.c +++ b/libft/src/str/ft_strappend.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/13 12:16:31 by jhalford #+# #+# */ -/* Updated: 2017/01/12 14:07:01 by jhalford ### ########.fr */ +/* Updated: 2017/01/22 17:46:19 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/libft/src/str/ft_strjoin.c b/libft/src/str/ft_strjoin.c index 17e18d35..3c67e018 100644 --- a/libft/src/str/ft_strjoin.c +++ b/libft/src/str/ft_strjoin.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/03 14:58:18 by jhalford #+# #+# */ -/* Updated: 2016/12/09 19:11:15 by jhalford ### ########.fr */ +/* Updated: 2017/01/22 17:46:33 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/libft/src/str/ft_strlen.c b/libft/src/str/ft_strlen.c index 04ee783c..a4661200 100644 --- a/libft/src/str/ft_strlen.c +++ b/libft/src/str/ft_strlen.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/03 14:58:22 by jhalford #+# #+# */ -/* Updated: 2016/11/28 15:35:58 by jhalford ### ########.fr */ +/* Updated: 2017/01/22 17:46:37 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */