From 2986bc1d6e5d89aa59e191f3b0e7eb0be7de42ba Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 16 Apr 2019 16:53:50 +0200 Subject: ClangFormat: add comments to ignore formatting --- source/blender/blenkernel/intern/idcode.c | 3 ++ source/blender/blenkernel/intern/unit.c | 5 ++ source/blender/blenlib/BLI_compiler_typecheck.h | 7 ++- source/blender/blenlib/BLI_utildefines_variadic.h | 5 ++ source/blender/blenlib/intern/fnmatch.c | 6 +++ source/blender/blenlib/intern/sort.c | 5 ++ source/blender/bmesh/intern/bmesh_opdefines.c | 5 ++ source/blender/draw/engines/eevee/eevee_private.h | 3 ++ .../blender/editors/space_text/text_format_lua.c | 24 ++++++++++ .../blender/editors/space_text/text_format_osl.c | 29 ++++++++++++ .../blender/editors/space_text/text_format_pov.c | 54 ++++++++++++++++++---- .../editors/space_text/text_format_pov_ini.c | 25 +++++++++- source/blender/editors/space_text/text_format_py.c | 26 +++++++++++ source/blender/nodes/NOD_static_types.h | 5 ++ tests/gtests/blenlib/BLI_ressource_strings.h | 5 ++ tests/gtests/blenlib/BLI_string_utf8_test.cc | 4 ++ 16 files changed, 199 insertions(+), 12 deletions(-) diff --git a/source/blender/blenkernel/intern/idcode.c b/source/blender/blenkernel/intern/idcode.c index 42864fa8350..5e37f586a2a 100644 --- a/source/blender/blenkernel/intern/idcode.c +++ b/source/blender/blenkernel/intern/idcode.c @@ -44,6 +44,8 @@ typedef struct { #define IDTYPE_FLAGS_ISLINKABLE (1 << 0) } IDType; +/* Keep alignment for readability. */ +/* clang-format off */ /** * When editing enusre that: * - Plural need to match rna_main.c's #MainCollectionDef. @@ -93,6 +95,7 @@ static IDType idtypes[] = { /** Keep last, not an ID exactly, only include for completeness */ {ID_LINK_PLACEHOLDER, "Link Placeholder", "link_placeholders", BLT_I18NCONTEXT_ID_ID, 0}, /* plural is fake */ }; +/* clang-format on */ /* -1 for ID_LINK_PLACEHOLDER */ BLI_STATIC_ASSERT((ARRAY_SIZE(idtypes) - 1 == MAX_LIBARRAY), "Missing IDType"); diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index 2d2db5fea1e..25f3a57791e 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -39,6 +39,9 @@ /* no BKE or DNA includes! */ +/* Keep alignment. */ +/* clang-format off */ + #define TEMP_STR_SIZE 256 #define SEP_CHR '#' @@ -77,6 +80,8 @@ #define UN_SC_LB 0.45359237f #define UN_SC_OZ 0.028349523125f +/* clang-format on */ + /* define a single unit */ typedef struct bUnitDef { const char *name; diff --git a/source/blender/blenlib/BLI_compiler_typecheck.h b/source/blender/blenlib/BLI_compiler_typecheck.h index 4503848d6ea..c816e422c81 100644 --- a/source/blender/blenlib/BLI_compiler_typecheck.h +++ b/source/blender/blenlib/BLI_compiler_typecheck.h @@ -85,7 +85,8 @@ * \endcode */ #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) - +/* Over wrapped args. */ +/* clang-format off */ #define _VA_CHECK_TYPE_ANY2(v, a0) \ ((void)_Generic((v), a0: 0)) #define _VA_CHECK_TYPE_ANY3(v, a0, b0) \ @@ -373,6 +374,7 @@ t1: 0, u1: 0, v1: 0, w1: 0, x1: 0, y1: 0, z1: 0, a2: 0, b2: 0, c2: 0, d2: 0, e2: 0, f2: 0, g2: 0, h2: 0, i2: 0, \ j2: 0, k2: 0)) # define CHECK_TYPE_ANY(...) VA_NARGS_CALL_OVERLOAD(_VA_CHECK_TYPE_ANY, __VA_ARGS__) +/* clang-format on */ #else # define CHECK_TYPE_ANY(...) (void)0 #endif @@ -396,6 +398,8 @@ * print(" %s: r " % (": r, ".join(args))) * \endcode */ +/* Over wrapped args. */ +/* clang-format off */ #define _VA_GENERIC_TYPE_ANY2(r, a0) \ a0: r #define _VA_GENERIC_TYPE_ANY3(r, a0, b0) \ @@ -673,6 +677,7 @@ q0: r, r0: r, s0: r, t0: r, u0: r, v0: r, w0: r, x0: r, y0: r, z0: r, a1: r, b1: r, c1: r, d1: r, e1: r, f1: r, \ g1: r, h1: r, i1: r, j1: r, k1: r, l1: r, m1: r, n1: r, o1: r, p1: r, q1: r, r1: r, s1: r, t1: r, u1: r, v1: r, \ w1: r, x1: r, y1: r, z1: r, a2: r, b2: r, c2: r, d2: r, e2: r, f2: r, g2: r, h2: r, i2: r, j2: r, k2: r +/* clang-format on */ # define GENERIC_TYPE_ANY(...) VA_NARGS_CALL_OVERLOAD(_VA_GENERIC_TYPE_ANY, __VA_ARGS__) diff --git a/source/blender/blenlib/BLI_utildefines_variadic.h b/source/blender/blenlib/BLI_utildefines_variadic.h index 3048b814383..658733c80dc 100644 --- a/source/blender/blenlib/BLI_utildefines_variadic.h +++ b/source/blender/blenlib/BLI_utildefines_variadic.h @@ -21,6 +21,9 @@ * \ingroup bli */ +/* Over wrapped args. */ +/* clang-format off */ + /* --- internal helpers --- */ #define _VA_NARGS_GLUE(x, y) x y #define _VA_NARGS_RETURN_COUNT(\ @@ -43,4 +46,6 @@ #define VA_NARGS_CALL_OVERLOAD(name, ...) \ _VA_NARGS_GLUE(_VA_NARGS_OVERLOAD_MACRO(name, VA_NARGS_COUNT(__VA_ARGS__)), (__VA_ARGS__)) +/* clang-format on */ + #endif /* __BLI_UTILDEFINES_VARIADIC_H__ */ diff --git a/source/blender/blenlib/intern/fnmatch.c b/source/blender/blenlib/intern/fnmatch.c index 9ba2cdbf2e6..c0675e8c4d6 100644 --- a/source/blender/blenlib/intern/fnmatch.c +++ b/source/blender/blenlib/intern/fnmatch.c @@ -19,6 +19,10 @@ #ifdef WIN32 + +/* Maintained by GLIBC. */ +/* clang-format off */ + /* Enable GNU extensions in fnmatch.h. */ #ifndef _GNU_SOURCE # define _GNU_SOURCE 1 @@ -237,6 +241,8 @@ fnmatch (const char *pattern, const char *string, int flags) #endif /* _LIBC or not __GNU_LIBRARY__. */ +/* clang-format on */ + #else /* intentionally empty for UNIX */ diff --git a/source/blender/blenlib/intern/sort.c b/source/blender/blenlib/intern/sort.c index 921eec5ddc4..07c85e6ba7b 100644 --- a/source/blender/blenlib/intern/sort.c +++ b/source/blender/blenlib/intern/sort.c @@ -35,6 +35,9 @@ # undef min #endif +/* Maintained by FreeBSD. */ +/* clang-format off */ + /** * qsort, copied from FreeBSD source. * with only very minor edits, see: @@ -177,4 +180,6 @@ loop: } } +/* clang-format on */ + #endif /* __GLIBC__ */ diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c index 0ed1338e62f..4ca8e02e94d 100644 --- a/source/blender/bmesh/intern/bmesh_opdefines.c +++ b/source/blender/bmesh/intern/bmesh_opdefines.c @@ -90,6 +90,9 @@ * note that '//' comments are ignored. */ +/* Keep struct definition from wrapping. */ +/* clang-format off */ + /* enums shared between multiple operators */ static BMO_FlagSet bmo_enum_axis_xyz[] = { @@ -2067,6 +2070,8 @@ static BMOpDefine bmo_symmetrize_def = { BMO_OPTYPE_FLAG_SELECT_VALIDATE), }; +/* clang-format on */ + const BMOpDefine *bmo_opdefines[] = { &bmo_automerge_def, &bmo_average_vert_facedata_def, diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h index 66e45430e18..5f073d45dfb 100644 --- a/source/blender/draw/engines/eevee/eevee_private.h +++ b/source/blender/draw/engines/eevee/eevee_private.h @@ -59,6 +59,8 @@ extern struct DrawEngineType draw_engine_eevee_type; # define SHADER_IRRADIANCE "#define IRRADIANCE_HL2\n" #endif +/* Macro causes over indentation. */ +/* clang-format off */ #define SHADER_DEFINES \ "#define EEVEE_ENGINE\n" \ "#define MAX_PROBE " STRINGIFY(MAX_PROBE) "\n" \ @@ -70,6 +72,7 @@ extern struct DrawEngineType draw_engine_eevee_type; "#define MAX_SHADOW_CASCADE " STRINGIFY(MAX_SHADOW_CASCADE) "\n" \ "#define MAX_CASCADE_NUM " STRINGIFY(MAX_CASCADE_NUM) "\n" \ SHADER_IRRADIANCE +/* clang-format on */ #define SWAP_DOUBLE_BUFFERS() { \ if (effects->swap_double_buffer) { \ diff --git a/source/blender/editors/space_text/text_format_lua.c b/source/blender/editors/space_text/text_format_lua.c index 4b25c5d39a7..30080d2395b 100644 --- a/source/blender/editors/space_text/text_format_lua.c +++ b/source/blender/editors/space_text/text_format_lua.c @@ -45,6 +45,9 @@ static int txtfmt_lua_find_keyword(const char *string) { int i, len; + /* Keep aligned args for readability. */ + /* clang-format off */ + if (STR_LITERAL_STARTSWITH(string, "and", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "break", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "do", len)) i = len; @@ -65,6 +68,8 @@ static int txtfmt_lua_find_keyword(const char *string) else if (STR_LITERAL_STARTSWITH(string, "while", len)) i = len; else i = 0; + /* clang-format on */ + /* If next source char is an identifier (eg. 'i' in "definite") no match */ if (i == 0 || text_check_identifier(string[i])) return -1; @@ -86,6 +91,9 @@ static int txtfmt_lua_find_specialvar(const char *string) { int i, len; + /* Keep aligned args for readability. */ + /* clang-format off */ + if (STR_LITERAL_STARTSWITH(string, "assert", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "collectgarbage", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "dofile", len)) i = len; @@ -116,6 +124,8 @@ static int txtfmt_lua_find_specialvar(const char *string) else if (STR_LITERAL_STARTSWITH(string, "xpcall", len)) i = len; else i = 0; + /* clang-format on */ + /* If next source char is an identifier (eg. 'i' in "definite") no match */ if (i == 0 || text_check_identifier(string[i])) return -1; @@ -131,6 +141,8 @@ static int txtfmt_lua_find_bool(const char *string) else if (STR_LITERAL_STARTSWITH(string, "false", len)) i = len; else i = 0; + /* clang-format on */ + /* If next source char is an identifier (eg. 'i' in "Nonetheless") no match */ if (i == 0 || text_check_identifier(string[i])) return -1; @@ -140,9 +152,16 @@ static int txtfmt_lua_find_bool(const char *string) static char txtfmt_lua_format_identifier(const char *str) { char fmt; + + /* Keep aligned args for readability. */ + /* clang-format off */ + if ((txtfmt_lua_find_specialvar(str)) != -1) fmt = FMT_TYPE_SPECIAL; else if ((txtfmt_lua_find_keyword(str)) != -1) fmt = FMT_TYPE_KEYWORD; else fmt = FMT_TYPE_DEFAULT; + + /* clang-format on */ + return fmt; } @@ -265,11 +284,16 @@ static void txtfmt_lua_format_line(SpaceText *st, TextLine *line, const bool do_ } /* Not ws, a digit, punct, or continuing text. Must be new, check for special words */ else { + /* Keep aligned args for readability. */ + /* clang-format off */ + /* Special vars(v) or built-in keywords(b) */ /* keep in sync with 'txtfmt_osl_format_identifier()' */ if ((i = txtfmt_lua_find_specialvar(str)) != -1) prev = FMT_TYPE_SPECIAL; else if ((i = txtfmt_lua_find_keyword(str)) != -1) prev = FMT_TYPE_KEYWORD; + /* clang-format on */ + if (i > 0) { text_format_fill_ascii(&str, &fmt, prev, i); } diff --git a/source/blender/editors/space_text/text_format_osl.c b/source/blender/editors/space_text/text_format_osl.c index 08cae0d978d..66980b30c4d 100644 --- a/source/blender/editors/space_text/text_format_osl.c +++ b/source/blender/editors/space_text/text_format_osl.c @@ -33,6 +33,10 @@ static int txtfmt_osl_find_builtinfunc(const char *string) { int i, len; + + /* Keep aligned args for readability. */ + /* clang-format off */ + /* list is from * https://github.com/imageworks/OpenShadingLanguage/raw/master/src/doc/osl-languagespec.pdf */ @@ -62,6 +66,8 @@ static int txtfmt_osl_find_builtinfunc(const char *string) else if (STR_LITERAL_STARTSWITH(string, "while", len)) i = len; else i = 0; + /* clang-format on */ + /* If next source char is an identifier (eg. 'i' in "definite") no match */ if (i == 0 || text_check_identifier(string[i])) return -1; @@ -71,6 +77,10 @@ static int txtfmt_osl_find_builtinfunc(const char *string) static int txtfmt_osl_find_reserved(const char *string) { int i, len; + + /* Keep aligned args for readability. */ + /* clang-format off */ + /* list is from... * https://github.com/imageworks/OpenShadingLanguage/raw/master/src/doc/osl-languagespec.pdf */ @@ -112,6 +122,8 @@ static int txtfmt_osl_find_reserved(const char *string) else if (STR_LITERAL_STARTSWITH(string, "volatile", len)) i = len; else i = 0; + /* clang-format on */ + /* If next source char is an identifier (eg. 'i' in "definite") no match */ if (i == 0 || text_check_identifier(string[i])) return -1; @@ -129,6 +141,9 @@ static int txtfmt_osl_find_specialvar(const char *string) { int i, len; + /* Keep aligned args for readability. */ + /* clang-format off */ + /* OSL shader types */ if (STR_LITERAL_STARTSWITH(string, "shader", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "surface", len)) i = len; @@ -136,6 +151,8 @@ static int txtfmt_osl_find_specialvar(const char *string) else if (STR_LITERAL_STARTSWITH(string, "displacement", len)) i = len; else i = 0; + /* clang-format on */ + /* If next source char is an identifier (eg. 'i' in "definite") no match */ if (i == 0 || text_check_identifier(string[i])) return -1; @@ -162,11 +179,18 @@ static int txtfmt_osl_find_preprocessor(const char *string) static char txtfmt_osl_format_identifier(const char *str) { char fmt; + + /* Keep aligned args for readability. */ + /* clang-format off */ + if ((txtfmt_osl_find_specialvar(str)) != -1) fmt = FMT_TYPE_SPECIAL; else if ((txtfmt_osl_find_builtinfunc(str)) != -1) fmt = FMT_TYPE_KEYWORD; else if ((txtfmt_osl_find_reserved(str)) != -1) fmt = FMT_TYPE_RESERVED; else if ((txtfmt_osl_find_preprocessor(str)) != -1) fmt = FMT_TYPE_DIRECTIVE; else fmt = FMT_TYPE_DEFAULT; + + /* clang-format on */ + return fmt; } @@ -276,6 +300,9 @@ static void txtfmt_osl_format_line(SpaceText *st, TextLine *line, const bool do_ } /* Not ws, a digit, punct, or continuing text. Must be new, check for special words */ else { + /* Keep aligned args for readability. */ + /* clang-format off */ + /* Special vars(v) or built-in keywords(b) */ /* keep in sync with 'txtfmt_osl_format_identifier()' */ if ((i = txtfmt_osl_find_specialvar(str)) != -1) prev = FMT_TYPE_SPECIAL; @@ -283,6 +310,8 @@ static void txtfmt_osl_format_line(SpaceText *st, TextLine *line, const bool do_ else if ((i = txtfmt_osl_find_reserved(str)) != -1) prev = FMT_TYPE_RESERVED; else if ((i = txtfmt_osl_find_preprocessor(str)) != -1) prev = FMT_TYPE_DIRECTIVE; + /* clang-format on */ + if (i > 0) { if (prev == FMT_TYPE_DIRECTIVE) { /* can contain utf8 */ text_format_fill(&str, &fmt, prev, i); diff --git a/source/blender/editors/space_text/text_format_pov.c b/source/blender/editors/space_text/text_format_pov.c index 2435d2f21da..c0f4507aa5d 100644 --- a/source/blender/editors/space_text/text_format_pov.c +++ b/source/blender/editors/space_text/text_format_pov.c @@ -43,6 +43,9 @@ */ static int txtfmt_pov_find_keyword(const char *string) { + /* Keep aligned args for readability. */ + /* clang-format off */ + int i, len; /* Language Directives */ if (STR_LITERAL_STARTSWITH(string, "deprecated", len)) i = len; @@ -79,6 +82,8 @@ static int txtfmt_pov_find_keyword(const char *string) else if (STR_LITERAL_STARTSWITH(string, "if", len)) i = len; else i = 0; + /* clang-format on */ + /* If next source char is an identifier (eg. 'i' in "definite") no match */ return (i == 0 || text_check_identifier(string[i])) ? -1 : i; } @@ -91,6 +96,9 @@ static int txtfmt_pov_find_reserved_keywords(const char *string) * http://www.povray.org/documentation/view/3.7.0/212/ */ + /* Keep aligned args for readability. */ + /* clang-format off */ + /* Float Functions */ if (STR_LITERAL_STARTSWITH(string, "conserve_energy", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "max_intersections", len)) i = len; @@ -232,6 +240,8 @@ static int txtfmt_pov_find_reserved_keywords(const char *string) else if (STR_LITERAL_STARTSWITH(string, "str", len)) i = len; else i = 0; + /* clang-format on */ + /* If next source char is an identifier (eg. 'i' in "definite") no match */ return (i == 0 || text_check_identifier(string[i])) ? -1 : i; } @@ -245,6 +255,10 @@ static int txtfmt_pov_find_reserved_builtins(const char *string) * list is from... * http://www.povray.org/documentation/view/3.7.0/212/ */ + + /* Keep aligned args for readability. */ + /* clang-format off */ + /* Language Keywords */ if (STR_LITERAL_STARTSWITH(string, "reflection_exponent", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "area_illumination", len)) i = len; @@ -462,6 +476,8 @@ static int txtfmt_pov_find_reserved_builtins(const char *string) else if (STR_LITERAL_STARTSWITH(string, "z", len)) i = len; else i = 0; + /* clang-format off */ + /* If next source char is an identifier (eg. 'i' in "definite") no match */ return (i == 0 || text_check_identifier(string[i])) ? -1 : i; } @@ -686,16 +702,20 @@ static int txtfmt_pov_find_specialvar(const char *string) static int txtfmt_pov_find_bool(const char *string) { int i, len; - /*Built-in Constants*/ - if (STR_LITERAL_STARTSWITH(string, "unofficial", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "false", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "no", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "off", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "true", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "yes", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "on", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "pi", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "tau", len)) i = len; + + /* Keep aligned args for readability. */ + /* clang-format off */ + + /* Built-in Constants */ + if (STR_LITERAL_STARTSWITH(string, "unofficial", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "false", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "no", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "off", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "true", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "yes", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "on", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "pi", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "tau", len)) i = len; /* Encodings */ else if (STR_LITERAL_STARTSWITH(string, "sint16be", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "sint16le", len)) i = len; @@ -725,6 +745,8 @@ static int txtfmt_pov_find_bool(const char *string) else if (STR_LITERAL_STARTSWITH(string, "ttf", len)) i = len; else i = 0; + /* clang-format on */ + /* If next source char is an identifier (eg. 'i' in "Nonetheless") no match */ return (i == 0 || text_check_identifier(string[i])) ? -1 : i; } @@ -732,11 +754,18 @@ static int txtfmt_pov_find_bool(const char *string) static char txtfmt_pov_format_identifier(const char *str) { char fmt; + + /* Keep aligned args for readability. */ + /* clang-format off */ + if ((txtfmt_pov_find_specialvar(str)) != -1) fmt = FMT_TYPE_SPECIAL; else if ((txtfmt_pov_find_keyword(str)) != -1) fmt = FMT_TYPE_KEYWORD; else if ((txtfmt_pov_find_reserved_keywords(str)) != -1) fmt = FMT_TYPE_RESERVED; else if ((txtfmt_pov_find_reserved_builtins(str)) != -1) fmt = FMT_TYPE_DIRECTIVE; else fmt = FMT_TYPE_DEFAULT; + + /* clang-format on */ + return fmt; } @@ -855,6 +884,9 @@ static void txtfmt_pov_format_line(SpaceText *st, TextLine *line, const bool do_ } /* Not ws, a digit, punct, or continuing text. Must be new, check for special words */ else { + /* Keep aligned args for readability. */ + /* clang-format off */ + /* Special vars(v) or built-in keywords(b) */ /* keep in sync with 'txtfmt_pov_format_identifier()' */ if ((i = txtfmt_pov_find_specialvar(str)) != -1) prev = FMT_TYPE_SPECIAL; @@ -862,6 +894,8 @@ static void txtfmt_pov_format_line(SpaceText *st, TextLine *line, const bool do_ else if ((i = txtfmt_pov_find_reserved_keywords(str)) != -1) prev = FMT_TYPE_RESERVED; else if ((i = txtfmt_pov_find_reserved_builtins(str)) != -1) prev = FMT_TYPE_DIRECTIVE; + /* clang-format on */ + if (i > 0) { text_format_fill_ascii(&str, &fmt, prev, i); } diff --git a/source/blender/editors/space_text/text_format_pov_ini.c b/source/blender/editors/space_text/text_format_pov_ini.c index da69a35f0b0..5ef5746bffb 100644 --- a/source/blender/editors/space_text/text_format_pov_ini.c +++ b/source/blender/editors/space_text/text_format_pov_ini.c @@ -44,6 +44,10 @@ static int txtfmt_ini_find_keyword(const char *string) { int i, len; + + /* Keep aligned args for readability. */ + /* clang-format off */ + /* Language Directives */ if (STR_LITERAL_STARTSWITH(string, "deprecated", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "statistics", len)) i = len; @@ -89,6 +93,8 @@ static int txtfmt_ini_find_keyword(const char *string) else i = 0; + /* clang-format on */ + /* If next source char is an identifier (eg. 'i' in "definite") no match */ return (i == 0 || text_check_identifier(string[i])) ? -1 : i; } @@ -96,11 +102,15 @@ static int txtfmt_ini_find_keyword(const char *string) static int txtfmt_ini_find_reserved(const char *string) { int i, len; + + /* Keep aligned args for readability. */ + /* clang-format off */ + /* POV-Ray Built-in INI Variables * list is from... * http://www.povray.org/documentation/view/3.7.0/212/ */ - if (STR_LITERAL_STARTSWITH(string, "RenderCompleteSoundEnabled", len)) i = len; + if (STR_LITERAL_STARTSWITH(string, "RenderCompleteSoundEnabled", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Create_Continue_Trace_Log", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "ParseErrorSoundEnabled", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "RenderErrorSoundEnabled", len)) i = len; @@ -295,6 +305,8 @@ static int txtfmt_ini_find_reserved(const char *string) else i = 0; + /* clang-format on */ + /* If next source char is an identifier (eg. 'i' in "definite") no match */ return (i == 0 || text_check_identifier(string[i])) ? -1 : i; } @@ -305,6 +317,10 @@ static int txtfmt_ini_find_reserved(const char *string) static int txtfmt_ini_find_bool(const char *string) { int i, len; + + /* Keep aligned args for readability. */ + /* clang-format off */ + /* Built-in Constants */ if (STR_LITERAL_STARTSWITH(string, "false", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "no", len)) i = len; @@ -322,6 +338,8 @@ static int txtfmt_ini_find_bool(const char *string) else if (STR_LITERAL_STARTSWITH(string, "%w", len)) i = len; else i = 0; + /* clang-format on */ + /* If next source char is an identifier (eg. 'i' in "Nonetheless") no match */ return (i == 0 || text_check_identifier(string[i])) ? -1 : i; } @@ -445,11 +463,16 @@ static void txtfmt_pov_ini_format_line(SpaceText *st, TextLine *line, const bool } /* Not ws, a digit, punct, or continuing text. Must be new, check for special words */ else { + /* Keep aligned args for readability. */ + /* clang-format off */ + /* Special vars(v) or built-in keywords(b) */ /* keep in sync with 'txtfmt_ini_format_identifier()' */ if ((i = txtfmt_ini_find_keyword(str)) != -1) prev = FMT_TYPE_KEYWORD; else if ((i = txtfmt_ini_find_reserved(str)) != -1) prev = FMT_TYPE_RESERVED; + /* clang-format on */ + if (i > 0) { text_format_fill_ascii(&str, &fmt, prev, i); } diff --git a/source/blender/editors/space_text/text_format_py.c b/source/blender/editors/space_text/text_format_py.c index 87b3835ce1e..bb0b639f508 100644 --- a/source/blender/editors/space_text/text_format_py.c +++ b/source/blender/editors/space_text/text_format_py.c @@ -55,6 +55,9 @@ static int txtfmt_py_find_builtinfunc(const char *string) * if kw not in {"False", "None", "True", "def", "class"}])) */ + /* Keep aligned args for readability. */ + /* clang-format off */ + if (STR_LITERAL_STARTSWITH(string, "and", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "as", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "assert", len)) i = len; @@ -87,6 +90,8 @@ static int txtfmt_py_find_builtinfunc(const char *string) else if (STR_LITERAL_STARTSWITH(string, "yield", len)) i = len; else i = 0; + /* clang-format on */ + /* If next source char is an identifier (eg. 'i' in "definite") no match */ if (i == 0 || text_check_identifier(string[i])) return -1; @@ -104,10 +109,15 @@ static int txtfmt_py_find_specialvar(const char *string) { int i, len; + /* Keep aligned args for readability. */ + /* clang-format off */ + if (STR_LITERAL_STARTSWITH(string, "def", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "class", len)) i = len; else i = 0; + /* clang-format on */ + /* If next source char is an identifier (eg. 'i' in "definite") no match */ if (i == 0 || text_check_identifier(string[i])) return -1; @@ -138,11 +148,16 @@ static int txtfmt_py_find_bool(const char *string) { int i, len; + /* Keep aligned args for readability. */ + /* clang-format off */ + if (STR_LITERAL_STARTSWITH(string, "None", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "True", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "False", len)) i = len; else i = 0; + /* clang-format on */ + /* If next source char is an identifier (eg. 'i' in "Nonetheless") no match */ if (i == 0 || text_check_identifier(string[i])) return -1; @@ -152,10 +167,16 @@ static int txtfmt_py_find_bool(const char *string) static char txtfmt_py_format_identifier(const char *str) { char fmt; + + /* Keep aligned args for readability. */ + /* clang-format off */ + if ((txtfmt_py_find_specialvar(str)) != -1) fmt = FMT_TYPE_SPECIAL; else if ((txtfmt_py_find_builtinfunc(str)) != -1) fmt = FMT_TYPE_KEYWORD; else if ((txtfmt_py_find_decorator(str)) != -1) fmt = FMT_TYPE_RESERVED; else fmt = FMT_TYPE_DEFAULT; + + /* clang-format on */ return fmt; } @@ -272,12 +293,17 @@ static void txtfmt_py_format_line(SpaceText *st, TextLine *line, const bool do_n } /* Not ws, a digit, punct, or continuing text. Must be new, check for special words */ else { + /* Keep aligned args for readability. */ + /* clang-format off */ + /* Special vars(v) or built-in keywords(b) */ /* keep in sync with 'txtfmt_py_format_identifier()' */ if ((i = txtfmt_py_find_specialvar(str)) != -1) prev = FMT_TYPE_SPECIAL; else if ((i = txtfmt_py_find_builtinfunc(str)) != -1) prev = FMT_TYPE_KEYWORD; else if ((i = txtfmt_py_find_decorator(str)) != -1) prev = FMT_TYPE_DIRECTIVE; + /* clang-format on */ + if (i > 0) { if (prev == FMT_TYPE_DIRECTIVE) { /* can contain utf8 */ text_format_fill(&str, &fmt, prev, i); diff --git a/source/blender/nodes/NOD_static_types.h b/source/blender/nodes/NOD_static_types.h index 1c3b792f20b..ea642303ef6 100644 --- a/source/blender/nodes/NOD_static_types.h +++ b/source/blender/nodes/NOD_static_types.h @@ -20,6 +20,9 @@ /* intentionally no include guard */ +/* Keep aligned args for readability. */ +/* clang-format off */ + /* Empty definitions for undefined macros to avoid warnings */ #ifndef DefNode #define DefNode(Category, ID, DefFunc, EnumName, StructName, UIName, UIDesc) @@ -249,3 +252,5 @@ DefNode(TextureNode, TEX_NODE_PROC+TEX_DISTNOISE, 0, "TEX_DI /* undefine macros */ #undef DefNode + +/* clang-format on */ diff --git a/tests/gtests/blenlib/BLI_ressource_strings.h b/tests/gtests/blenlib/BLI_ressource_strings.h index 819cf893575..da28a05d7ea 100644 --- a/tests/gtests/blenlib/BLI_ressource_strings.h +++ b/tests/gtests/blenlib/BLI_ressource_strings.h @@ -3,6 +3,9 @@ #ifndef __BLENDER_TESTING_BLI_RESSOURCE_STRING_H__ #define __BLENDER_TESTING_BLI_RESSOURCE_STRING_H__ +/* Data file, don't format. */ +/* clang-format off */ + const char words10k[] = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam auctor ultrices purus tincidunt mollis. Vestibulum " "tincidunt imperdiet molestie. Vivamus posuere, risus ut mollis rutrum, lacus nulla mollis velit, consectetur auctor " @@ -602,4 +605,6 @@ const char words10k[] = #endif ; +/* clang-format on */ + #endif /* __BLENDER_TESTING_BLI_RESSOURCE_STRING_H__ */ diff --git a/tests/gtests/blenlib/BLI_string_utf8_test.cc b/tests/gtests/blenlib/BLI_string_utf8_test.cc index 89483d3d440..0dbe36158c5 100644 --- a/tests/gtests/blenlib/BLI_string_utf8_test.cc +++ b/tests/gtests/blenlib/BLI_string_utf8_test.cc @@ -35,6 +35,9 @@ int mk_wcswidth(const wchar_t *pwcs, size_t n) /* -------------------------------------------------------------------- */ /* tests */ +/* Breaking strings is confusing here, prefer over-long lines. */ +/* clang-format off */ + /* Each test is made of a 79 bytes (80 with NULL char) string to test, expected string result after * stripping invalid utf8 bytes, and a single-byte string encoded with expected number of errors. * @@ -283,6 +286,7 @@ const char *utf8_invalid_tests[][3] = { // 5.3.4 U+nFFFE U+nFFFF (for n = 1..10) {NULL, NULL, NULL}, }; +/* clang-format on */ /* BLI_utf8_invalid_strip (and indirectly, BLI_utf8_invalid_byte). */ TEST(string, Utf8InvalidBytes) -- cgit v1.2.3