Use HAVE_UNISTD_H when including unistd.h.
[idzebra-moved-to-github.git] / index / rank1.c
index df7b7c1..0b1ddfb 100644 (file)
@@ -1,6 +1,6 @@
-/* $Id: rank1.c,v 1.20 2004-11-04 13:09:06 heikki Exp $
-   Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
-   Index Data Aps
+/* $Id: rank1.c,v 1.25 2005-06-14 20:28:54 adam Exp $
+   Copyright (C) 1995-2005
+   Index Data ApS
 
 This file is part of the Zebra server.
 
@@ -20,13 +20,12 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.
 */
 
-
-
 #include <stdio.h>
 #include <assert.h>
 #ifdef WIN32
 #include <io.h>
-#else
+#endif
+#if HAVE_UNISTD_H
 #include <unistd.h>
 #endif
 
@@ -58,9 +57,11 @@ struct rank_set_info {
     NMEM nmem;
 };
 
-static int log2_int (unsigned g)
+static int log2_int (zint g)
 {
     int n = 0;
+    if (g < 0)
+       return 0;
     while ((g = g>>1))
        n++;
     return n;