-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
50 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: brda-sil <[email protected] +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2022/02/22 13:16:35 by brda-sil #+# #+# */ | ||
/* Updated: 2023/12/04 02:17:45 by brda-sil ### ########.fr */ | ||
/* Updated: 2024/01/23 01:02:52 by brda-sil ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -211,6 +211,8 @@ char *ft_printf_buff_get(void); | |
t_bin ft_printf_fmt_get_flags(int *i, const char *format); | ||
|
||
// print/ft_printf/ft_printf_main.c | ||
void ft_printf_fmt_setup(t_fmt_conf *conf, int *i_fmt, \ | ||
const char *format); | ||
void ft_printf_fmt_parse(int *i_fmt, int *i_buff, \ | ||
const char *format, va_list args); | ||
t_size ft_printf_parse(va_list args, const char *format); | ||
|
@@ -230,6 +232,8 @@ void ft_printf_fmt_get_type(t_fmt_conf *conf, va_list args); | |
t_size ft_printf_fmt_get_width(int *i_fmt, const char *format); | ||
|
||
// print/ft_printf/padding/addr.c | ||
void ft_printf_type_padding_addr_short(t_fmt_conf *conf, char *buff, \ | ||
t_size str_len); | ||
void ft_printf_type_padding_addr(t_fmt_conf *conf); | ||
|
||
// print/ft_printf/padding/char.c | ||
|
@@ -245,7 +249,8 @@ void ft_printf_type_padding_hex_pad(t_fmt_conf *conf, t_size begin, \ | |
void ft_printf_type_padding_hex(t_fmt_conf *conf); | ||
|
||
// print/ft_printf/padding/integer.c | ||
void ft_printf_type_padding_integer_post(t_fmt_conf *conf, char sign); | ||
void ft_printf_type_padding_integer_post(t_fmt_conf *conf, char sign, \ | ||
char *buff); | ||
void ft_printf_type_padding_integer_pad(t_fmt_conf *conf, t_size begin, \ | ||
int to_pad); | ||
void ft_printf_type_padding_integer(t_fmt_conf *conf); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,26 +6,32 @@ | |
/* By: brda-sil <[email protected] +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2023/11/28 16:46:32 by brda-sil #+# #+# */ | ||
/* Updated: 2024/01/18 15:07:33 by brda-sil ### ########.fr */ | ||
/* Updated: 2024/01/23 01:03:02 by brda-sil ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include "libft_print.h" | ||
|
||
void ft_printf_fmt_setup(t_fmt_conf *conf, int *i_fmt, \ | ||
const char *format) | ||
{ | ||
conf->i_fmt = i_fmt; | ||
(*conf->i_fmt)++; | ||
conf->flags = ft_printf_fmt_get_flags(i_fmt, format); | ||
conf->width = ft_printf_fmt_get_width(i_fmt, format); | ||
conf->precision = ft_printf_fmt_get_precision(i_fmt, format); | ||
conf->fmt = format; | ||
} | ||
|
||
void ft_printf_fmt_parse(int *i_fmt, int *i_buff, \ | ||
const char *format, va_list args) | ||
{ | ||
t_fmt_conf conf; | ||
char *buff; | ||
t_size str_len; | ||
|
||
conf.i_fmt = i_fmt; | ||
(*conf.i_fmt)++; | ||
conf.flags = ft_printf_fmt_get_flags(i_fmt, format); | ||
conf.width = ft_printf_fmt_get_width(i_fmt, format); | ||
conf.precision = ft_printf_fmt_get_precision(i_fmt, format); | ||
ft_printf_fmt_setup(&conf, i_fmt, format); | ||
conf.i_buff = i_buff; | ||
conf.fmt = format; | ||
ft_printf_fmt_get_type(&conf, args); | ||
buff = ft_printf_buff_get(); | ||
if (conf.width) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,12 +6,23 @@ | |
/* By: brda-sil <[email protected] +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2023/12/03 15:28:01 by brda-sil #+# #+# */ | ||
/* Updated: 2023/12/04 00:37:21 by brda-sil ### ########.fr */ | ||
/* Updated: 2024/01/23 01:01:55 by brda-sil ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include "libft_print.h" | ||
|
||
void ft_printf_type_padding_addr_short(t_fmt_conf *conf, char *buff, \ | ||
t_size str_len) | ||
{ | ||
if (conf->flags & FT_PRINTF_FLAG_MINUS) | ||
ft_strncpy(buff + *conf->i_buff, conf->cur_type, str_len); | ||
else | ||
ft_strncpy(buff + *conf->i_buff + conf->width - str_len, \ | ||
conf->cur_type, str_len); | ||
(*conf->i_buff) += conf->width; | ||
} | ||
|
||
void ft_printf_type_padding_addr(t_fmt_conf *conf) | ||
{ | ||
t_size begin; | ||
|
@@ -25,11 +36,8 @@ void ft_printf_type_padding_addr(t_fmt_conf *conf) | |
begin = *conf->i_buff; | ||
if (conf->flags & FT_PRINTF_FLAG_MINUS) | ||
begin += str_len; | ||
while (to_pad > 0) | ||
{ | ||
while (to_pad-- > 0) | ||
buff[begin++] = ' '; | ||
to_pad--; | ||
} | ||
if (str_len > conf->width) | ||
{ | ||
if (conf->flags & FT_PRINTF_FLAG_MINUS) | ||
|
@@ -39,12 +47,5 @@ void ft_printf_type_padding_addr(t_fmt_conf *conf) | |
(*conf->i_buff) += str_len; | ||
} | ||
else | ||
{ | ||
if (conf->flags & FT_PRINTF_FLAG_MINUS) | ||
ft_strncpy(buff + *conf->i_buff, conf->cur_type, str_len); | ||
else | ||
ft_strncpy(buff + *conf->i_buff + conf->width - str_len, \ | ||
conf->cur_type, str_len); | ||
(*conf->i_buff) += conf->width; | ||
} | ||
ft_printf_type_padding_addr_short(conf, buff, str_len); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,18 +6,17 @@ | |
/* By: brda-sil <[email protected] +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2023/12/03 15:28:37 by brda-sil #+# #+# */ | ||
/* Updated: 2023/12/04 22:34:44 by brda-sil ### ########.fr */ | ||
/* Updated: 2024/01/23 01:01:14 by brda-sil ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include "libft_print.h" | ||
|
||
void ft_printf_type_padding_integer_post(t_fmt_conf *conf, char sign) | ||
void ft_printf_type_padding_integer_post(t_fmt_conf *conf, char sign, \ | ||
char *buff) | ||
{ | ||
char *buff; | ||
t_size str_len; | ||
|
||
buff = ft_printf_buff_get(); | ||
str_len = ft_strlen(conf->cur_type) - (sign != 0); | ||
if (sign && !(conf->flags & FT_PRINTF_FLAG_MINUS)) | ||
{ | ||
|
@@ -68,6 +67,7 @@ void ft_printf_type_padding_integer(t_fmt_conf *conf) | |
int to_pad; | ||
char sign; | ||
t_size str_len; | ||
char *buff; | ||
|
||
sign = ft_printf_type_padding_remove_sign(conf->cur_type); | ||
str_len = ft_strlen(conf->cur_type) - (sign != 0); | ||
|
@@ -76,5 +76,6 @@ void ft_printf_type_padding_integer(t_fmt_conf *conf) | |
if (conf->flags & FT_PRINTF_FLAG_MINUS) | ||
begin += str_len; | ||
ft_printf_type_padding_integer_pad(conf, begin, to_pad); | ||
ft_printf_type_padding_integer_post(conf, sign); | ||
buff = ft_printf_buff_get(); | ||
ft_printf_type_padding_integer_post(conf, sign, buff); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: brda-sil <[email protected] +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2022/11/07 03:09:08 by brda-sil #+# #+# */ | ||
/* Updated: 2023/12/04 22:22:30 by brda-sil ### ########.fr */ | ||
/* Updated: 2024/01/23 01:05:20 by brda-sil ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -180,13 +180,13 @@ int ci_flags_padding(void) | |
retv |= test_printf_integer("%-06x", 0x10); | ||
retv |= test_printf_integer("%-#06x", 0x10); | ||
|
||
// retv |= test_printf_integer("%#6x", -0x10); | ||
// retv |= test_printf_integer("%06x", -0x10); | ||
// retv |= test_printf_integer("%#06x", -0x10); | ||
// retv |= test_printf_integer("%-6x", -0x10); | ||
// retv |= test_printf_integer("%-#6x", -0x10); | ||
// retv |= test_printf_integer("%-06x", -0x10); | ||
// retv |= test_printf_integer("%-#06x", -0x10); | ||
retv |= test_printf_integer("%#6x", -0x10); | ||
retv |= test_printf_integer("%06x", -0x10); | ||
retv |= test_printf_integer("%#06x", -0x10); | ||
retv |= test_printf_integer("%-6x", -0x10); | ||
retv |= test_printf_integer("%-#6x", -0x10); | ||
retv |= test_printf_integer("%-06x", -0x10); | ||
retv |= test_printf_integer("%-#06x", -0x10); | ||
|
||
retv |= test_printf_integer("%6d", 0x10); | ||
retv |= test_printf_integer("%06d", 0x10); | ||
|
@@ -208,8 +208,8 @@ int ci_test(void) | |
int retv; | ||
|
||
retv = 0; | ||
// retv |= ci_base(); | ||
// retv |= ci_flags_padding(); | ||
retv |= ci_base(); | ||
retv |= ci_flags_padding(); | ||
// ft_dprintf(2, "test\n"); | ||
// ft_perr("test [%#06x]\n", 0x10); | ||
printf(" {%01d} \n", -9); | ||
|