printf minus for i conversions

This commit is contained in:
Jack Halford 2017-01-22 18:22:16 +01:00
parent a9d24f3685
commit 5b078df76d
8 changed files with 15 additions and 16 deletions

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 13:49:04 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_WS(x) (x == ' ' || x == '\t' || x == '\n')
# define FT_ABS(x) (((x) < 0) ? -(x) : (x)) # define FT_ABS(x) (((x) < 0) ? -(x) : (x))
# define FT_NEG(x) (((x) < 0) ? 1 : 0) # define FT_NEG(x) ((x) < 0)
# define FT_POS(x) (((x) > 0) ? 1 : 0) # define FT_POS(x) ((x) > 0)
# define FT_MIN(a, b) ((a) < (b) ? (a) : (b)) # define FT_MIN(a, b) ((a) < (b) ? (a) : (b))
# define FT_MAX(a, b) ((a) > (b) ? (a) : (b)) # define FT_MAX(a, b) ((a) > (b) ? (a) : (b))
# define FT_DIST(a, b) (FT_ABS((a) - (b))) # define FT_DIST(a, b) (FT_ABS((a) - (b)))

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 13:31:48 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 *ft_signed_conversion(t_fmt *fmt, va_list ap)
{ {
char base10[11]; char base10[] = "0123456789";
long long arg; long long arg;
arg = va_arg(ap, int); arg = va_arg(ap, int);
ft_strcpy(base10, "0123456789");
(void)fmt; (void)fmt;
return (ft_lltoa_base(arg, base10, fmt->flags)); return (ft_lltoa_base(arg, base10, fmt->flags));
} }

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 13:33:27 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 */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 13:52:51 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 */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 13:10:42 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) static char *ft_flags(char *str, int *i, char *flags, int neg)
{ {
if (neg) if (neg)
str[*i++] = '-'; str[(*i)++] = '-';
else if (ft_strchr(flags, '+')) else if (ft_strchr(flags, '+'))
str[*i++] = '+'; str[(*i)++] = '+';
else if (ft_strchr(flags, ' ')) else if (ft_strchr(flags, ' '))
str[*i++] = ' '; str[(*i)++] = ' ';
return (str); return (str);
} }
@ -46,7 +46,7 @@ char *ft_lltoa_base(long long nbr, char *base, char *flags)
nbr = nbr / base_size; nbr = nbr / base_size;
} }
str = ft_flags(str, &i, flags, neg); str = ft_flags(str, &i, flags, neg);
str[i] = '\0'; str[i] = 0;
ft_strrev(str); ft_strrev(str);
return (str); return (str);
} }

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/13 12:16:31 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 */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:58:18 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 */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:58:22 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 */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */