aboutsummaryrefslogtreecommitdiff
path: root/parse.c
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2019-10-14 16:26:31 +0200
committerCharles <sircharlesaze@gmail.com>2019-10-14 16:26:31 +0200
commit60733a2298c7a93fe681f78af9b69e1639a791b5 (patch)
treeb1097d7596a7e369ecd12059533da4173967411e /parse.c
parent374a9c43da4c2ee0ac19798abc840cd57cb7cf15 (diff)
downloadft_printf-60733a2298c7a93fe681f78af9b69e1639a791b5.tar.gz
ft_printf-60733a2298c7a93fe681f78af9b69e1639a791b5.tar.bz2
ft_printf-60733a2298c7a93fe681f78af9b69e1639a791b5.zip
WIP: format parsing arguments extraction
Changed pformat struct, everything is broken
Diffstat (limited to 'parse.c')
-rw-r--r--parse.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/parse.c b/parse.c
index 66ff9ee..17cbb22 100644
--- a/parse.c
+++ b/parse.c
@@ -4,6 +4,10 @@
#define STRRCHR_CONVERSIONS(c) (ft_strrchr(CONVERSIONS_STR, c))
#define IS_STANDALONE_FLAG(c) (c == '0' || c == '-')
+/*
+** %(?:\d+\$)?[-]?(?:[0]|'.{1})?-?\d*(?:\.\d+)?[cdusxX]
+*/
+
t_list *parse(const char *format)
{
t_list *format_list;
@@ -38,6 +42,27 @@ char *isolate_conversion(const char *conversion_start)
return (ft_strndup(conversion_start, i + 1));
}
+
+t_pformat *parse_reduced_fmt(char *fmt)
+{
+ t_pformat *pformat;
+
+ if (conversion == NULL)
+ return (NULL);
+ if ((pformat = (t_pformat*)malloc(sizeof(t_pformat))) == NULL)
+ return (NULL);
+ pformat->ap_index = -1;
+ pformat->left_adjusted = FALSE;
+ pformat->zero_padding = FALSE;
+ pformat->min_width->wildcard->exist = FALSE;
+ pformat->precision->wildcard->exist = FALSE;
+ fmt = extrac_ap_index(pformat, fmt);
+ fmt = extrac_standalone_flags(pformat, fmt);
+ fmt = extract_min_width(pformat, fmt);
+ fmt = extract_precision(pformat, fmt);
+ return (pformat);
+}
+
// %[position][dollar][flags][width][.precision][length]type
t_pformat *parse_conversion(char *conversion)
{