diff options
| author | Charles <sircharlesaze@gmail.com> | 2019-10-15 13:02:53 +0200 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2019-10-15 13:02:53 +0200 |
| commit | fa4bf89263e897695dbf48061369a23d695fef8b (patch) | |
| tree | 0c1bd50114f49adac07bd2fabda5d7a5ea74e88e /extract.c | |
| parent | 60733a2298c7a93fe681f78af9b69e1639a791b5 (diff) | |
| download | ft_printf-fa4bf89263e897695dbf48061369a23d695fef8b.tar.gz ft_printf-fa4bf89263e897695dbf48061369a23d695fef8b.tar.bz2 ft_printf-fa4bf89263e897695dbf48061369a23d695fef8b.zip | |
Parsing rewrite
- 4 extraction functions which parse some format attributes
and remove them.
- Not handling wildcard yet
Diffstat (limited to 'extract.c')
| -rw-r--r-- | extract.c | 62 |
1 files changed, 33 insertions, 29 deletions
@@ -1,3 +1,4 @@ +#include <stdlib.h> #include "header.h" char *extract_ap_index(t_pformat *pformat, char *fmt) @@ -27,44 +28,46 @@ char *extract_standalone_flags(t_pformat *pformat, char *fmt) int i; char *fmt_dup; - i = -1; - while (IS_STANDALONE_FLAG(fmt[++i])) + i = 0; + while (IS_STANDALONE_FLAG(fmt[i])) { if (!pformat->zero_padding) pformat->zero_padding = fmt[i] == '0'; if (!pformat->left_adjusted) pformat->left_adjusted = fmt[i] == '-'; + i++; } fmt_dup = ft_strdup(&fmt[i]); free(fmt); - return (fmt_dup); + return (fmt_dup); } char *extract_min_width(t_pformat *pformat, char *fmt) { int i; int tmp; - char fmt_dup; + char *fmt_dup; i = 0; - if (*fmt == '*') - { - pformat->min_width->wildcard->exist = TRUE; - i++; - } + /* if (*fmt == '*') */ + /* { */ + /* pformat->min_width.wildcard.exist = TRUE; */ + /* i++; */ + /* } */ if (ft_isdigit(fmt[i])) { - tmp = ft_atoi(fmt[i]); + tmp = ft_atoi(&fmt[i]); while (ft_isdigit(fmt[i])) i++; - if (fmt[i] == '$') - pformat->min_width->wildcard->ap_index = tmp; - else - { - pformat->min_width->hardcoded = tmp; - pformat->min_width->wildcard->exist = FALSE; - } + /* 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; + /* } */ } fmt_dup = ft_strdup(&fmt[i]); free(fmt); @@ -74,25 +77,26 @@ char *extract_min_width(t_pformat *pformat, char *fmt) char *extract_precision(t_pformat *pformat, char *fmt) { int i; + int tmp; char *fmt_dup; 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; - tmp = ft_atoi(fmt[i]); + /* if (fmt[i] == '*') */ + /* { */ + /* pformat->precision.wildcard.exist = TRUE; */ + /* i++; */ + /* } */ + /* else if (!ft_isdigit(fmt[i])) */ + /* pformat->precision.hardcoded = 0; */ + tmp = ft_atoi(&fmt[i]); while (ft_isdigit(fmt[i])) i++; - if (pformat->precision->wildcard->exist && fmt[i] == '$') - pformat->precision->wilcard->ap_index = tmp; - else - pformat->precision->hardcoded = tmp; + /* if (pformat->precision.wildcard.exist && fmt[i] == '$') */ + /* pformat->precision.wildcard.ap_index = tmp; */ + /* else */ + pformat->precision.hardcoded = tmp; fmt_dup = ft_strdup(&fmt[i]); free(fmt); return (fmt); |
