Fix a bunch of scan 'dead increments' and cleanup

* HTMLparser.c c14n.c debugXML.c entities.c nanohttp.c parser.c
  testC14N.c uri.c xmlcatalog.c xmllint.c xmlregexp.c xpath.c:
  fix unused variables, or unneeded increments as well as a couple
  of space issues
* runtest.c: check for NULL before calling unlink()
diff --git a/HTMLparser.c b/HTMLparser.c
index ceb47fa..f638511 100644
--- a/HTMLparser.c
+++ b/HTMLparser.c
@@ -2560,7 +2560,7 @@
 	    NEXT;
 	}
     }
-    *out++ = 0;
+    *out = 0;
     return(buffer);
 }
 
diff --git a/c14n.c b/c14n.c
index 5c6c456..9c3cad2 100644
--- a/c14n.c
+++ b/c14n.c
@@ -2226,7 +2226,7 @@
         }
         cur++;
     }
-    *out++ = 0;
+    *out = 0;
     return (buffer);
 }
 #endif /* LIBXML_OUTPUT_ENABLED */
diff --git a/debugXML.c b/debugXML.c
index 76134cc..415889a 100644
--- a/debugXML.c
+++ b/debugXML.c
@@ -2803,7 +2803,6 @@
 {
     char prompt[500] = "/ > ";
     char *cmdline = NULL, *cur;
-    int nbargs;
     char command[100];
     char arg[400];
     int i;
@@ -2855,7 +2854,6 @@
          * Parse the command itself
          */
         cur = cmdline;
-        nbargs = 0;
         while ((*cur == ' ') || (*cur == '\t'))
             cur++;
         i = 0;
@@ -2868,7 +2866,6 @@
         command[i] = 0;
         if (i == 0)
             continue;
-        nbargs++;
 
         /*
          * Parse the argument
@@ -2882,8 +2879,6 @@
             arg[i++] = *cur++;
         }
         arg[i] = 0;
-        if (i != 0)
-            nbargs++;
 
         /*
          * start interpreting the command
diff --git a/entities.c b/entities.c
index c171e97..6aef49f 100644
--- a/entities.c
+++ b/entities.c
@@ -690,7 +690,7 @@
 	}
 	cur++;
     }
-    *out++ = 0;
+    *out = 0;
     return(buffer);
 }
 
@@ -772,7 +772,7 @@
 	}
 	cur++;
     }
-    *out++ = 0;
+    *out = 0;
     return(buffer);
 }
 
diff --git a/nanohttp.c b/nanohttp.c
index 9ae3574..9df7a97 100644
--- a/nanohttp.c
+++ b/nanohttp.c
@@ -150,6 +150,7 @@
     int inlen;		/* len of the input buffer */
     int last;		/* return code for last operation */
     int returnValue;	/* the protocol return value */
+    int version;        /* the protocol version */
     int ContentLength;  /* specified content length from HTTP header */
     char *contentType;	/* the MIME type for the input */
     char *location;	/* the new URL in case of redirect */
@@ -722,6 +723,7 @@
 	}
 	if ((*cur != 0) && (*cur != ' ') && (*cur != '\t')) return;
 	ctxt->returnValue = ret;
+        ctxt->version = version;
     } else if (!xmlStrncasecmp(BAD_CAST line, BAD_CAST"Content-Type:", 13)) {
         const xmlChar *charset, *last, *mime;
         cur += 13;
diff --git a/parser.c b/parser.c
index 6d92656..6ae2d77 100644
--- a/parser.c
+++ b/parser.c
@@ -2616,7 +2616,7 @@
 	else
 	    c = 0;
     }
-    buffer[nbchars++] = 0;
+    buffer[nbchars] = 0;
     return(buffer);
 
 mem_error:
