Normed most of the stdme
This commit is contained in:
parent
882d5cb5bb
commit
ac5458d42c
31 changed files with 149 additions and 617 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/07/07 18:01:52 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/07/07 18:03:28 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/07/10 17:58:04 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -15,19 +15,20 @@
|
|||
#include "me/string/string.h"
|
||||
#include "me/types.h"
|
||||
|
||||
void me_printf_append_string(t_const_str to_write, t_usize to_write_len,
|
||||
void *p_args)
|
||||
void me_printf_append_string(t_const_str to_write, t_usize to_write_len,
|
||||
void *p_args)
|
||||
{
|
||||
t_sprintf_arg *arg;
|
||||
t_sprintf_arg *arg;
|
||||
|
||||
arg = p_args;
|
||||
arg->total_print += to_write_len;
|
||||
string_push(arg->buffer, to_write);
|
||||
}
|
||||
|
||||
void me_printf_write(t_const_str to_write, t_usize to_write_len, void *p_args)
|
||||
void me_printf_write(t_const_str to_write, \
|
||||
t_usize to_write_len, void *p_args)
|
||||
{
|
||||
t_fprintf_arg *arg;
|
||||
t_fprintf_arg *arg;
|
||||
|
||||
arg = (t_fprintf_arg *)p_args;
|
||||
write_fd(arg->fd, (t_u8 *)to_write, to_write_len, NULL);
|
||||
|
|
|
|||
|
|
@ -6,15 +6,15 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/12/01 21:05:47 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/07/07 17:40:12 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/07/10 17:58:28 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "me/mem/mem.h"
|
||||
#include "me/printf/formatter/utils.h"
|
||||
|
||||
void handle_weird_precision_stuff(t_printf_arg *data, t_prec_strs strs,
|
||||
t_usize value)
|
||||
void handle_weird_precision_stuff(t_printf_arg *data, t_prec_strs strs,
|
||||
t_usize value)
|
||||
{
|
||||
if (!value && data->extra.precision == 0 && (data->flags & PRECISION))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,21 +6,18 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/11 17:50:56 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/07/07 18:01:58 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/07/10 17:57:15 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "me/printf/printf.h"
|
||||
#include "me/fs/fs.h"
|
||||
#include "me/fs/write.h"
|
||||
#include "me/printf/_internal_printf.h"
|
||||
#include "me/types.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
t_usize me_printf(t_const_str fmt, ...)
|
||||
t_usize me_printf(t_const_str fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
t_usize res;
|
||||
va_list args;
|
||||
t_usize res;
|
||||
|
||||
va_start(args, fmt);
|
||||
res = me_vprintf(fmt, &args);
|
||||
|
|
@ -28,45 +25,13 @@ t_usize me_printf(t_const_str fmt, ...)
|
|||
return (res);
|
||||
}
|
||||
|
||||
t_usize me_eprintf(t_const_str fmt, ...)
|
||||
t_usize me_eprintf(t_const_str fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
t_usize res;
|
||||
va_list args;
|
||||
t_usize res;
|
||||
|
||||
va_start(args, fmt);
|
||||
res = me_veprintf(fmt, &args);
|
||||
va_end(args);
|
||||
return (res);
|
||||
}
|
||||
|
||||
/*
|
||||
t_usize me_printf(t_const_str fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
t_str str;
|
||||
t_usize len;
|
||||
|
||||
va_start(args, fmt);
|
||||
str = me_printf_str(fmt, &args);
|
||||
va_end(args);
|
||||
len = str_len(str);
|
||||
write(1, str, len);
|
||||
mem_free(str);
|
||||
return (len);
|
||||
}
|
||||
|
||||
t_usize me_eprintf(t_const_str fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
t_str str;
|
||||
t_usize len;
|
||||
|
||||
va_start(args, fmt);
|
||||
str = me_printf_str(fmt, &args);
|
||||
va_end(args);
|
||||
len = str_len(str);
|
||||
write(2, str, len);
|
||||
mem_free(str);
|
||||
return (len);
|
||||
}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
|
|
@ -7,7 +6,7 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/07/05 19:55:09 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/07/05 19:57:23 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/07/10 17:55:18 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -17,9 +16,9 @@
|
|||
#include "me/types.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
t_usize me_vprintf_fd(t_fd *fd, t_const_str fmt, va_list *args)
|
||||
t_usize me_vprintf_fd(t_fd *fd, t_const_str fmt, va_list *args)
|
||||
{
|
||||
t_fprintf_arg passthru;
|
||||
t_fprintf_arg passthru;
|
||||
|
||||
if (fd == NULL || fmt == NULL || args == NULL)
|
||||
return (0);
|
||||
|
|
@ -29,10 +28,10 @@ t_usize me_vprintf_fd(t_fd *fd, t_const_str fmt, va_list *args)
|
|||
return (passthru.total_print);
|
||||
}
|
||||
|
||||
t_usize me_printf_fd(t_fd *fd, t_const_str fmt, ...)
|
||||
t_usize me_printf_fd(t_fd *fd, t_const_str fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
t_usize res;
|
||||
va_list args;
|
||||
t_usize res;
|
||||
|
||||
va_start(args, fmt);
|
||||
res = me_vprintf_fd(fd, fmt, &args);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/07/07 17:27:50 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/07/07 18:03:40 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/07/10 17:57:32 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -17,9 +17,9 @@
|
|||
#include "me/types.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
t_usize me_vprintf_str(t_string *buf, t_const_str fmt, va_list *args)
|
||||
t_usize me_vprintf_str(t_string *buf, t_const_str fmt, va_list *args)
|
||||
{
|
||||
t_sprintf_arg passthru;
|
||||
t_sprintf_arg passthru;
|
||||
|
||||
if (buf == NULL || fmt == NULL || args == NULL)
|
||||
return (0);
|
||||
|
|
@ -29,10 +29,10 @@ t_usize me_vprintf_str(t_string *buf, t_const_str fmt, va_list *args)
|
|||
return (passthru.total_print);
|
||||
}
|
||||
|
||||
t_usize me_printf_str(t_string *buf, t_const_str fmt, ...)
|
||||
t_usize me_printf_str(t_string *buf, t_const_str fmt, ...)
|
||||
{
|
||||
t_usize res;
|
||||
va_list args;
|
||||
t_usize res;
|
||||
va_list args;
|
||||
|
||||
va_start(args, fmt);
|
||||
res = me_vprintf_str(buf, fmt, &args);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/02/09 14:57:28 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/07/07 18:00:14 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/07/10 17:56:24 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -16,11 +16,12 @@
|
|||
#include "me/types.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
void me_printf_write(t_const_str to_write, t_usize to_write_len, void *p_args);
|
||||
void me_printf_write(t_const_str to_write, \
|
||||
t_usize to_write_len, void *p_args);
|
||||
|
||||
t_usize me_vprintf(t_const_str fmt, va_list *args)
|
||||
t_usize me_vprintf(t_const_str fmt, va_list *args)
|
||||
{
|
||||
t_fprintf_arg passthru;
|
||||
t_fprintf_arg passthru;
|
||||
|
||||
if (fmt == NULL || args == NULL)
|
||||
return (0);
|
||||
|
|
@ -30,9 +31,9 @@ t_usize me_vprintf(t_const_str fmt, va_list *args)
|
|||
return (passthru.total_print);
|
||||
}
|
||||
|
||||
t_usize me_veprintf(t_const_str fmt, va_list *args)
|
||||
t_usize me_veprintf(t_const_str fmt, va_list *args)
|
||||
{
|
||||
t_fprintf_arg passthru;
|
||||
t_fprintf_arg passthru;
|
||||
|
||||
if (fmt == NULL || args == NULL)
|
||||
return (0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue