Skip to content

Commit

Permalink
STYLE: Consistently indent C++ sources
Browse files Browse the repository at this point in the history
This commit ensures consistent indentation for C++ source files. The adjustments
were made in anticipation of upcoming changes that will introduce a standard
configuration based on clang-format.

The changes were applied after locally building uncrustify/uncrustify@0cdcdd92d
and executing the following command:

```
uncrustify \
  -l CPP \
  -c /path/to/uncrustify.cfg \
  --no-backup \
  $(fd -e hpp -e h -e cpp -e cxx)
```

The `uncrustify.cfg` file includes the following non-default settings:

```
# Uncrustify-0.78.1-136-0cdcdd92d-dirty
input_tab_size                  = 2
sp_enum_brace                   = ignore
sp_pp_concat                    = ignore
sp_after_type                   = ignore
sp_angle_shift                  = ignore
sp_before_semi                  = ignore
sp_after_semi                   = ignore
sp_after_semi_for               = ignore
sp_before_vardef_square         = ignore
sp_before_comma                 = ignore
sp_paren_comma                  = ignore
sp_after_constr_colon           = ignore
sp_before_constr_colon          = ignore
sp_before_case_colon            = ignore
sp_return                       = ignore
sp_super_paren                  = ignore
sp_this_paren                   = ignore
sp_word_brace_ns                = ignore
sp_not                          = ignore
sp_inv                          = ignore
sp_addr                         = ignore
sp_member                       = ignore
sp_deref                        = ignore
sp_sign                         = ignore
sp_incdec                       = ignore
sp_before_nl_cont               = ignore
sp_before_emb_cmt               = ignore
sp_after_emb_cmt                = ignore
indent_columns                  = 2
indent_with_tabs                = 0
indent_class                    = true
indent_constr_colon             = true
indent_switch_case              = 2
indent_switch_body              = 2
nl_assign_leave_one_liners      = true
nl_class_leave_one_liners       = true
nl_func_leave_one_liners        = true
nl_if_brace                     = remove
nl_brace_else                   = force
nl_elseif_brace                 = force
nl_else_brace                   = remove
cmt_indent_multi                = false
cmt_multi_first_len_minimum     = 2
pp_multiline_define_body_indent = 2
# option(s) with 'not default' value: 44
#
```

This list of non-default was obtained by first building building
uncrustify applying the patch below and running the following command:

```
uncrustify \
  -c /path/to/complete-uncrustify.cfg \
  --update-config \
  -o /path/to/minimal-uncrustify.cfg
```

Patch applied to save a minimal configuration:

```diff
diff --git a/src/uncrustify.cpp b/src/uncrustify.cpp
index c8b2d3620..b282bbf57 100644
--- a/src/uncrustify.cpp
+++ b/src/uncrustify.cpp
@@ -936,7 +936,7 @@ int main(int argc, char *argv[])
       {
          return(error);
       }
-      save_option_file(stdout, update_config_wd);
+      save_option_file(stdout, update_config_wd, true);
       return(EXIT_SUCCESS);
    }

```
  • Loading branch information
jcfr committed Feb 21, 2024
1 parent 4dff159 commit 9f04027
Show file tree
Hide file tree
Showing 146 changed files with 11,685 additions and 11,562 deletions.
94 changes: 47 additions & 47 deletions autoscoper/src/core/History.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,61 +61,61 @@ class History
{
public:

History(unsigned size) : size(size)
{
it = states.begin();
History(unsigned size) : size(size)
{
it = states.begin();
}

void clear()
{
states.clear();
it = states.end();
}

void push(const State& state)
{
states.erase(it,states.end());
states.push_back(state);
if (states.size() > size) {
states.pop_front();
}

void clear()
{
states.clear();
it = states.end();
}

void push(const State& state)
{
states.erase(it,states.end());
states.push_back(state);
if (states.size() > size) {
states.pop_front();
}
it = states.end();
}

bool can_undo() const
{
return it != states.begin();
it = states.end();
}

bool can_undo() const
{
return it != states.begin();
}

State undo()
{
if (!can_undo()) {
throw std::runtime_error("There is nothing to undo");
}

State undo()
{
if (!can_undo()) {
throw std::runtime_error("There is nothing to undo");
}
return *(--it);
}

bool can_redo() const
{
std::list<State>::iterator test = it;
return test != states.end() && (++test) != states.end();
}

State redo()
{
if (!can_redo()) {
throw std::runtime_error("There is nothing to redo");
}
return *(++it);
return *(--it);
}

bool can_redo() const
{
std::list<State>::iterator test = it;
return test != states.end() && (++test) != states.end();
}

State redo()
{
if (!can_redo()) {
throw std::runtime_error("There is nothing to redo");
}
return *(++it);
}

private:

unsigned size;
unsigned size;

std::list<State> states;
std::list<State> states;

std::list<State>::iterator it;
std::list<State>::iterator it;
};

#endif // HISTORY_HPP
5 changes: 3 additions & 2 deletions autoscoper/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ int main ( int argc, char **argv )
int ret = app.exec();
delete socket;
delete widget;
return ret;
} else {
return ret;
}
else {
fprintf(stderr, "Start Batch %s\n", argv[1]);
AutoscoperMainWindow *widget = new AutoscoperMainWindow(true);
Socket* socket = new Socket(widget, 30007);
Expand Down
Loading

0 comments on commit 9f04027

Please sign in to comment.