summaryrefslogtreecommitdiffstats
path: root/debian/uncrustify-trinity/uncrustify-trinity-0.78.1/src/align_add.cpp
blob: ae8460d2195501aba9dabbb23d3c4985f6145f82 (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
/**
 * @file align_add.cpp
 *
 * @author  Guy Maurel
 * split from align.cpp
 * @author  Ben Gardner
 * @license GPL v2+
 */

#include "align_add.h"
#include "uncrustify.h"


void align_add(ChunkStack &cs, Chunk *pc, size_t &max_col)
{
   LOG_FUNC_ENTRY();

   size_t min_col;
   Chunk  *prev = Chunk::NullChunkPtr;

   if (pc->IsNotNullChunk())
   {
      prev = pc->GetPrev();
   }

   if (  prev->IsNullChunk()
      || prev->IsNewline())
   {
      min_col = 1;
      LOG_FMT(LALADD, "%s(%d): pc orig line=%zu, pc->col=%zu max_col=%zu min_col=%zu\n",
              __func__, __LINE__, pc->GetOrigLine(), pc->GetColumn(), max_col, min_col);
   }
   else
   {
      if (prev->Is(CT_COMMENT_MULTI))
      {
         min_col = prev->GetOrigColEnd() + 1;
      }
      else
      {
         min_col = prev->GetColumn() + prev->Len() + 1;
      }
      LOG_FMT(LALADD, "%s(%d): pc orig line=%zu, pc->col=%zu max_col=%zu min_col=%zu multi:%s prev->col=%zu prev->Len()=%zu %s\n",
              __func__, __LINE__, pc->GetOrigLine(), pc->GetColumn(), max_col, min_col, (prev->Is(CT_COMMENT_MULTI)) ? "Y" : "N",
              (prev->Is(CT_COMMENT_MULTI)) ? prev->GetOrigColEnd() : (UINT32)prev->GetColumn(), prev->Len(), get_token_name(prev->GetType()));
   }

   if (cs.Empty())
   {
      max_col = 0;
   }
   cs.Push_Back(pc);

   if (min_col > max_col)
   {
      max_col = min_col;
   }
} // align_add