Silenced intel compiler warnings (reported by Kjartan Maraas, bug

* tree.c pattern.c: Silenced intel compiler warnings (reported
  by Kjartan Maraas, bug #318517).
* xmlschemas.c: The above changes in pattern.c revealed an
  inconsistency wrt IDCs: we now _only_ pop XPath states, if
  we really pushed them beforehand; this was previously not
  checked for the case when we discover an element node to be
  invalid wrt the content model.
  Fixed segfault in xmlSchemaGetEffectiveValueConstraint().
diff --git a/ChangeLog b/ChangeLog
index d9e4c16..00266bf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+Mon Oct 17 14:29:08 CEST 2005 Kasimier Buchcik <libxml2-cvs@cazic.net>
+
+	* tree.c pattern.c: Silenced intel compiler warnings (reported
+	  by Kjartan Maraas, bug #318517).
+	* xmlschemas.c: The above changes in pattern.c revealed an
+	  inconsistency wrt IDCs: we now _only_ pop XPath states, if
+	  we really pushed them beforehand; this was previously not
+	  checked for the case when we discover an element node to be
+	  invalid wrt the content model.
+	  Fixed segfault in xmlSchemaGetEffectiveValueConstraint().
+
 Fri Oct 14 16:40:18 CEST 2005 Kasimier Buchcik <libxml2-cvs@cazic.net>
 
 	* result/schemas/*.err: Adapted regression test results.
diff --git a/pattern.c b/pattern.c
index f65c615..9f3b025 100644
--- a/pattern.c
+++ b/pattern.c
@@ -1931,11 +1931,9 @@
 int
 xmlStreamPop(xmlStreamCtxtPtr stream) {
     int i, lev;
-    int ret;
-
+    
     if (stream == NULL)
         return(-1);
-    ret = 0;
     while (stream != NULL) {
 	/*
 	* Reset block-level.
@@ -1945,7 +1943,7 @@
 
 	stream->level--;
 	if (stream->level < 0)
-	    ret = -1;		
+	    return(-1);		
 	/*
 	 * Check evolution of existing states
 	 */	
diff --git a/tree.c b/tree.c
index 3031d50..fa7785b 100644
--- a/tree.c
+++ b/tree.c
@@ -6258,7 +6258,7 @@
  */
 int
 xmlUnsetProp(xmlNodePtr node, const xmlChar *name) {
-    xmlAttrPtr prop, prev = NULL;;
+    xmlAttrPtr prop;
 
     if ((node == NULL) || (node->type != XML_ELEMENT_NODE) || (name == NULL))
 	return(-1);
@@ -6270,7 +6270,6 @@
 	    xmlFreeProp(prop);
 	    return(0);
 	}
-	prev = prop;
 	prop = prop->next;
     }
     return(-1);
@@ -6287,7 +6286,7 @@
  */
 int
 xmlUnsetNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name) {
-    xmlAttrPtr prop, prev = NULL;;
+    xmlAttrPtr prop;
 
     if ((node == NULL) || (node->type != XML_ELEMENT_NODE) || (name == NULL))
 	return(-1);
@@ -6303,7 +6302,6 @@
 	    xmlFreeProp(prop);
 	    return(0);
 	}
-	prev = prop;
 	prop = prop->next;
     }
     return(-1);
diff --git a/xmlschemas.c b/xmlschemas.c
index 43e66fb..dbefae7 100644
--- a/xmlschemas.c
+++ b/xmlschemas.c
@@ -896,6 +896,7 @@
     int sizeNsBindings;    
 
     int hasKeyrefs;
+    int appliedXPath; /* Indicates that an XPath has been applied. */
 };
 
 #define XML_SCHEMAS_ATTR_UNKNOWN 1
@@ -13867,15 +13868,17 @@
 
     if (attruse->defValue != NULL) {	    
 	*value = attruse->defValue;
-	*val = attruse->defVal;
+	if (val != NULL)
+	    *val = attruse->defVal;
 	if (attruse->flags & XML_SCHEMA_ATTR_USE_FIXED)
 	    *fixed = 1;
 	return(1);
-    } else if ((WXS_ATTRUSE_DECL(attruse) != NULL) &&
-	(WXS_ATTRUSE_DECL(attruse)->defValue != NULL)) {
-	*value = (WXS_ATTRUSE_DECL(attruse))->defValue;
-	*val = (WXS_ATTRUSE_DECL(attruse))->defVal;
-	if ((WXS_ATTRUSE_DECL(attruse))->flags & XML_SCHEMAS_ATTR_FIXED)
+    } else if ((attruse->attrDecl != NULL) &&
+	(attruse->attrDecl->defValue != NULL)) {
+	*value = attruse->attrDecl->defValue;
+	if (val != NULL)
+	    *val = attruse->attrDecl->defVal;
+	if (attruse->attrDecl->flags & XML_SCHEMAS_ATTR_FIXED)
 	    *fixed = 1;
 	return(1);
     }
@@ -20965,7 +20968,7 @@
     if (res == -1)
 	goto exit_failure;
     if (res != 0)
-	goto exit;
+	goto exit;   
 
     if (bucket == NULL) {
 	/* TODO: Error code, actually we failed to *locate* the schema. */
@@ -23510,6 +23513,7 @@
 xmlSchemaClearElemInfo(xmlSchemaNodeInfoPtr ielem)
 {
     ielem->hasKeyrefs = 0;
+    ielem->appliedXPath = 0;
     if (ielem->flags & XML_SCHEMA_NODE_INFO_FLAG_OWNED_NAMES) {
 	FREE_AND_NULL(ielem->localName);
 	FREE_AND_NULL(ielem->nsName);
@@ -25811,7 +25815,8 @@
     /*
     * Evaluate the history of XPath state objects.
     */    
-    if (xmlSchemaXPathProcessHistory(vctxt, vctxt->depth) == -1)
+    if (inode->appliedXPath &&
+	(xmlSchemaXPathProcessHistory(vctxt, vctxt->depth) == -1))
 	goto internal_error;
     /*
     * MAYBE TODO:
@@ -26390,6 +26395,7 @@
     */
     if (vctxt->xpathStates != NULL) {
 	ret = xmlSchemaXPathEvaluate(vctxt, XML_ELEMENT_NODE);
+	vctxt->inode->appliedXPath = 1;
 	if (ret == -1) {
 	    VERROR_INT("xmlSchemaValidateElem",
 		"calling xmlSchemaXPathEvaluate()");