refactor(uncrustify): disable formatting in problematic code sections

This commit is contained in:
Dundar Goc 2022-04-18 12:54:25 +02:00
parent 8c548c9e54
commit 995c186368
5 changed files with 20 additions and 4 deletions

View File

@ -546,6 +546,8 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer
goto error;
}
// uncrustify:off
struct {
const char *name;
Object *opt;
@ -559,6 +561,8 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer
{ NULL, NULL, NULL },
};
// uncrustify:on
for (int j = 0; hls[j].name && hls[j].dest; j++) {
if (HAS_KEY(*hls[j].opt)) {
*hls[j].dest = object_to_hl_id(*hls[j].opt, hls[j].name, err);

View File

@ -1,5 +1,3 @@
// uncrustify:off
#ifndef NVIM_ASSERT_H
#define NVIM_ASSERT_H
@ -110,6 +108,8 @@
# define STATIC_ASSERT_STATEMENT STATIC_ASSERT_EXPR
#endif
// uncrustify:off
#define ASSERT_CONCAT_(a, b) a##b
#define ASSERT_CONCAT(a, b) ASSERT_CONCAT_(a, b)
// These can't be used after statements in c89.
@ -125,6 +125,8 @@
((enum { ASSERT_CONCAT(assert_line_, __LINE__) = 1/(!!(e)), }) 0)
#endif
// uncrustify:on
/// @def STRICT_ADD
/// @brief Adds (a + b) and stores result in `c`. Aborts on overflow.
///

View File

@ -3972,12 +3972,16 @@ static int eval6(char_u **arg, typval_T *rettv, int evaluate, int want_string)
if (op == '*') {
f1 = f1 * f2;
} else if (op == '/') {
// uncrustify:off
// Division by zero triggers error from AddressSanitizer
f1 = (f2 == 0 ? (
#ifdef NAN
f1 == 0 ? (float_T)NAN :
#endif
(f1 > 0 ? (float_T)INFINITY : (float_T)-INFINITY)) : f1 / f2);
// uncrustify:on
} else {
emsg(_("E804: Cannot use '%' with Float"));
return FAIL;

View File

@ -4317,6 +4317,8 @@ skip:
lnum -= regmatch.startpos[0].lnum;
}
// uncrustify:off
#define PUSH_PREVIEW_LINES() \
do { \
if (preview) { \
@ -4336,6 +4338,8 @@ skip:
} \
} while (0)
// uncrustify:on
// Push the match to preview_lines.
PUSH_PREVIEW_LINES();

View File

@ -3,8 +3,6 @@
// fileio.c: read from and write to a file
// uncrustify:off
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
@ -4912,11 +4910,15 @@ int buf_check_timestamp(buf_T *buf)
char *mesg = NULL;
char *mesg2 = "";
bool helpmesg = false;
// uncrustify:off
enum {
RELOAD_NONE,
RELOAD_NORMAL,
RELOAD_DETECT
} reload = RELOAD_NONE;
// uncrustify:on
bool can_reload = false;
uint64_t orig_size = buf->b_orig_size;
int orig_mode = buf->b_orig_mode;