blob: face575c3e70b92dcd75e8d75bd74bd28bc77b79 (
plain)
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
|
/**
* @file align_typedefs.cpp
*
* @author Guy Maurel
* split from align.cpp
* @author Ben Gardner
* @license GPL v2+
*/
#include "align_typedefs.h"
#include "align_stack.h"
#include "log_rules.h"
constexpr static auto LCURRENT = LALTD;
using namespace uncrustify;
void align_typedefs(size_t span)
{
LOG_FUNC_ENTRY();
AlignStack as;
as.Start(span);
log_rule_B("align_typedef_gap");
as.m_gap = options::align_typedef_gap();
log_rule_B("align_typedef_star_style");
as.m_star_style = static_cast<AlignStack::StarStyle>(options::align_typedef_star_style());
log_rule_B("align_typedef_amp_style");
as.m_amp_style = static_cast<AlignStack::StarStyle>(options::align_typedef_amp_style());
chunk_t *c_typedef = nullptr;
chunk_t *pc = chunk_get_head();
while (pc != nullptr)
{
if (chunk_is_newline(pc))
{
as.NewLines(pc->nl_count);
c_typedef = nullptr;
}
else if (c_typedef != nullptr)
{
if (pc->flags.test(PCF_ANCHOR))
{
as.Add(pc);
LOG_FMT(LALTD, "%s(%d): typedef @ %zu:%zu, tag '%s' @ %zu:%zu\n",
__func__, __LINE__, c_typedef->orig_line, c_typedef->orig_col,
pc->text(), pc->orig_line, pc->orig_col);
c_typedef = nullptr;
}
}
else
{
if (chunk_is_token(pc, CT_TYPEDEF))
{
c_typedef = pc;
}
}
pc = chunk_get_next(pc);
}
as.End();
} // align_typedefs
|