-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpadding.c
More file actions
32 lines (29 loc) · 1.33 KB
/
padding.c
File metadata and controls
32 lines (29 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* padding.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: stoupin <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/04/24 13:53:21 by stoupin #+# #+# */
/* Updated: 2017/04/24 14:05:52 by stoupin ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int pad_left(t_buf *buffer, int width, int flags, int len)
{
if (flags & FLAG_MINUS || len >= width)
return (0);
if (flags & FLAG_ZERO)
buf_putnchar(buffer, '0', width - len);
else
buf_putnchar(buffer, ' ', width - len);
return (width - len);
}
int pad_right(t_buf *buffer, int width, int flags, int len)
{
if (!(flags & FLAG_MINUS) || len >= width)
return (0);
buf_putnchar(buffer, ' ', width - len);
return (width - len);
}