diff options
| author | Charles <sircharlesaze@gmail.com> | 2019-10-13 16:02:48 +0200 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2019-10-13 16:02:48 +0200 |
| commit | 374a9c43da4c2ee0ac19798abc840cd57cb7cf15 (patch) | |
| tree | 52ac65e7543b0d9322e522cf497b6ebae50968ce /printer.c | |
| parent | d744e75aea3145927a4e725eb95496499dc54630 (diff) | |
| download | ft_printf-374a9c43da4c2ee0ac19798abc840cd57cb7cf15.tar.gz ft_printf-374a9c43da4c2ee0ac19798abc840cd57cb7cf15.tar.bz2 ft_printf-374a9c43da4c2ee0ac19798abc840cd57cb7cf15.zip | |
Handled wildcard overwrite
Diffstat (limited to 'printer.c')
| -rw-r--r-- | printer.c | 19 |
1 files changed, 16 insertions, 3 deletions
@@ -119,11 +119,21 @@ char *convert_to_str(t_pformat *pformat, va_list ap) str = NULL; if (pformat->min_field_width_wildcard) - pformat->min_field_width = va_arg(ap, int); + { + if (pformat->min_field_width != -1) + va_arg(ap, int); + else + { + pformat->min_field_width = va_arg(ap, int); + if (pformat->min_field_width < 0) + { + pformat->left_adjusted = TRUE; + pformat->min_field_width = -pformat->min_field_width; + } + } + } if (pformat->precision_wildcard) pformat->precision = va_arg(ap, int); - /* printf("\n%d\n", pformat->precision); */ - /* pformat->precision = 45; */ if (conversion == CONVERSION_CHAR) { if ((str = ft_strnew(2)) == NULL) @@ -133,7 +143,10 @@ char *convert_to_str(t_pformat *pformat, va_list ap) else if (conversion == CONVERSION_STR) str = ft_strdup(va_arg(ap, char*)); else if (conversion == CONVERSION_PTR) + { + // handle 0x with and without zero padding str = ITOA_HEX_UPPER(va_arg(ap, int)); + } else if (conversion == CONVERSION_DECIMAL || conversion == CONVERSION_INT) str = ITOA_DEC(va_arg(ap, int)); else if (conversion == CONVERSION_UINT) |
