diff options
| author | Charles <sircharlesaze@gmail.com> | 2019-10-30 03:57:47 +0100 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2019-10-30 03:57:47 +0100 |
| commit | d963161275bcb3af4097872ba033da3ff9255606 (patch) | |
| tree | 41476dcab3fa209ae6f49c6f1abe37d454674a12 /extract.c | |
| parent | 07c9232121c8d6cb1e473bd7b623792253375d93 (diff) | |
| download | ft_printf-d963161275bcb3af4097872ba033da3ff9255606.tar.gz ft_printf-d963161275bcb3af4097872ba033da3ff9255606.tar.bz2 ft_printf-d963161275bcb3af4097872ba033da3ff9255606.zip | |
Individual convert functions, more flags
- Each conversion type is handle by individual functions in convert_*
files
- handle the ' ', '#', '+' and length modifier flags.
Diffstat (limited to 'extract.c')
| -rw-r--r-- | extract.c | 32 |
1 files changed, 31 insertions, 1 deletions
@@ -6,7 +6,7 @@ /* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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); + } +} |
