From 1b4df01bfa793fe91a58192a4b79917909bf1614 Mon Sep 17 00:00:00 2001 From: Charles Date: Tue, 15 Oct 2019 13:57:21 +0200 Subject: Wildcard handling Back where I was before rewrite --- extract.c | 59 +++++++++++++++++++++++++++++++---------------------------- 1 file changed, 31 insertions(+), 28 deletions(-) (limited to 'extract.c') diff --git a/extract.c b/extract.c index 27f1078..0ca4aed 100644 --- a/extract.c +++ b/extract.c @@ -50,24 +50,27 @@ char *extract_min_width(t_pformat *pformat, char *fmt) i = 0; - /* if (*fmt == '*') */ - /* { */ - /* pformat->min_width.wildcard.exist = TRUE; */ - /* i++; */ - /* } */ - if (ft_isdigit(fmt[i])) + if (*fmt == '*') { - tmp = ft_atoi(&fmt[i]); - while (ft_isdigit(fmt[i])) - i++; - /* printf("%d\n", tmp); */ - /* if (fmt[i] == '$') */ - /* pformat->min_width.wildcard.ap_index = tmp; */ - /* else */ - /* { */ - pformat->min_width.hardcoded = tmp; - pformat->min_width.wildcard.exist = FALSE; - /* } */ + pformat->min_width.wildcard.exist = TRUE; + i++; + } + else + { + if (ft_isdigit(fmt[i])) + { + tmp = ft_atoi(&fmt[i]); + while (ft_isdigit(fmt[i])) + i++; + /* printf("%d\n", tmp); */ + if (fmt[i] == '$') + pformat->min_width.wildcard.ap_index = tmp; + else + { + pformat->min_width.value = tmp; + pformat->min_width.wildcard.exist = FALSE; + } + } } fmt_dup = ft_strdup(&fmt[i]); free(fmt); @@ -83,20 +86,20 @@ char *extract_precision(t_pformat *pformat, char *fmt) if (*fmt != '.') return (fmt); i = 1; - /* if (fmt[i] == '*') */ - /* { */ - /* pformat->precision.wildcard.exist = TRUE; */ - /* i++; */ - /* } */ - /* else if (!ft_isdigit(fmt[i])) */ - /* pformat->precision.hardcoded = 0; */ + if (fmt[i] == '*') + { + pformat->precision.wildcard.exist = TRUE; + i++; + } + else if (!ft_isdigit(fmt[i])) + pformat->precision.value = 0; tmp = ft_atoi(&fmt[i]); while (ft_isdigit(fmt[i])) i++; - /* if (pformat->precision.wildcard.exist && fmt[i] == '$') */ - /* pformat->precision.wildcard.ap_index = tmp; */ - /* else */ - pformat->precision.hardcoded = tmp; + if (pformat->precision.wildcard.exist && fmt[i] == '$') + pformat->precision.wildcard.ap_index = tmp; + else + pformat->precision.value = tmp; fmt_dup = ft_strdup(&fmt[i]); free(fmt); return (fmt); -- cgit