fixed problem with referenced attribute groups (bug #417621) re-ordered

* xmlschemas.c: fixed problem with referenced attribute groups
  (bug #417621)
* configure.in: re-ordered some includes for types.h / socket.h
  (bug 416001)

svn path=/trunk/; revision=3590
diff --git a/xmlschemas.c b/xmlschemas.c
index 11e3eac..aec901a 100644
--- a/xmlschemas.c
+++ b/xmlschemas.c
@@ -19139,7 +19139,8 @@
 	    * Just remove the reference if the referenced group does not
 	    * contain any attribute uses.
 	    */
-	    if (gr->attrUses == NULL) {
+	    sublist = ((xmlSchemaItemListPtr) gr->attrUses);
+	    if ((sublist == NULL) || sublist->nbItems == 0) {
 		if (xmlSchemaItemListRemove(list, i) == -1)
 		    return(-1);
 		i--;
@@ -19148,18 +19149,15 @@
 	    /*
 	    * Add the attribute uses.
 	    */
-	    sublist = ((xmlSchemaItemListPtr) gr->attrUses);
-	    if (sublist->nbItems != 0) {
-		list->items[i] = sublist->items[0];
-		if (sublist->nbItems != 1) {
-		    for (j = 1; j < sublist->nbItems; j++) {
-			i++;
-			if (xmlSchemaItemListInsert(list,
-				sublist->items[j], i) == -1)
-			    return(-1);
-		    }
+	    list->items[i] = sublist->items[0];
+	    if (sublist->nbItems != 1) {
+		for (j = 1; j < sublist->nbItems; j++) {
+		    i++;
+		    if (xmlSchemaItemListInsert(list,
+			    sublist->items[j], i) == -1)
+			return(-1);
 		}
-	    }	      
+	    }
 	}
 
     }