[Bf-blender-cvs] [c11a317ee15] master: Cleanup: style, use braces for makesdna, datatoc

Campbell Barton noreply at git.blender.org
Thu Mar 28 00:16:30 CET 2019


Commit: c11a317ee15a2e4405cad550e54bd6cf552cb546
Author: Campbell Barton
Date:   Thu Mar 28 09:49:10 2019 +1100
Branches: master
https://developer.blender.org/rBc11a317ee15a2e4405cad550e54bd6cf552cb546

Cleanup: style, use braces for makesdna, datatoc

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

M	source/blender/datatoc/datatoc.c
M	source/blender/makesdna/intern/dna_genfile.c
M	source/blender/makesdna/intern/makesdna.c

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

diff --git a/source/blender/datatoc/datatoc.c b/source/blender/datatoc/datatoc.c
index 454c0a5d0e7..d54fa898968 100644
--- a/source/blender/datatoc/datatoc.c
+++ b/source/blender/datatoc/datatoc.c
@@ -36,8 +36,12 @@ static char *basename(char *string)
 
 	lfslash = strrchr(string, '/');
 	lbslash = strrchr(string, '\\');
-	if (lbslash) lbslash++;
-	if (lfslash) lfslash++;
+	if (lbslash) {
+		lbslash++;
+	}
+	if (lfslash) {
+		lfslash++;
+	}
 
 	return MAX3(string, lfslash, lbslash);
 }
@@ -66,15 +70,18 @@ int main(int argc, char **argv)
 	size = ftell(fpin);
 	fseek(fpin, 0L,  SEEK_SET);
 
-	if (argv[1][0] == '.') argv[1]++;
+	if (argv[1][0] == '.') {
+		argv[1]++;
+	}
 
 #ifdef VERBOSE
 	printf("Making C file <%s>\n", argv[2]);
 #endif
 
 	argv_len = (int)strlen(argv[1]);
-	for (i = 0; i < argv_len; i++)
+	for (i = 0; i < argv_len; i++) {
 		if (argv[1][i] == '.') argv[1][i] = '_';
+	}
 
 	fpout = fopen(argv[2], "w");
 	if (!fpout) {
diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c
index f53651621c2..60e9b69923d 100644
--- a/source/blender/makesdna/intern/dna_genfile.c
+++ b/source/blender/makesdna/intern/dna_genfile.c
@@ -345,7 +345,9 @@ static bool init_structDNA(
 					gravity_fix = nr;
 				}
 			}
-			while (*cp) cp++;
+			while (*cp) {
+				cp++;
+			}
 			cp++;
 		}
 