diff --git a/runtest.c b/runtest.c
index 1d64695..7640aad 100644
--- a/runtest.c
+++ b/runtest.c
@@ -1704,9 +1704,11 @@
     if (compareFiles(temp, result)) {
         fprintf(stderr, "Got a difference for %s\n", filename);
         ret = 1;
-    } else
-    unlink(temp);
-    free(temp);
+    }
+    if (temp != NULL) {
+        unlink(temp);
+        free(temp);
+    }
 
     /* switch back to structured error handling */
     xmlSetGenericErrorFunc(NULL, NULL);
@@ -1779,8 +1781,10 @@
     }
     xmlFreeDoc(doc);
 
-    unlink(temp);
-    free(temp);
+    if (temp != NULL) {
+        unlink(temp);
+        free(temp);
+    }
     return(res);
 }
 
@@ -1980,8 +1984,10 @@
     }
     xmlFreeDoc(doc);
 
-    unlink(temp);
-    free(temp);
+    if (temp != NULL) {
+        unlink(temp);
+        free(temp);
+    }
     return(res);
 }
 
@@ -2120,8 +2126,10 @@
 	    testErrorHandler(NULL, "Relax-NG schema %s failed to compile\n",
 	                     rng);
 	    fclose(t);
-	    unlink(temp);
-	    free(temp);
+            if (temp != NULL) {
+                unlink(temp);
+                free(temp);
+            }
 	    return(0);
 	}
     }
@@ -2147,8 +2155,10 @@
     if (t != NULL) {
         fclose(t);
 	ret = compareFiles(temp, result);
-	unlink(temp);
-	free(temp);
+        if (temp != NULL) {
+            unlink(temp);
+            free(temp);
+        }
 	if (ret) {
 	    fprintf(stderr, "Result for %s failed\n", filename);
 	    return(-1);
@@ -2357,8 +2367,10 @@
 	}
     }
 
-    unlink(temp);
-    free(temp);
+    if (temp != NULL) {
+        unlink(temp);
+        free(temp);
+    }
     return(ret);
 }
 
@@ -2527,8 +2539,10 @@
 	}
     }
 
-    unlink(temp);
-    free(temp);
+    if (temp != NULL) {
+        unlink(temp);
+        free(temp);
+    }
     xmlFreeDoc(xpathDocument);
 
     if (err != NULL) {
@@ -2614,8 +2628,10 @@
     if (f == NULL) {
 	fprintf(stderr, "failed to open input file %s\n", filename);
 	fclose(o);
-	unlink(temp);
-        free(temp);
+        if (temp != NULL) {
+            unlink(temp);
+            free(temp);
+        }
 	return(-1);
     }
 
@@ -2658,8 +2674,10 @@
 	}
     }
 
-    unlink(temp);
-    free(temp);
+    if (temp != NULL) {
+        unlink(temp);
+        free(temp);
+    }
     return(res);
 }
 
@@ -2933,8 +2951,10 @@
 	    ret = 1;
 	}
     }
-    unlink(temp);
-    free(temp);
+    if (temp != NULL) {
+        unlink(temp);
+        free(temp);
+    }
 
     if ((validResult != 0) && (err != NULL)) {
 	if (compareFileMem(err, testErrors, testErrorsSize)) {
@@ -3106,8 +3126,10 @@
 	    ret = 1;
 	}
     }
-    unlink(temp);
-    free(temp);
+    if (temp != NULL) {
+        unlink(temp);
+        free(temp);
+    }
 
     if (err != NULL) {
 	if (compareFileMem(err, testErrors, testErrorsSize)) {
@@ -3464,7 +3486,7 @@
 		namespaces[j++] = ns->prefix;
 	    }
 	    namespaces[j++] = NULL;
-	    namespaces[j++] = NULL;
+	    namespaces[j] = NULL;
 
 	    patternc = xmlPatterncompile((const xmlChar *) str, doc->dict,
 					 0, &namespaces[0]);
@@ -3512,8 +3534,10 @@
 	fprintf(stderr, "Result for %s failed\n", filename);
 	ret = 1;
     }
-    unlink(temp);
-    free(temp);
+    if (temp != NULL) {
+        unlink(temp);
+        free(temp);
+    }
     return(ret);
 }
 #endif /* READER */
