aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--convert_hex.c8
-rw-r--r--convert_ptr.c9
-rw-r--r--convert_uint.c6
-rw-r--r--main.c14
-rwxr-xr-xtestbin27916 -> 27868 bytes
5 files changed, 27 insertions, 10 deletions
diff --git a/convert_hex.c b/convert_hex.c
index fa0d4e6..9d3ee00 100644
--- a/convert_hex.c
+++ b/convert_hex.c
@@ -6,7 +6,7 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/10/30 23:23:06 by cacharle #+# #+# */
-/* Updated: 2019/11/02 02:09:15 by cacharle ### ########.fr */
+/* Updated: 2019/11/04 19:23:28 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -21,7 +21,11 @@ char *convert_hex(va_list ap, t_pformat *pformat)
char *tmp;
long long unsigned int n;
- if (pformat->flags & FLAG_LONG)
+ if (pformat->flags & FLAG_SHORT)
+ n = (unsigned short)va_arg(ap, int);
+ else if (pformat->flags & FLAG_SHORT_SHORT)
+ n = (unsigned char)va_arg(ap, int);
+ else if (pformat->flags & FLAG_LONG)
n = va_arg(ap, long unsigned int);
else if (pformat->flags & FLAG_LONG_LONG)
n = va_arg(ap, long long unsigned int);
diff --git a/convert_ptr.c b/convert_ptr.c
index aa24cb5..8c0797a 100644
--- a/convert_ptr.c
+++ b/convert_ptr.c
@@ -6,7 +6,7 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/10/30 23:24:08 by cacharle #+# #+# */
-/* Updated: 2019/10/30 23:25:33 by cacharle ### ########.fr */
+/* Updated: 2019/11/04 01:41:49 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -20,8 +20,13 @@ char *convert_ptr(va_list ap, t_pformat *pformat)
str = ITOA_HEX_LOW((long long unsigned int)va_arg(ap, void*));
str = handle_precision(pformat, str);
- str = add_hex_prefix(str);
+ if (!(pformat->flags & FLAG_ZERO_PADDING))
+ str = add_hex_prefix(str);
+ if (pformat->flags & FLAG_ZERO_PADDING)
+ pformat->min_width -= 2;
str = handle_padding(pformat, str);
+ if (pformat->flags & FLAG_ZERO_PADDING)
+ str = add_hex_prefix(str);
return (str);
}
diff --git a/convert_uint.c b/convert_uint.c
index 055317b..ddf9773 100644
--- a/convert_uint.c
+++ b/convert_uint.c
@@ -6,7 +6,7 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/10/30 23:25:40 by cacharle #+# #+# */
-/* Updated: 2019/11/04 00:18:39 by cacharle ### ########.fr */
+/* Updated: 2019/11/04 19:20:27 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -19,9 +19,9 @@ char *convert_uint(va_list ap, t_pformat *pformat)
long long unsigned int n;
if (pformat->flags & FLAG_SHORT)
- n = va_arg(ap, int);
+ n = (unsigned short)va_arg(ap, int);
else if (pformat->flags & FLAG_SHORT_SHORT)
- n = va_arg(ap, int);
+ n = (unsigned char)va_arg(ap, int);
else if (pformat->flags & FLAG_LONG)
n = va_arg(ap, long unsigned int);
else if (pformat->flags & FLAG_LONG_LONG)
diff --git a/main.c b/main.c
index ba59065..7464ce9 100644
--- a/main.c
+++ b/main.c
@@ -6,7 +6,7 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/10/28 04:25:09 by cacharle #+# #+# */
-/* Updated: 2019/11/04 01:21:36 by cacharle ### ########.fr */
+/* Updated: 2019/11/04 04:45:36 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -18,12 +18,20 @@ int main()
{
int test = 42;
+ /* ft_printf("%-72.170%%183.84x%174.189x%0+0'191.159s%107.*i%0#0+ 12.162c%#.38s%+'# 197.161i%'+#138.189s%#-0+'45.16X%' #+.71X%#-058.*d%0 +#137.30x%+16.145u%'23.72u" ,800115413,3199362515,"l$l%H6",-84514175,10,"fF(@Ju",795959316,";",3064849260,1535631011,-706426049,3490703638,3859198544,2268674351); */
+ /* printf("%#26.49p%'*.96c%-+-+ 37.180%%0#141.85i% 146.152X%91.199x%58.77i%0+'+'.140p%#67.141i%- 151.136d%101.187%%#*.56X%'+ 116.169x%69.74X%#0 #7.176%" ,16318453712790348322lu,46,814074579,1778514580,2425607191,1566569696,9615815307080556729lu,935162517,-447393454,385385973,3774990313,589711275); */
+ /* ft_printf("%'+-+ 115.57d%#+0#115.33p%0--198.37x%77.42s%#+0+118.*X% 62.25i%0+#0#21.164i%+''157.91x%0 -0179.107c%++ 70.100i%126.119d%118.182p%175.10i%''+-28.c%#167.153X" ,-812555527,8065328576609463455lu,2102650417,"Pw\tOVtwS",2307405425,1290938377,-351008211,3819076396,-51,-101089464,267730313,5298290595841494834lu,-911149367,-70,485455641); */
+ /* printf("%#+0#115.33p\n", 54); */
+ /* ft_printf("%#+0#115.33p\n", 54); */
+ ft_printf("%");
/* ft_printf("%"); */
/* printf("%"); */
/* ft_printf("32 This is an int : %0d\n\n", 0); */
/* printf("32 This is an int : %0d\n\n", 0); */
- ft_printf("{%05.*d}\n", -15, 42);
- printf("{%05.*d}\n", -15, 42);
+ /* ft_printf("{%05.*d}\n", -15, 42); */
+ /* printf("{%05.*d}\n", -15, 42); */
+ /* printf("%010p\n", 0x1); */
+ /* ft_printf("%010p\n", 0x1); */
/* ft_printf("%050 d\n", 500); */
/* printf("%050 d\n", 500); */
/* ft_printf("%020.5s\n", "Hallo heimur"); */
diff --git a/test b/test
index 759edde..b4c8a7a 100755
--- a/test
+++ b/test
Binary files differ