GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — 42_ft_printf/srcs/parsing.c at master · mohammadbutt/42_ft_printf

Expand file tree

/

parsing.c

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
88 lines (80 loc) · 2.5 KB
/

parsing.c

Copy path

File metadata and controls

88 lines (80 loc) · 2.5 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* parsing.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mbutt <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/09/12 12:04:22 by mbutt #+# #+# */
/* Updated: 2019/09/16 13:51:47 by mbutt ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
void initialize_flag_and_field_values(t_printf *pr)
{
pr->width_field = 0;
pr->precision_field = -1;
pr->length_field = 0;
pr->type_field = 0;
ft_bzero(&pr->flag, sizeof(pr->flag));
ft_bzero(&pr->length, sizeof(pr->length));
}
void start_collecting_flags(t_printf *pr)
{
while (collect_flags(pr) != -1)
pr->i++;
cancel_flags(pr);
collect_width(pr);
collect_precision(pr);
collect_length(pr);
collect_type_field(pr);
}
/*
** 0 = c, 1 = s, 2 = p
** 3 = d, 4 = i, 5 = o
** 6 = u, 7 = x, 8 = X
** 9 = f, 10 = b, 11 = %
*/
/*
**void collect_data(t_printf *pr)
**{
** if(pr->type_field == 0)
** collect_c(pr);
** else if(pr->type_field == 1)
** collect_s(pr);
** else if(pr->type_field == 2)
** collect_p(pr);
** else if(pr->type_field == 3 || pr->type_field == 4)
** collect_d(pr);
** else if(pr->type_field == 5)
** collect_o(pr);
** else if(pr->type_field == 6)
** collect_u(pr);
** else if(pr->type_field == 7 || pr->type_field == 8)
** collect_x(pr);
** else if(pr->type_field == 9)
** collect_f(pr);
** else if(pr->type_field == 10)
** collect_b(pr);
** else if(pr->type_field == 11)
** collect_percent(pr);
**}
*/
/*
** Above commented function that uses if and else if statements can also be
** used to instead of the disptach table. But I implemented dispatch table to
** learn how it works, which is pretty similar to if and else if statements.
*/
void collect_data(t_printf *pr)
{
g_ft_dispatch_table[pr->type_field](pr);
}
void start_parsing(t_printf *pr)
{
pr->i++;
initialize_flag_and_field_values(pr);
if (pr->string[pr->i] == '\0')
return ;
start_collecting_flags(pr);
collect_data(pr);
}
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.