-
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
Antoine BOURIN
committed
Oct 22, 2019
1 parent
be1b13b
commit fb17488
Showing
3 changed files
with
28 additions
and
8 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: abourin <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2019/10/10 10:11:01 by abourin #+# #+# */ | ||
/* Updated: 2019/10/18 17:15:26 by abourin ### ########.fr */ | ||
/* Updated: 2019/10/22 10:22:01 by abourin ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -40,6 +40,7 @@ typedef struct s_converter | |
|
||
static char g_buff[BUFFER_SIZE]; | ||
|
||
int ft_is_conversion_specifier(char c); | ||
intmax_t ft_get_round_number(double f, long double after); | ||
char *ft_strdup(char const *s1); | ||
char *ft_strjoin_free(char const *s1, char sep, char const *s2); | ||
|
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: abourin <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2019/10/10 10:12:08 by abourin #+# #+# */ | ||
/* Updated: 2019/10/21 15:20:38 by abourin ### ########.fr */ | ||
/* Updated: 2019/10/22 10:40:49 by abourin ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
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,37 +6,56 @@ | |
/* By: abourin <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2019/10/11 13:54:18 by abourin #+# #+# */ | ||
/* Updated: 2019/10/21 15:20:04 by abourin ### ########.fr */ | ||
/* Updated: 2019/10/22 10:53:55 by abourin ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include "../ft_printf.h" | ||
|
||
int ft_get_int_char_size(int n) | ||
{ | ||
int count; | ||
int count; | ||
long int nb; | ||
|
||
nb = n; | ||
count = 1; | ||
while (n >= 10) | ||
if (nb < 0) | ||
{ | ||
n = n / 10; | ||
nb = nb * -1; | ||
count++; | ||
} | ||
while (nb >= 10) | ||
{ | ||
nb = nb / 10; | ||
count++; | ||
} | ||
return (count); | ||
} | ||
|
||
int ft_rewrite_asterix(char **result, int to_allow, int n, int *j) | ||
int ft_rewrite_asterix(char **result, int to_allow, long int n, int *j) | ||
{ | ||
int x; | ||
int is_min; | ||
|
||
x = to_allow; | ||
is_min = 0; | ||
if (n < 0) | ||
{ | ||
n = n * -1; | ||
is_min = 1; | ||
} | ||
while (n >= 10) | ||
{ | ||
(*result)[*j + x - 1] = (n % 10) + 48; | ||
n = n / 10; | ||
x--; | ||
} | ||
(*result)[*j + x - 1] = (n % 10) + 48; | ||
if (is_min) | ||
{ | ||
x--; | ||
(*result)[*j + x - 1] = '-'; | ||
} | ||
*j = *j + to_allow; | ||
return (1); | ||
} | ||
|
@@ -81,7 +100,7 @@ char *ft_replace_identifier(char *str, va_list ap) | |
i = 0; | ||
while (with_identifiers[i] && ft_is_valid_char(with_identifiers[i])) | ||
{ | ||
if (i != 0 && str[i] == '%') | ||
if (ft_is_conversion_specifier(with_identifiers[i])) | ||
return (with_identifiers); | ||
if (with_identifiers[i] == '*') | ||
{ | ||
|