[Bf-blender-cvs] [f27bf3aeff2] temp-clang-format: Disable clang-format for large blocks of string comparisons

Campbell Barton noreply at git.blender.org
Tue Apr 16 15:56:18 CEST 2019


Commit: f27bf3aeff2e29874a84eac457ef255e5fa4aefc
Author: Campbell Barton
Date:   Tue Apr 16 15:55:45 2019 +0200
Branches: temp-clang-format
https://developer.blender.org/rBf27bf3aeff2e29874a84eac457ef255e5fa4aefc

Disable clang-format for large blocks of string comparisons

===================================================================

M	source/blender/editors/space_text/text_format_lua.c
M	source/blender/editors/space_text/text_format_osl.c
M	source/blender/editors/space_text/text_format_pov.c
M	source/blender/editors/space_text/text_format_pov_ini.c
M	source/blender/editors/space_text/text_format_py.c

===================================================================

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, "fals

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list