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/ChangeLog b/ChangeLog
index 815a9df..87b68fb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Wed Mar 14 19:35:28 HKT 2007 William Brack <wbrack@mmm.com.hk>
+
+	* xmlschemas.c: fixed problem with referenced attribute groups
+	  (bug #417621)
+	* configure.in: re-ordered some includes for types.h / socket.h
+	  (bug #416001)
+
 Fri Mar  9 17:54:40 CET 2007 Daniel Veillard <daniel@veillard.com>
 
 	* xmlreader.c: applied patch from Julien Reichel cleaning up mode
diff --git a/configure.in b/configure.in
index debf196..6075468 100644
--- a/configure.in
+++ b/configure.in
@@ -506,8 +506,8 @@
 if test $enable_ipv6 = yes; then
   have_ipv6=no
   AC_TRY_COMPILE([
-    #include <sys/socket.h>
     #include <sys/types.h>], [
+    #include <sys/socket.h>
     struct sockaddr_storage ss;
     socket(AF_INET6, SOCK_STREAM, 0)
     ],
@@ -529,8 +529,8 @@
     dnl ********************************************************************
     AC_MSG_CHECKING([struct sockaddr::ss_family])
     AC_TRY_COMPILE([
-      #include <sys/socket.h>
       #include <sys/types.h>], [
+      #include <sys/socket.h>
       struct sockaddr_storage ss ;
       ss.ss_family = 0 ;
       ],
@@ -541,8 +541,8 @@
     if test x$have_ss_family = xno ; then
       AC_MSG_CHECKING([broken struct sockaddr::ss_family])
       AC_TRY_COMPILE([
-        #include <sys/socket.h>
         #include <sys/types.h>], [
+        #include <sys/socket.h>
         struct sockaddr_storage ss ;
         ss.__ss_family = 0 ;
         ],
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);
 		}
-	    }	      
+	    }
 	}
 
     }