[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [44651] trunk/blender/source/blender/ makesdna/intern/makesdna.c: added check for DNA C syntax we cant parse:

Campbell Barton ideasman42 at gmail.com
Mon Mar 5 17:21:14 CET 2012


Revision: 44651
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=44651
Author:   campbellbarton
Date:     2012-03-05 16:21:13 +0000 (Mon, 05 Mar 2012)
Log Message:
-----------
added check for DNA C syntax we cant parse:

 void*somepointer;

.. this is valid C but breaks makesdna.c

Modified Paths:
--------------
    trunk/blender/source/blender/makesdna/intern/makesdna.c

Modified: trunk/blender/source/blender/makesdna/intern/makesdna.c
===================================================================
--- trunk/blender/source/blender/makesdna/intern/makesdna.c	2012-03-05 16:19:16 UTC (rev 44650)
+++ trunk/blender/source/blender/makesdna/intern/makesdna.c	2012-03-05 16:21:13 UTC (rev 44651)
@@ -229,7 +229,15 @@
 	int nr;
 	char *cp;
 	
-	if(str[0]==0) return -1;
+	/* first do validity check */
+	if(str[0]==0) {
+		return -1;
+	}
+	else if (strchr(str, '*')) {
+		/* note: this is valid C syntax but we can't parse, complain!
+		 * 'struct SomeStruct* somevar;' <-- correct but we cant handle right now. */
+		return -1;
+	}
 	
 	/* search through type array */
 	for(nr=0; nr<nr_types; nr++) {
@@ -572,8 +580,12 @@
 				/* we've got a struct name when... */
 				if( strncmp(md1-7, "struct", 6)==0 ) {
 
-					
-					strct= add_type(md1, 0);
+					strct = add_type(md1, 0);
+					if (strct == -1) {
+						printf("File '%s' contains struct we cant parse \"%s\"\n", filename, md1);
+						return 1;
+					}
+
 					structpoin= add_struct(strct);
 					sp= structpoin+2;
 
@@ -601,6 +613,10 @@
 							
 							/* we've got a type! */
 							type= add_type(md1, 0);
+							if (type == -1) {
+								printf("File '%s' contains struct we can't parse \"%s\"\n", filename, md1);
+								return 1;
+							}
 
 							if (debugSDNA > 1) printf("\t|\t|\tfound type %s (", md1);
 




More information about the Bf-blender-cvs mailing list