Tcl Source Code

Artifact [9201ef1229]
Login

Artifact 9201ef122942183f014d0a15f2e10c657ba32691:

Attachment "1749987.patch" to ticket [1749987fff] added by dgp 2007-07-09 21:50:05.
Index: generic/tclCompExpr.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclCompExpr.c,v
retrieving revision 1.59
diff -u -r1.59 tclCompExpr.c
--- generic/tclCompExpr.c	5 Jul 2007 22:21:35 -0000	1.59
+++ generic/tclCompExpr.c	9 Jul 2007 14:46:46 -0000
@@ -450,6 +450,7 @@
 		}
 		scanned = 0;
 		insertMark = 1;
+		parsePtr->errorType = TCL_PARSE_BAD_NUMBER;
 		code = TCL_ERROR;
 		continue;
 	    }
@@ -631,6 +632,7 @@
 		if (prec[nodePtr[-1].lexeme] > precedence) {
 		    if (nodePtr[-1].lexeme == OPEN_PAREN) {
 			TclNewLiteralStringObj(msg, "unbalanced open paren");
+			parsePtr->errorType = TCL_PARSE_MISSING_PAREN;
 		    } else if (nodePtr[-1].lexeme == COMMA) {
 			msg = Tcl_ObjPrintf(
 				"missing function argument at %s", mark);
@@ -708,6 +710,7 @@
 		if ((otherPtr->lexeme == OPEN_PAREN)
 			&& (lexeme != CLOSE_PAREN)) {
 		    TclNewLiteralStringObj(msg, "unbalanced open paren");
+		    parsePtr->errorType = TCL_PARSE_MISSING_PAREN;
 		    code = TCL_ERROR;
 		    break;
 		}
@@ -852,6 +855,9 @@
 		parsePtr->string, (numBytes < limit) ? "" : "..."));
     }
 
+    if (code != TCL_OK && parsePtr->errorType == TCL_PARSE_SUCCESS) {
+	parsePtr->errorType = TCL_PARSE_SYNTAX;
+    }
     return code;
 }
 
@@ -1225,6 +1231,8 @@
 				/* Holds the Tcl_Tokens of substitutions */
     int code = ParseExpr(interp, start, numBytes, &opTree, litList,
 	    funcList, exprParsePtr);
+    int errorType = exprParsePtr->errorType;
+    const char* term = exprParsePtr->term;
 
     if (numBytes < 0) {
 	numBytes = (start ? strlen(start) : 0);
@@ -1235,7 +1243,8 @@
 	ConvertTreeToTokens(interp, start, numBytes, opTree, litList,
 		exprParsePtr->tokenPtr, parsePtr);
     } else {
-	/* TODO: copy over any error info to *parsePtr */
+	parsePtr->term = term;
+	parsePtr->errorType = errorType;
     }
 
     Tcl_FreeParse(exprParsePtr);