Skip to content

Commit fbef24a

Browse files
committed
Merge branch '4592_clang_format'
Signed-off-by: Yury V. Zaytsev <[email protected]>
2 parents 0a97ffd + 8406bdd commit fbef24a

File tree

385 files changed

+16579
-17548
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

385 files changed

+16579
-17548
lines changed

.clang-format

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
BasedOnStyle: GNU
3+
AlignConsecutiveMacros:
4+
Enabled: true
5+
AcrossEmptyLines: true
6+
PadOperators: true
7+
AlignOperands: DontAlign
8+
AttributeMacros:
9+
- G_GNUC_PRINTF
10+
BraceWrapping:
11+
AfterCaseLabel: true
12+
AfterClass: true
13+
AfterControlStatement: Always
14+
AfterEnum: true
15+
AfterExternBlock: true
16+
AfterFunction: true
17+
AfterNamespace: true
18+
AfterObjCDeclaration: true
19+
AfterStruct: true
20+
AfterUnion: true
21+
BeforeCatch: true
22+
BeforeElse: true
23+
BeforeLambdaBody: false
24+
BeforeWhile: true
25+
IndentBraces: false
26+
SplitEmptyFunction: true
27+
SplitEmptyRecord: true
28+
SplitEmptyNamespace: true
29+
BreakBeforeBinaryOperators: NonAssignment
30+
BreakBeforeBraces: Custom
31+
ColumnLimit: 100
32+
IndentPPDirectives: AfterHash
33+
IndentWidth: 4
34+
SortIncludes: Never
35+
SpaceAfterCStyleCast: true
36+
SpacesBeforeTrailingComments: 2

.github/workflows/ci-fedora.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@ jobs:
1111
timeout-minutes: 5
1212

1313
steps:
14+
- name: Install git inside container
15+
run: dnf install -y git
16+
1417
- uses: actions/checkout@v4
1518

1619
- name: Install dependencies
1720
run: |
18-
dnf install -y autoconf automake gcc gettext-devel groff libtool make pkgconfig
21+
dnf install -y autoconf automake clang-tools-extra gcc gettext-devel groff libtool make pkgconfig
1922
dnf install -y aspell-devel check-devel gpm-devel libX11-devel "pkgconfig(ext2fs)" "pkgconfig(glib-2.0)" "pkgconfig(gmodule-2.0)" "pkgconfig(libssh2)" "pkgconfig(slang)"
2023
2124
# For tests
@@ -41,6 +44,11 @@ jobs:
4144
--enable-werror \
4245
&& \
4346
\
47+
echo "Checking formatting..." && \
48+
clang-format --version && \
49+
make indent && \
50+
git diff --exit-code && \
51+
\
4452
make -j$(nproc) && \
4553
make check && \
4654
make install \

.github/workflows/ci-macos.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919

2020
- name: Install dependencies
2121
run: |
22-
brew install autoconf automake gettext check gnu-indent libtool pkg-config
22+
brew install autoconf automake gettext check libtool pkg-config
2323
brew install aspell e2fsprogs glib libssh2 openssl s-lang
2424
2525
# unzip is part of the base system

.github/workflows/ci-ubuntu.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313

1414
- name: Install dependencies
1515
run: |
16-
sudo apt-get install -y autoconf autopoint check gettext indent libtool pkg-config
16+
sudo apt-get install -y autoconf autopoint check gettext libtool pkg-config
1717
sudo apt-get install -y e2fslibs-dev libaspell-dev libglib2.0-dev libgpm-dev libncurses5-dev libpcre2-dev libslang2-dev libssh2-1-dev libx11-dev unzip
1818
1919
- name: Bootstrap build system
@@ -39,10 +39,6 @@ jobs:
3939
--enable-vfs-undelfs \
4040
--enable-werror
4141
42-
make indent
43-
# TODO: exit 1
44-
git ls-files --modified
45-
4642
make -j$(nproc)
4743
make check
4844
make install

Makefile.am

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,7 @@ cppcheck-split-all: \
115115
cppcheck-unusedFunction \
116116
cppcheck-missingInclude
117117

118-
INDENT_CMD = $(INDENT) \
119-
--gnu-style \
120-
--format-first-column-comments \
121-
--indent-level4 \
122-
--brace-indent0 \
123-
--line-length100 \
124-
--no-tabs \
125-
--blank-lines-after-procedures
118+
INDENT_CMD = clang-format -i
126119

127120
INDENT_DIRS = \
128121
"$(top_srcdir)/lib" \

configure.ac

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,6 @@ dnl ############################################################################
218218
dnl Check for other tools
219219
dnl ############################################################################
220220

221-
AC_CHECK_TOOLS([INDENT], [gindent indent])
222221
mc_UNIT_TESTS
223222

224223

doc/HACKING

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -66,29 +66,11 @@ cd mc-slang
6666
cd ../mc-ncurses
6767
/usr/local/src/mc/configure --with-screen=ncurses && make all
6868

69-
Please use the same indentation as other developers. To indent a block,
70-
select in the internal editor and use Shift-F9 to call the external
71-
indent. For historic reasons, GNU Midnight Commander used formatting
72-
that is not default for GNU Indent. Please put following text to your
73-
~/.indent.pro file to make GNU Indent follow the style used in GNU
74-
Midnight Commander:
75-
76-
--gnu-style
77-
--format-first-column-comments
78-
--indent-level4
79-
--brace-indent0
80-
--line-length100
81-
--no-tabs
82-
--blank-lines-after-procedures
83-
84-
or in short notation:
85-
86-
indent -gnu -fc1 -i4 -bli0 -nut -bap -l100
87-
88-
It's OK to indent the whole function if you edit it. However, please
89-
refrain from it if you are posting your patch for review. In this case
90-
you would save time of other developers if you only include significant
91-
changes. The developer applying your patch can format the code for you.
69+
Please use the same indentation as other developers. We enforce our
70+
indentation style with clang-format. If your IDE doesn't have a
71+
suitable itegration, make sure to run the formatter yourself:
72+
73+
make indent
9274

9375
Please keep in mind that the VFS subsystem is licensed under LGPL, while
9476
the rest of the code uses GPL.

lib/charsets.c

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
#include <string.h>
3535

3636
#include "lib/global.h"
37-
#include "lib/strutil.h" /* utf-8 functions */
37+
#include "lib/strutil.h" // utf-8 functions
3838
#include "lib/fileloc.h"
39-
#include "lib/util.h" /* whitespace() */
39+
#include "lib/util.h" // whitespace()
4040

4141
#include "lib/charsets.h"
4242

@@ -52,7 +52,7 @@ const char *cp_source = NULL;
5252

5353
/*** file scope macro definitions ****************************************************************/
5454

55-
#define UNKNCHAR '\001'
55+
#define UNKNCHAR '\001'
5656

5757
#define OTHER_8BIT "Other_8_bit"
5858

@@ -106,7 +106,7 @@ load_codepages_list_from_file (GPtrArray **list, const char *fname)
106106

107107
while (fgets (buf, sizeof buf, f) != NULL)
108108
{
109-
/* split string into id and cpname */
109+
// split string into id and cpname
110110
char *p = buf;
111111
size_t buflen;
112112

@@ -142,8 +142,8 @@ load_codepages_list_from_file (GPtrArray **list, const char *fname)
142142
{
143143
unsigned int i;
144144

145-
/* whether id is already present in list */
146-
/* if yes, overwrite description */
145+
// whether id is already present in list
146+
// if yes, overwrite description
147147
for (i = 0; i < (*list)->len; i++)
148148
{
149149
codepage_desc *desc;
@@ -152,14 +152,14 @@ load_codepages_list_from_file (GPtrArray **list, const char *fname)
152152

153153
if (strcmp (id, desc->id) == 0)
154154
{
155-
/* found */
155+
// found
156156
g_free (desc->name);
157157
desc->name = g_strdup (p);
158158
break;
159159
}
160160
}
161161

162-
/* not found */
162+
// not found
163163
if (i == (*list)->len)
164164
g_ptr_array_add (*list, new_codepage_desc (id, p));
165165
}
@@ -172,7 +172,7 @@ load_codepages_list_from_file (GPtrArray **list, const char *fname)
172172
g_free (default_codepage);
173173
}
174174

175-
fail:
175+
fail:
176176
fclose (f);
177177
}
178178

@@ -203,23 +203,23 @@ load_codepages_list (void)
203203
{
204204
char *fname;
205205

206-
/* 1: try load /usr/share/mc/mc.charsets */
206+
// 1: try load /usr/share/mc/mc.charsets
207207
fname = g_build_filename (mc_global.share_data_dir, CHARSETS_LIST, (char *) NULL);
208208
load_codepages_list_from_file (&codepages, fname);
209209
g_free (fname);
210210

211-
/* 2: try load /etc/mc/mc.charsets */
211+
// 2: try load /etc/mc/mc.charsets
212212
fname = g_build_filename (mc_global.sysconfig_dir, CHARSETS_LIST, (char *) NULL);
213213
load_codepages_list_from_file (&codepages, fname);
214214
g_free (fname);
215215

216216
if (codepages == NULL)
217217
{
218-
/* files are not found, add default codepage */
219-
fprintf (stderr, "%s\n", _("Warning: cannot load codepages list"));
218+
// files are not found, add default codepage
219+
fprintf (stderr, "%s\n", _ ("Warning: cannot load codepages list"));
220220

221221
codepages = g_ptr_array_new_with_free_func (free_codepage_desc);
222-
g_ptr_array_add (codepages, new_codepage_desc (DEFAULT_CHARSET, _("7-bit ASCII")));
222+
g_ptr_array_add (codepages, new_codepage_desc (DEFAULT_CHARSET, _ ("7-bit ASCII")));
223223
}
224224
}
225225

@@ -229,7 +229,7 @@ void
229229
free_codepages_list (void)
230230
{
231231
g_ptr_array_free (codepages, TRUE);
232-
/* NULL-ize pointer to make unit tests happy */
232+
// NULL-ize pointer to make unit tests happy
233233
codepages = NULL;
234234
}
235235

@@ -288,7 +288,7 @@ init_translation_table (int cpsource, int cpdisplay)
288288
int i;
289289
GIConv cd;
290290

291-
/* Fill input <-> display tables */
291+
// Fill input <-> display tables
292292