@@ -3643,7 +3667,6 @@
     if((str[0] == '\'') && (str[len - 1] == '\'')) {
 	str[len - 1] = '\0';
 	str++;
-	len -= 2;
     }
     /*
      * allocate an translation buffer.
diff --git a/testC14N.c b/testC14N.c
index ba70127..fbfa869 100644
--- a/testC14N.c
+++ b/testC14N.c
@@ -170,7 +170,7 @@
      */
     xmlCleanupParser();
     xmlMemoryDump();
-    
+
     return((ret >= 0) ? 0 : 1);
 }
 
@@ -180,7 +180,7 @@
 #define growBufferReentrant() {						\
     buffer_size *= 2;							\
     buffer = (xmlChar **)						\
-    		xmlRealloc(buffer, buffer_size * sizeof(xmlChar*));	\
+		xmlRealloc(buffer, buffer_size * sizeof(xmlChar*));	\
     if (buffer == NULL) {						\
 	perror("realloc failed");					\
 	return(NULL);							\
@@ -202,7 +202,6 @@
     if((str[0] == '\'') && (str[len - 1] == '\'')) {
 	str[len - 1] = '\0';
 	str++;
-	len -= 2;
     }
     /*
      * allocate an translation buffer.
@@ -214,7 +213,7 @@
 	return(NULL);
     }
     out = buffer;
-    
+
     while(*str != '\0') {
 	if (out - buffer > buffer_size - 10) {
 	    int indx = out - buffer;
diff --git a/uri.c b/uri.c
index 28401c8..1e5e03f 100644
--- a/uri.c
+++ b/uri.c
@@ -1373,7 +1373,7 @@
 		    }
 		    ret = temp;
     }
-    ret[len++] = 0;
+    ret[len] = 0;
     return(ret);
 }
 
diff --git a/xmlcatalog.c b/xmlcatalog.c
index 6f193b1..489509f 100644
--- a/xmlcatalog.c
+++ b/xmlcatalog.c
@@ -124,7 +124,6 @@
 	    free(cmdline);
 	    continue;
 	}
-	nbargs++;
 
 	/*
 	 * Parse the argument string
@@ -138,8 +137,6 @@
 	    arg[i++] = *cur++;
 	}
 	arg[i] = 0;
-	if (i != 0) 
-	    nbargs++;
 
 	/*
 	 * Parse the arguments
diff --git a/xmllint.c b/xmllint.c
index 9b0b89d..25c6fb9 100644
--- a/xmllint.c
+++ b/xmllint.c
@@ -1990,7 +1990,7 @@
         namespaces[i++] = ns->prefix;
     }
     namespaces[i++] = NULL;
-    namespaces[i++] = NULL;
+    namespaces[i] = NULL;
 
     if (pattern != NULL) {
         patternc = xmlPatterncompile((const xmlChar *) pattern, doc->dict,
diff --git a/xmlregexp.c b/xmlregexp.c
index ac6d8bc..b1f1326 100644
--- a/xmlregexp.c
+++ b/xmlregexp.c
@@ -6923,7 +6923,7 @@
 		    return(0);
             if (nb >= len)
 	        return(-2);
-	    list[nb++] = exp->exp_str;
+	    list[nb] = exp->exp_str;
 	    return(1);
         case XML_EXP_COUNT:
 	    exp = exp->exp_left;
@@ -6978,7 +6978,7 @@
 		    return(0);
             if (nb >= len)
 	        return(-2);
-	    list[nb++] = exp->exp_str;
+	    list[nb] = exp->exp_str;
 	    return(1);
         case XML_EXP_COUNT:
 	    exp = exp->exp_left;
diff --git a/xpath.c b/xpath.c
index a1b7dda..ab130d3 100644
--- a/xpath.c
+++ b/xpath.c
@@ -14505,7 +14505,7 @@
 		    namespaces[i++] = ns->prefix;
 		}
 		namespaces[i++] = NULL;
-		namespaces[i++] = NULL;
+		namespaces[i] = NULL;
 	    }
 	}