From e057040a77f31971b903685b4e95254e898b7fad Mon Sep 17 00:00:00 2001
From: David Walter Seikel
Date: Thu, 2 Feb 2012 14:05:15 +1000
Subject: Disable the diff check again, and count bugs instead.

---
 LuaSL/src/LuaSL_LSL_tree.h     |  1 +
 LuaSL/src/LuaSL_compile.c      | 32 +++++++++++++++++++++++++-------
 LuaSL/src/LuaSL_lemon_yaccer.y |  3 +++
 3 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/LuaSL/src/LuaSL_LSL_tree.h b/LuaSL/src/LuaSL_LSL_tree.h
index ca91ff0..00094b1 100644
--- a/LuaSL/src/LuaSL_LSL_tree.h
+++ b/LuaSL/src/LuaSL_LSL_tree.h
@@ -310,6 +310,7 @@ struct _LSL_Script
     Eina_Hash		*functions;
     Eina_Hash		*states;
     Eina_Hash		*variables;
+    int			bugCount, warningCount;
 };
 
 /* Tracking variables.
diff --git a/LuaSL/src/LuaSL_compile.c b/LuaSL/src/LuaSL_compile.c
index d32a44f..a63c6ca 100644
--- a/LuaSL/src/LuaSL_compile.c
+++ b/LuaSL/src/LuaSL_compile.c
@@ -341,8 +341,11 @@ LSL_Leaf *checkVariable(LuaSL_compiler *compiler, LSL_Leaf *identifier, LSL_Leaf
 		}
 	    }
 	}
-	else 
+	else
+	{
+	    compiler->script.bugCount++;
 	    PE("NOT found %s @ line %d, column %d!", identifier->value.stringValue, identifier->line, identifier->column);
+	}
     }
 
     return identifier;
@@ -384,6 +387,7 @@ LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval,
 		lType = left->basicType;
 	    if (OT_undeclared == lType)
 	    {
+		compiler->script.warningCount++;
 		PW("Undeclared identifier issue, deferring this until the second pass. @ line %d, column %d.", lval->line, lval->column);
 		lval->basicType = OT_undeclared;
 		return lval;
@@ -411,6 +415,7 @@ LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval,
 		rType = right->basicType;
 	    if (OT_undeclared == rType)
 	    {
+		compiler->script.warningCount++;
 		PW("Undeclared identifier issue, deferring this until the second pass. @ line %d, column %d.", lval->line, lval->column);
 		lval->basicType = OT_undeclared;
 		return lval;
@@ -479,6 +484,7 @@ LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval,
 		rightType = allowed[right->basicType].name;
 	    }
 
+	    compiler->script.bugCount++;
 	    PE("Invalid operation [%s(%s) %s %s(%s)] @ line %d, column %d!", leftType, leftToken, lval->toKen->toKen, rightType, rightToken, lval->line, lval->column);
 	}
     }
@@ -949,6 +955,7 @@ LSL_Leaf *addStatement(LuaSL_compiler *compiler, LSL_Leaf *lval, LSL_Leaf *flow,
 	    }
 	    default :
 	    {
+		compiler->script.bugCount++;
 		PE("Should not be here %d.", stat->type);
 		break;
 	    }
@@ -1925,18 +1932,18 @@ static boolean doneParsing(LuaSL_compiler *compiler)
 	    if (out)
 	    {
 		char diffName[PATH_MAX];
-		int count;
+//		int count;
 
 		strcpy(diffName, compiler->fileName);
 		strcat(diffName, ".diff");
 		outputLeaf(out, OM_LSL, compiler->ast);
 		fclose(out);
 		sprintf(buffer, "diff -u \"%s\" \"%s\" > \"%s\"", compiler->fileName, outName, diffName);
-		count = system(buffer);
-		if (0 != count)
-		    PE("LSL output file is different - %s!", outName);
-		else
-		    result = TRUE;
+//		count = system(buffer);
+//		if (0 != count)
+//		    PE("LSL output file is different - %s!", outName);
+//		else
+//		    result = TRUE;
 	    }
 	    else
 		PC("Unable to open file %s for writing!", outName);
@@ -1953,6 +1960,17 @@ static boolean doneParsing(LuaSL_compiler *compiler)
 	    PC("Unable to open file %s for writing!", luaName);
     }
 
+    if (compiler->script.bugCount)
+	PE("%d errors and %d warnings in %s", compiler->script.bugCount, compiler->script.warningCount, compiler->fileName);
+    else
+    {
+	if (compiler->script.warningCount)
+	    PW("%d errors and %d warnings in %s", compiler->script.bugCount, compiler->script.warningCount, compiler->fileName);
+	else
+	    PI("%d errors and %d warnings in %s", compiler->script.bugCount, compiler->script.warningCount, compiler->fileName);
+	result = TRUE;
+    }
+
     return result;
 }
 
diff --git a/LuaSL/src/LuaSL_lemon_yaccer.y b/LuaSL/src/LuaSL_lemon_yaccer.y
index c225b26..9199699 100644
--- a/LuaSL/src/LuaSL_lemon_yaccer.y
+++ b/LuaSL/src/LuaSL_lemon_yaccer.y
@@ -223,6 +223,7 @@ expr(A) ::= LSL_STRING(B).									{ B->basicType = OT_string; A = B; }
 {
     gameGlobals *game = compiler->game;
 
+    compiler->script.bugCount++;
     PE("Giving up.  Parser is hopelessly lost!");
 }
 
@@ -230,6 +231,7 @@ expr(A) ::= LSL_STRING(B).									{ B->basicType = OT_string; A = B; }
 {
     gameGlobals *game = compiler->game;
 
+    compiler->script.bugCount++;
     PE("Giving up.  Parser stack overflow @ line %d, column %d!", yypMinor->yy0->line, yypMinor->yy0->column);  // Gotta love consistancy, if it ever happens.
 }
 
@@ -237,6 +239,7 @@ expr(A) ::= LSL_STRING(B).									{ B->basicType = OT_string; A = B; }
 {
     gameGlobals *game = compiler->game;
 
+    compiler->script.bugCount++;
     PE("Syntax error @ line %d, column %d!", yyminor.yy0->line, yyminor.yy0->column);
 }
 
-- 
cgit v1.1