Skip to content

Commit

Permalink
change some int to unsigned int
Browse files Browse the repository at this point in the history
  • Loading branch information
gmaurel committed Dec 19, 2016
1 parent b4a791e commit e731568
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 71 deletions.
2 changes: 1 addition & 1 deletion documentation/htdocs/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<title>Uncrustify: where do the options work</title>
</head>
<body lang="en-US">
<h1><a href="https://github.com/gmaurel/uncrustify4Qt">Uncrustify4Qt</a>:
<h1><a href="https://github.com/uncrustify/uncrustify">Uncrustify</a>:
Where do the options work?</h1>
Move the cursor to a caret to see which option operates at this part of the code.
<h2>New lines</h2>
Expand Down
22 changes: 11 additions & 11 deletions src/ChunkStack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
void ChunkStack::Set(const ChunkStack &cs)
{
m_cse.resize(cs.m_cse.size());
for (int idx = 0; idx < (int)m_cse.size(); idx++)
for (size_t idx = 0; idx < m_cse.size(); idx++)
{
m_cse[idx].m_pc = cs.m_cse[idx].m_pc;
m_cse[idx].m_seqnum = cs.m_cse[idx].m_seqnum;
Expand All @@ -32,19 +32,19 @@ const ChunkStack::Entry *ChunkStack::Top() const
}


const ChunkStack::Entry *ChunkStack::Get(int idx) const
const ChunkStack::Entry *ChunkStack::Get(size_t idx) const
{
if ((idx >= 0) && (idx < (int)m_cse.size()))
if (idx < m_cse.size())
{
return(&m_cse[idx]);
}
return(NULL);
}


chunk_t *ChunkStack::GetChunk(int idx) const
chunk_t *ChunkStack::GetChunk(size_t idx) const
{
if ((idx >= 0) && (idx < (int)m_cse.size()))
if (idx < m_cse.size())
{
return(m_cse[idx].m_pc);
}
Expand Down Expand Up @@ -78,7 +78,7 @@ chunk_t *ChunkStack::Pop_Back()
}


void ChunkStack::Push_Back(chunk_t *pc, int seqnum)
void ChunkStack::Push_Back(chunk_t *pc, size_t seqnum)
{
m_cse.push_back(Entry(seqnum, pc));
if (m_seqnum < seqnum)
Expand All @@ -93,9 +93,9 @@ void ChunkStack::Push_Back(chunk_t *pc, int seqnum)
*
* @param idx The item to remove
*/
void ChunkStack::Zap(int idx)
void ChunkStack::Zap(size_t idx)
{
if ((idx >= 0) && (idx < (int)m_cse.size()))
if (idx < m_cse.size())
{
m_cse[idx].m_pc = NULL;
}
Expand All @@ -107,10 +107,10 @@ void ChunkStack::Zap(int idx)
*/
void ChunkStack::Collapse()
{
int wr_idx = 0;
int rd_idx;
size_t wr_idx = 0;
size_t rd_idx;

for (rd_idx = 0; rd_idx < (int)m_cse.size(); rd_idx++)
for (rd_idx = 0; rd_idx < m_cse.size(); rd_idx++)
{
if (m_cse[rd_idx].m_pc != NULL)
{
Expand Down
16 changes: 8 additions & 8 deletions src/ChunkStack.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ class ChunkStack
}


Entry(int sn, chunk_t *pc)
Entry(size_t sn, chunk_t *pc)
: m_seqnum(sn)
, m_pc(pc)
{
}
int m_seqnum;
size_t m_seqnum;
chunk_t *m_pc;
};

protected:
deque<Entry> m_cse;
int m_seqnum; // current seq num
size_t m_seqnum; // current seq num

public:
ChunkStack()
Expand Down Expand Up @@ -75,17 +75,17 @@ class ChunkStack
}


int Len() const
size_t Len() const
{
return(m_cse.size());
}

const Entry *Top() const;
const Entry *Get(int idx) const;
chunk_t *GetChunk(int idx) const;
const Entry *Get(size_t idx) const;
chunk_t *GetChunk(size_t idx) const;

chunk_t *Pop_Back();
void Push_Back(chunk_t *pc, int seqnum);
void Push_Back(chunk_t *pc, size_t seqnum);

chunk_t *Pop_Front();

Expand All @@ -95,7 +95,7 @@ class ChunkStack
m_cse.clear();
}

void Zap(int idx);
void Zap(size_t idx);
void Collapse();
};

Expand Down
14 changes: 7 additions & 7 deletions src/align.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static void align_func_params(void);
static void align_same_func_call_params();
static void align_func_proto(int span);
static void align_oc_msg_spec(int span);
static void align_typedefs(int span);
static void align_typedefs(size_t span);
static void align_left_shift(void);
static void align_oc_msg_colons(void);
static void align_oc_msg_colon(chunk_t *so);
Expand Down Expand Up @@ -265,9 +265,9 @@ void quick_indent_again(void)
void align_all(void)
{
LOG_FUNC_ENTRY();
if (cpd.settings[UO_align_typedef_span].n > 0)
if (cpd.settings[UO_align_typedef_span].u > 0)
{
align_typedefs(cpd.settings[UO_align_typedef_span].n);
align_typedefs(cpd.settings[UO_align_typedef_span].u);
}

if (cpd.settings[UO_align_left_shift].b)
Expand Down Expand Up @@ -1850,17 +1850,17 @@ static void align_init_brace(chunk_t *start)
* typedef char bar_t;
* typedef const char cc_t;
*/
static void align_typedefs(int span)
static void align_typedefs(size_t span)
{
LOG_FUNC_ENTRY();
chunk_t *pc;
chunk_t *c_typedef = NULL;
AlignStack as;

as.Start(span);
as.m_gap = cpd.settings[UO_align_typedef_gap].n;
as.m_star_style = (AlignStack::StarStyle)cpd.settings[UO_align_typedef_star_style].n;
as.m_amp_style = (AlignStack::StarStyle)cpd.settings[UO_align_typedef_amp_style].n;
as.m_gap = cpd.settings[UO_align_typedef_gap].u;
as.m_star_style = (AlignStack::StarStyle)cpd.settings[UO_align_typedef_star_style].u;
as.m_amp_style = (AlignStack::StarStyle)cpd.settings[UO_align_typedef_amp_style].u;

pc = chunk_get_head();
while (pc != NULL)
Expand Down
56 changes: 28 additions & 28 deletions src/align_stack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
* @param span The row span limit
* @param thresh The column threshold
*/
void AlignStack::Start(int span, int thresh)
void AlignStack::Start(size_t span, size_t thresh)
{
LOG_FMT(LAS, "Start(%d, %d)\n", span, thresh);
LOG_FMT(LAS, "Start(%lu, %lu)\n", span, thresh);

m_aligned.Reset();
m_skipped.Reset();
Expand Down Expand Up @@ -51,10 +51,10 @@ void AlignStack::ReAddSkipped()
const ChunkStack::Entry *ce;

/* Need to add them in order so that m_nl_seqnum is correct */
for (int idx = 0; idx < m_scratch.Len(); idx++)
for (size_t idx = 0; idx < m_scratch.Len(); idx++)
{
ce = m_scratch.Get(idx);
LOG_FMT(LAS, "ReAddSkipped [%d] - ", ce->m_seqnum);
LOG_FMT(LAS, "ReAddSkipped [%lu] - ", ce->m_seqnum);
Add(ce->m_pc, ce->m_seqnum);
}

Expand All @@ -70,7 +70,7 @@ void AlignStack::ReAddSkipped()
* @param pc The chunk
* @param seqnum Optional seqnum (0=assign one)
*/
void AlignStack::Add(chunk_t *start, int seqnum)
void AlignStack::Add(chunk_t *start, size_t seqnum)
{
LOG_FUNC_ENTRY();
/* Assign a seqnum if needed */
Expand All @@ -85,10 +85,10 @@ void AlignStack::Add(chunk_t *start, int seqnum)
chunk_t *prev;
chunk_t *next;

int col_adj = 0; /* Amount the column is shifted for 'dangle' mode */
int tmp_col;
int endcol;
int gap;
size_t col_adj = 0; /* Amount the column is shifted for 'dangle' mode */
size_t tmp_col;
size_t endcol;
size_t gap;

m_last_added = 0;

Expand Down Expand Up @@ -268,7 +268,7 @@ void AlignStack::Add(chunk_t *start, int seqnum)
m_aligned.Push_Back(ali, seqnum);
m_last_added = 1;

LOG_FMT(LAS, "Add-[%s]: line %lu, col %d, adj %d : ref=[%s] endcol=%d\n",
LOG_FMT(LAS, "Add-[%s]: line %lu, col %d, adj %d : ref=[%s] endcol=%lu\n",
ali->text(), ali->orig_line, ali->column, ali->align.col_adj,
ref->text(), endcol);

Expand All @@ -279,7 +279,7 @@ void AlignStack::Add(chunk_t *start, int seqnum)

if (endcol > m_max_col)
{
LOG_FMT(LAS, "Add-aligned [%d/%d/%d]: line %lu, col %d : max_col old %d, new %d - min_col %d\n",
LOG_FMT(LAS, "Add-aligned [%lu/%lu/%lu]: line %lu, col %d : max_col old %d, new %lu - min_col %d\n",
seqnum, m_nl_seqnum, m_seqnum,
ali->orig_line, ali->column, m_max_col, endcol, m_min_col);
m_max_col = endcol;
Expand All @@ -295,7 +295,7 @@ void AlignStack::Add(chunk_t *start, int seqnum)
}
else
{
LOG_FMT(LAS, "Add-aligned [%d/%d/%d]: line %lu, col %d : col %d <= %d - min_col %d\n",
LOG_FMT(LAS, "Add-aligned [%lu/%lu/%lu]: line %lu, col %d : col %lu <= %d - min_col %d\n",
seqnum, m_nl_seqnum, m_seqnum,
ali->orig_line, ali->column, endcol, m_max_col, m_min_col);
}
Expand All @@ -306,7 +306,7 @@ void AlignStack::Add(chunk_t *start, int seqnum)
m_skipped.Push_Back(start, seqnum);
m_last_added = 2;

LOG_FMT(LAS, "Add-skipped [%d/%d/%d]: line %lu, col %d <= %d + %d\n",
LOG_FMT(LAS, "Add-skipped [%lu/%lu/%lu]: line %lu, col %d <= %d + %d\n",
seqnum, m_nl_seqnum, m_seqnum,
start->orig_line, start->column, m_max_col, m_thresh);
}
Expand All @@ -316,19 +316,19 @@ void AlignStack::Add(chunk_t *start, int seqnum)
/**
* Adds some newline and calls Flush() if needed
*/
void AlignStack::NewLines(int cnt)
void AlignStack::NewLines(size_t cnt)
{
if (!m_aligned.Empty())
{
m_seqnum += cnt;
if (m_seqnum > (m_nl_seqnum + m_span))
{
LOG_FMT(LAS, "Newlines<%d>-", cnt);
LOG_FMT(LAS, "Newlines<%lu>-", cnt);
Flush();
}
else
{
LOG_FMT(LAS, "Newlines<%d>\n", cnt);
LOG_FMT(LAS, "Newlines<%lu>\n", cnt);
}
}
}
Expand All @@ -340,13 +340,13 @@ void AlignStack::NewLines(int cnt)
*/
void AlignStack::Flush()
{
int last_seqnum = 0;
int idx;
int tmp_col;
size_t last_seqnum = 0;
size_t idx;
size_t tmp_col;
const ChunkStack::Entry *ce = NULL;
chunk_t *pc;

LOG_FMT(LAS, "%s: m_aligned.Len()=%d\n", __func__, m_aligned.Len());
LOG_FMT(LAS, "%s: m_aligned.Len()=%lu\n", __func__, m_aligned.Len());
LOG_FMT(LAS, "Flush (min=%d, max=%d)\n", m_min_col, m_max_col);
if (m_aligned.Len() == 1)
{
Expand All @@ -372,8 +372,8 @@ void AlignStack::Flush()
pc = m_aligned.Get(idx)->m_pc;

/* Set the column adjust and gap */
int col_adj = 0;
int gap = 0;
size_t col_adj = 0;
size_t gap = 0;
if (pc != pc->align.ref)
{
gap = pc->column - (pc->align.ref->column + pc->align.ref->len());
Expand All @@ -391,7 +391,7 @@ void AlignStack::Flush()
if (m_right_align)
{
/* Adjust the width for signed numbers */
int start_len = pc->align.start->len();
size_t start_len = pc->align.start->len();
if (pc->align.start->type == CT_NEG)
{
tmp = chunk_get_next(pc->align.start);
Expand All @@ -406,7 +406,7 @@ void AlignStack::Flush()
pc->align.col_adj = col_adj;

/* See if this pushes out the max_col */
int endcol = pc->column + col_adj;
size_t endcol = pc->column + col_adj;
if (gap < m_gap)
{
endcol += m_gap - gap;
Expand All @@ -422,7 +422,7 @@ void AlignStack::Flush()
m_max_col = align_tab_column(m_max_col);
}

LOG_FMT(LAS, "%s: m_aligned.Len()=%d\n",
LOG_FMT(LAS, "%s: m_aligned.Len()=%lu\n",
__func__, m_aligned.Len());
for (idx = 0; idx < m_aligned.Len(); idx++)
{
Expand All @@ -445,14 +445,14 @@ void AlignStack::Flush()
chunk_flags_set(pc, PCF_ALIGN_START);

pc->align.right_align = m_right_align;
pc->align.amp_style = (int)m_amp_style;
pc->align.star_style = (int)m_star_style;
pc->align.amp_style = m_amp_style;
pc->align.star_style = m_star_style;
}
pc->align.gap = m_gap;
pc->align.next = m_aligned.GetChunk(idx + 1);

/* Indent the token, taking col_adj into account */
LOG_FMT(LAS, "%s: line %lu: '%s' to col %d (adj=%d)\n",
LOG_FMT(LAS, "%s: line %lu: '%s' to col %lu (adj=%d)\n",
__func__, pc->orig_line, pc->text(), tmp_col, pc->align.col_adj);
align_to_column(pc, tmp_col);
}
Expand Down
16 changes: 8 additions & 8 deletions src/align_stack.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ class AlignStack
ChunkStack m_skipped; /* contains the tokens sent to Add() */
int m_max_col;
int m_min_col;
int m_span;
size_t m_span;
int m_thresh;
int m_seqnum;
int m_nl_seqnum;
size_t m_seqnum;
size_t m_nl_seqnum;
int m_gap;
bool m_right_align;
StarStyle m_star_style;
Expand Down Expand Up @@ -78,16 +78,16 @@ class AlignStack
{
}

void Start(int span, int threshold = 0);
void Add(chunk_t *pc, int seqnum = 0);
void NewLines(int cnt);
void Start(size_t span, size_t threshold = 0);
void Add(chunk_t *pc, size_t seqnum = 0);
void NewLines(size_t cnt);
void Flush();
void Reset();
void End();

protected:
int m_last_added; /* 0=none, 1=aligned, 2=skipped */
void ReAddSkipped();
size_t m_last_added; /* 0=none, 1=aligned, 2=skipped */
void ReAddSkipped();

ChunkStack m_scratch; /* used in ReAddSkipped() */
};
Expand Down
2 changes: 1 addition & 1 deletion src/brace_cleanup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ static void parse_cleanup(struct parse_frame *frm, chunk_t *pc)
if (!cpd.unc_off_used)
{
/* fatal error */
fprintf(stderr, "Unmatched BRACE_CLOSE\nat line=%d, column=%d\n",
fprintf(stderr, "Unmatched BRACE_CLOSE\nat line=%lu, column=%lu\n",
pc->orig_line, pc->orig_col);
exit(EXIT_FAILURE);
}
Expand Down
Loading

0 comments on commit e731568

Please sign in to comment.