diff --git a/source/blender/blenloader/intern/genfile.c b/source/blender/blenloader/intern/genfile.c index 7eb6220066e..87c859de839 100644 --- a/source/blender/blenloader/intern/genfile.c +++ b/source/blender/blenloader/intern/genfile.c @@ -213,6 +213,12 @@ void dna_freestructDNA(struct SDNA *sdna) MEM_freeN(sdna); } +static int ispointer(char *name) +{ + /* check if pointer or function pointer */ + return (name[0]=='*' || (name[0]=='(' && name[1]=='*')); +} + static int elementsize(struct SDNA *sdna, short type, short name) /* call with numbers from struct-array */ { @@ -224,7 +230,7 @@ static int elementsize(struct SDNA *sdna, short type, short name) namelen= strlen(cp); /* is it a pointer or function pointer? */ - if(cp[0]=='*' || cp[1]=='*') { + if(ispointer(cp)) { /* has the naam an extra length? (array) */ mul= 1; if( cp[namelen-1]==']') mul= arraysize(cp, namelen); @@ -508,7 +514,7 @@ static void recurs_test_compflags(struct SDNA *sdna, char *compflags, int struct for(b=0; bnames[ sp[1] ]; - if(cp[0]!= '*') { + if(!ispointer(cp)) { compflags[a]= 2; recurs_test_compflags(sdna, compflags, a); } @@ -579,7 +585,7 @@ char *dna_get_structDNA_compareflags(struct SDNA *sdna, struct SDNA *newsdna) if(strcmp(str1, str2)!=0) break; /* same type and same name, now pointersize */ - if(str1[0]=='*') { + if(ispointer(str1)) { if(sdna->pointerlen!=newsdna->pointerlen) break; } @@ -834,7 +840,7 @@ static void reconstruct_elem(struct SDNA *newsdna, struct SDNA *oldsdna, char *t if( strcmp(name, oname)==0 ) { /* name equal */ - if( name[0]=='*') { /* pointer afhandelen */ + if(ispointer(name)) { /* pointer of functionpointer afhandelen */ cast_pointer(newsdna->pointerlen, oldsdna->pointerlen, name, curdata, olddata); } else if( strcmp(type, otype)==0 ) { /* type equal */ @@ -851,11 +857,11 @@ static void reconstruct_elem(struct SDNA *newsdna, struct SDNA *oldsdna, char *t cursize= arraysize(name, strlen(name)); oldsize= arraysize(oname, strlen(oname)); - if( name[0]=='*') { /* handle pointer */ + if(ispointer(name)) { /* handle pointer or functionpointer */ if(cursize>oldsize) cast_pointer(newsdna->pointerlen, oldsdna->pointerlen, oname, curdata, olddata); else cast_pointer(newsdna->pointerlen, oldsdna->pointerlen, name, curdata, olddata); } - else if(name[0]=='*' || strcmp(type, otype)==0 ) { /* type equal */ + else if(strcmp(type, otype)==0 ) { /* type equal */ mul= len/oldsize; mul*= MIN2(cursize, oldsize); memcpy(curdata, olddata, mul); @@ -909,7 +915,7 @@ static void reconstruct_struct(struct SDNA *newsdna, struct SDNA *oldsdna, char elen= elementsize(newsdna, spc[0], spc[1]); /* test: is type a struct? */ - if(spc[0]>=firststructtypenr && name[0]!='*') { + if(spc[0]>=firststructtypenr && !ispointer(name)) { /* where does the old struct data start (and is there an old one?) */ cpo= find_elem(oldsdna, type, name, spo, data, &sppo); @@ -976,7 +982,7 @@ void dna_switch_endian_struct(struct SDNA *oldsdna, int oldSDNAnr, char *data) elen= elementsize(oldsdna, spc[0], spc[1]); /* test: is type a struct? */ - if(spc[0]>=firststructtypenr && name[0]!='*') { + if(spc[0]>=firststructtypenr && !ispointer(name)) { /* where does the old data start (is there one?) */ cpo= find_elem(oldsdna, type, name, spo, data, 0); if(cpo) { @@ -993,7 +999,7 @@ void dna_switch_endian_struct(struct SDNA *oldsdna, int oldSDNAnr, char *data) } else { - if( name[0]=='*' ) { + if(ispointer(name)) { if(oldsdna->pointerlen==8) { mul= arraysize(name, strlen(name));