fixed the bug in lang() as raised by Elliotte Rusty Harold added a

* xpath.c: fixed the bug in lang() as raised by Elliotte Rusty Harold
* result/XPath/tests/langsimple test/XPath/tests/langsimple
  test/XPath/docs/lang: added a regression test
Daniel
diff --git a/xpath.c b/xpath.c
index 7967861..82e7f24 100644
--- a/xpath.c
+++ b/xpath.c
@@ -7092,8 +7092,8 @@
  */
 void
 xmlXPathLangFunction(xmlXPathParserContextPtr ctxt, int nargs) {
-    xmlXPathObjectPtr val;
-    const xmlChar *theLang;
+    xmlXPathObjectPtr val = NULL;
+    const xmlChar *theLang = NULL;
     const xmlChar *lang;
     int ret = 0;
     int i;
@@ -7108,10 +7108,12 @@
         for (i = 0;lang[i] != 0;i++)
 	    if (toupper(lang[i]) != toupper(theLang[i]))
 	        goto not_equal;
-        ret = 1;
+	if ((theLang[i] == 0) || (theLang[i] == '-'))
+	    ret = 1;
     }
 not_equal:
-    xmlFree((void *)theLang);
+    if (theLang != NULL)
+	xmlFree((void *)theLang);
     xmlXPathFreeObject(val);
     valuePush(ctxt, xmlXPathNewBoolean(ret));
 }