@@ -373,7 +375,9 @@ static bool init_structDNA(
 		for (int nr = 0; nr < sdna->nr_types; nr++) {
 			/* WARNING! See: DNA_struct_rename_legacy_hack_static_from_alias docs. */
 			sdna->types[nr] = DNA_struct_rename_legacy_hack_static_from_alias(cp);
-			while (*cp) cp++;
+			while (*cp) {
+				cp++;
+			}
 			cp++;
 		}
 
@@ -396,7 +400,10 @@ static bool init_structDNA(
 			*r_error_message = "TLEN error in SDNA file";
 			return false;
 		}
-		if (sdna->nr_types & 1) sp++;   /* prevent BUS error */
+		/* prevent BUS error */
+		if (sdna->nr_types & 1) {
+			sp++;
+		}
 
 		/* Struct array ('STRC') */
 		data = (int *)sp;
@@ -445,8 +452,9 @@ static bool init_structDNA(
 		if (gravity_fix > -1) {
 			for (int nr = 0; nr < sdna->nr_structs; nr++) {
 				sp = sdna->structs[nr];
-				if (strcmp(sdna->types[sp[0]], "ClothSimSettings") == 0)
+				if (strcmp(sdna->types[sp[0]], "ClothSimSettings") == 0) {
 					sp[10] = SDNA_TYPE_VOID;
+				}
 			}
 		}
 	}
@@ -646,15 +654,21 @@ const char *DNA_struct_get_compareflags(const SDNA *oldsdna, const SDNA *newsdna
 					while (b > 0) {
 						str1 = newsdna->types[sp_new[0]];
 						str2 = oldsdna->types[sp_old[0]];
-						if (strcmp(str1, str2) != 0) break;
+						if (strcmp(str1, str2) != 0) {
+							break;
+						}
 
 						str1 = newsdna->names[sp_new[1]];
 						str2 = oldsdna->names[sp_old[1]];
-						if (strcmp(str1, str2) != 0) break;
+						if (strcmp(str1, str2) != 0) {
+							break;
+						}
 
 						/* same type and same name, now pointersize */
 						if (ispointer(str1)) {
-							if (oldsdna->pointer_size != newsdna->pointer_size) break;
+							if (oldsdna->pointer_size != newsdna->pointer_size) {
+								break;
+							}
 						}
 
 						b--;
@@ -703,17 +717,17 @@ const char *DNA_struct_get_compareflags(const SDNA *oldsdna, const SDNA *newsdna
  */
 static eSDNA_Type sdna_type_nr(const char *dna_type)
 {
-	if     ((strcmp(dna_type, "char") == 0) || (strcmp(dna_type, "const char") == 0))          return SDNA_TYPE_CHAR;
-	else if ((strcmp(dna_type, "uchar") == 0) || (strcmp(dna_type, "unsigned char") == 0))     return SDNA_TYPE_UCHAR;
-	else if ( strcmp(dna_type, "short") == 0)                                                  return SDNA_TYPE_SHORT;
-	else if ((strcmp(dna_type, "ushort") == 0) || (strcmp(dna_type, "unsigned short") == 0))   return SDNA_TYPE_USHORT;
-	else if ( strcmp(dna_type, "int") == 0)                                                    return SDNA_TYPE_INT;
-	else if ( strcmp(dna_type, "float") == 0)                                                  return SDNA_TYPE_FLOAT;
-	else if ( strcmp(dna_type, "double") == 0)                                                 return SDNA_TYPE_DOUBLE;
-	else if ( strcmp(dna_type, "int64_t") == 0)                                                return SDNA_TYPE_INT64;
-	else if ( strcmp(dna_type, "uint64_t") == 0)                                               return SDNA_TYPE_UINT64;
+	if     ((strcmp(dna_type, "char") == 0) || (strcmp(dna_type, "const char") == 0))        { return SDNA_TYPE_CHAR; }
+	else if ((strcmp(dna_type, "uchar") == 0) || (strcmp(dna_type, "unsigned char") == 0))   { return SDNA_TYPE_UCHAR; }
+	else if ( strcmp(dna_type, "short") == 0)                                                { return SDNA_TYPE_SHORT; }
+	else if ((strcmp(dna_type, "ushort") == 0) || (strcmp(dna_type, "unsigned short") == 0)) { return SDNA_TYPE_USHORT; }
+	else if ( strcmp(dna_type, "int") == 0)                                                  { return SDNA_TYPE_INT; }
+	else if ( strcmp(dna_type, "float") == 0)                                                { return SDNA_TYPE_FLOAT; }
+	else if ( strcmp(dna_type, "double") == 0)                                               { return SDNA_TYPE_DOUBLE; }
+	else if ( strcmp(dna_type, "int64_t") == 0)                                              { return SDNA_TYPE_INT64; }
+	else if ( strcmp(dna_type, "uint64_t") == 0)                                             { return SDNA_TYPE_UINT64; }
 	/* invalid! */
-	else                                                                                       return -1;
+	else                                                                                     { return -1; }
 }
 
 /**
@@ -780,10 +794,14 @@ static void cast_elem(
 			case SDNA_TYPE_INT:
 				*( (int *)curdata) = val; break;
 			case SDNA_TYPE_FLOAT:
-				if (otypenr < 2) val /= 255;
+				if (otypenr < 2) {
+					val /= 255;
+				}
 				*( (float *)curdata) = val; break;
 			case SDNA_TYPE_DOUBLE:
-				if (otypenr < 2) val /= 255;
+				if (otypenr < 2) {
+					val /= 255;
+				}
 				*( (double *)curdata) = val; break;
 			case SDNA_TYPE_INT64:
 				*( (int64_t *)curdata) = val; break;
@@ -848,9 +866,15 @@ static int elem_strcmp(const char *name, const char *oname)
 	int a = 0;
 
 	while (1) {
-		if (name[a] != oname[a]) return 1;
-		if (name[a] == '[' || oname[a] == '[') break;
-		if (name[a] == 0 || oname[a] == 0) break;
+		if (name[a] != oname[a]) {
+			return 1;
+		}
+		if (name[a] == '[' || oname[a] == '[') {
+			break;
+		}
+		if (name[a] == 0 || oname[a] == 0) {
+			break;
+		}
 		a++;
 	}
 	return 0;
@@ -931,7 +955,9 @@ static const char *find_elem(
 
 		if (elem_strcmp(name, oname) == 0) {  /* name equal */
 			if (strcmp(type, otype) == 0) {   /* type equal */
-				if (sppo) *sppo = old;
+				if (sppo) {
+					*sppo = old;
+				}
 				return olddata;
 			}
 
@@ -983,7 +1009,9 @@ static void reconstruct_elem(
 	while (*cp && *cp != '[') {
 		cp++; countpos++;
 	}
-	if (*cp != '[') countpos = 0;
+	if (*cp != '[') {
+		countpos = 0;
+	}
 
 	/* in old is the old struct */
 	elemcount = old[1];
@@ -1087,8 +1115,12 @@ static void reconstruct_struct(
 	unsigned int cursdna_index_last = UINT_MAX;
 
 
-	if (oldSDNAnr == -1) return;
-	if (curSDNAnr == -1) return;
+	if (oldSDNAnr == -1) {
+		return;
+	}
+	if (curSDNAnr == -1) {
+		return;
+	}
 
 	if (compflags[oldSDNAnr] == SDNA_CMP_EQUAL) {
 		/* if recursive: test for equal */
@@ -1146,7 +1178,9 @@ static void reconstruct_struct(
 
 					/* new struct array larger than old */
 					mulo--;
-					if (mulo <= 0) break;
+					if (mulo <= 0) {
+						break;
+					}
 				}
 			}
 			else {
@@ -1179,7 +1213,9 @@ void DNA_struct_switch_endian(const SDNA *oldsdna, int oldSDNAnr, char *data)
 	const char *type, *name;
 	unsigned int oldsdna_index_last = UINT_MAX;
 
-	if (oldSDNAnr == -1) return;
+	if (oldSDNAnr == -1) {
+		return;
+	}
 	firststructtypenr = *(oldsdna->structs[0]);
 
 	spo = spc = oldsdna->structs[oldSDNAnr];
@@ -1227,7 +1263,9 @@ void DNA_struct_switch_endian(const SDNA *oldsdna, int oldSDNAnr, char *data)
 					/* exception: variable called blocktype: derived from ID_  */
 					bool skip = false;
 					if (name[0] == 'b' && name[1] == 'l') {
-						if (strcmp(name, "blocktype") == 0) skip = true;
+						if (strcmp(name, "blocktype") == 0) {
+							skip = true;
+						}
 					}
 
 					if (skip == false) {
diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c
index edf15c5fe39..4e16aec5fdc 100644
--- a/source/blender/makesdna/intern/makesdna.c
+++ b/source/blender/makesdna/intern/makesdna.c
@@ -400,7 +400,9 @@ static int add_name(const char *str)
 
 	additional_slen_offset = 0;
 
-	if (str[0] == 0 /*  || (str[1] == 0) */) return -1;
+	if (str[0] == 0 /*  || (str[1] == 0) */) {
+		return -1;
+	}
 
 	if (str[0] == '(' && str[1] == '*') {
 		/* we handle function pointer and special array cases here, e.g.
@@ -437,8 +439,9 @@ static int add_name(const char *str)
 			if (str[j] == 0) {
 				DEBUG_PRINTF(3, "offsetting for multidim array pointer\n");
 			}
-			else
+			else {
 				printf("Error during tokening multidim array pointer\n");
+			}
 		}
 		else if (str[j] == 0) {
 			DEBUG_PRINTF(3, "offsetting for space\n");
@@ -713,9 +716,14 @@ static int convert_include(const char *filename)
 				skip_struct = false;
 			}
 			else {
-				if (md[-1] == ' ') md[-1] = 0;
+				if (md[-1] == ' ') {
+					md[-1] = 0;
+				}
 				md1 = md - 2;
-				while (*md1 != 32) md1--;       /* to beginning of word */
+				while (*md1 != 32) {
+					/* to beginning of word */
+					md1--;
+				}
 				md1++;
 
 				/* we've got a struct name when... */
@@ -735,22 +743,28 @@ static int convert_include(const char *filename)
 					/* first lets make it all nice strings */
 					md1 = md + 1;
 					while (*md1 != '}') {
-						if (md1 > mainend) break;
+						if (md1 > mainend) {
+							break;
+						}
 
-						if (*md1 == ',' || *md1 == ' ') *md1 = 0;
+						if (*md1 == ',' || *md1 == ' ') {
+							*md1 = 0;
+						}
 						md1++;
 					}
 
 					/* read types and names until first character that is not '}' */
 					md1 = md + 1;
 					while (*md1 != '}') {
-						if (md1 > mainend) break;
+						if (md1 > mainend) {
+							break;
+						}
 
 						/* skip when it says 'struct' or 'un

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list