293293
if (cpsource < 0 || cpdisplay < 0 || cpsource == cpdisplay)
294294
{
@@ -309,22 +309,22 @@ init_translation_table (int cpsource, int cpdisplay)
309309
cp_source = ((codepage_desc *) g_ptr_array_index (codepages, cpsource))->id;
310310
cp_display = ((codepage_desc *) g_ptr_array_index (codepages, cpdisplay))->id;
311311

312-
/* display <- inpit table */
312+
// display <- inpit table
313313

314314
cd = g_iconv_open (cp_display, cp_source);
315315
if (cd == INVALID_CONV)
316-
return g_strdup_printf (_("Cannot translate from %s to %s"), cp_source, cp_display);
316+
return g_strdup_printf (_ ("Cannot translate from %s to %s"), cp_source, cp_display);
317317

318318
for (i = 128; i <= 255; ++i)
319319
conv_displ[i] = translate_character (cd, i);
320320

321321
g_iconv_close (cd);
322322

323-
/* inpit <- display table */
323+
// inpit <- display table
324324

325325
cd = g_iconv_open (cp_source, cp_display);
326326
if (cd == INVALID_CONV)
327-
return g_strdup_printf (_("Cannot translate from %s to %s"), cp_display, cp_source);
327+
return g_strdup_printf (_ ("Cannot translate from %s to %s"), cp_display, cp_source);
328328

329329
for (i = 128; i <= 255; ++i)
330330
{
@@ -489,13 +489,13 @@ convert_from_8bit_to_utf_c (char input_char, GIConv conv)
489489
switch (str_translate_char (conv, (char *) str, -1, (char *) buf_ch, sizeof (buf_ch)))
490490
{
491491
case ESTR_SUCCESS:
492-
{
493-
int res;
492+
{
493+
int res;
494494

495-
res = g_utf8_get_char_validated ((char *) buf_ch, -1);
496-
ch = res >= 0 ? res : buf_ch[0];
497-
break;
498-
}
495+
res = g_utf8_get_char_validated ((char *) buf_ch, -1);
496+
ch = res >= 0 ? res : buf_ch[0];
497+
break;
498+
}
499499
case ESTR_PROBLEM:
500500
case ESTR_FAILURE:
501501
default:

lib/charsets.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,4 @@ str_convert_to_display (const char *str)
110110

111111
/* --------------------------------------------------------------------------------------------- */
112112

113-
#endif /* MC__CHARSETS_H */
113+
#endif

lib/event-types.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
/*** typedefs(not structures) and defined constants **********************************************/
77

88
/* Event groups for main modules */
9-
#define MCEVENT_GROUP_CORE "Core"
10-
#define MCEVENT_GROUP_DIALOG "Dialog"
11-
#define MCEVENT_GROUP_DIFFVIEWER "DiffViewer"
12-
#define MCEVENT_GROUP_EDITOR "Editor"
9+
#define MCEVENT_GROUP_CORE "Core"
10+
#define MCEVENT_GROUP_DIALOG "Dialog"
11+
#define MCEVENT_GROUP_DIFFVIEWER "DiffViewer"
12+
#define MCEVENT_GROUP_EDITOR "Editor"
1313
#define MCEVENT_GROUP_FILEMANAGER "FileManager"
14-
#define MCEVENT_GROUP_VIEWER "Viewer"
14+
#define MCEVENT_GROUP_VIEWER "Viewer"
1515

1616
/* Events */
1717
#define MCEVENT_HISTORY_LOAD "history_load"
@@ -72,7 +72,7 @@ struct Widget;
7272
typedef struct
7373
{
7474
struct mc_config_t *cfg;
75-
struct Widget *receiver; /* NULL means broadcast message */
75+
struct Widget *receiver; // NULL means broadcast message
7676
} ev_history_load_save_t;
7777

7878
/*** global variables defined in .c file *********************************************************/
@@ -81,4 +81,4 @@ typedef struct
8181

8282
/*** inline functions ****************************************************************************/
8383

84-
#endif /* MC__EVENT_TYPES_H */
84+
#endif

lib/event.h

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,23 @@ typedef struct
2424
/*** declarations of public functions ************************************************************/
2525

2626
/* event.c: */
27-
gboolean mc_event_init (GError ** mcerror);
28-
gboolean mc_event_deinit (GError ** mcerror);
29-
27+
gboolean mc_event_init (GError **mcerror);
28+
gboolean mc_event_deinit (GError **mcerror);
3029

3130
/* manage.c: */
32-
gboolean mc_event_add (const gchar * event_group_name, const gchar * event_name,
31+
gboolean mc_event_add (const gchar *event_group_name, const gchar *event_name,
3332
mc_event_callback_func_t event_callback, gpointer event_init_data,
34-
GError ** mcerror);
35-
void mc_event_del (const gchar * event_group_name, const gchar * event_name,
33+
GError **mcerror);
34+
void mc_event_del (const gchar *event_group_name, const gchar *event_name,
3635
mc_event_callback_func_t event_callback, gpointer event_init_data);
37-
void mc_event_destroy (const gchar * event_group_name, const gchar * event_name);
38-
void mc_event_group_del (const gchar * event_group_name);
39-
gboolean mc_event_present (const gchar * event_group_name, const gchar * event_name);
40-
gboolean mc_event_mass_add (const event_init_t * events, GError ** mcerror);
36+
void mc_event_destroy (const gchar *event_group_name, const gchar *event_name);
37+
void mc_event_group_del (const gchar *event_group_name);
38+
gboolean mc_event_present (const gchar *event_group_name, const gchar *event_name);
39+
gboolean mc_event_mass_add (const event_init_t *events, GError **mcerror);
4140

4241
/* raise.c: */
4342
gboolean mc_event_raise (const gchar *, const gchar *, gpointer);
4443

45-
4644
/*** inline functions ****************************************************************************/
4745

48-
#endif /* MC__EVENT_H */
46+
#endif

0 commit comments

Comments
 (0)