From d963161275bcb3af4097872ba033da3ff9255606 Mon Sep 17 00:00:00 2001 From: Charles Date: Wed, 30 Oct 2019 03:57:47 +0100 Subject: Individual convert functions, more flags - Each conversion type is handle by individual functions in convert_* files - handle the ' ', '#', '+' and length modifier flags. --- extract.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'extract.c') diff --git a/extract.c b/extract.c index 11bff1d..75d4929 100644 --- a/extract.c +++ b/extract.c @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/10/29 00:10:36 by cacharle #+# #+# */ -/* Updated: 2019/10/29 18:17:38 by cacharle ### ########.fr */ +/* Updated: 2019/10/30 03:40:28 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -25,8 +25,14 @@ char *extract_standalone_flags(t_pformat *pformat, char *fmt) pformat->flags |= FLAG_LEFT_ADJUSTED; if (*fmt == '+') pformat->flags |= FLAG_SIGNED; + if (*fmt == ' ') + pformat->flags |= FLAG_SPACE; + if (*fmt == '#') + pformat->flags |= FLAG_ALTERNATE; fmt++; } + if (pformat->flags & FLAG_SIGNED) + pformat->flags &= ~FLAG_SPACE; return (fmt); } @@ -65,3 +71,27 @@ char *extract_precision(t_pformat *pformat, char *fmt) fmt++; return (fmt); } + +char *extract_length_modifier(t_pformat *pformat, char *fmt) +{ + if (fmt[0] && fmt[0] == 'l') + { + if (fmt[1] && fmt[1] == 'l') + { + pformat->flags |= FLAG_LONG_LONG; + return (fmt + 2); + } + pformat->flags |= FLAG_LONG; + return (fmt + 1); + } + if (fmt[0] && fmt[0] == 'h') + { + if (fmt[1] && fmt[1] == 'h') + { + pformat->flags |= FLAG_SHORT_SHORT; + return (fmt + 2); + } + pformat->flags |= FLAG_SHORT; + return (fmt + 1); + } +} -- cgit