This repository was archived by the owner on Mar 28, 2026. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathft_procspec.c
More file actions
111 lines (103 loc) · 2.11 KB
/
Copy pathft_procspec.c
File metadata and controls
111 lines (103 loc) · 2.11 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_procspec.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jijerde <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/08/29 01:02:00 by jijerde #+# #+# */
/* Updated: 2019/09/19 04:55:18 by jijerde ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
void ft_procspec(t_flags *fl)
{
if (!fl->mi)
{
ft_flag(fl, 1, 1);
write(1, "%", 1);
fl->re += 1;
}
else
{
ft_flagmi(fl, 1, 1);
write(1, "%", 1);
fl->re += 1;
}
if (fl->mi)
{
if (fl->wdh > 1)
{
fl->wdh -= 1;
while (fl->wdh)
{
write(1, " ", 1);
fl->wdh -= 1;
fl->re += 1;
}
}
}
}
void ft_flagstr(t_flags *fl, char *str)
{
char *buff;
char *tmp;
int i;
i = 0;
buff = (char *)malloc(sizeof(char));
if (buff == NULL)
exit(-1);
buff[i] = '\0';
ft_flagstr2(fl, str, &buff);
if (fl->wdh > 0)
{
while (fl->wdh)
{
tmp = ft_strjoin(" ", buff);
free(buff);
buff = tmp;
fl->wdh -= 1;
fl->re += 1;
}
}
while (buff[i] != '\0')
write(1, &buff[i++], 1);
free(buff);
}
int ft_flagstrmi2(t_flags *fl, char *str, int psn1)
{
int i;
i = 0;
while (psn1 && str[i])
{
write(1, &str[i], 1);
psn1 -= 1;
fl->wdh -= 1;
fl->re += 1;
i++;
}
return (i);
}
int ft_flagstrmi(t_flags *fl, char *str)
{
int i;
int psn1;
psn1 = fl->psn;
i = 0;
if (fl->mi)
{
if (psn1 > 0)
i += ft_flagstrmi2(fl, str, psn1);
else if (psn1 == -1)
{
while (str[i])
{
write(1, &str[i], 1);
fl->wdh -= 1;
fl->re += 1;
i++;
}
}
}
return (i);
}