-
Notifications
You must be signed in to change notification settings - Fork 565
/
prototypes.h
78 lines (68 loc) · 1.44 KB
/
prototypes.h
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
/**
* @file prototypes.h
* Big jumble of prototypes used in Uncrustify.
*
* @author Ben Gardner
* @license GPL v2+
*/
#ifndef C_PARSE_PROTOTYPES_H_INCLUDED
#define C_PARSE_PROTOTYPES_H_INCLUDED
#include "uncrustify_types.h"
#include "chunk_list.h"
#include <string>
#include <deque>
/**
* Advances to the next tab stop.
* Column 1 is the left-most column.
*
* @param col The current column
* @param tabsize The tabsize
* @return the next tabstop column
*/
static inline size_t calc_next_tab_column(size_t col, size_t tabsize)
{
if (col == 0)
{
col = 1;
}
if (cpd.frag_cols > 0)
{
col += cpd.frag_cols - 1;
}
col = 1 + ((((col - 1) / tabsize) + 1) * tabsize);
if (cpd.frag_cols > 0)
{
col -= cpd.frag_cols - 1;
}
return(col);
}
/**
* Advances to the next tab stop for output.
*
* @param col The current column
* @return the next tabstop column
*/
static inline size_t next_tab_column(size_t col)
{
return(calc_next_tab_column(col, uncrustify::options::output_tab_size()));
}
/**
* Advances to the next tab stop if not currently on one.
*
* @param col The current column
* @return the next tabstop column
*/
static inline size_t align_tab_column(size_t col)
{
//if (col <= 0)
if (col == 0)
{
col = 1;
}
if ((col % uncrustify::options::output_tab_size()) != 1)
{
col = next_tab_column(col);
}
return(col);
}
#endif /* C_PARSE_PROTOTYPES_H_INCLUDED */