Index: main/trunk/greenstone2/common-src/indexers/mg/Makefile.in
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/Makefile.in	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/Makefile.in	(revision 25147)
@@ -28,9 +28,9 @@
 
 CC = @CC@
-CFLAGS = @CFLAGS@ @COMPAT32BITFLAGS@ -fpic 
+CFLAGS = @CFLAGS@ -fpic 
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
-LDFLAGS = @LDFLAGS@ @COMPAT32BITFLAGS@ 
+LDFLAGS = @LDFLAGS@ 
 LIBS = @LIBS@  
 TOUCH = echo timestamp >
Index: main/trunk/greenstone2/common-src/indexers/mg/configure
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/configure	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/configure	(revision 25147)
@@ -1,10 +1,10 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.67.
+# Generated by GNU Autoconf 2.65.
 #
 #
 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
-# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
-# Foundation, Inc.
+# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
 #
 #
@@ -317,5 +317,5 @@
     done
     test -z "$as_dirs" || eval "mkdir $as_dirs"
-  } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
+  } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir"
 
 
@@ -357,17 +357,17 @@
 
 
-# as_fn_error STATUS ERROR [LINENO LOG_FD]
-# ----------------------------------------
+# as_fn_error ERROR [LINENO LOG_FD]
+# ---------------------------------
 # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
 # provided, also output the error to LOG_FD, referencing LINENO. Then exit the
-# script with STATUS, using 1 if that was 0.
+# script with status $?, using 1 if that was 0.
 as_fn_error ()
 {
-  as_status=$1; test $as_status -eq 0 && as_status=1
-  if test "$4"; then
-    as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-    $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
+  as_status=$?; test $as_status -eq 0 && as_status=1
+  if test "$3"; then
+    as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+    $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3
   fi
-  $as_echo "$as_me: error: $2" >&2
+  $as_echo "$as_me: error: $1" >&2
   as_fn_exit $as_status
 } # as_fn_error
@@ -531,5 +531,5 @@
 
 # Name of the host.
-# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status,
+# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
 # so uname gets run too.
 ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
@@ -626,5 +626,4 @@
 CXXFLAGS
 CXX
-COMPAT32BITFLAGS
 ENABLE_JAVA
 VERSION
@@ -763,7 +762,6 @@
 
   case $ac_option in
-  *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
-  *=)   ac_optarg= ;;
-  *)    ac_optarg=yes ;;
+  *=*)	ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
+  *)	ac_optarg=yes ;;
   esac
 
@@ -810,5 +808,5 @@
     # Reject names that are not valid shell variable names.
     expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error $? "invalid feature name: $ac_useropt"
+      as_fn_error "invalid feature name: $ac_useropt"
     ac_useropt_orig=$ac_useropt
     ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
@@ -836,5 +834,5 @@
     # Reject names that are not valid shell variable names.
     expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error $? "invalid feature name: $ac_useropt"
+      as_fn_error "invalid feature name: $ac_useropt"
     ac_useropt_orig=$ac_useropt
     ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
@@ -1040,5 +1038,5 @@
     # Reject names that are not valid shell variable names.
     expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error $? "invalid package name: $ac_useropt"
+      as_fn_error "invalid package name: $ac_useropt"
     ac_useropt_orig=$ac_useropt
     ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
@@ -1056,5 +1054,5 @@
     # Reject names that are not valid shell variable names.
     expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error $? "invalid package name: $ac_useropt"
+      as_fn_error "invalid package name: $ac_useropt"
     ac_useropt_orig=$ac_useropt
     ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
@@ -1086,6 +1084,6 @@
     x_libraries=$ac_optarg ;;
 
-  -*) as_fn_error $? "unrecognized option: \`$ac_option'
-Try \`$0 --help' for more information"
+  -*) as_fn_error "unrecognized option: \`$ac_option'
+Try \`$0 --help' for more information."
     ;;
 
@@ -1095,5 +1093,5 @@
     case $ac_envvar in #(
       '' | [0-9]* | *[!_$as_cr_alnum]* )
-      as_fn_error $? "invalid variable name: \`$ac_envvar'" ;;
+      as_fn_error "invalid variable name: \`$ac_envvar'" ;;
     esac
     eval $ac_envvar=\$ac_optarg
@@ -1113,5 +1111,5 @@
 if test -n "$ac_prev"; then
   ac_option=--`echo $ac_prev | sed 's/_/-/g'`
-  as_fn_error $? "missing argument to $ac_option"
+  as_fn_error "missing argument to $ac_option"
 fi
 
@@ -1119,5 +1117,5 @@
   case $enable_option_checking in
     no) ;;
-    fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;;
+    fatal) as_fn_error "unrecognized options: $ac_unrecognized_opts" ;;
     *)     $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
   esac
@@ -1142,5 +1140,5 @@
     NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
   esac
-  as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val"
+  as_fn_error "expected an absolute directory name for --$ac_var: $ac_val"
 done
 
@@ -1156,6 +1154,6 @@
   if test "x$build_alias" = x; then
     cross_compiling=maybe
-    $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host.
-    If a cross compiler is detected then cross compile mode will be used" >&2
+    $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
+    If a cross compiler is detected then cross compile mode will be used." >&2
   elif test "x$build_alias" != "x$host_alias"; then
     cross_compiling=yes
@@ -1172,7 +1170,7 @@
 ac_ls_di=`ls -di .` &&
 ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
-  as_fn_error $? "working directory cannot be determined"
+  as_fn_error "working directory cannot be determined"
 test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
-  as_fn_error $? "pwd does not report name of working directory"
+  as_fn_error "pwd does not report name of working directory"
 
 
@@ -1213,9 +1211,9 @@
 if test ! -r "$srcdir/$ac_unique_file"; then
   test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
-  as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir"
+  as_fn_error "cannot find sources ($ac_unique_file) in $srcdir"
 fi
 ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
 ac_abs_confdir=`(
-	cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg"
+	cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error "$ac_msg"
 	pwd)`
 # When building in place, set srcdir=.
@@ -1257,5 +1255,5 @@
       --help=recursive    display the short help of all the included packages
   -V, --version           display version information and exit
-  -q, --quiet, --silent   do not print \`checking ...' messages
+  -q, --quiet, --silent   do not print \`checking...' messages
       --cache-file=FILE   cache test results in FILE [disabled]
   -C, --config-cache      alias for \`--cache-file=config.cache'
@@ -1413,7 +1411,7 @@
   cat <<\_ACEOF
 configure
-generated by GNU Autoconf 2.67
-
-Copyright (C) 2010 Free Software Foundation, Inc.
+generated by GNU Autoconf 2.65
+
+Copyright (C) 2009 Free Software Foundation, Inc.
 This configure script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it.
@@ -1523,5 +1521,5 @@
   fi
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } > conftest.i && {
+  test $ac_status = 0; } >/dev/null && {
 	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
 	 test ! -s conftest.err
@@ -1547,8 +1545,8 @@
 {
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  if eval "test \"\${$3+set}\"" = set; then :
+  if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
 $as_echo_n "checking for $2... " >&6; }
-if eval "test \"\${$3+set}\"" = set; then :
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
   $as_echo_n "(cached) " >&6
 fi
@@ -1586,5 +1584,5 @@
   ac_header_preproc=no
 fi
-rm -f conftest.err conftest.i conftest.$ac_ext
+rm -f conftest.err conftest.$ac_ext
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
 $as_echo "$ac_header_preproc" >&6; }
@@ -1613,5 +1611,5 @@
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
 $as_echo_n "checking for $2... " >&6; }
-if eval "test \"\${$3+set}\"" = set; then :
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
   $as_echo_n "(cached) " >&6
 else
@@ -1677,5 +1675,5 @@
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
 $as_echo_n "checking for $2... " >&6; }
-if eval "test \"\${$3+set}\"" = set; then :
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
   $as_echo_n "(cached) " >&6
 else
@@ -1754,5 +1752,5 @@
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
 $as_echo_n "checking for $2... " >&6; }
-if eval "test \"\${$3+set}\"" = set; then :
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
   $as_echo_n "(cached) " >&6
 else
@@ -1807,5 +1805,5 @@
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
 $as_echo_n "checking for $2... " >&6; }
-if eval "test \"\${$3+set}\"" = set; then :
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
   $as_echo_n "(cached) " >&6
 else
@@ -1870,5 +1868,5 @@
 
 It was created by $as_me, which was
-generated by GNU Autoconf 2.67.  Invocation command line was
+generated by GNU Autoconf 2.65.  Invocation command line was
 
   $ $0 $@
@@ -1980,7 +1978,9 @@
     echo
 
-    $as_echo "## ---------------- ##
+    cat <<\_ASBOX
+## ---------------- ##
 ## Cache variables. ##
-## ---------------- ##"
+## ---------------- ##
+_ASBOX
     echo
     # The following way of writing the cache mishandles newlines in values,
@@ -2016,7 +2016,9 @@
     echo
 
-    $as_echo "## ----------------- ##
+    cat <<\_ASBOX
+## ----------------- ##
 ## Output variables. ##
-## ----------------- ##"
+## ----------------- ##
+_ASBOX
     echo
     for ac_var in $ac_subst_vars
@@ -2031,7 +2033,9 @@
 
     if test -n "$ac_subst_files"; then
-      $as_echo "## ------------------- ##
+      cat <<\_ASBOX
+## ------------------- ##
 ## File substitutions. ##
-## ------------------- ##"
+## ------------------- ##
+_ASBOX
       echo
       for ac_var in $ac_subst_files
@@ -2047,7 +2051,9 @@
 
     if test -s confdefs.h; then
-      $as_echo "## ----------- ##
+      cat <<\_ASBOX
+## ----------- ##
 ## confdefs.h. ##
-## ----------- ##"
+## ----------- ##
+_ASBOX
       echo
       cat confdefs.h
@@ -2104,10 +2110,5 @@
 ac_site_file2=NONE
 if test -n "$CONFIG_SITE"; then
-  # We do not want a PATH search for config.site.
-  case $CONFIG_SITE in #((
-    -*)  ac_site_file1=./$CONFIG_SITE;;
-    */*) ac_site_file1=$CONFIG_SITE;;
-    *)   ac_site_file1=./$CONFIG_SITE;;
-  esac
+  ac_site_file1=$CONFIG_SITE
 elif test "x$prefix" != xNONE; then
   ac_site_file1=$prefix/share/config.site
@@ -2124,9 +2125,5 @@
 $as_echo "$as_me: loading site script $ac_site_file" >&6;}
     sed 's/^/| /' "$ac_site_file" >&5
-    . "$ac_site_file" \
-      || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "failed to load site script $ac_site_file
-See \`config.log' for more details" "$LINENO" 5 ; }
+    . "$ac_site_file"
   fi
 done
@@ -2204,5 +2201,5 @@
   { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
-  as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
+  as_fn_error "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
 fi
 ## -------------------- ##
@@ -2222,20 +2219,14 @@
 ac_aux_dir=
 for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
-  if test -f "$ac_dir/install-sh"; then
-    ac_aux_dir=$ac_dir
-    ac_install_sh="$ac_aux_dir/install-sh -c"
-    break
-  elif test -f "$ac_dir/install.sh"; then
-    ac_aux_dir=$ac_dir
-    ac_install_sh="$ac_aux_dir/install.sh -c"
-    break
-  elif test -f "$ac_dir/shtool"; then
-    ac_aux_dir=$ac_dir
-    ac_install_sh="$ac_aux_dir/shtool install -c"
-    break
-  fi
+  for ac_t in install-sh install.sh shtool; do
+    if test -f "$ac_dir/$ac_t"; then
+      ac_aux_dir=$ac_dir
+      ac_install_sh="$ac_aux_dir/$ac_t -c"
+      break 2
+    fi
+  done
 done
 if test -z "$ac_aux_dir"; then
-  as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5
+  as_fn_error "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5
 fi
 
@@ -2251,5 +2242,5 @@
 # Make sure we can run config.sub.
 $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
-  as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
+  as_fn_error "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5
@@ -2262,7 +2253,7 @@
   ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
 test "x$ac_build_alias" = x &&
-  as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5
+  as_fn_error "cannot guess build type; you must specify one" "$LINENO" 5
 ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
-  as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
+  as_fn_error "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
 
 fi
@@ -2271,5 +2262,5 @@
 case $ac_cv_build in
 *-*-*) ;;
-*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5 ;;
+*) as_fn_error "invalid value of canonical build" "$LINENO" 5;;
 esac
 build=$ac_cv_build
@@ -2296,5 +2287,5 @@
 else
   ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
-    as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
+    as_fn_error "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
 fi
 
@@ -2304,5 +2295,5 @@
 case $ac_cv_host in
 *-*-*) ;;
-*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5 ;;
+*) as_fn_error "invalid value of canonical host" "$LINENO" 5;;
 esac
 host=$ac_cv_host
@@ -2329,5 +2320,5 @@
 else
   ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` ||
-    as_fn_error $? "$SHELL $ac_aux_dir/config.sub $target_alias failed" "$LINENO" 5
+    as_fn_error "$SHELL $ac_aux_dir/config.sub $target_alias failed" "$LINENO" 5
 fi
 
@@ -2337,5 +2328,5 @@
 case $ac_cv_target in
 *-*-*) ;;
-*) as_fn_error $? "invalid value of canonical target" "$LINENO" 5 ;;
+*) as_fn_error "invalid value of canonical target" "$LINENO" 5;;
 esac
 target=$ac_cv_target
@@ -2402,26 +2393,4 @@
 else
   ENABLE_JAVA=0
-fi
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking to see if architecture is 64-bit" >&5
-$as_echo_n "checking to see if architecture is 64-bit... " >&6; }
-arch_64bit=no
-case "$host_cpu" in
-x86_64) arch_64bit=yes ;;
-esac
-
-if test "$arch_64bit" = yes; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-  if test -z "$COMPAT32BITFLAGS" ; then
-    COMPAT32BITFLAGS="-m32"
-  fi
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-  if test -z "$COMPAT32BITFLAGS" ; then
-    COMPAT32BITFLAGS=
-  fi
 fi
 
@@ -2651,6 +2620,7 @@
 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error 77 "C++ compiler cannot create executables
-See \`config.log' for more details" "$LINENO" 5 ; }
+{ as_fn_set_status 77
+as_fn_error "C++ compiler cannot create executables
+See \`config.log' for more details." "$LINENO" 5; }; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
@@ -2694,6 +2664,6 @@
   { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot compute suffix of executables: cannot compile and link
-See \`config.log' for more details" "$LINENO" 5 ; }
+as_fn_error "cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details." "$LINENO" 5; }
 fi
 rm -f conftest conftest$ac_cv_exeext
@@ -2752,7 +2722,7 @@
 	{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot run C++ compiled programs.
+as_fn_error "cannot run C++ compiled programs.
 If you meant to cross compile, use \`--host'.
-See \`config.log' for more details" "$LINENO" 5 ; }
+See \`config.log' for more details." "$LINENO" 5; }
     fi
   fi
@@ -2805,6 +2775,6 @@
 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot compute suffix of object files: cannot compile
-See \`config.log' for more details" "$LINENO" 5 ; }
+as_fn_error "cannot compute suffix of object files: cannot compile
+See \`config.log' for more details." "$LINENO" 5; }
 fi
 rm -f conftest.$ac_cv_objext conftest.$ac_ext
@@ -3320,6 +3290,6 @@
 test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "no acceptable C compiler found in \$PATH
-See \`config.log' for more details" "$LINENO" 5 ; }
+as_fn_error "no acceptable C compiler found in \$PATH
+See \`config.log' for more details." "$LINENO" 5; }
 
 # Provide some information about the compiler.
@@ -3668,5 +3638,5 @@
 set x ${MAKE-make}
 ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
-if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\"" = set; then :
+if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then :
   $as_echo_n "(cached) " >&6
 else
@@ -3676,5 +3646,5 @@
 	@echo '@@@%%%=$(MAKE)=@@@%%%'
 _ACEOF
-# GNU make sometimes prints "make[1]: Entering ...", which would confuse us.
+# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
 case `${MAKE-make} -f conftest.make 2>/dev/null` in
   *@@@%%%=?*=@@@%%%*)
@@ -3879,5 +3849,5 @@
 
 	fi
-	test x$JAVA = x && as_fn_error $? "no acceptable Java virtual machine found in \$PATH" "$LINENO" 5
+	test x$JAVA = x && as_fn_error "no acceptable Java virtual machine found in \$PATH" "$LINENO" 5
 fi
 
@@ -3941,5 +3911,5 @@
         ac_cv_prog_uudecode_base64=yes
 else
-        echo "configure: 3943: uudecode had trouble decoding base 64 file 'Test.uue'" >&5
+        echo "configure: 3913: uudecode had trouble decoding base 64 file 'Test.uue'" >&5
         echo "configure: failed file was:" >&5
         cat Test.uue >&5
@@ -3956,5 +3926,5 @@
 $as_echo "$as_me: WARNING: I have to compile Test.class from scratch" >&2;}
         if test x$ac_cv_prog_javac_works = xno; then
-                as_fn_error $? "Cannot compile java source. $JAVAC does not work properly" "$LINENO" 5
+                as_fn_error "Cannot compile java source. $JAVAC does not work properly" "$LINENO" 5
         fi
         if test x$ac_cv_prog_javac_works = x; then
@@ -4049,5 +4019,5 @@
 
   fi
-  test "x$JAVAC" = x && as_fn_error $? "no acceptable Java compiler found in \$PATH" "$LINENO" 5
+  test "x$JAVAC" = x && as_fn_error "no acceptable Java compiler found in \$PATH" "$LINENO" 5
 else
   echo "Checking for javac... $JAVAC"
@@ -4064,5 +4034,5 @@
 CLASS_TEST=Test.class
 cat << \EOF > $JAVA_TEST
-/* #line 4066 "configure" */
+/* #line 4036 "configure" */
 public class Test {
 }
@@ -4076,5 +4046,5 @@
   ac_cv_prog_javac_works=yes
 else
-  as_fn_error $? "The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?)" "$LINENO" 5
+  as_fn_error "The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?)" "$LINENO" 5
   echo "configure: failed program was:" >&5
   cat $JAVA_TEST >&5
@@ -4103,5 +4073,5 @@
 TEST=Test
 cat << \EOF > $JAVA_TEST
-/* [#]line 4105 "configure" */
+/* [#]line 4075 "configure" */
 public class Test {
 public static void main (String args[]) {
@@ -4120,5 +4090,5 @@
           echo "configure: failed program was:" >&5
           cat $JAVA_TEST >&5
-          as_fn_error $? "The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?)" "$LINENO" 5
+          as_fn_error "The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?)" "$LINENO" 5
         fi
 fi
@@ -4133,5 +4103,5 @@
   echo "configure: failed program was:" >&5
   cat $JAVA_TEST >&5
-  as_fn_error $? "The Java VM $JAVA failed (see config.log, check the CLASSPATH?)" "$LINENO" 5
+  as_fn_error "The Java VM $JAVA failed (see config.log, check the CLASSPATH?)" "$LINENO" 5
 fi
 rm -fr $JAVA_TEST $CLASS_TEST Test.uue
@@ -4233,5 +4203,5 @@
 
   fi
-  test "x$JAVAC" = x && as_fn_error $? "no acceptable Java compiler found in \$PATH" "$LINENO" 5
+  test "x$JAVAC" = x && as_fn_error "no acceptable Java compiler found in \$PATH" "$LINENO" 5
 else
   echo "Checking for javac... $JAVAC"
@@ -4248,5 +4218,5 @@
 CLASS_TEST=Test.class
 cat << \EOF > $JAVA_TEST
-/* #line 4250 "configure" */
+/* #line 4220 "configure" */
 public class Test {
 }
@@ -4260,5 +4230,5 @@
   ac_cv_prog_javac_works=yes
 else
-  as_fn_error $? "The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?)" "$LINENO" 5
+  as_fn_error "The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?)" "$LINENO" 5
   echo "configure: failed program was:" >&5
   cat $JAVA_TEST >&5
@@ -4320,5 +4290,5 @@
 continue
 fi
-rm -f conftest.err conftest.i conftest.$ac_ext
+rm -f conftest.err conftest.$ac_ext
 
   # OK, works on sane cases.  Now check whether nonexistent headers
@@ -4336,9 +4306,9 @@
 break
 fi
-rm -f conftest.err conftest.i conftest.$ac_ext
+rm -f conftest.err conftest.$ac_ext
 
 done
 # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.i conftest.err conftest.$ac_ext
+rm -f conftest.err conftest.$ac_ext
 if $ac_preproc_ok; then :
   break
@@ -4379,5 +4349,5 @@
 continue
 fi
-rm -f conftest.err conftest.i conftest.$ac_ext
+rm -f conftest.err conftest.$ac_ext
 
   # OK, works on sane cases.  Now check whether nonexistent headers
@@ -4395,9 +4365,9 @@
 break
 fi
-rm -f conftest.err conftest.i conftest.$ac_ext
+rm -f conftest.err conftest.$ac_ext
 
 done
 # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.i conftest.err conftest.$ac_ext
+rm -f conftest.err conftest.$ac_ext
 if $ac_preproc_ok; then :
 
@@ -4405,6 +4375,6 @@
   { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
-See \`config.log' for more details" "$LINENO" 5 ; }
+as_fn_error "C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." "$LINENO" 5; }
 fi
 
@@ -4467,5 +4437,5 @@
 IFS=$as_save_IFS
   if test -z "$ac_cv_path_GREP"; then
-    as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+    as_fn_error "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
   fi
 else
@@ -4533,5 +4503,5 @@
 IFS=$as_save_IFS
   if test -z "$ac_cv_path_EGREP"; then
-    as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+    as_fn_error "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
   fi
 else
@@ -4665,5 +4635,6 @@
 ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
 "
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
@@ -5097,5 +5068,5 @@
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_hdr that defines DIR" >&5
 $as_echo_n "checking for $ac_hdr that defines DIR... " >&6; }
-if eval "test \"\${$as_ac_Header+set}\"" = set; then :
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then :
   $as_echo_n "(cached) " >&6
 else
@@ -5124,5 +5095,6 @@
 	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
 $as_echo "$ac_res" >&6; }
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_hdr" | $as_tr_cpp` 1
@@ -5366,5 +5338,6 @@
   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
 ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
@@ -5539,5 +5512,6 @@
     as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+eval as_val=\$$as_ac_var
+   if test "x$as_val" = x""yes; then :
 
 cat >>confdefs.h <<_ACEOF
@@ -5699,5 +5673,6 @@
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+eval as_val=\$$as_ac_var
+   if test "x$as_val" = x""yes; then :
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
@@ -5707,42 +5682,23 @@
 done
 
-ac_fn_c_check_func "$LINENO" "ftruncate" "ac_cv_func_ftruncate"
-if test "x$ac_cv_func_ftruncate" = x""yes; then :
-  $as_echo "#define HAVE_FTRUNCATE 1" >>confdefs.h
+for ac_func in ftruncate strstr strcasecmp
+do :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+eval as_val=\$$as_ac_var
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
 
 else
   case " $LIBOBJS " in
-  *" ftruncate.$ac_objext "* ) ;;
-  *) LIBOBJS="$LIBOBJS ftruncate.$ac_objext"
+  *" $ac_func.$ac_objext "* ) ;;
+  *) LIBOBJS="$LIBOBJS $ac_func.$ac_objext"
  ;;
 esac
 
 fi
-
-ac_fn_c_check_func "$LINENO" "strstr" "ac_cv_func_strstr"
-if test "x$ac_cv_func_strstr" = x""yes; then :
-  $as_echo "#define HAVE_STRSTR 1" >>confdefs.h
-
-else
-  case " $LIBOBJS " in
-  *" strstr.$ac_objext "* ) ;;
-  *) LIBOBJS="$LIBOBJS strstr.$ac_objext"
- ;;
-esac
-
-fi
-
-ac_fn_c_check_func "$LINENO" "strcasecmp" "ac_cv_func_strcasecmp"
-if test "x$ac_cv_func_strcasecmp" = x""yes; then :
-  $as_echo "#define HAVE_STRCASECMP 1" >>confdefs.h
-
-else
-  case " $LIBOBJS " in
-  *" strcasecmp.$ac_objext "* ) ;;
-  *) LIBOBJS="$LIBOBJS strcasecmp.$ac_objext"
- ;;
-esac
-
-fi
+done
 
 
@@ -6093,6 +6049,6 @@
      ;; #(
    *)
-     as_fn_error $? "unknown endianness
- presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5  ;;
+     as_fn_error "unknown endianness
+ presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;;
  esac
 
@@ -6204,5 +6160,4 @@
 ac_libobjs=
 ac_ltlibobjs=
-U=
 for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
   # 1. Remove the extension, and $U if already installed.
@@ -6367,17 +6322,17 @@
 
 
-# as_fn_error STATUS ERROR [LINENO LOG_FD]
-# ----------------------------------------
+# as_fn_error ERROR [LINENO LOG_FD]
+# ---------------------------------
 # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
 # provided, also output the error to LOG_FD, referencing LINENO. Then exit the
-# script with STATUS, using 1 if that was 0.
+# script with status $?, using 1 if that was 0.
 as_fn_error ()
 {
-  as_status=$1; test $as_status -eq 0 && as_status=1
-  if test "$4"; then
-    as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-    $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
+  as_status=$?; test $as_status -eq 0 && as_status=1
+  if test "$3"; then
+    as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+    $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3
   fi
-  $as_echo "$as_me: error: $2" >&2
+  $as_echo "$as_me: error: $1" >&2
   as_fn_exit $as_status
 } # as_fn_error
@@ -6575,5 +6530,5 @@
     done
     test -z "$as_dirs" || eval "mkdir $as_dirs"
-  } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
+  } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir"
 
 
@@ -6629,5 +6584,5 @@
 ac_log="
 This file was extended by $as_me, which was
-generated by GNU Autoconf 2.67.  Invocation command line was
+generated by GNU Autoconf 2.65.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -6695,8 +6650,8 @@
 ac_cs_version="\\
 config.status
-configured by $0, generated by GNU Autoconf 2.67,
+configured by $0, generated by GNU Autoconf 2.65,
   with options \\"\$ac_cs_config\\"
 
-Copyright (C) 2010 Free Software Foundation, Inc.
+Copyright (C) 2009 Free Software Foundation, Inc.
 This config.status script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it."
@@ -6715,12 +6670,7 @@
 do
   case $1 in
-  --*=?*)
+  --*=*)
     ac_option=`expr "X$1" : 'X\([^=]*\)='`
     ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
-    ac_shift=:
-    ;;
-  --*=)
-    ac_option=`expr "X$1" : 'X\([^=]*\)='`
-    ac_optarg=
     ac_shift=:
     ;;
@@ -6746,5 +6696,4 @@
     case $ac_optarg in
     *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
-    '') as_fn_error $? "missing file argument" ;;
     esac
     as_fn_append CONFIG_FILES " '$ac_optarg'"
@@ -6759,5 +6708,5 @@
   --he | --h)
     # Conflict between --help and --header
-    as_fn_error $? "ambiguous option: \`$1'
+    as_fn_error "ambiguous option: \`$1'
 Try \`$0 --help' for more information.";;
   --help | --hel | -h )
@@ -6768,5 +6717,5 @@
 
   # This is an error.
-  -*) as_fn_error $? "unrecognized option: \`$1'
+  -*) as_fn_error "unrecognized option: \`$1'
 Try \`$0 --help' for more information." ;;
 
@@ -6825,5 +6774,5 @@
     "default") CONFIG_COMMANDS="$CONFIG_COMMANDS default" ;;
 
-  *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5 ;;
+  *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
   esac
 done
@@ -6863,5 +6812,5 @@
   tmp=./conf$$-$RANDOM
   (umask 077 && mkdir "$tmp")
-} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5
+} || as_fn_error "cannot create a temporary directory in ." "$LINENO" 5
 
 # Set up the scripts for CONFIG_FILES section.
@@ -6880,5 +6829,5 @@
 ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
 if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
-  ac_cs_awk_cr='\\r'
+  ac_cs_awk_cr='\r'
 else
   ac_cs_awk_cr=$ac_cr
@@ -6894,10 +6843,10 @@
   echo "_ACEOF"
 } >conf$$subs.sh ||
-  as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
-ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'`
+  as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
+ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'`
 ac_delim='%!_!# '
 for ac_last_try in false false false false false :; do
   . ./conf$$subs.sh ||
-    as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+    as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
 
   ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
@@ -6905,5 +6854,5 @@
     break
   elif $ac_last_try; then
-    as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+    as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
   else
     ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
@@ -6994,26 +6943,18 @@
   cat
 fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \
-  || as_fn_error $? "could not setup config files machinery" "$LINENO" 5
-_ACEOF
-
-# VPATH may cause trouble with some makes, so we remove sole $(srcdir),
-# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and
+  || as_fn_error "could not setup config files machinery" "$LINENO" 5
+_ACEOF
+
+# VPATH may cause trouble with some makes, so we remove $(srcdir),
+# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
 # trailing colons and then remove the whole line if VPATH becomes empty
 # (actually we leave an empty line to preserve line numbers).
 if test "x$srcdir" = x.; then
-  ac_vpsub='/^[	 ]*VPATH[	 ]*=[	 ]*/{
-h
-s///
-s/^/:/
-s/[	 ]*$/:/
-s/:\$(srcdir):/:/g
-s/:\${srcdir}:/:/g
-s/:@srcdir@:/:/g
-s/^:*//
+  ac_vpsub='/^[	 ]*VPATH[	 ]*=/{
+s/:*\$(srcdir):*/:/
+s/:*\${srcdir}:*/:/
+s/:*@srcdir@:*/:/
+s/^\([^=]*=[	 ]*\):*/\1/
 s/:*$//
-x
-s/\(=[	 ]*\).*/\1/
-G
-s/\n//
 s/^[^=]*=[	 ]*$//
 }'
@@ -7043,5 +6984,5 @@
     break
   elif $ac_last_try; then
-    as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5
+    as_fn_error "could not make $CONFIG_HEADERS" "$LINENO" 5
   else
     ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
@@ -7128,5 +7069,5 @@
 _ACEOF
 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-  as_fn_error $? "could not setup config headers machinery" "$LINENO" 5
+  as_fn_error "could not setup config headers machinery" "$LINENO" 5
 fi # test -n "$CONFIG_HEADERS"
 
@@ -7141,5 +7082,5 @@
   case $ac_mode$ac_tag in
   :[FHL]*:*);;
-  :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5 ;;
+  :L* | :C*:*) as_fn_error "invalid tag \`$ac_tag'" "$LINENO" 5;;
   :[FH]-) ac_tag=-:-;;
   :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
@@ -7169,5 +7110,5 @@
 	   *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
 	   esac ||
-	   as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5 ;;
+	   as_fn_error "cannot find input file: \`$ac_f'" "$LINENO" 5;;
       esac
       case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
@@ -7196,5 +7137,5 @@
     case $ac_tag in
     *:-:* | *:-) cat >"$tmp/stdin" \
-      || as_fn_error $? "could not create $ac_file" "$LINENO" 5  ;;
+      || as_fn_error "could not create $ac_file" "$LINENO" 5 ;;
     esac
     ;;
@@ -7327,5 +7268,5 @@
 "
 eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \
-  || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+  || as_fn_error "could not create $ac_file" "$LINENO" 5
 
 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
@@ -7333,7 +7274,7 @@
   { ac_out=`sed -n '/^[	 ]*datarootdir[	 ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } &&
   { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
-which seems to be undefined.  Please make sure it is defined" >&5
+which seems to be undefined.  Please make sure it is defined." >&5
 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
-which seems to be undefined.  Please make sure it is defined" >&2;}
+which seems to be undefined.  Please make sure it is defined." >&2;}
 
   rm -f "$tmp/stdin"
@@ -7342,5 +7283,5 @@
   *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";;
   esac \
-  || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+  || as_fn_error "could not create $ac_file" "$LINENO" 5
  ;;
   :H)
@@ -7353,5 +7294,5 @@
       && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs"
     } >"$tmp/config.h" \
-      || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+      || as_fn_error "could not create $ac_file" "$LINENO" 5
     if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5
@@ -7360,10 +7301,10 @@
       rm -f "$ac_file"
       mv "$tmp/config.h" "$ac_file" \
-	|| as_fn_error $? "could not create $ac_file" "$LINENO" 5
+	|| as_fn_error "could not create $ac_file" "$LINENO" 5
     fi
   else
     $as_echo "/* $configure_input  */" \
       && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \
-      || as_fn_error $? "could not create -" "$LINENO" 5
+      || as_fn_error "could not create -" "$LINENO" 5
   fi
  ;;
@@ -7387,5 +7328,5 @@
 
 test $ac_write_fail = 0 ||
-  as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5
+  as_fn_error "write failure creating $CONFIG_STATUS" "$LINENO" 5
 
 
@@ -7408,5 +7349,5 @@
   # Use ||, not &&, to avoid exiting from the if with $? = 1, which
   # would make configure fail if this is the last instruction.
-  $ac_cs_success || as_fn_exit 1
+  $ac_cs_success || as_fn_exit $?
 fi
 if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
Index: main/trunk/greenstone2/common-src/indexers/mg/configure.in
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/configure.in	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/configure.in	(revision 25147)
@@ -34,23 +34,9 @@
 AC_SUBST(ENABLE_JAVA)
 
-AC_MSG_CHECKING(to see if architecture is 64-bit)
-arch_64bit=no
-case "$host_cpu" in
-x86_64) arch_64bit=yes ;;
-esac
-
-if test "$arch_64bit" = yes; then
-  AC_MSG_RESULT(yes)
-  if test -z "$COMPAT32BITFLAGS" ; then
-    COMPAT32BITFLAGS="-m32"
-  fi
-else
-  AC_MSG_RESULT(no)
-  if test -z "$COMPAT32BITFLAGS" ; then
-    COMPAT32BITFLAGS=
-  fi
-fi
-AC_SUBST(COMPAT32BITFLAGS)
-
+dnl AC_MSG_CHECKING(to see if architecture is 64-bit)
+dnl arch_64bit=no
+dnl case "$host_cpu" in
+dnl x86_64) arch_64bit=yes ;;
+dnl esac
 
 dnl Checks for programs.
Index: main/trunk/greenstone2/common-src/indexers/mg/java/org/greenstone/mg/Makefile.in
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/java/org/greenstone/mg/Makefile.in	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/java/org/greenstone/mg/Makefile.in	(revision 25147)
@@ -17,6 +17,6 @@
 JAVAH = javah
 JAR = jar
-CFLAGS = @CFLAGS@ @COMPAT32BITFLAGS@ -ansi -DSILENT -DSHORT_SUFFIX
-CXXFLAGS = @CXXFLAGS@ @COMPAT32BITFLAGS@ -DSILENT -DSHORT_SUFFIX
+CFLAGS = @CFLAGS@ -ansi -DSILENT -DSHORT_SUFFIX
+CXXFLAGS = @CXXFLAGS@ -DSILENT -DSHORT_SUFFIX
 JAVACFLAGS = @JAVACFLAGS@
 DEFS = @DEFS@
@@ -25,5 +25,5 @@
 INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
-LDFLAGS = @LDFLAGS@ @COMPAT32BITFLAGS@
+LDFLAGS = @LDFLAGS@
 LIBS =  -lstdc++ @LIBS@
 TOUCH = echo timestamp >
Index: main/trunk/greenstone2/common-src/indexers/mg/jni/MGRetrieveWrapperImpl.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/jni/MGRetrieveWrapperImpl.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/jni/MGRetrieveWrapperImpl.c	(revision 25147)
@@ -180,5 +180,5 @@
 
   /* Save the object on the Java side */
-  (*j_env)->SetIntField(j_env, j_obj, FID_mg_data, (long) data);
+  (*j_env)->SetIntField(j_env, j_obj, FID_mg_data, (mg_s_long) data);
 
   /* Initialise MG environment variables */
@@ -250,5 +250,5 @@
   query_data* qd;
 
-  u_long pos, len;
+  mg_u_long pos, len;
   u_char* c_buffer = NULL;
   u_char* uc_buffer = NULL;
@@ -287,7 +287,7 @@
 
   /* Get the document position and length in the text file */
-  printf("Fetching document number %ld...\n", (unsigned long) j_docnum);
-  FetchDocStart(qd, (unsigned long) j_docnum, &pos, &len);
-  printf("Fetched document start. Pos: %ld, Len: %ld\n", pos, len);
+  printf("Fetching document number %d...\n", (mg_u_long) j_docnum);
+  FetchDocStart(qd, (mg_u_long) j_docnum, &pos, &len);
+  printf("Fetched document start. Pos: %d, Len: %d\n", pos, len);
 
   /* Allocate memory for the document text (from mg/src/text/mgquery.c:RawDocOutput()) */
Index: main/trunk/greenstone2/common-src/indexers/mg/jni/MGSearchWrapperImpl.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/jni/MGSearchWrapperImpl.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/jni/MGSearchWrapperImpl.c	(revision 25147)
@@ -619,5 +619,5 @@
 
   /* Print the data to a character array */
-  sprintf(result, "Query params:\nindex\t\t%s\ncasefold\t%d\nstem\t\t%d\nquery type\t%s\nmax docs\t%ld\n",
+  sprintf(result, "Query params:\nindex\t\t%s\ncasefold\t%d\nstem\t\t%d\nquery type\t%s\nmax docs\t%d\n",
 	  (data->queryInfo->index == NULL ? "<none loaded>" : data->queryInfo->index),
 	  (data->defaultStemMethod & 1),
Index: main/trunk/greenstone2/common-src/indexers/mg/jni/MGWrapperImpl.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/jni/MGWrapperImpl.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/jni/MGWrapperImpl.c	(revision 25147)
@@ -168,5 +168,5 @@
 
   /* Save the object on the Java side */
-  (*j_env)->SetIntField(j_env, j_obj, FID_mg_data, (long) data);
+  (*j_env)->SetIntField(j_env, j_obj, FID_mg_data, (mg_s_long) data);
 
   /* Initialise MG environment variables */
@@ -285,5 +285,5 @@
   query_data* qd;
 
-  u_long pos, len;
+  mg_u_long pos, len;
   u_char* c_buffer = NULL;
   u_char* uc_buffer = NULL;
@@ -322,7 +322,7 @@
 
   /* Get the document position and length in the text file */
-  printf("Fetching document number %ld...\n", (unsigned long) j_docnum);
-  FetchDocStart(qd, (unsigned long) j_docnum, &pos, &len);
-  printf("Fetched document start. Pos: %ld, Len: %ld\n", pos, len);
+  printf("Fetching document number %d...\n", (mg_u_long) j_docnum);
+  FetchDocStart(qd, (mg_u_long) j_docnum, &pos, &len);
+  printf("Fetched document start. Pos: %d, Len: %d\n", pos, len);
 
   /* Allocate memory for the document text (from mg/src/text/mgquery.c:RawDocOutput()) */
@@ -730,5 +730,5 @@
 
   /* Print the data to a character array */
-  sprintf(result, "Query params:\nindex\t\t%s\ncasefold\t%d\nstem\t\t%d\nquery type\t%s\nmax docs\t%ld\n",
+  sprintf(result, "Query params:\nindex\t\t%s\ncasefold\t%d\nstem\t\t%d\nquery type\t%s\nmax docs\t%d\n",
 	  (data->queryInfo->index == NULL ? "<none loaded>" : data->queryInfo->index),
 	  (data->defaultStemMethod & 1),
Index: main/trunk/greenstone2/common-src/indexers/mg/jni/MGWrapperImpl.h
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/jni/MGWrapperImpl.h	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/jni/MGWrapperImpl.h	(revision 25147)
@@ -36,5 +36,5 @@
   char* index;
   /* Maximum number of documents to retrieve */
-  unsigned long maxDocs;
+  mg_u_long maxDocs;
   /* Whether term frequency information is desired (boolean value) */
   int needTermFreqs;
Index: main/trunk/greenstone2/common-src/indexers/mg/jni/Makefile.in
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/jni/Makefile.in	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/jni/Makefile.in	(revision 25147)
@@ -14,5 +14,5 @@
 AR = ar
 CC = @CC@
-CFLAGS = @CFLAGS@ @COMPAT32BITFLAGS@ -ansi -fpic -DSILENT -DSHORT_SUFFIX -DNZDL -DQUIET -DPARADOCNUM
+CFLAGS = @CFLAGS@ -ansi -fpic -DSILENT -DSHORT_SUFFIX -DNZDL -DQUIET -DPARADOCNUM
 DEFS = @DEFS@
 RANLIB = @RANLIB@
@@ -20,5 +20,5 @@
 INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
-LDFLAGS = @LDFLAGS@ @COMPAT32BITFLAGS@
+LDFLAGS = @LDFLAGS@
 #NOTE: libmgtext.a needs to come before libmglib.a !!!
 QUERY_LIBS = ../src/text/libmgtext.a ../lib/libmglib.a @LIBS@
Index: main/trunk/greenstone2/common-src/indexers/mg/lib/Makefile.in
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/lib/Makefile.in	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/lib/Makefile.in	(revision 25147)
@@ -34,5 +34,5 @@
 AR = ar
 CC = @CC@
-CFLAGS = @CFLAGS@ @COMPAT32BITFLAGS@ -fpic 
+CFLAGS = @CFLAGS@ -fpic 
 DEFS = @DEFS@
 RANLIB = @RANLIB@
@@ -41,5 +41,5 @@
 # Uncomment for compiling for the nzdl project
 #
-CFLAGS = @CFLAGS@ @COMPAT32BITFLAGS@ -DQUIET -fpic
+CFLAGS = @CFLAGS@ -DQUIET -fpic
 ##########################################
 
Index: main/trunk/greenstone2/common-src/indexers/mg/lib/bitio_gen.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/lib/bitio_gen.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/lib/bitio_gen.c	(revision 25147)
@@ -28,8 +28,8 @@
 int fprintf (FILE *, const char *,...);
 
-unsigned long 
-BIO_Unary_Length (unsigned long val)
+mg_u_long 
+BIO_Unary_Length (mg_u_long val)
 {
-  register unsigned long num;
+  register mg_u_long num;
   UNARY_LENGTH (val, num);
   return (num);
@@ -37,8 +37,8 @@
 
 
-unsigned long 
-BIO_Binary_Length (unsigned long val, unsigned long b)
+mg_u_long 
+BIO_Binary_Length (mg_u_long val, mg_u_long b)
 {
-  register unsigned long num;
+  register mg_u_long num;
   BINARY_LENGTH (val, b, num);
   return (num);
@@ -46,8 +46,8 @@
 
 
-unsigned long 
-BIO_Gamma_Length (unsigned long val)
+mg_u_long 
+BIO_Gamma_Length (mg_u_long val)
 {
-  register unsigned long num;
+  register mg_u_long num;
   GAMMA_LENGTH (val, num);
   return (num);
@@ -55,8 +55,8 @@
 
 
-unsigned long 
-BIO_Delta_Length (unsigned long val)
+mg_u_long 
+BIO_Delta_Length (mg_u_long val)
 {
-  register unsigned long num;
+  register mg_u_long num;
   DELTA_LENGTH (val, num);
   return (num);
@@ -64,16 +64,16 @@
 
 
-unsigned long 
-BIO_Elias_Length (unsigned long val, unsigned long b, double s)
+mg_u_long 
+BIO_Elias_Length (mg_u_long val, mg_u_long b, double s)
 {
-  register unsigned long num;
+  register mg_u_long num;
   ELIAS_LENGTH (val, b, s, num);
   return (num);
 }
 
-unsigned long 
-BIO_Bblock_Length (unsigned long val, unsigned long b)
+mg_u_long 
+BIO_Bblock_Length (mg_u_long val, mg_u_long b)
 {
-  register unsigned long num;
+  register mg_u_long num;
   BBLOCK_LENGTH (val, b, num);
   return (num);
Index: main/trunk/greenstone2/common-src/indexers/mg/lib/bitio_gen.h
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/lib/bitio_gen.h	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/lib/bitio_gen.h	(revision 25147)
@@ -33,15 +33,15 @@
 #define H_BITIO_GEN
 
-unsigned long BIO_Unary_Length (unsigned long val);
+mg_u_long BIO_Unary_Length (mg_u_long val);
 
-unsigned long BIO_Binary_Length (unsigned long val, unsigned long b);
+mg_u_long BIO_Binary_Length (mg_u_long val, mg_u_long b);
 
-unsigned long BIO_Gamma_Length (unsigned long val);
+mg_u_long BIO_Gamma_Length (mg_u_long val);
 
-unsigned long BIO_Delta_Length (unsigned long val);
+mg_u_long BIO_Delta_Length (mg_u_long val);
 
-unsigned long BIO_Elias_Length (unsigned long val, unsigned long b, double s);
+mg_u_long BIO_Elias_Length (mg_u_long val, mg_u_long b, double s);
 
-unsigned long BIO_Bblock_Length (unsigned long val, unsigned long b);
+mg_u_long BIO_Bblock_Length (mg_u_long val, mg_u_long b);
 
 int BIO_Bblock_Init (int N, int p);
Index: main/trunk/greenstone2/common-src/indexers/mg/lib/bitio_m.h
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/lib/bitio_m.h	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/lib/bitio_m.h	(revision 25147)
@@ -50,5 +50,5 @@
 #define POSITIVE(f, x)							\
   if ((x)<=0) 								\
-    fprintf(stderr,"Error: Cannot "#f" encode %lu\n",(unsigned long)x),exit(1);
+    fprintf(stderr,"Error: Cannot "#f" encode %d\n",(mg_u_long)x),exit(1);
 
 
@@ -75,5 +75,5 @@
 #define UNARY_ENCODE(x)							\
 do {									\
-  register unsigned long _B_x = (x);					\
+  register mg_u_long _B_x = (x);					\
   BIO_ENCODE_PROLOGUE;							\
   POSITIVE(unary, _B_x);						\
@@ -85,5 +85,5 @@
 #define UNARY_ENCODE_L(x, count)					\
 do {									\
-  register unsigned long _B_x = (x);					\
+  register mg_u_long _B_x = (x);					\
   BIO_ENCODE_PROLOGUE;							\
   POSITIVE(unary, _B_x);						\
@@ -124,6 +124,6 @@
 #define BINARY_ENCODE(x, b)						\
 do {									\
-  register unsigned long _B_x = (x);					\
-  register unsigned long _B_b = (b);					\
+  register mg_u_long _B_x = (x);					\
+  register mg_u_long _B_b = (b);					\
   register int _B_nbits, _B_logofb, _B_thresh;				\
   BIO_ENCODE_PROLOGUE;							\
@@ -145,6 +145,6 @@
 #define BINARY_ENCODE_L(x, b, count)					\
 do {									\
-  register unsigned long _B_x = (x);					\
-  register unsigned long _B_b = (b);					\
+  register mg_u_long _B_x = (x);					\
+  register mg_u_long _B_b = (b);					\
   register int _B_nbits, _B_logofb, _B_thresh;				\
   BIO_ENCODE_PROLOGUE;							\
@@ -168,6 +168,6 @@
 #define BINARY_DECODE(x, b)						\
 do {									\
-  register unsigned long _B_x = 0;					\
-  register unsigned long _B_b = (b);					\
+  register mg_u_long _B_x = 0;					\
+  register mg_u_long _B_b = (b);					\
   register int _B_i, _B_logofb, _B_thresh;				\
   BIO_DECODE_PROLOGUE;							\
@@ -193,6 +193,6 @@
 #define BINARY_DECODE_L(x, b, count)					\
 do {									\
-  register unsigned long _B_x = 0;					\
-  register unsigned long _B_b = (b);					\
+  register mg_u_long _B_x = 0;					\
+  register mg_u_long _B_b = (b);					\
   register int _B_i, _B_logofb, _B_thresh;				\
   BIO_DECODE_PROLOGUE;							\
@@ -220,6 +220,6 @@
 #define BINARY_LENGTH(x, b, count)					\
 do {									\
-  register unsigned long _B_x = (x);					\
-  register unsigned long _B_b = (b);					\
+  register mg_u_long _B_x = (x);					\
+  register mg_u_long _B_b = (b);					\
   register int _B_nbits, _B_logofb, _B_thresh;				\
   POSITIVE(binary, _B_x);						\
@@ -240,5 +240,5 @@
 #define GAMMA_ENCODE(x)							\
 do {									\
-  register unsigned long _B_xx = (x);					\
+  register mg_u_long _B_xx = (x);					\
   register int _B_logofb;						\
   register int _B_nbits;						\
@@ -255,5 +255,5 @@
 #define GAMMA_ENCODE_L(x, count)					\
 do {									\
-  register unsigned long _B_xx = (x);					\
+  register mg_u_long _B_xx = (x);					\
   register int _B_logofb;						\
   register int _B_nbits;						\
@@ -271,5 +271,5 @@
 #define GAMMA_DECODE(x)							\
 do {									\
-  register unsigned long _B_xx = 1;					\
+  register mg_u_long _B_xx = 1;					\
   register int _B_nbits = 0;						\
   BIO_DECODE_PROLOGUE;							\
@@ -283,5 +283,5 @@
 #define GAMMA_DECODE_L(x, count)					\
 do {									\
-  register unsigned long _B_xx = 1;					\
+  register mg_u_long _B_xx = 1;					\
   register int _B_nbits = 0;						\
   BIO_DECODE_PROLOGUE;							\
@@ -296,5 +296,5 @@
 #define GAMMA_LENGTH(x, count)						\
 do {									\
-  register unsigned long _B_xx = (x);					\
+  register mg_u_long _B_xx = (x);					\
   register int _B_logofb;						\
   POSITIVE(gamma, _B_xx);						\
@@ -310,5 +310,5 @@
 #define DELTA_ENCODE(x)							\
 do {									\
-  register unsigned long _B_xxx = (x);					\
+  register mg_u_long _B_xxx = (x);					\
   register int _B_logx;							\
   FLOORLOG_2(_B_xxx, _B_logx);						\
@@ -319,5 +319,5 @@
 #define DELTA_ENCODE_L(x, count)					\
 do {									\
-  register unsigned long _B_xxx = (x);					\
+  register mg_u_long _B_xxx = (x);					\
   register int _B_logx;							\
   FLOORLOG_2(_B_xxx, _B_logx);						\
@@ -329,5 +329,5 @@
 #define DELTA_DECODE(x)							\
 do {									\
-  register unsigned long _B_xxx;					\
+  register mg_u_long _B_xxx;					\
   register int _B_logx;							\
   GAMMA_DECODE(_B_logx); --_B_logx;					\
@@ -338,5 +338,5 @@
 #define DELTA_DECODE_L(x, count)					\
 do {									\
-  register unsigned long _B_xxx;					\
+  register mg_u_long _B_xxx;					\
   register int _B_logx;							\
   GAMMA_DECODE_L(_B_logx, count); --_B_logx;				\
@@ -347,5 +347,5 @@
 #define DELTA_LENGTH(x, count)						\
 do {									\
-  register unsigned long _B_xxx = (x);					\
+  register mg_u_long _B_xxx = (x);					\
   register int _B_logx, _B_dcount;					\
   FLOORLOG_2(_B_xxx, _B_logx);						\
@@ -363,6 +363,6 @@
 #define ELIAS_ENCODE(x, b, s)						\
 do {									\
-  register unsigned long _B_xx = (x);					\
-  register unsigned long _B_b = (b);					\
+  register mg_u_long _B_xx = (x);					\
+  register mg_u_long _B_b = (b);					\
   register double _B_s = (s);						\
   register int _B_lower=1, _B_upper=1;					\
@@ -383,6 +383,6 @@
 #define ELIAS_ENCODE_L(x, b, s, count)					\
 do {									\
-  register unsigned long _B_xx = (x);					\
-  register unsigned long _B_b = (b);					\
+  register mg_u_long _B_xx = (x);					\
+  register mg_u_long _B_b = (b);					\
   register double _B_s = (s);						\
   register int _B_lower=1, _B_upper=1;					\
@@ -403,6 +403,6 @@
 #define ELIAS_DECODE(x, b, s)						\
 do {									\
-  register unsigned long _B_xx;						\
-  register unsigned long _B_b = (b);					\
+  register mg_u_long _B_xx;						\
+  register mg_u_long _B_b = (b);					\
   register double _B_s = (s);						\
   register int _B_lower=1, _B_upper=1;					\
@@ -423,6 +423,6 @@
 #define ELIAS_DECODE_L(x, b, s, count)					\
 do {									\
-  register unsigned long _B_xx;						\
-  register unsigned long _B_b = (b);					\
+  register mg_u_long _B_xx;						\
+  register mg_u_long _B_b = (b);					\
   register double _B_s = (s);						\
   register int _B_lower=1, _B_upper=1;					\
@@ -443,6 +443,6 @@
 #define ELIAS_LENGTH(x, b, s, count)					\
 do {									\
-  register unsigned long _B_xx = (x);					\
-  register unsigned long _B_b = (b);					\
+  register mg_u_long _B_xx = (x);					\
+  register mg_u_long _B_b = (b);					\
   register double _B_s = (s);						\
   register int _B_lower=1, _B_upper=1;					\
@@ -468,6 +468,6 @@
 #define BBLOCK_ENCODE(x, b)						\
 do {									\
-  register unsigned long _B_xx = (x);					\
-  register unsigned long _B_bb = (b);					\
+  register mg_u_long _B_xx = (x);					\
+  register mg_u_long _B_bb = (b);					\
   register int _B_xdivb = 0;						\
   POSITIVE(bblock, _B_xx);						\
@@ -484,6 +484,6 @@
 #define BBLOCK_ENCODE_L(x, b, count)					\
 do {									\
-  register unsigned long _B_xx = (x);					\
-  register unsigned long _B_bb = (b);					\
+  register mg_u_long _B_xx = (x);					\
+  register mg_u_long _B_bb = (b);					\
   register int _B_xdivb = 0;						\
   POSITIVE(bblock, _B_xx);						\
@@ -500,6 +500,6 @@
 #define BBLOCK_DECODE(x, b)						\
 do {									\
-  register unsigned long _B_x1, _B_xx = 0;				\
-  register unsigned long _B_bb = (b);					\
+  register mg_u_long _B_x1, _B_xx = 0;				\
+  register mg_u_long _B_bb = (b);					\
   register int _B_xdivb;						\
   UNARY_DECODE(_B_xdivb); --_B_xdivb;					\
@@ -512,6 +512,6 @@
 #define BBLOCK_DECODE_L(x, b, count)					\
 do {									\
-  register unsigned long _B_x1, _B_xx = 0;				\
-  register unsigned long _B_bb = (b);					\
+  register mg_u_long _B_x1, _B_xx = 0;				\
+  register mg_u_long _B_bb = (b);					\
   register int _B_xdivb;						\
   UNARY_DECODE_L(_B_xdivb, count); --_B_xdivb;				\
@@ -524,6 +524,6 @@
 #define BBLOCK_LENGTH(x, b, count)					\
 do {									\
-  register unsigned long _B_bcount, _B_xx = (x);			\
-  register unsigned long _B_bb = (b);					\
+  register mg_u_long _B_bcount, _B_xx = (x);			\
+  register mg_u_long _B_bb = (b);					\
   register int _B_xdivb = 0;						\
   POSITIVE(bblock, _B_xx);						\
Index: main/trunk/greenstone2/common-src/indexers/mg/lib/bitio_m_mems.h
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/lib/bitio_m_mems.h	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/lib/bitio_m_mems.h	(revision 25147)
@@ -36,5 +36,5 @@
   {
     unsigned char *Base;
-    unsigned long pos;
+    mg_u_long pos;
   }
 mems_bitio_state;
@@ -44,10 +44,10 @@
   {									\
     register unsigned char *__base = b;					\
-    register unsigned long __pos = p;
+    register mg_u_long __pos = p;
 
 #define ENCODE_CONTINUE(b)						\
   {									\
     register unsigned char *__base = (b).Base;				\
-    register unsigned long __pos = (b).pos;
+    register mg_u_long __pos = (b).pos;
 
 #define ENCODE_BIT(b)							\
@@ -76,10 +76,10 @@
   {									\
     register unsigned char *__base = b;					\
-    register unsigned long __pos = p;
+    register mg_u_long __pos = p;
 
 #define DECODE_CONTINUE(b)						\
   {									\
     register unsigned char *__base = (b).Base;				\
-    register unsigned long __pos = (b).pos;
+    register mg_u_long __pos = (b).pos;
 
 #define DECODE_ADD_FF(b)						\
Index: main/trunk/greenstone2/common-src/indexers/mg/lib/bitio_m_random.h
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/lib/bitio_m_random.h	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/lib/bitio_m_random.h	(revision 25147)
@@ -38,9 +38,9 @@
     FILE *File;
     unsigned char *Buf;
-    unsigned long Base;
-    unsigned long Used;
-    unsigned long pos;
-    unsigned long len;
-    unsigned long sft;
+    mg_u_long Base;
+    mg_u_long Used;
+    mg_u_long pos;
+    mg_u_long len;
+    mg_u_long sft;
   }
 random_bitio_state;
@@ -51,9 +51,9 @@
     register FILE *__file = f;						\
     register unsigned char *__buf;					\
-    register unsigned long __pos = 0;					\
-    register unsigned long __base = 0;					\
-    register unsigned long __is_used = 0;					\
-    register unsigned long __len = (l)-1;				\
-    register unsigned long __sft = 0;					\
+    register mg_u_long __pos = 0;					\
+    register mg_u_long __base = 0;					\
+    register mg_u_long __is_used = 0;					\
+    register mg_u_long __len = (l)-1;				\
+    register mg_u_long __sft = 0;					\
     while (__len) { ++__sft; __len >>=1; }				\
     __len = 1<<__sft;							\
@@ -66,9 +66,9 @@
     register FILE *__file = (b).File;					\
     register unsigned char *__buf = (b).Buf;				\
-    register unsigned long __pos = (b).pos;				\
-    register unsigned long __base = (b).Base;				\
-    register unsigned long __is_used = (b).Used;				\
-    register unsigned long __len = (b).len;				\
-    register unsigned long __sft = (b).sft;
+    register mg_u_long __pos = (b).pos;				\
+    register mg_u_long __base = (b).Base;				\
+    register mg_u_long __is_used = (b).Used;				\
+    register mg_u_long __len = (b).len;				\
+    register mg_u_long __sft = (b).sft;
 
 #define SEEK fprintf(stderr, "Seek to %d\n",__base)
Index: main/trunk/greenstone2/common-src/indexers/mg/lib/bitio_mem.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/lib/bitio_mem.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/lib/bitio_mem.c	(revision 25147)
@@ -55,6 +55,6 @@
 
 void 
-BIO_Mem_Unary_Encode (unsigned long val, mem_bitio_state * bs,
-		      unsigned long *bits)
+BIO_Mem_Unary_Encode (mg_u_long val, mem_bitio_state * bs,
+		      mg_u_long *bits)
 {
   ENCODE_CONTINUE (*bs)
@@ -67,9 +67,9 @@
 
 
-unsigned long 
+mg_u_long 
 BIO_Mem_Unary_Decode (mem_bitio_state * bs,
-		      unsigned long *bits)
-{
-  register unsigned long val;
+		      mg_u_long *bits)
+{
+  register mg_u_long val;
   DECODE_CONTINUE (*bs)
     if (bits)
@@ -88,6 +88,6 @@
 
 void 
-BIO_Mem_Binary_Encode (unsigned long val, unsigned long b,
-		       mem_bitio_state * bs, unsigned long *bits)
+BIO_Mem_Binary_Encode (mg_u_long val, mg_u_long b,
+		       mem_bitio_state * bs, mg_u_long *bits)
 {
   ENCODE_CONTINUE (*bs)
@@ -100,9 +100,9 @@
 
 
-unsigned long 
-BIO_Mem_Binary_Decode (unsigned long b, mem_bitio_state * bs,
-		       unsigned long *bits)
-{
-  register unsigned long val;
+mg_u_long 
+BIO_Mem_Binary_Decode (mg_u_long b, mem_bitio_state * bs,
+		       mg_u_long *bits)
+{
+  register mg_u_long val;
   DECODE_CONTINUE (*bs)
     if (bits)
@@ -121,6 +121,6 @@
 
 void 
-BIO_Mem_Gamma_Encode (unsigned long val, mem_bitio_state * bs,
-		      unsigned long *bits)
+BIO_Mem_Gamma_Encode (mg_u_long val, mem_bitio_state * bs,
+		      mg_u_long *bits)
 {
   ENCODE_CONTINUE (*bs)
@@ -133,8 +133,8 @@
 
 
-unsigned long 
-BIO_Mem_Gamma_Decode (mem_bitio_state * bs, unsigned long *bits)
-{
-  register unsigned long val;
+mg_u_long 
+BIO_Mem_Gamma_Decode (mem_bitio_state * bs, mg_u_long *bits)
+{
+  register mg_u_long val;
   DECODE_CONTINUE (*bs)
     if (bits)
@@ -150,6 +150,6 @@
 
 void 
-BIO_Mem_Delta_Encode (unsigned long val, mem_bitio_state * bs,
-		      unsigned long *bits)
+BIO_Mem_Delta_Encode (mg_u_long val, mem_bitio_state * bs,
+		      mg_u_long *bits)
 {
   ENCODE_CONTINUE (*bs)
@@ -162,8 +162,8 @@
 
 
-unsigned long 
-BIO_Mem_Delta_Decode (mem_bitio_state * bs, unsigned long *bits)
-{
-  register unsigned long val;
+mg_u_long 
+BIO_Mem_Delta_Decode (mem_bitio_state * bs, mg_u_long *bits)
+{
+  register mg_u_long val;
   DECODE_CONTINUE (*bs)
     if (bits)
@@ -176,6 +176,6 @@
 
 void 
-BIO_Mem_Elias_Encode (unsigned long val, unsigned long b, double s,
-		      mem_bitio_state * bs, unsigned long *bits)
+BIO_Mem_Elias_Encode (mg_u_long val, mg_u_long b, double s,
+		      mem_bitio_state * bs, mg_u_long *bits)
 {
   ENCODE_CONTINUE (*bs)
@@ -188,9 +188,9 @@
 
 
-unsigned long 
-BIO_Mem_Elias_Decode (unsigned long b, double s,
-		      mem_bitio_state * bs, unsigned long *bits)
-{
-  register unsigned long val;
+mg_u_long 
+BIO_Mem_Elias_Decode (mg_u_long b, double s,
+		      mem_bitio_state * bs, mg_u_long *bits)
+{
+  register mg_u_long val;
   DECODE_CONTINUE (*bs)
     if (bits)
@@ -203,6 +203,6 @@
 
 void 
-BIO_Mem_Bblock_Encode (unsigned long val, unsigned long b,
-		       mem_bitio_state * bs, unsigned long *bits)
+BIO_Mem_Bblock_Encode (mg_u_long val, mg_u_long b,
+		       mem_bitio_state * bs, mg_u_long *bits)
 {
   ENCODE_CONTINUE (*bs)
@@ -215,9 +215,9 @@
 
 
-unsigned long 
-BIO_Mem_Bblock_Decode (unsigned long b, mem_bitio_state * bs,
-		       unsigned long *bits)
-{
-  register unsigned long val;
+mg_u_long 
+BIO_Mem_Bblock_Decode (mg_u_long b, mem_bitio_state * bs,
+		       mg_u_long *bits)
+{
+  register mg_u_long val;
   DECODE_CONTINUE (*bs)
     if (bits)
@@ -230,5 +230,5 @@
 
 void 
-BIO_Mem_Decode_Seek (unsigned long pos, mem_bitio_state * bs)
+BIO_Mem_Decode_Seek (mg_u_long pos, mem_bitio_state * bs)
 {
   DECODE_CONTINUE (*bs)
Index: main/trunk/greenstone2/common-src/indexers/mg/lib/bitio_mem.h
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/lib/bitio_mem.h	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/lib/bitio_mem.h	(revision 25147)
@@ -61,42 +61,42 @@
 
 
-void BIO_Mem_Unary_Encode (unsigned long val, mem_bitio_state * bs,
-			   unsigned long *bits);
-unsigned long BIO_Mem_Unary_Decode (mem_bitio_state * bs,
-				    unsigned long *bits);
+void BIO_Mem_Unary_Encode (mg_u_long val, mem_bitio_state * bs,
+			   mg_u_long *bits);
+mg_u_long BIO_Mem_Unary_Decode (mem_bitio_state * bs,
+				    mg_u_long *bits);
 
 
 
-void BIO_Mem_Binary_Encode (unsigned long val, unsigned long b,
-			    mem_bitio_state * bs, unsigned long *bits);
-unsigned long BIO_Mem_Binary_Decode (unsigned long b, mem_bitio_state * bs,
-				     unsigned long *bits);
+void BIO_Mem_Binary_Encode (mg_u_long val, mg_u_long b,
+			    mem_bitio_state * bs, mg_u_long *bits);
+mg_u_long BIO_Mem_Binary_Decode (mg_u_long b, mem_bitio_state * bs,
+				     mg_u_long *bits);
 
 
 
-void BIO_Mem_Gamma_Encode (unsigned long val, mem_bitio_state * bs,
-			   unsigned long *bits);
-unsigned long BIO_Mem_Gamma_Decode (mem_bitio_state * bs, unsigned long *bits);
+void BIO_Mem_Gamma_Encode (mg_u_long val, mem_bitio_state * bs,
+			   mg_u_long *bits);
+mg_u_long BIO_Mem_Gamma_Decode (mem_bitio_state * bs, mg_u_long *bits);
 
 
 
-void BIO_Mem_Delta_Encode (unsigned long val, mem_bitio_state * bs,
-			   unsigned long *bits);
-unsigned long BIO_Mem_Delta_Decode (mem_bitio_state * bs, unsigned long *bits);
+void BIO_Mem_Delta_Encode (mg_u_long val, mem_bitio_state * bs,
+			   mg_u_long *bits);
+mg_u_long BIO_Mem_Delta_Decode (mem_bitio_state * bs, mg_u_long *bits);
 
 
-void BIO_Mem_Elias_Encode (unsigned long val, unsigned long b, double s,
-			   mem_bitio_state * bs, unsigned long *bits);
-unsigned long BIO_Mem_Elias_Decode (unsigned long b, double s,
-				 mem_bitio_state * bs, unsigned long *bits);
+void BIO_Mem_Elias_Encode (mg_u_long val, mg_u_long b, double s,
+			   mem_bitio_state * bs, mg_u_long *bits);
+mg_u_long BIO_Mem_Elias_Decode (mg_u_long b, double s,
+				 mem_bitio_state * bs, mg_u_long *bits);
 
 
-void BIO_Mem_Bblock_Encode (unsigned long val, unsigned long b,
-			    mem_bitio_state * bs, unsigned long *bits);
-unsigned long BIO_Mem_Bblock_Decode (unsigned long b, mem_bitio_state * bs,
-				     unsigned long *bits);
+void BIO_Mem_Bblock_Encode (mg_u_long val, mg_u_long b,
+			    mem_bitio_state * bs, mg_u_long *bits);
+mg_u_long BIO_Mem_Bblock_Decode (mg_u_long b, mem_bitio_state * bs,
+				     mg_u_long *bits);
 
 
-void BIO_Mem_Decode_Seek (unsigned long pos, mem_bitio_state * bs);
+void BIO_Mem_Decode_Seek (mg_u_long pos, mem_bitio_state * bs);
 
 
Index: main/trunk/greenstone2/common-src/indexers/mg/lib/bitio_mems.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/lib/bitio_mems.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/lib/bitio_mems.c	(revision 25147)
@@ -30,5 +30,5 @@
 
 void 
-BIO_Mems_Encode_Start (unsigned char *buf, unsigned long pos,
+BIO_Mems_Encode_Start (unsigned char *buf, mg_u_long pos,
 		       mems_bitio_state * bs)
 {
@@ -46,5 +46,5 @@
 
 void 
-BIO_Mems_Decode_Start (unsigned char *buf, unsigned long pos,
+BIO_Mems_Decode_Start (unsigned char *buf, mg_u_long pos,
 		       mems_bitio_state * bs)
 {
@@ -57,6 +57,6 @@
 
 void 
-BIO_Mems_Unary_Encode (unsigned long val, mems_bitio_state * bs,
-		       unsigned long *bits)
+BIO_Mems_Unary_Encode (mg_u_long val, mems_bitio_state * bs,
+		       mg_u_long *bits)
 {
   ENCODE_CONTINUE (*bs)
@@ -69,9 +69,9 @@
 
 
-unsigned long 
+mg_u_long 
 BIO_Mems_Unary_Decode (mems_bitio_state * bs,
-		       unsigned long *bits)
-{
-  register unsigned long val;
+		       mg_u_long *bits)
+{
+  register mg_u_long val;
   DECODE_CONTINUE (*bs)
     if (bits)
@@ -90,6 +90,6 @@
 
 void 
-BIO_Mems_Binary_Encode (unsigned long val, unsigned long b,
-			mems_bitio_state * bs, unsigned long *bits)
+BIO_Mems_Binary_Encode (mg_u_long val, mg_u_long b,
+			mems_bitio_state * bs, mg_u_long *bits)
 {
   ENCODE_CONTINUE (*bs)
@@ -102,9 +102,9 @@
 
 
-unsigned long 
-BIO_Mems_Binary_Decode (unsigned long b, mems_bitio_state * bs,
-			unsigned long *bits)
-{
-  register unsigned long val;
+mg_u_long 
+BIO_Mems_Binary_Decode (mg_u_long b, mems_bitio_state * bs,
+			mg_u_long *bits)
+{
+  register mg_u_long val;
   DECODE_CONTINUE (*bs)
     if (bits)
@@ -123,6 +123,6 @@
 
 void 
-BIO_Mems_Gamma_Encode (unsigned long val, mems_bitio_state * bs,
-		       unsigned long *bits)
+BIO_Mems_Gamma_Encode (mg_u_long val, mems_bitio_state * bs,
+		       mg_u_long *bits)
 {
   ENCODE_CONTINUE (*bs)
@@ -135,8 +135,8 @@
 
 
-unsigned long 
-BIO_Mems_Gamma_Decode (mems_bitio_state * bs, unsigned long *bits)
-{
-  register unsigned long val;
+mg_u_long 
+BIO_Mems_Gamma_Decode (mems_bitio_state * bs, mg_u_long *bits)
+{
+  register mg_u_long val;
   DECODE_CONTINUE (*bs)
     if (bits)
@@ -152,6 +152,6 @@
 
 void 
-BIO_Mems_Delta_Encode (unsigned long val, mems_bitio_state * bs,
-		       unsigned long *bits)
+BIO_Mems_Delta_Encode (mg_u_long val, mems_bitio_state * bs,
+		       mg_u_long *bits)
 {
   ENCODE_CONTINUE (*bs)
@@ -164,8 +164,8 @@
 
 
-unsigned long 
-BIO_Mems_Delta_Decode (mems_bitio_state * bs, unsigned long *bits)
-{
-  register unsigned long val;
+mg_u_long 
+BIO_Mems_Delta_Decode (mems_bitio_state * bs, mg_u_long *bits)
+{
+  register mg_u_long val;
   DECODE_CONTINUE (*bs)
     if (bits)
@@ -178,6 +178,6 @@
 
 void 
-BIO_Mems_Elias_Encode (unsigned long val, unsigned long b, double s,
-		       mems_bitio_state * bs, unsigned long *bits)
+BIO_Mems_Elias_Encode (mg_u_long val, mg_u_long b, double s,
+		       mems_bitio_state * bs, mg_u_long *bits)
 {
   ENCODE_CONTINUE (*bs)
@@ -190,9 +190,9 @@
 
 
-unsigned long 
-BIO_Mems_Elias_Decode (unsigned long b, double s,
-		       mems_bitio_state * bs, unsigned long *bits)
-{
-  register unsigned long val;
+mg_u_long 
+BIO_Mems_Elias_Decode (mg_u_long b, double s,
+		       mems_bitio_state * bs, mg_u_long *bits)
+{
+  register mg_u_long val;
   DECODE_CONTINUE (*bs)
     if (bits)
@@ -205,6 +205,6 @@
 
 void 
-BIO_Mems_Bblock_Encode (unsigned long val, unsigned long b,
-			mems_bitio_state * bs, unsigned long *bits)
+BIO_Mems_Bblock_Encode (mg_u_long val, mg_u_long b,
+			mems_bitio_state * bs, mg_u_long *bits)
 {
   ENCODE_CONTINUE (*bs)
@@ -217,9 +217,9 @@
 
 
-unsigned long 
-BIO_Mems_Bblock_Decode (unsigned long b, mems_bitio_state * bs,
-			unsigned long *bits)
-{
-  register unsigned long val;
+mg_u_long 
+BIO_Mems_Bblock_Decode (mg_u_long b, mems_bitio_state * bs,
+			mg_u_long *bits)
+{
+  register mg_u_long val;
   DECODE_CONTINUE (*bs)
     if (bits)
@@ -232,5 +232,5 @@
 
 void 
-BIO_Mems_Decode_Seek (unsigned long pos, mems_bitio_state * bs)
+BIO_Mems_Decode_Seek (mg_u_long pos, mems_bitio_state * bs)
 {
   DECODE_CONTINUE (*bs)
@@ -240,5 +240,5 @@
 
 void 
-BIO_Mems_Encode_Seek (unsigned long pos, mems_bitio_state * bs)
+BIO_Mems_Encode_Seek (mg_u_long pos, mems_bitio_state * bs)
 {
   ENCODE_CONTINUE (*bs)
Index: main/trunk/greenstone2/common-src/indexers/mg/lib/bitio_mems.h
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/lib/bitio_mems.h	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/lib/bitio_mems.h	(revision 25147)
@@ -38,5 +38,5 @@
   {
     unsigned char *Base;
-    unsigned long pos;
+    mg_u_long pos;
   }
 mems_bitio_state;
@@ -46,51 +46,51 @@
 
 
-void BIO_Mems_Encode_Start (char *buf, unsigned long pos, mems_bitio_state * bs);
+void BIO_Mems_Encode_Start (char *buf, mg_u_long pos, mems_bitio_state * bs);
 void BIO_Mems_Encode_Done (mems_bitio_state * bs);
 
 
 
-void BIO_Mems_Decode_Start (void *buf, unsigned long pos, mems_bitio_state * bs);
+void BIO_Mems_Decode_Start (void *buf, mg_u_long pos, mems_bitio_state * bs);
 
 
 
-void BIO_Mems_Unary_Encode (unsigned long val, mems_bitio_state * bs,
-			    unsigned long *bits);
-unsigned long BIO_Mems_Unary_Decode (mems_bitio_state * bs,
-				     unsigned long *bits);
+void BIO_Mems_Unary_Encode (mg_u_long val, mems_bitio_state * bs,
+			    mg_u_long *bits);
+mg_u_long BIO_Mems_Unary_Decode (mems_bitio_state * bs,
+				     mg_u_long *bits);
 
 
 
-void BIO_Mems_Binary_Encode (unsigned long val, unsigned long b,
-			     mems_bitio_state * bs, unsigned long *bits);
-unsigned long BIO_Mems_Binary_Decode (unsigned long b, mems_bitio_state * bs,
-				      unsigned long *bits);
+void BIO_Mems_Binary_Encode (mg_u_long val, mg_u_long b,
+			     mems_bitio_state * bs, mg_u_long *bits);
+mg_u_long BIO_Mems_Binary_Decode (mg_u_long b, mems_bitio_state * bs,
+				      mg_u_long *bits);
 
 
 
-void BIO_Mems_Gamma_Encode (unsigned long val, mems_bitio_state * bs,
-			    unsigned long *bits);
-unsigned long BIO_Mems_Gamma_Decode (mems_bitio_state * bs, unsigned long *bits);
+void BIO_Mems_Gamma_Encode (mg_u_long val, mems_bitio_state * bs,
+			    mg_u_long *bits);
+mg_u_long BIO_Mems_Gamma_Decode (mems_bitio_state * bs, mg_u_long *bits);
 
 
 
-void BIO_Mems_Delta_Encode (unsigned long val, mems_bitio_state * bs,
-			    unsigned long *bits);
-unsigned long BIO_Mems_Delta_Decode (mems_bitio_state * bs, unsigned long *bits);
+void BIO_Mems_Delta_Encode (mg_u_long val, mems_bitio_state * bs,
+			    mg_u_long *bits);
+mg_u_long BIO_Mems_Delta_Decode (mems_bitio_state * bs, mg_u_long *bits);
 
 
-void BIO_Mems_Elias_Encode (unsigned long val, unsigned long b, double s,
-			    mems_bitio_state * bs, unsigned long *bits);
-unsigned long BIO_Mems_Elias_Decode (unsigned long b, double s,
-				mems_bitio_state * bs, unsigned long *bits);
+void BIO_Mems_Elias_Encode (mg_u_long val, mg_u_long b, double s,
+			    mems_bitio_state * bs, mg_u_long *bits);
+mg_u_long BIO_Mems_Elias_Decode (mg_u_long b, double s,
+				mems_bitio_state * bs, mg_u_long *bits);
 
 
-void BIO_Mems_Bblock_Encode (unsigned long val, unsigned long b,
-			     mems_bitio_state * bs, unsigned long *bits);
-unsigned long BIO_Mems_Bblock_Decode (unsigned long b, mems_bitio_state * bs,
-				      unsigned long *bits);
+void BIO_Mems_Bblock_Encode (mg_u_long val, mg_u_long b,
+			     mems_bitio_state * bs, mg_u_long *bits);
+mg_u_long BIO_Mems_Bblock_Decode (mg_u_long b, mems_bitio_state * bs,
+				      mg_u_long *bits);
 
 
-void BIO_Mems_Decode_Seek (unsigned long pos, mems_bitio_state * bs);
+void BIO_Mems_Decode_Seek (mg_u_long pos, mems_bitio_state * bs);
 
 
Index: main/trunk/greenstone2/common-src/indexers/mg/lib/bitio_random.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/lib/bitio_random.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/lib/bitio_random.c	(revision 25147)
@@ -30,5 +30,5 @@
 
 void 
-BIO_Random_Start (FILE * f, unsigned long len,
+BIO_Random_Start (FILE * f, mg_u_long len,
 		  random_bitio_state * bs)
 {
@@ -64,6 +64,6 @@
 
 void 
-BIO_Random_Unary_Encode (unsigned long val, random_bitio_state * bs,
-			 unsigned long *bits)
+BIO_Random_Unary_Encode (mg_u_long val, random_bitio_state * bs,
+			 mg_u_long *bits)
 {
   ENCODE_CONTINUE (*bs)
@@ -76,9 +76,9 @@
 
 
-unsigned long 
+mg_u_long 
 BIO_Random_Unary_Decode (random_bitio_state * bs,
-			 unsigned long *bits)
-{
-  register unsigned long val;
+			 mg_u_long *bits)
+{
+  register mg_u_long val;
   DECODE_CONTINUE (*bs)
     if (bits)
@@ -97,6 +97,6 @@
 
 void 
-BIO_Random_Binary_Encode (unsigned long val, unsigned long b,
-			  random_bitio_state * bs, unsigned long *bits)
+BIO_Random_Binary_Encode (mg_u_long val, mg_u_long b,
+			  random_bitio_state * bs, mg_u_long *bits)
 {
   ENCODE_CONTINUE (*bs)
@@ -109,10 +109,10 @@
 
 
-unsigned long 
-BIO_Random_Binary_Decode (unsigned long b,
+mg_u_long 
+BIO_Random_Binary_Decode (mg_u_long b,
 			  random_bitio_state * bs,
-			  unsigned long *bits)
-{
-  register unsigned long val;
+			  mg_u_long *bits)
+{
+  register mg_u_long val;
   DECODE_CONTINUE (*bs)
     if (bits)
@@ -131,6 +131,6 @@
 
 void 
-BIO_Random_Gamma_Encode (unsigned long val, random_bitio_state * bs,
-			 unsigned long *bits)
+BIO_Random_Gamma_Encode (mg_u_long val, random_bitio_state * bs,
+			 mg_u_long *bits)
 {
   ENCODE_CONTINUE (*bs)
@@ -143,9 +143,9 @@
 
 
-unsigned long 
+mg_u_long 
 BIO_Random_Gamma_Decode (random_bitio_state * bs,
-			 unsigned long *bits)
-{
-  register unsigned long val;
+			 mg_u_long *bits)
+{
+  register mg_u_long val;
   DECODE_CONTINUE (*bs)
     if (bits)
@@ -161,6 +161,6 @@
 
 void 
-BIO_Random_Delta_Encode (unsigned long val, random_bitio_state * bs,
-			 unsigned long *bits)
+BIO_Random_Delta_Encode (mg_u_long val, random_bitio_state * bs,
+			 mg_u_long *bits)
 {
   ENCODE_CONTINUE (*bs)
@@ -173,9 +173,9 @@
 
 
-unsigned long 
+mg_u_long 
 BIO_Random_Delta_Decode (random_bitio_state * bs,
-			 unsigned long *bits)
-{
-  register unsigned long val;
+			 mg_u_long *bits)
+{
+  register mg_u_long val;
   DECODE_CONTINUE (*bs)
     if (bits)
@@ -188,6 +188,6 @@
 
 void 
-BIO_Random_Elias_Encode (unsigned long val, unsigned long b, double s,
-			 random_bitio_state * bs, unsigned long *bits)
+BIO_Random_Elias_Encode (mg_u_long val, mg_u_long b, double s,
+			 random_bitio_state * bs, mg_u_long *bits)
 {
   ENCODE_CONTINUE (*bs)
@@ -200,10 +200,10 @@
 
 
-unsigned long 
-BIO_Random_Elias_Decode (unsigned long b, double s,
+mg_u_long 
+BIO_Random_Elias_Decode (mg_u_long b, double s,
 			 random_bitio_state * bs,
-			 unsigned long *bits)
-{
-  register unsigned long val;
+			 mg_u_long *bits)
+{
+  register mg_u_long val;
   DECODE_CONTINUE (*bs)
     if (bits)
@@ -216,6 +216,6 @@
 
 void 
-BIO_Random_Bblock_Encode (unsigned long val, unsigned long b,
-			  random_bitio_state * bs, unsigned long *bits)
+BIO_Random_Bblock_Encode (mg_u_long val, mg_u_long b,
+			  random_bitio_state * bs, mg_u_long *bits)
 {
   ENCODE_CONTINUE (*bs)
@@ -228,10 +228,10 @@
 
 
-unsigned long 
-BIO_Random_Bblock_Decode (unsigned long b,
+mg_u_long 
+BIO_Random_Bblock_Decode (mg_u_long b,
 			  random_bitio_state * bs,
-			  unsigned long *bits)
-{
-  register unsigned long val;
+			  mg_u_long *bits)
+{
+  register mg_u_long val;
   DECODE_CONTINUE (*bs)
     if (bits)
@@ -244,5 +244,5 @@
 
 void 
-BIO_Random_Seek (unsigned long pos, random_bitio_state * bs)
+BIO_Random_Seek (mg_u_long pos, random_bitio_state * bs)
 {
   ENCODE_CONTINUE (*bs)
@@ -258,8 +258,8 @@
 }
 
-unsigned long 
+mg_u_long 
 BIO_Random_Tell (random_bitio_state * bs)
 {
-  register unsigned long t;
+  register mg_u_long t;
   ENCODE_CONTINUE (*bs)
     t = ENCODE_TELL;
@@ -278,14 +278,14 @@
 	((((pos)+7) >> 3) < (mg_ullong)(__base + __len)))
       {
-	__pos = (long)((pos) - (mg_ullong)(__base << 3));
+	__pos = (mg_s_long)((pos) - (mg_ullong)(__base << 3));
       }
     else
       {
         ENCODE_FLUSH;
-	__base = (long)(((pos) >> (__sft+3)) << __sft);
+	__base = (mg_s_long)(((pos) >> (__sft+3)) << __sft);
 	
 	fseek(__file,__base,0);
 	fread(__buf,1,__len,__file);
-	__pos = (long)((pos) & ((8 << __sft)-1));
+	__pos = (mg_s_long)((pos) & ((8 << __sft)-1));
       }
   
Index: main/trunk/greenstone2/common-src/indexers/mg/lib/bitio_random.h
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/lib/bitio_random.h	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/lib/bitio_random.h	(revision 25147)
@@ -43,9 +43,9 @@
     FILE *File;
     unsigned char *Buf;
-    unsigned long Base;
-    unsigned long Used;
-    unsigned long pos;
-    unsigned long len;
-    unsigned long sft;
+    mg_u_long Base;
+    mg_u_long Used;
+    mg_u_long pos;
+    mg_u_long len;
+    mg_u_long sft;
   }
 random_bitio_state;
@@ -55,5 +55,5 @@
 
 
-void BIO_Random_Start (FILE * f, unsigned long len,
+void BIO_Random_Start (FILE * f, mg_u_long len,
 		       random_bitio_state * bs);
 void BIO_Random_Done (random_bitio_state * bs);
@@ -61,5 +61,5 @@
 
 
-void BIO_Random_Decode_Start (void *buf, unsigned long pos,
+void BIO_Random_Decode_Start (void *buf, mg_u_long pos,
 			      random_bitio_state * bs);
 
@@ -69,50 +69,50 @@
 
 
-void BIO_Random_Unary_Encode (unsigned long val, random_bitio_state * bs,
-			      unsigned long *bits);
-unsigned long BIO_Random_Unary_Decode (random_bitio_state * bs,
-				       unsigned long *bits);
+void BIO_Random_Unary_Encode (mg_u_long val, random_bitio_state * bs,
+			      mg_u_long *bits);
+mg_u_long BIO_Random_Unary_Decode (random_bitio_state * bs,
+				       mg_u_long *bits);
 
 
 
-void BIO_Random_Binary_Encode (unsigned long val, unsigned long b,
-			       random_bitio_state * bs, unsigned long *bits);
-unsigned long BIO_Random_Binary_Decode (unsigned long b, random_bitio_state * bs,
-					unsigned long *bits);
+void BIO_Random_Binary_Encode (mg_u_long val, mg_u_long b,
+			       random_bitio_state * bs, mg_u_long *bits);
+mg_u_long BIO_Random_Binary_Decode (mg_u_long b, random_bitio_state * bs,
+					mg_u_long *bits);
 
 
 
-void BIO_Random_Gamma_Encode (unsigned long val, random_bitio_state * bs,
-			      unsigned long *bits);
-unsigned long BIO_Random_Gamma_Decode (random_bitio_state * bs,
-				       unsigned long *bits);
+void BIO_Random_Gamma_Encode (mg_u_long val, random_bitio_state * bs,
+			      mg_u_long *bits);
+mg_u_long BIO_Random_Gamma_Decode (random_bitio_state * bs,
+				       mg_u_long *bits);
 
 
 
-void BIO_Random_Delta_Encode (unsigned long val, random_bitio_state * bs,
-			      unsigned long *bits);
-unsigned long BIO_Random_Delta_Decode (random_bitio_state * bs,
-				       unsigned long *bits);
+void BIO_Random_Delta_Encode (mg_u_long val, random_bitio_state * bs,
+			      mg_u_long *bits);
+mg_u_long BIO_Random_Delta_Decode (random_bitio_state * bs,
+				       mg_u_long *bits);
 
 
-void BIO_Random_Elias_Encode (unsigned long val, unsigned long b, double s,
-			      random_bitio_state * bs, unsigned long *bits);
-unsigned long BIO_Random_Elias_Decode (unsigned long b, double s,
+void BIO_Random_Elias_Encode (mg_u_long val, mg_u_long b, double s,
+			      random_bitio_state * bs, mg_u_long *bits);
+mg_u_long BIO_Random_Elias_Decode (mg_u_long b, double s,
 				       random_bitio_state * bs,
-				       unsigned long *bits);
+				       mg_u_long *bits);
 
 
-void BIO_Random_Bblock_Encode (unsigned long val, unsigned long b,
-			       random_bitio_state * bs, unsigned long *bits);
-unsigned long BIO_Random_Bblock_Decode (unsigned long b,
+void BIO_Random_Bblock_Encode (mg_u_long val, mg_u_long b,
+			       random_bitio_state * bs, mg_u_long *bits);
+mg_u_long BIO_Random_Bblock_Decode (mg_u_long b,
 					random_bitio_state * bs,
-					unsigned long *bits);
+					mg_u_long *bits);
 
 
-void BIO_Random_Seek (unsigned long pos, random_bitio_state * bs);
+void BIO_Random_Seek (mg_u_long pos, random_bitio_state * bs);
 
 void BIO_Random_Flush (random_bitio_state * bs);
 
-unsigned long BIO_Random_Tell (random_bitio_state * bs);
+mg_u_long BIO_Random_Tell (random_bitio_state * bs);
 
 #ifdef USE_LONG_LONG
Index: main/trunk/greenstone2/common-src/indexers/mg/lib/bitio_stdio.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/lib/bitio_stdio.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/lib/bitio_stdio.c	(revision 25147)
@@ -72,6 +72,6 @@
 
 void 
-BIO_Stdio_Unary_Encode (unsigned long val, stdio_bitio_state * bs,
-			unsigned long *bits)
+BIO_Stdio_Unary_Encode (mg_u_long val, stdio_bitio_state * bs,
+			mg_u_long *bits)
 {
   ENCODE_CONTINUE (*bs)
@@ -84,9 +84,9 @@
 
 
-unsigned long 
+mg_u_long 
 BIO_Stdio_Unary_Decode (stdio_bitio_state * bs,
-			unsigned long *bits)
-{
-  register unsigned long val;
+			mg_u_long *bits)
+{
+  register mg_u_long val;
   DECODE_CONTINUE (*bs)
     if (bits)
@@ -105,6 +105,6 @@
 
 void 
-BIO_Stdio_Binary_Encode (unsigned long val, unsigned long b,
-			 stdio_bitio_state * bs, unsigned long *bits)
+BIO_Stdio_Binary_Encode (mg_u_long val, mg_u_long b,
+			 stdio_bitio_state * bs, mg_u_long *bits)
 {
   ENCODE_CONTINUE (*bs)
@@ -117,9 +117,9 @@
 
 
-unsigned long 
-BIO_Stdio_Binary_Decode (unsigned long b, stdio_bitio_state * bs,
-			 unsigned long *bits)
-{
-  register unsigned long val;
+mg_u_long 
+BIO_Stdio_Binary_Decode (mg_u_long b, stdio_bitio_state * bs,
+			 mg_u_long *bits)
+{
+  register mg_u_long val;
   DECODE_CONTINUE (*bs)
     if (bits)
@@ -138,6 +138,6 @@
 
 void 
-BIO_Stdio_Gamma_Encode (unsigned long val, stdio_bitio_state * bs,
-			unsigned long *bits)
+BIO_Stdio_Gamma_Encode (mg_u_long val, stdio_bitio_state * bs,
+			mg_u_long *bits)
 {
   ENCODE_CONTINUE (*bs)
@@ -150,9 +150,9 @@
 
 
-unsigned long 
+mg_u_long 
 BIO_Stdio_Gamma_Decode (stdio_bitio_state * bs,
-			unsigned long *bits)
-{
-  register unsigned long val;
+			mg_u_long *bits)
+{
+  register mg_u_long val;
   DECODE_CONTINUE (*bs)
     if (bits)
@@ -168,6 +168,6 @@
 
 void 
-BIO_Stdio_Delta_Encode (unsigned long val, stdio_bitio_state * bs,
-			unsigned long *bits)
+BIO_Stdio_Delta_Encode (mg_u_long val, stdio_bitio_state * bs,
+			mg_u_long *bits)
 {
   ENCODE_CONTINUE (*bs)
@@ -180,9 +180,9 @@
 
 
-unsigned long 
+mg_u_long 
 BIO_Stdio_Delta_Decode (stdio_bitio_state * bs,
-			unsigned long *bits)
-{
-  register unsigned long val;
+			mg_u_long *bits)
+{
+  register mg_u_long val;
   DECODE_CONTINUE (*bs)
     if (bits)
@@ -198,6 +198,6 @@
 
 void 
-BIO_Stdio_Elias_Encode (unsigned long val, unsigned long b, double s,
-			stdio_bitio_state * bs, unsigned long *bits)
+BIO_Stdio_Elias_Encode (mg_u_long val, mg_u_long b, double s,
+			stdio_bitio_state * bs, mg_u_long *bits)
 {
   ENCODE_CONTINUE (*bs)
@@ -210,10 +210,10 @@
 
 
-unsigned long 
-BIO_Stdio_Elias_Decode (unsigned long b, double s,
+mg_u_long 
+BIO_Stdio_Elias_Decode (mg_u_long b, double s,
 			stdio_bitio_state * bs,
-			unsigned long *bits)
-{
-  register unsigned long val;
+			mg_u_long *bits)
+{
+  register mg_u_long val;
   DECODE_CONTINUE (*bs)
     if (bits)
@@ -228,6 +228,6 @@
 
 void 
-BIO_Stdio_Bblock_Encode (unsigned long val, unsigned long b,
-			 stdio_bitio_state * bs, unsigned long *bits)
+BIO_Stdio_Bblock_Encode (mg_u_long val, mg_u_long b,
+			 stdio_bitio_state * bs, mg_u_long *bits)
 {
   ENCODE_CONTINUE (*bs)
@@ -240,9 +240,9 @@
 
 
-unsigned long 
-BIO_Stdio_Bblock_Decode (unsigned long b, stdio_bitio_state * bs,
-			 unsigned long *bits)
-{
-  register unsigned long val;
+mg_u_long 
+BIO_Stdio_Bblock_Decode (mg_u_long b, stdio_bitio_state * bs,
+			 mg_u_long *bits)
+{
+  register mg_u_long val;
   DECODE_CONTINUE (*bs)
     if (bits)
@@ -255,5 +255,5 @@
 
 void 
-BIO_Stdio_Decode_Seek (unsigned long pos, stdio_bitio_state * bs)
+BIO_Stdio_Decode_Seek (mg_u_long pos, stdio_bitio_state * bs)
 {
   DECODE_CONTINUE (*bs)
Index: main/trunk/greenstone2/common-src/indexers/mg/lib/bitio_stdio.h
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/lib/bitio_stdio.h	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/lib/bitio_stdio.h	(revision 25147)
@@ -59,46 +59,46 @@
 
 
-void BIO_Stdio_Unary_Encode (unsigned long val, stdio_bitio_state * bs,
-			     unsigned long *bits);
-unsigned long BIO_Stdio_Unary_Decode (stdio_bitio_state * bs,
-				      unsigned long *bits);
+void BIO_Stdio_Unary_Encode (mg_u_long val, stdio_bitio_state * bs,
+			     mg_u_long *bits);
+mg_u_long BIO_Stdio_Unary_Decode (stdio_bitio_state * bs,
+				      mg_u_long *bits);
 
 
 
-void BIO_Stdio_Binary_Encode (unsigned long val, unsigned long b,
-			      stdio_bitio_state * bs, unsigned long *bits);
-unsigned long BIO_Stdio_Binary_Decode (unsigned long b, stdio_bitio_state * bs,
-				       unsigned long *bits);
+void BIO_Stdio_Binary_Encode (mg_u_long val, mg_u_long b,
+			      stdio_bitio_state * bs, mg_u_long *bits);
+mg_u_long BIO_Stdio_Binary_Decode (mg_u_long b, stdio_bitio_state * bs,
+				       mg_u_long *bits);
 
 
 
-void BIO_Stdio_Gamma_Encode (unsigned long val, stdio_bitio_state * bs,
-			     unsigned long *bits);
-unsigned long BIO_Stdio_Gamma_Decode (stdio_bitio_state * bs,
-				      unsigned long *bits);
+void BIO_Stdio_Gamma_Encode (mg_u_long val, stdio_bitio_state * bs,
+			     mg_u_long *bits);
+mg_u_long BIO_Stdio_Gamma_Decode (stdio_bitio_state * bs,
+				      mg_u_long *bits);
 
 
 
-void BIO_Stdio_Delta_Encode (unsigned long val, stdio_bitio_state * bs,
-			     unsigned long *bits);
-unsigned long BIO_Stdio_Delta_Decode (stdio_bitio_state * bs,
-				      unsigned long *bits);
+void BIO_Stdio_Delta_Encode (mg_u_long val, stdio_bitio_state * bs,
+			     mg_u_long *bits);
+mg_u_long BIO_Stdio_Delta_Decode (stdio_bitio_state * bs,
+				      mg_u_long *bits);
 
 
 
-void BIO_Stdio_Elias_Encode (unsigned long val, unsigned long b, double s,
-			     stdio_bitio_state * bs, unsigned long *bits);
-unsigned long BIO_Stdio_Elias_Decode (unsigned long b, double s,
+void BIO_Stdio_Elias_Encode (mg_u_long val, mg_u_long b, double s,
+			     stdio_bitio_state * bs, mg_u_long *bits);
+mg_u_long BIO_Stdio_Elias_Decode (mg_u_long b, double s,
 				      stdio_bitio_state * bs,
-				      unsigned long *bits);
+				      mg_u_long *bits);
 
 
-void BIO_Stdio_Bblock_Encode (unsigned long val, unsigned long b,
-			      stdio_bitio_state * bs, unsigned long *bits);
-unsigned long BIO_Stdio_Bblock_Decode (unsigned long b, stdio_bitio_state * bs,
-				       unsigned long *bits);
+void BIO_Stdio_Bblock_Encode (mg_u_long val, mg_u_long b,
+			      stdio_bitio_state * bs, mg_u_long *bits);
+mg_u_long BIO_Stdio_Bblock_Decode (mg_u_long b, stdio_bitio_state * bs,
+				       mg_u_long *bits);
 
 
-void BIO_Stdio_Decode_Seek (unsigned long pos, stdio_bitio_state * bs);
+void BIO_Stdio_Decode_Seek (mg_u_long pos, stdio_bitio_state * bs);
 
 #endif
Index: main/trunk/greenstone2/common-src/indexers/mg/lib/filestats.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/lib/filestats.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/lib/filestats.c	(revision 25147)
@@ -28,9 +28,9 @@
 
 File *
-Fopen (char *name, char *mode, unsigned long magic)
+Fopen (char *name, char *mode, mg_u_long magic)
 {
   FILE *f;
   File *F;
-  unsigned long m;
+  mg_u_long m;
   if (!(f = fopen (name, mode)))
     return (NULL);
@@ -90,5 +90,5 @@
 
 int 
-Fseek (File * F, long offset, int ptrname)
+Fseek (File * F, mg_s_long offset, int ptrname)
 {
   int num;
Index: main/trunk/greenstone2/common-src/indexers/mg/lib/filestats.h
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/lib/filestats.h	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/lib/filestats.h	(revision 25147)
@@ -23,10 +23,11 @@
 #define H_FILESTATS
 
+#include "mglong.h"
 
 typedef struct FileStats
   {
-    unsigned long NumSeeks;
-    unsigned long NumReads;
-    unsigned long NumBytes;
+    mg_u_long NumSeeks;
+    mg_u_long NumReads;
+    mg_u_long NumBytes;
   }
 FileStats;
@@ -45,9 +46,9 @@
 
 /* if magic is 0 no magic number is read or written */
-File *Fopen (char *name, char *mode, unsigned long magic);
+File *Fopen (char *name, char *mode, mg_u_long magic);
 
 size_t Fread (void *ptr, size_t size, size_t nitems, File * F);
 
-int Fseek (File * F, long offset, int ptrname);
+int Fseek (File * F, mg_s_long offset, int ptrname);
 
 void Rewind (File * F);
Index: main/trunk/greenstone2/common-src/indexers/mg/lib/gmalloc.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/lib/gmalloc.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/lib/gmalloc.c	(revision 25147)
@@ -401,8 +401,8 @@
 {
   __ptr_t result;
-  unsigned long int adj;
+  mg_u_long adj;
 
   result = (*__morecore) (size);
-  adj = (unsigned long int) ((unsigned long int) ((char *) result -
+  adj = (mg_u_long) ((mg_u_long) ((char *) result -
 						  (char *) NULL)) % BLOCKSIZE;
   if (adj != 0)
@@ -549,6 +549,6 @@
 	  block = BLOCK (result);
 	  if (--_heapinfo[block].busy.info.frag.nfree != 0)
-	    _heapinfo[block].busy.info.frag.first = (unsigned long int)
-	      ((unsigned long int) ((char *) next->next - (char *) NULL)
+	    _heapinfo[block].busy.info.frag.first = (mg_u_long)
+	      ((mg_u_long) ((char *) next->next - (char *) NULL)
 	       % BLOCKSIZE) >> log;
 
@@ -872,6 +872,6 @@
 	  prev = (struct list *) ptr;
 	  _heapinfo[block].busy.info.frag.nfree = 1;
-	  _heapinfo[block].busy.info.frag.first = (unsigned long int)
-	    ((unsigned long int) ((char *) ptr - (char *) NULL)
+	  _heapinfo[block].busy.info.frag.first = (mg_u_long)
+	    ((mg_u_long) ((char *) ptr - (char *) NULL)
 	     % BLOCKSIZE >> type);
 	  prev->next = _fraghead[type].next;
@@ -1284,5 +1284,5 @@
 {
   __ptr_t result;
-  unsigned long int adj;
+  mg_u_long int adj;
 
   size = ((size + alignment - 1) / alignment) * alignment;
@@ -1291,5 +1291,5 @@
   if (result == NULL)
     return NULL;
-  adj = (unsigned long int) ((unsigned long int) ((char *) result -
+  adj = (mg_u_long) ((mg_u_long) ((char *) result -
 						  (char *) NULL)) % alignment;
   if (adj != 0)
Index: main/trunk/greenstone2/common-src/indexers/mg/lib/huffman.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/lib/huffman.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/lib/huffman.c	(revision 25147)
@@ -30,9 +30,9 @@
  */
 huff_data *
-Generate_Huffman_Data (int num, long *freqs, huff_data * data,
-		       u_long * mem)
+Generate_Huffman_Data (int num, mg_s_long *freqs, huff_data * data,
+		       mg_u_long * mem)
 {
   int HNum, i, count;
-  unsigned long *heap;
+  mg_u_long *heap;
   huff_data *hd = data;
   if (!hd)
@@ -73,5 +73,5 @@
 	  if (heap[heap[curr - 1]] > heap[heap[child - 1]])
 	    {
-	      register u_long temp;
+	      register mg_u_long temp;
 	      temp = heap[child - 1];
 	      heap[child - 1] = heap[curr - 1];
@@ -141,5 +141,5 @@
 
   /* Calculate the code lens */
-  heap[0] = -1UL;
+  heap[0] = -1;
   heap[1] = 0;
   for (i = 2; i < num * 2; i++)
@@ -154,5 +154,5 @@
   for (i = 0; i < num; i++)
     {
-      register u_long codelen = heap[i + num];
+      register mg_u_long codelen = heap[i + num];
       hd->clens[i] = (char) codelen;
       if (!codelen)
@@ -190,10 +190,10 @@
 }
 
-unsigned long *
-Generate_Huffman_Codes (huff_data * data, u_long * mem)
+mg_u_long *
+Generate_Huffman_Codes (huff_data * data, mg_u_long * mem)
 {
   int i;
-  unsigned long *codes;
-  unsigned long mc[MAX_HUFFCODE_LEN + 1];
+  mg_u_long *codes;
+  mg_u_long mc[MAX_HUFFCODE_LEN + 1];
 
   if (!data)
@@ -212,11 +212,11 @@
 
 
-unsigned long **
-Generate_Huffman_Vals (huff_data * data, u_long * mem)
+mg_u_long **
+Generate_Huffman_Vals (huff_data * data, mg_u_long * mem)
 {
   int i;
-  unsigned long *fcode[MAX_HUFFCODE_LEN + 1];
-  unsigned long **values;
-  unsigned long *vals;
+  mg_u_long *fcode[MAX_HUFFCODE_LEN + 1];
+  mg_u_long **values;
+  mg_u_long *vals;
 
   if (!data)
@@ -224,5 +224,5 @@
   if (!(vals = Xmalloc (data->num_codes * sizeof (*vals))))
     return (NULL);
-  if (!(values = Xmalloc ((MAX_HUFFCODE_LEN + 1) * sizeof (unsigned long *))))
+  if (!(values = Xmalloc ((MAX_HUFFCODE_LEN + 1) * sizeof (mg_u_long *))))
     {
       free (vals);
@@ -230,9 +230,9 @@
     }
 
-  bzero ((char *) values, (MAX_HUFFCODE_LEN + 1) * sizeof (unsigned long *));
+  bzero ((char *) values, (MAX_HUFFCODE_LEN + 1) * sizeof (mg_u_long *));
 
   if (mem)
     *mem += data->num_codes * sizeof (*vals) +
-      (MAX_HUFFCODE_LEN + 1) * sizeof (unsigned long *);
+      (MAX_HUFFCODE_LEN + 1) * sizeof (mg_u_long *);
 
   fcode[0] = values[0] = &vals[0];
@@ -249,5 +249,5 @@
 
 double 
-Calculate_Huffman_Size (int num, long *freqs, long *counts)
+Calculate_Huffman_Size (int num, mg_s_long *freqs, mg_s_long *counts)
 {
   double size = 0;
@@ -321,5 +321,5 @@
 static int 
 General_Read_Huffman_Data (size_t (*rd) (), void *f,
-			   huff_data * hd, u_long * mem, u_long * disk)
+			   huff_data * hd, mg_u_long * mem, mg_u_long * disk)
 {
   if (rd (&hd->num_codes, sizeof (hd->num_codes), 1, f) != 1)
@@ -392,5 +392,5 @@
 
 int 
-Read_Huffman_Data (FILE * f, huff_data * hd, u_long * mem, u_long * disk)
+Read_Huffman_Data (FILE * f, huff_data * hd, mg_u_long * mem, mg_u_long * disk)
 {
   return General_Read_Huffman_Data (fread, f, hd, mem, disk);
@@ -401,5 +401,5 @@
 
 int 
-F_Read_Huffman_Data (File * f, huff_data * hd, u_long * mem, u_long * disk)
+F_Read_Huffman_Data (File * f, huff_data * hd, mg_u_long * mem, mg_u_long * disk)
 {
   return General_Read_Huffman_Data (Fread, f, hd, mem, disk);
Index: main/trunk/greenstone2/common-src/indexers/mg/lib/huffman.h
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/lib/huffman.h	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/lib/huffman.h	(revision 25147)
@@ -37,5 +37,5 @@
     int maxcodelen;
     int lencount[MAX_HUFFCODE_LEN + 1];
-    unsigned long min_code[MAX_HUFFCODE_LEN + 1];
+    mg_u_long min_code[MAX_HUFFCODE_LEN + 1];
     char *clens;
   }
@@ -43,21 +43,21 @@
 
 
-huff_data *Generate_Huffman_Data (int num, long *freqs, huff_data * data,
-				  u_long * mem);
+huff_data *Generate_Huffman_Data (int num, mg_s_long *freqs, huff_data * data,
+				  mg_u_long * mem);
 
-unsigned long *Generate_Huffman_Codes (huff_data * data, u_long * mem);
+mg_u_long *Generate_Huffman_Codes (huff_data * data, mg_u_long * mem);
 
-unsigned long **Generate_Huffman_Vals (huff_data * data, u_long * mem);
+mg_u_long **Generate_Huffman_Vals (huff_data * data, mg_u_long * mem);
 
 int Write_Huffman_Data (FILE * f, huff_data * hd);
 
-int Read_Huffman_Data (FILE * f, huff_data * hd, u_long * mem, u_long * disk);
+int Read_Huffman_Data (FILE * f, huff_data * hd, mg_u_long * mem, mg_u_long * disk);
 
-int F_Read_Huffman_Data (File * f, huff_data * hd, u_long * mem, u_long * disk);
+int F_Read_Huffman_Data (File * f, huff_data * hd, mg_u_long * mem, mg_u_long * disk);
 
 /* Calculate the number of bits required to code the data with the
    specified frequencies. Normally freqs and counts should point to
    the same array. */
-double Calculate_Huffman_Size (int num, long *freqs, long *counts);
+double Calculate_Huffman_Size (int num, mg_s_long *freqs, mg_s_long *counts);
 
 
@@ -67,5 +67,5 @@
     register int __i;							\
     register int __clen = (lens)[x];					\
-    register unsigned long __code = (codes)[x];				\
+    register mg_u_long __code = (codes)[x];				\
     for (__i=__clen-1; __i>=0; --__i)					\
       ENCODE_BIT((__code >> __i) & 1);					\
@@ -81,8 +81,8 @@
 #define HUFF_DECODE(x, mcodes, values)					\
   do {									\
-    register unsigned long *__min_code = (mcodes);			\
-    register unsigned long *__mclen = __min_code;			\
-    register unsigned long **__values = (values);			\
-    register unsigned long __code = 0;					\
+    register mg_u_long *__min_code = (mcodes);			\
+    register mg_u_long *__mclen = __min_code;			\
+    register mg_u_long **__values = (values);			\
+    register mg_u_long __code = 0;					\
     do									\
       {									\
@@ -96,8 +96,8 @@
 #define HUFF_DECODE_L(x, mcodes, values, count)				\
   do {									\
-    register unsigned long *__min_code = (mcodes);			\
-    register unsigned long *__mclen = __min_code;			\
-    register unsigned long **__values = (values);			\
-    register unsigned long __code = 0;					\
+    register mg_u_long *__min_code = (mcodes);			\
+    register mg_u_long *__mclen = __min_code;			\
+    register mg_u_long **__values = (values);			\
+    register mg_u_long __code = 0;					\
     do									\
       {									\
Index: main/trunk/greenstone2/common-src/indexers/mg/lib/huffman_mem.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/lib/huffman_mem.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/lib/huffman_mem.c	(revision 25147)
@@ -30,5 +30,5 @@
 
 void 
-BIO_Mem_Huff_Encode (unsigned long val, unsigned long *codes,
+BIO_Mem_Huff_Encode (mg_u_long val, mg_u_long *codes,
 		     char *clens, mem_bitio_state * bs)
 {
@@ -38,9 +38,9 @@
 }
 
-unsigned long 
-BIO_Mem_Huff_Decode (unsigned long *mincodes,
-		     unsigned long **values, mem_bitio_state * bs)
+mg_u_long 
+BIO_Mem_Huff_Decode (mg_u_long *mincodes,
+		     mg_u_long **values, mem_bitio_state * bs)
 {
-  unsigned long val;
+  mg_u_long val;
   DECODE_CONTINUE (*bs)
     HUFF_DECODE (val, mincodes, values);
Index: main/trunk/greenstone2/common-src/indexers/mg/lib/huffman_mem.h
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/lib/huffman_mem.h	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/lib/huffman_mem.h	(revision 25147)
@@ -25,9 +25,9 @@
 
 
-void BIO_Mem_Huff_Encode (unsigned long val, unsigned long *codes,
+void BIO_Mem_Huff_Encode (mg_u_long val, mg_u_long *codes,
 			  char *clens, mem_bitio_state * bs);
 
-unsigned long BIO_Mem_Huff_Decode (unsigned long *mincodes,
-			      unsigned long **values, mem_bitio_state * bs);
+mg_u_long BIO_Mem_Huff_Decode (mg_u_long *mincodes,
+			      mg_u_long **values, mem_bitio_state * bs);
 
 
Index: main/trunk/greenstone2/common-src/indexers/mg/lib/huffman_stdio.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/lib/huffman_stdio.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/lib/huffman_stdio.c	(revision 25147)
@@ -33,5 +33,5 @@
 
 void 
-BIO_Stdio_Huff_Encode (unsigned long val, unsigned long *codes,
+BIO_Stdio_Huff_Encode (mg_u_long val, mg_u_long *codes,
 		       char *clens, stdio_bitio_state * bs)
 {
@@ -41,10 +41,10 @@
 }
 
-unsigned long 
-BIO_Stdio_Huff_Decode (unsigned long *mincodes,
-		       unsigned long **values,
+mg_u_long 
+BIO_Stdio_Huff_Decode (mg_u_long *mincodes,
+		       mg_u_long **values,
 		       stdio_bitio_state * bs)
 {
-  unsigned long val;
+  mg_u_long val;
   DECODE_CONTINUE (*bs)
     HUFF_DECODE (val, mincodes, values);
Index: main/trunk/greenstone2/common-src/indexers/mg/lib/huffman_stdio.h
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/lib/huffman_stdio.h	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/lib/huffman_stdio.h	(revision 25147)
@@ -25,10 +25,10 @@
 
 
-void BIO_Stdio_Huff_Encode (unsigned long val, unsigned long *codes,
+void BIO_Stdio_Huff_Encode (mg_u_long val, mg_u_long *codes,
 			    char *clens, stdio_bitio_state * bs);
 
 
-unsigned long BIO_Stdio_Huff_Decode (unsigned long *mincodes,
-				     unsigned long **values,
+mg_u_long BIO_Stdio_Huff_Decode (mg_u_long *mincodes,
+				     mg_u_long **values,
 				     stdio_bitio_state * bs);
 
Index: main/trunk/greenstone2/common-src/indexers/mg/lib/longlong.h
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/lib/longlong.h	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/lib/longlong.h	(revision 25147)
@@ -22,4 +22,6 @@
 #ifndef H_LONGLONG
 #define H_LONGLONG
+
+#include "mglong.h"
 
 #ifndef __WIN32__
@@ -71,9 +73,9 @@
 
 /* Not using GCC, so fall back on plain "long" (32-bit) types */
-typedef unsigned long int mg_ullong;
-typedef long int mg_llong;
+typedef uint32_t mg_ullong;
+typedef int32_t mg_llong;
 
-#define ULL_FS "lu"
-#define LL_FS "ld"
+#define ULL_FS "u"
+#define LL_FS "d"
 
 #endif /* __GNUC__ */
Index: main/trunk/greenstone2/common-src/indexers/mg/lib/messages.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/lib/messages.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/lib/messages.c	(revision 25147)
@@ -28,5 +28,5 @@
 
 
-void VOLATILE 
+void
 FatalError (int ExitCode, const char *fmt,...)
 {
Index: main/trunk/greenstone2/common-src/indexers/mg/lib/messages.h
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/lib/messages.h	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/lib/messages.h	(revision 25147)
@@ -31,5 +31,5 @@
 extern char *msg_prefix;
 
-void VOLATILE FatalError (int ExitCode, const char *fmt,...);
+void FatalError (int ExitCode, const char *fmt,...);
 
 void Message (const char *fmt,...);
Index: main/trunk/greenstone2/common-src/indexers/mg/lib/mglong.h
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/lib/mglong.h	(revision 25147)
+++ main/trunk/greenstone2/common-src/indexers/mg/lib/mglong.h	(revision 25147)
@@ -0,0 +1,14 @@
+#ifndef MGLONG_H
+#define MGLONG_H
+
+#include <stdint.h>
+
+#ifndef mg_u_long
+#define mg_u_long uint32_t
+#endif
+
+#ifndef mg_s_long
+#define mg_s_long int32_t
+#endif
+
+#endif
Index: main/trunk/greenstone2/common-src/indexers/mg/lib/netorder.h
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/lib/netorder.h	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/lib/netorder.h	(revision 25147)
@@ -17,5 +17,5 @@
 #define HTOND(d)                                                                                  \
         do {                                                                                      \
-             unsigned long tmph, tmpl;                                                            \
+             mg_u_long tmph, tmpl;                                                            \
 	     bcopy ((char *) &d, (char *) &tmph, sizeof(double) >> 1);                            \
 	     bcopy ((char *) &d + (sizeof(double) >> 1), (char *) &tmpl, sizeof (double) >> 1);   \
@@ -27,5 +27,5 @@
 #define NTOHD(d)                                                                                  \
         do {                                                                                      \
-             unsigned long tmph, tmpl;                                                            \
+             mg_u_long tmph, tmpl;                                                            \
 	     bcopy ((char *) &d, (char *) &tmph, sizeof(double) >> 1);                            \
 	     bcopy ((char *) &d + (sizeof(double) >> 1), (char *) &tmpl, sizeof (double) >> 1);   \
@@ -37,5 +37,5 @@
 #define HTOND2(hd, nd)                                                                            \
         do {                                                                                      \
-             unsigned long tmph, tmpl;                                                            \
+             mg_u_long tmph, tmpl;                                                            \
 	     bcopy ((char *) &hd, (char *) &tmph, sizeof(double) >> 1);                           \
 	     bcopy ((char *) &hd + (sizeof(double) >> 1), (char *) &tmpl, sizeof (double) >> 1);  \
@@ -47,5 +47,5 @@
 #define NTOHD2(nd, hd)                                                                            \
         do {                                                                                      \
-             unsigned long tmph, tmpl;                                                            \
+             mg_u_long tmph, tmpl;                                                            \
 	     bcopy ((char *) &nd, (char *) &tmph, sizeof(double) >> 1);                           \
 	     bcopy ((char *) &nd + (sizeof(double) >> 1), (char *) &tmpl, sizeof (double) >> 1);  \
@@ -59,5 +59,5 @@
 #define HTONF(f)                                                                   \
         do {                                                                       \
-             unsigned long tmp;                                                    \
+             mg_u_long tmp;                                                    \
              bcopy ((char *) &(f), (char *) &tmp, sizeof (float));                 \
              HTONUL (tmp);                                                         \
@@ -66,5 +66,5 @@
 #define NTOHF(f)                                                                   \
         do {                                                                       \
-             unsigned long tmp;                                                    \
+             mg_u_long tmp;                                                    \
              bcopy ((char *) &(f), (char *) &tmp, sizeof (float));                 \
 	     NTOHUL (tmp);                                                         \
@@ -73,5 +73,5 @@
 #define HTONF2(hf, nf)                                                             \
         do {                                                                       \
-             unsigned long tmp;                                                    \
+             mg_u_long tmp;                                                    \
              bcopy ((char *) &(hf), (char *) &tmp, sizeof (float));                \
              HTONUL (tmp);                                                         \
@@ -80,5 +80,5 @@
 #define NTOHF2(nf, hf)                                                             \
         do {                                                                       \
-             unsigned long tmp;                                                    \
+             mg_u_long tmp;                                                    \
              bcopy ((char *) &(nf), (char *) &tmp, sizeof (float));                \
 	     NTOHUL (tmp);                                                         \
@@ -115,8 +115,8 @@
 
 /* pointers */
-#define HTONP(p)          ((p) = (void *) htonl ((unsigned long) p))
-#define NTOHP(p)          ((p) = (void *) ntohl ((unsigned long) p))
-#define HTONP2(hp, np)    ((np) = (void *) htonl ((unsigned long) hp))
-#define NTOHP2(np, hp)    ((hp) = (void *) ntohl ((unsigned long) np))
+#define HTONP(p)          ((p) = (void *) htonl ((mg_u_long) p))
+#define NTOHP(p)          ((p) = (void *) ntohl ((mg_u_long) p))
+#define HTONP2(hp, np)    ((np) = (void *) htonl ((mg_u_long) hp))
+#define NTOHP2(np, hp)    ((hp) = (void *) ntohl ((mg_u_long) np))
 
 /* unsigned long */
@@ -127,20 +127,20 @@
 
 /* signed long */
-#define HTONSL(l)         ((l) = (long) htonl ((unsigned long) (l)))
-#define NTOHSL(l)         ((l) = (long) ntohl ((unsigned long) (l)))
-#define HTONSL2(hl, nl)   ((nl) = (long) htonl ((unsigned long) (hl)))
-#define NTOHSL2(nl, hl)   ((hl) = (long) ntohl ((unsigned long) (nl)))
+#define HTONSL(l)         ((l) = (mg_s_long) htonl ((mg_u_long) (l)))
+#define NTOHSL(l)         ((l) = (mg_s_long) ntohl ((mg_u_long) (l)))
+#define HTONSL2(hl, nl)   ((nl) = (mg_s_long) htonl ((mg_u_long) (hl)))
+#define NTOHSL2(nl, hl)   ((hl) = (mg_s_long) ntohl ((mg_u_long) (nl)))
 
 /* unsigned int */
-#define HTONUI(i)         ((i) = (unsigned int) htonl ((unsigned long) (i)))
-#define NTOHUI(i)         ((i) = (unsigned int) ntohl ((unsigned long) (i)))
-#define HTONUI2(hi, ni)   ((ni) = (unsigned int) htonl ((unsigned long) (hi)))
-#define NTOHUI2(ni, hi)   ((hi) = (unsigned int) ntohl ((unsigned long) (ni)))
+#define HTONUI(i)         ((i) = (unsigned int) htonl ((mg_u_long) (i)))
+#define NTOHUI(i)         ((i) = (unsigned int) ntohl ((mg_u_long) (i)))
+#define HTONUI2(hi, ni)   ((ni) = (unsigned int) htonl ((mg_u_long) (hi)))
+#define NTOHUI2(ni, hi)   ((hi) = (unsigned int) ntohl ((mg_u_long) (ni)))
 
 /* signed int */
-#define HTONSI(i)         ((i) = (int) htonl ((unsigned long) (i)))
-#define NTOHSI(i)         ((i) = (int) ntohl ((unsigned long) (i)))
-#define HTONSI2(hi, ni)   ((ni) = (int) htonl ((unsigned long) (hi)))
-#define NTOHSI2(ni, hi)   ((hi) = (int) ntohl ((unsigned long) (ni)))
+#define HTONSI(i)         ((i) = (int) htonl ((mg_u_long) (i)))
+#define NTOHSI(i)         ((i) = (int) ntohl ((mg_u_long) (i)))
+#define HTONSI2(hi, ni)   ((ni) = (int) htonl ((mg_u_long) (hi)))
+#define NTOHSI2(ni, hi)   ((hi) = (int) ntohl ((mg_u_long) (ni)))
 
 /* unsigned short */
Index: main/trunk/greenstone2/common-src/indexers/mg/lib/perf_hash.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/lib/perf_hash.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/lib/perf_hash.c	(revision 25147)
@@ -42,5 +42,5 @@
 
 /* Random Number stuff */
-static long seed[] = {0, 0};
+static mg_s_long seed[] = {0, 0};
 #define RANDOM() irandm(seed)
 #define SEED_RANDOM(the_seed) do{ seed[0] = the_seed; }while(0)
@@ -105,5 +105,5 @@
 
 #ifndef STRUCT
-static long **tb0, **tb1, **tb2;
+static mg_s_long **tb0, **tb1, **tb2;
 #else
 struct tb_entry **tb;
@@ -128,6 +128,5 @@
 {				/* deletes edge e from list of v */
 
-  int b;
-
+  int b, norm_b;
   b = FIRST[v];
   assert (norm (b) != 0);
@@ -700,11 +699,11 @@
     {
       if (tb0)
-	if (!(tb0[i] = Xmalloc (sizeof (long) * MAX_L)))
+	if (!(tb0[i] = Xmalloc (sizeof (mg_s_long) * MAX_L)))
 	    ok = 0;
       if (tb1)
-	if (!(tb1[i] = Xmalloc (sizeof (long) * MAX_L)))
+	if (!(tb1[i] = Xmalloc (sizeof (mg_s_long) * MAX_L)))
 	    ok = 0;
       if (tb2)
-	if (!(tb2[i] = Xmalloc (sizeof (long) * MAX_L)))
+	if (!(tb2[i] = Xmalloc (sizeof (mg_s_long) * MAX_L)))
 	    ok = 0;
     }
@@ -744,5 +743,5 @@
 
   if (r <= 0)
-    SEED_RANDOM ((long) time ((time_t *) NULL));
+    SEED_RANDOM ((mg_s_long) time ((time_t *) NULL));
   else
     SEED_RANDOM (r);
@@ -907,11 +906,11 @@
     {
       if (phd->tb0)
-	if (!(phd->tb0[i] = Xmalloc (sizeof (long) * phd->MAX_L)))
+	if (!(phd->tb0[i] = Xmalloc (sizeof (mg_s_long) * phd->MAX_L)))
 	    ok = 0;
       if (phd->tb1)
-	if (!(phd->tb1[i] = Xmalloc (sizeof (long) * phd->MAX_L)))
+	if (!(phd->tb1[i] = Xmalloc (sizeof (mg_s_long) * phd->MAX_L)))
 	    ok = 0;
       if (phd->tb2)
-	if (!(phd->tb2[i] = Xmalloc (sizeof (long) * phd->MAX_L)))
+	if (!(phd->tb2[i] = Xmalloc (sizeof (mg_s_long) * phd->MAX_L)))
 	    ok = 0;
     }
@@ -951,9 +950,9 @@
       int j;
 
-      tot += fread ((char *) phd->tb0[i], sizeof (long), phd->MAX_L, f) *
+      tot += fread ((char *) phd->tb0[i], sizeof (mg_s_long), phd->MAX_L, f) *
         sizeof (int);
-      tot += fread ((char *) phd->tb1[i], sizeof (long), phd->MAX_L, f) *
+      tot += fread ((char *) phd->tb1[i], sizeof (mg_s_long), phd->MAX_L, f) *
         sizeof (int);
-      tot += fread ((char *) phd->tb2[i], sizeof (long), phd->MAX_L, f) *
+      tot += fread ((char *) phd->tb2[i], sizeof (mg_s_long), phd->MAX_L, f) *
         sizeof (int);
 
Index: main/trunk/greenstone2/common-src/indexers/mg/lib/perf_hash.h
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/lib/perf_hash.h	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/lib/perf_hash.h	(revision 25147)
@@ -23,10 +23,9 @@
 #define H_PERF_HASH
 
-
-
+#include "mglong.h"
 
 struct tb_entry
   {
-    long tb0, tb1, tb2;
+    mg_s_long tb0, tb1, tb2;
   };
 
Index: main/trunk/greenstone2/common-src/indexers/mg/lib/random.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/lib/random.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/lib/random.c	(revision 25147)
@@ -33,6 +33,7 @@
  *	The table mt[0:127] is defined by mt[i] = 69069 ** (128-i)
  */
-
-#define MASK ((long) 593970775)
+#include "random.h"
+
+#define MASK ((mg_s_long) 593970775)
 /*	or in hex, 23674657	*/
 
@@ -40,5 +41,5 @@
 /*	i.e. 2 to power -31	*/
 
-static long mt [128] =   {
+static mg_s_long mt [128] =   {
       902906369,
      2030498053,
@@ -172,7 +173,7 @@
 
 double 
-random (long is [2])
+random (mg_s_long is [2])
 {
-	long it, leh, nit;
+	mg_s_long it, leh, nit;
 
 	it = is [0];
@@ -187,13 +188,13 @@
 	is [0] = it;    is [1] = leh;
 	if (leh < 0) leh = ~leh;
-	return (SCALE * ((long) (leh | 1)));
+	return (SCALE * ((mg_s_long) (leh | 1)));
 }
 
 
 
-long 
-irandm (long is [2])
+mg_s_long 
+irandm (mg_s_long is [2])
 {
-	long it, leh, nit;
+	mg_s_long it, leh, nit;
 
 	it = is [0];
Index: main/trunk/greenstone2/common-src/indexers/mg/lib/random.h
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/lib/random.h	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/lib/random.h	(revision 25147)
@@ -36,7 +36,8 @@
  *	The table mt[0:127] is defined by mt[i] = 69069 ** (128-i)
  */
+#include "mglong.h"
 
-double random (long is [2]);
-long irandm (long is [2]);
+double random (mg_s_long is [2]);
+mg_s_long irandm (mg_s_long is [2]);
 
 #endif
Index: main/trunk/greenstone2/common-src/indexers/mg/lib/regex.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/lib/regex.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/lib/regex.c	(revision 25147)
@@ -2896,5 +2896,5 @@
   register char *fastmap = bufp->fastmap;
   unsigned char *pattern = bufp->buffer;
-  unsigned long size = bufp->used;
+  mg_u_long size = bufp->used;
   unsigned char *p = pattern;
   register unsigned char *pend = pattern + size;
Index: main/trunk/greenstone2/common-src/indexers/mg/lib/regex.h
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/lib/regex.h	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/lib/regex.h	(revision 25147)
@@ -292,8 +292,8 @@
 
 	/* Number of bytes to which `buffer' points.  */
-  unsigned long allocated;
+  mg_u_long allocated;
 
 	/* Number of bytes actually used in `buffer'.  */
-  unsigned long used;	
+  mg_u_long used;	
 
         /* Syntax setting with which the pattern was compiled.  */
Index: main/trunk/greenstone2/common-src/indexers/mg/lib/rx.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/lib/rx.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/lib/rx.c	(revision 25147)
@@ -615,8 +615,8 @@
 
 #ifdef __STDC__
-RX_DECL unsigned long
+RX_DECL mg_u_long
 rx_bitset_hash (int size, rx_Bitset b)
 #else
-RX_DECL unsigned long
+RX_DECL mg_u_long
 rx_bitset_hash (size, b)
      int size;
@@ -625,5 +625,5 @@
 {
   int x;
-  unsigned long hash = (unsigned long)rx_bitset_hash;
+  uintptr_t hash = (uintptr_t)rx_bitset_hash;
 
   for (x = rx_bitset_numb_subsets(size) - 1; x >= 0; --x)
@@ -701,5 +701,5 @@
 
 
-static unsigned long rx_hash_masks[4] =
+static mg_u_long rx_hash_masks[4] =
 {
   0x12488421,
@@ -714,5 +714,5 @@
 RX_DECL struct rx_hash_item * 
 rx_hash_find (struct rx_hash * table,
-	      unsigned long hash,
+	      mg_u_long hash,
 	      void * value,
 	      struct rx_hash_rules * rules)
@@ -721,5 +721,5 @@
 rx_hash_find (table, hash, value, rules)
      struct rx_hash * table;
-     unsigned long hash;
+     mg_u_long hash;
      void * value;
      struct rx_hash_rules * rules;
@@ -728,5 +728,5 @@
   rx_hash_eq eq = rules->eq;
   int maskc = 0;
-  long mask = rx_hash_masks [0];
+  mg_s_long mask = rx_hash_masks [0];
   int bucket = (hash & mask) % 13;
 
@@ -755,5 +755,5 @@
 RX_DECL struct rx_hash_item *
 rx_hash_store (struct rx_hash * table,
-	       unsigned long hash,
+	       mg_u_long hash,
 	       void * value,
 	       struct rx_hash_rules * rules)
@@ -762,5 +762,5 @@
 rx_hash_store (table, hash, value, rules)
      struct rx_hash * table;
-     unsigned long hash;
+     mg_u_long hash;
      void * value;
      struct rx_hash_rules * rules;
@@ -769,5 +769,5 @@
   rx_hash_eq eq = rules->eq;
   int maskc = 0;
-  long mask = rx_hash_masks[0];
+  mg_s_long mask = rx_hash_masks[0];
   int bucket = (hash & mask) % 13;
   int depth = 0;
@@ -803,5 +803,5 @@
 	{
 	  struct rx_hash_item * them = table->buckets[bucket];
-	  unsigned long newmask = rx_hash_masks[maskc + 1];
+	  mg_u_long newmask = rx_hash_masks[maskc + 1];
 	  while (them)
 	    {
@@ -855,5 +855,5 @@
     {
       struct rx_hash * table = it->table;
-      unsigned long hash = it->hash;
+      mg_u_long hash = it->hash;
       int depth = (table->parent
 		   ? (table->parent->parent
@@ -1775,7 +1775,7 @@
 	     : (!vb
 		? 1
-		: ((long)a->car < (long)b->car
+		: ((intptr_t)a->car < (intptr_t)b->car
 		   ? 1
-		   : ((long)a->car > (long)b->car
+		   : ((intptr_t)a->car > (intptr_t)b->car
 		      ? -1
 		      : se_list_cmp ((void *)a->cdr, (void *)b->cdr))))));
@@ -1842,5 +1842,5 @@
 #endif
 {
-  long hash = (long)car ^ (long)cdr;
+  intptr_t hash = (intptr_t)car ^ (intptr_t)cdr;
   struct rx_se_list template;
 
@@ -1955,5 +1955,5 @@
   template.cdr = set;
   node = rx_hash_store (memo,
-			(((long)state) >> 8) ^ (long)set,
+			(((intptr_t)state) >> 8) ^ (intptr_t)set,
 			&template, &nfa_set_hash_rules);
   if (!node)
@@ -2264,5 +2264,5 @@
 RX_DECL int 
 rx_compactify_nfa (struct rx *rx,
-		   void **mem, unsigned long *size)
+		   void **mem, mg_u_long *size)
 #else
 RX_DECL int 
@@ -2270,5 +2270,5 @@
      struct rx *rx;
      void **mem;
-     unsigned long *size;
+     mg_u_long *size;
 #endif
 {
@@ -2279,5 +2279,5 @@
   int se_list_consc = count_hash_nodes (&rx->se_list_memo);
   int nfa_setc = count_hash_nodes (&rx->set_list_memo);
-  unsigned long total_size;
+  mg_u_long total_size;
 
   /* This takes place in two stages.   First, the total size of the
@@ -2407,5 +2407,5 @@
 	      {
 		sp = rx_hash_find (&rx->se_list_memo,
-				   (long)sesrc->car ^ (long)sesrc->cdr,
+				   (intptr_t)sesrc->car ^ (intptr_t)sesrc->cdr,
 				   sesrc, &se_list_hash_rules);
 		if (sp->binding)
@@ -2425,6 +2425,6 @@
 	      {
 		sp = rx_hash_find (&rx->set_list_memo,
-				   ((((long)destlst->car) >> 8)
-				    ^ (long)destlst->cdr),
+				   ((((intptr_t)destlst->car) >> 8)
+				    ^ (intptr_t)destlst->cdr),
 				   destlst, &nfa_set_hash_rules);
 		if (sp->binding)
@@ -2798,5 +2798,5 @@
 	(rx_hash_find
 	 (&cache->superset_table,
-	  (unsigned long)set->car ^ set->id ^ (unsigned long)set->cdr,
+	  (intptr_t)set->car ^ set->id ^ (intptr_t)set->cdr,
 	  (void *)set,
 	  &cache->superset_hash_rules),
@@ -3056,5 +3056,5 @@
     = ((struct rx_cache *)
        ((char *)rules
-	- (unsigned long)(&((struct rx_cache *)0)->superset_hash_rules)));
+	- (intptr_t)(&((struct rx_cache *)0)->superset_hash_rules)));
   struct rx_superset * template = (struct rx_superset *)val;
   struct rx_superset * newset
@@ -3088,5 +3088,5 @@
     = ((struct rx_cache *)
        ((char *)rules
-	- (unsigned long)(&((struct rx_cache *)0)->superset_hash_rules)));
+	- (intptr_t)(&((struct rx_cache *)0)->superset_hash_rules)));
   return ((struct rx_hash *)
 	  rx_cache_malloc_or_get (cache,
@@ -3107,5 +3107,5 @@
   struct rx_cache * cache
     = ((struct rx_cache *)
-       (char *)rules - (long)(&((struct rx_cache *)0)->superset_hash_rules));
+       (char *)rules - (intptr_t)(&((struct rx_cache *)0)->superset_hash_rules));
   rx_cache_free (cache, &cache->free_hash, (char *)hash);
 }
@@ -3264,5 +3264,5 @@
     template.id = car->id;
     hit = rx_hash_store (&cache->superset_table,
-			 (unsigned long)car ^ car->id ^ (unsigned long)cdr,
+			 (intptr_t)car ^ car->id ^ (intptr_t)cdr,
 			 (void *)&template,
 			 &cache->superset_hash_rules);
@@ -4332,7 +4332,7 @@
 	return;
       case r_side_effect:
-	if (   ((long)rexp->params.side_effect >= 0)
-	    && (params [(long)rexp->params.side_effect].se == re_se_backref))
-	  out[ params [(long)rexp->params.side_effect].op1] = 1;
+	if (   ((intptr_t)rexp->params.side_effect >= 0)
+	    && (params [(intptr_t)rexp->params.side_effect].se == re_se_backref))
+	  out[ params [(intptr_t)rexp->params.side_effect].op1] = 1;
 	return;
       }
@@ -4516,5 +4516,5 @@
       case r_side_effect:
 	{
-	  int se = (long)rexp->params.side_effect;
+	  int se = (intptr_t)rexp->params.side_effect;
 	  if (   (se >= 0)
 	      && (   ((enum re_side_effects)params[se].se == re_se_lparen)
@@ -4563,7 +4563,7 @@
       return pointless_if_repeated (node->params.pair.left, params);
     case r_side_effect:
-      switch ((enum re_side_effects) (((long)node->params.side_effect < 0)
-	      ? (enum re_side_effects) (long) node->params.side_effect
-	      : (enum re_side_effects)params[(long)node->params.side_effect].se))
+      switch ((enum re_side_effects) (((intptr_t)node->params.side_effect < 0)
+	      ? (enum re_side_effects) (intptr_t) node->params.side_effect
+	      : (enum re_side_effects)params[(intptr_t)node->params.side_effect].se))
 	{
 	case re_se_try:
@@ -4588,4 +4588,12 @@
 	case re_se_backref:
 	  return 0;
+	case re_se_pushback:
+	case re_se_push0:
+	case re_se_pushpos:
+	case re_se_chkpos:
+	case re_se_poppos:
+	case re_se_tv:
+	case re_floogle_flap:
+	  return -1;
 	}
     case r_data:
@@ -4637,5 +4645,5 @@
       case r_side_effect:
 	{
-	  int se = (long)rexp->params.side_effect;
+	  int se = (intptr_t)rexp->params.side_effect;
 	  if (   in_danger
 	      && (se >= 0)
@@ -4757,7 +4765,7 @@
     case r_side_effect:
       return
-	!((long)rexp->params.side_effect > 0
-	  ? idempotent_complex_se [ params [(long)rexp->params.side_effect].se ]
-	  : idempotent_se [-(long)rexp->params.side_effect]);
+	!((intptr_t)rexp->params.side_effect > 0
+	  ? idempotent_complex_se [ params [(intptr_t)rexp->params.side_effect].se ]
+	  : idempotent_se [-(intptr_t)rexp->params.side_effect]);
       
     case r_alternate:
@@ -4811,5 +4819,5 @@
 
     case r_side_effect:
-      return ((long)rexp->params.side_effect >= 0);
+      return ((intptr_t)rexp->params.side_effect >= 0);
       
     case r_alternate:
@@ -5204,5 +5212,5 @@
 	      if (need_sync)
 		{
-		  int sync_se = paramc;
+		  intptr_t sync_se = paramc;
 		  params = (params
 			    ? ((struct re_se_params *)
@@ -5552,9 +5560,12 @@
             handle_close:
               /* See similar code for backslashed left paren above.  */
-              if (COMPILE_STACK_EMPTY)
-                if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD)
+              if (COMPILE_STACK_EMPTY){
+                if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD){
                   goto normal_char;
-                else
+		}
+                else{
                   return REG_ERPAREN;
+		}
+	      }
 
               /* Since we just checked for an empty stack above, this
@@ -5573,6 +5584,6 @@
                 this_group_regnum = COMPILE_STACK_TOP.regnum;
 		{
-		  int left_se = paramc;
-		  int right_se = paramc + 1;
+		  intptr_t left_se = paramc;
+		  intptr_t right_se = paramc + 1;
 
 		  params = (params
@@ -5625,5 +5636,5 @@
 		last_expression = &alt->params.pair.right;
 		{
-		  int sync_se = paramc;
+		  intptr_t sync_se = paramc;
 
 		  params = (params
@@ -5742,6 +5753,6 @@
 		  /* Otherwise, we have a nontrivial interval. */
 		  {
-		    int iter_se = paramc;
-		    int end_se = paramc + 1;
+		    intptr_t iter_se = paramc;
+		    intptr_t end_se = paramc + 1;
 		    params = (params
 			      ? ((struct re_se_params *)
@@ -5939,5 +5950,5 @@
 
 	      {
-		int backref_se = paramc;
+		intptr_t backref_se = paramc;
 		params = (params
 			  ? ((struct re_se_params *)
@@ -6009,5 +6020,5 @@
   
   {
-    int win_se = paramc;
+    intptr_t win_se = paramc;
     params = (params
 	      ? ((struct re_se_params *)
@@ -6149,5 +6160,5 @@
       {
 	void * mem = (void *)rxb->buffer;
-	unsigned long size = rxb->allocated;
+	mg_u_long size = rxb->allocated;
 	int start_id;
 	char * perm_mem;
@@ -6757,5 +6768,5 @@
   while (list)
     {
-      if ((long)list->car >= 0)
+      if ((intptr_t)list->car >= 0)
 	++x;
       list = list->cdr;
@@ -6812,5 +6823,5 @@
       for (ai = al - 1; ai >= 0; --ai)
 	{
-	  while ((long)ap->car < 0)
+	  while ((intptr_t)ap->car < 0)
 	    ap = ap->cdr;
 	  av[ai] = ap->car;
@@ -6820,5 +6831,5 @@
       for (bi = bl - 1; bi >= 0; --bi)
 	{
-	  while ((long)bp->car < 0)
+	  while ((intptr_t)bp->car < 0)
 	    bp = bp->cdr;
 	  bv[bi] = bp->car;
Index: main/trunk/greenstone2/common-src/indexers/mg/lib/rx.h
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/lib/rx.h	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/lib/rx.h	(revision 25147)
@@ -22,11 +22,5 @@
 /*  t. lord	Wed Sep 23 18:20:57 1992	*/
 
-
-
-
-
-
-
-
+#include "mglong.h"
 
 #ifndef RX_WANT_SE_DEFS
@@ -91,5 +85,5 @@
   struct rx_hash_item * next_same_hash;
   struct rx_hash * table;
-  unsigned long hash;
+  mg_u_long hash;
   void * data;
   void * binding;
@@ -273,5 +267,5 @@
    */
   void * buffer;
-  unsigned long allocated;
+  mg_u_long allocated;
 
   /* Clients of RX can ask for some extra storage in the space pointed
@@ -280,5 +274,5 @@
    * at (buffer + allocated - reserved)
    */
-  unsigned long reserved;
+  mg_u_long reserved;
 
   /* --------- The remaining fields are for internal use only. --------- */
@@ -1274,5 +1268,5 @@
 
   void * buffer;		/* Malloced memory for the nfa. */
-  unsigned long allocated;	/* Size of that memory. */
+  mg_u_long allocated;	/* Size of that memory. */
 
   /* Pointer to a fastmap, if any, otherwise zero.  re_search uses
@@ -1580,11 +1574,11 @@
 				      rx_Bitset a, rx_Bitset b);
 RX_DECL void rx_bitset_xor (int size, rx_Bitset a, rx_Bitset b);
-RX_DECL unsigned long rx_bitset_hash (int size, rx_Bitset b);
+RX_DECL mg_u_long rx_bitset_hash (int size, rx_Bitset b);
 RX_DECL struct rx_hash_item * rx_hash_find (struct rx_hash * table,
-					    unsigned long hash,
+					    mg_u_long hash,
 					    void * value,
 					    struct rx_hash_rules * rules);
 RX_DECL struct rx_hash_item * rx_hash_store (struct rx_hash * table,
-					     unsigned long hash,
+					     mg_u_long hash,
 					     void * value,
 					     struct rx_hash_rules * rules);
@@ -1637,5 +1631,5 @@
 RX_DECL void rx_delete_epsilon_transitions (struct rx *rx);
 RX_DECL int rx_compactify_nfa (struct rx *rx,
-			       void **mem, unsigned long *size);
+			       void **mem, mg_u_long *size);
 RX_DECL void rx_release_superset (struct rx *rx,
 				  struct rx_superset *set);
@@ -1665,5 +1659,5 @@
 RX_DECL void rx_bitset_revdifference ();
 RX_DECL void rx_bitset_xor ();
-RX_DECL unsigned long rx_bitset_hash ();
+RX_DECL mg_u_long rx_bitset_hash ();
 RX_DECL struct rx_hash_item * rx_hash_find ();
 RX_DECL struct rx_hash_item * rx_hash_store ();
@@ -2230,5 +2224,4 @@
 
 
-
 /* How many characters in the character set.  */
 #define CHAR_SET_SIZE (1 << CHARBITS)
@@ -2344,5 +2337,5 @@
 RX_DECL __inline__ int
 rx_search  (struct re_pattern_buffer * rxb,
-	    int startpos,
+	    intptr_t startpos,
 	    int range,
 	    int stop,
@@ -2361,5 +2354,5 @@
 	    app_closure, regs, resume_state, save_state)
      struct re_pattern_buffer * rxb;
-     int startpos;
+     intptr_t startpos;
      int range;
      int stop;
@@ -2739,5 +2732,5 @@
   {
     enum rx_test_match_entry test_pc;
-    int inx;
+    intptr_t inx;
     test_pc = search_state.test_match_resume_pt;
     if (test_pc == rx_test_start)
@@ -2839,5 +2832,5 @@
 		    ((struct rx_superstate *)
 		     ((char *)this_tr_table
-		      - ((unsigned long)
+		      - ((mg_u_long)
 			 ((struct rx_superstate *)0)->transitions)));
 		  
@@ -2904,5 +2897,5 @@
 	    ((struct rx_superstate *)
 	     ((char *)this_tr_table
-	      - ((unsigned long)
+	      - ((uintptr_t)
 		 ((struct rx_superstate *)0)->transitions)));
 	}
@@ -2911,5 +2904,5 @@
 	 * Dispatch that instruction:
 	 */
-	inx = (int)search_state.ifr->inx;
+	inx = (intptr_t)search_state.ifr->inx;
 #ifdef RX_DEBUG_0
 	if (rx_debug_trace)
@@ -2949,6 +2942,6 @@
 	      while (el)
 		{
-		  long effect;
-		  effect = (long)el->car;
+		  intptr_t effect;
+		  effect = (intptr_t)el->car;
 		  if (effect < 0)
 		    {
@@ -2990,5 +2983,5 @@
 			    = ((struct rx_superstate *)
 			       ((char *)search_state.ifr->data
-				- (long)(((struct rx_superstate *)0)
+				- (intptr_t)(((struct rx_superstate *)0)
 					 ->transitions)));
 			  goto top_of_cycle;
Index: main/trunk/greenstone2/common-src/indexers/mg/lib/sptree.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/lib/sptree.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/lib/sptree.c	(revision 25147)
@@ -293,12 +293,16 @@
 		q->par = p;				\
 		q->rght = p->left;			\
-		if(q->rght)				\
-			q->rght->par = q;		\
+		if(q->rght){				\
+		  q->rght->par = q;			\
+		}                                       \
 		p->left = q;				\
-		if(p->par)				\
-			if(q == p->par->left)		\
-				p->par->left = p;	\
-			else				\
-				p->par->rght = p;	\
+		if(p->par){				\
+		  if(q == p->par->left){		\
+		    p->par->left = p;			\
+		  }                                     \
+		  else{					\
+		    p->par->rght = p;			\
+		  }                                     \
+		}                                       \
 	}while(0)
 
@@ -308,12 +312,16 @@
 		q->par = p;				\
 		q->left = p->rght;			\
-		if(q->left)				\
-			q->left->par = q;		\
+		if(q->left){				\
+		  q->left->par = q;			\
+		}                                       \
 		p->rght = q;				\
-		if(p->par)				\
-			if(q == p->par->left)		\
-				p->par->left = p;	\
-			else				\
-				p->par->rght = p;	\
+		if(p->par){				\
+		  if(q == p->par->left){		\
+		    p->par->left = p;			\
+		  }                                     \
+		  else{		                        \
+		    p->par->rght = p;			\
+		  }                                     \
+		}                                       \
 	}while(0)
 
@@ -341,6 +349,7 @@
       if (p == q->left)
 	{
-	  if (g == NNULL)
+	  if (g == NNULL){
 	    ROTATER (p, q);
+	  }
 	  else if (q == g->left)
 	    {
@@ -356,6 +365,7 @@
       else
 	{
-	  if (g == NNULL)
+	  if (g == NNULL){
 	    ROTATEL (p, q);
+	  }
 	  else if (q == g->rght)
 	    {
Index: main/trunk/greenstone2/common-src/indexers/mg/lib/sptree.h
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/lib/sptree.h	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/lib/sptree.h	(revision 25147)
@@ -29,5 +29,5 @@
   {
     int no_of_items;
-    unsigned long mem_in_use;
+    mg_u_long mem_in_use;
     int (*cmp) (void *, void *);
     void *root;
Index: main/trunk/greenstone2/common-src/indexers/mg/lib/unitool.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/lib/unitool.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/lib/unitool.c	(revision 25147)
@@ -15,5 +15,5 @@
  * column
  */
-unsigned long *unicode_cat_data=NULL;
+mg_u_long *unicode_cat_data=NULL;
 
 
@@ -1464,5 +1464,5 @@
  * column
  */
-unsigned long *unicode_cat_data;
+mg_u_long *unicode_cat_data;
 
 void create_unicat_data () {
@@ -1470,5 +1470,5 @@
   int min_start=0;
   int min_end=0;
-  register unsigned long min_value=0; /* filling the whole byte */
+  register mg_u_long min_value=0; /* filling the whole byte */
   
   const unirange *letter_here = letter_info;
@@ -1529,5 +1529,5 @@
 	
       } else {
-	register unsigned long mask = 3 << ((i % 16) * 2);
+	register mg_u_long mask = 3 << ((i % 16) * 2);
 	unicode_cat_data[i/16] = (unicode_cat_data[i/16] & (~mask)) |
 				  (min_value & mask);
Index: main/trunk/greenstone2/common-src/indexers/mg/lib/win32in.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/lib/win32in.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/lib/win32in.c	(revision 25147)
@@ -4,5 +4,5 @@
 /* unix systems. */
 
-unsigned long htonl(unsigned long x) {
+mg_u_long htonl(mg_u_long x) {
 #if defined (LITTLE_ENDIAN) || defined (_LITTLE_ENDIAN) || defined(__LITTLE_ENDIAN)
 	x = ((x >> 24) & 0x000000FF) | ((x >> 8) & 0x0000FF00) |
@@ -25,5 +25,5 @@
 }
 
-unsigned long ntohl(unsigned long x) {
+mg_u_long ntohl(mg_u_long x) {
 #if defined (LITTLE_ENDIAN) || defined (_LITTLE_ENDIAN) || defined(__LITTLE_ENDIAN)
 	x = ((x >> 24) & 0x000000FF) | ((x >> 8) & 0x0000FF00) |
@@ -51,5 +51,5 @@
 
 main () {
-	long x;
+	mg_s_long x;
 	short sx;
 
Index: main/trunk/greenstone2/common-src/indexers/mg/lib/win32in.h
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/lib/win32in.h	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/lib/win32in.h	(revision 25147)
@@ -4,6 +4,6 @@
 #include "longlong.h"
 
-unsigned long htonl(unsigned long x);
-unsigned long ntohl(unsigned long x);
+mg_u_long htonl(mg_u_long x);
+mg_u_long ntohl(mg_u_long x);
 mg_ullong ntohll(mg_ullong x);
 unsigned short htons(unsigned short x);
Index: main/trunk/greenstone2/common-src/indexers/mg/src/images/Makefile.in
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/images/Makefile.in	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/images/Makefile.in	(revision 25147)
@@ -36,5 +36,5 @@
  
 CC = @CC@
-CFLAGS = @CFLAGS@  @COMPAT32BITFLAGS@
+CFLAGS = @CFLAGS@
 CPPFLAGS = @CPPFLAGS@
 DEFS = @DEFS@
@@ -42,5 +42,5 @@
 INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
-LDFLAGS = @LDFLAGS@ @COMPAT32BITFLAGS@
+LDFLAGS = @LDFLAGS@
 LIBS = ../../lib/libmglib.a @LIBS@
 TOUCH = echo timestamp >
Index: main/trunk/greenstone2/common-src/indexers/mg/src/images/mgfelics.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/images/mgfelics.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/images/mgfelics.c	(revision 25147)
@@ -55,5 +55,5 @@
   FILE *fp_in = (stdin), *fp_out = (stdout);
   int width, height, maxval;
-  u_long magic;
+  mg_u_long magic;
   char *filename = NULL;
   unsigned int *line;
Index: main/trunk/greenstone2/common-src/indexers/mg/src/images/pbmtools.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/images/pbmtools.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/images/pbmtools.c	(revision 25147)
@@ -64,5 +64,5 @@
 pbm_isapbmfile (FILE * fp)
 {
-  u_long magic;
+  mg_u_long magic;
 
   magic = getmagicno_short (fp);
Index: main/trunk/greenstone2/common-src/indexers/mg/src/images/utils.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/images/utils.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/images/utils.c	(revision 25147)
@@ -230,5 +230,5 @@
 
 void 
-magic_write (FILE * fp, u_long magic_num)
+magic_write (FILE * fp, mg_u_long magic_num)
 {
   HTONUL(magic_num);  /* [RPAP - Jan 97: Endian Ordering] */
@@ -239,7 +239,7 @@
 
 void 
-magic_check (FILE * fp, u_long magic_num)
-{
-  u_long magic;
+magic_check (FILE * fp, mg_u_long magic_num)
+{
+  mg_u_long magic;
   if (fread (&magic, sizeof (magic), 1, fp) != 1 || NTOHUL(magic) != magic_num)  /* [RPAP - Jan 97: Endian Ordering] */
     error_msg ("magic num", "Incorrect magic number.", "");
@@ -247,8 +247,8 @@
 
 
-u_long 
+mg_u_long 
 magic_read (FILE * fp)
 {
-  u_long magic;
+  mg_u_long magic;
   if (fread (&magic, sizeof (magic), 1, fp) != 1)
     error_msg ("magic num", "Couldn't read magic number.", "");
Index: main/trunk/greenstone2/common-src/indexers/mg/src/images/utils.h
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/images/utils.h	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/images/utils.h	(revision 25147)
@@ -45,5 +45,5 @@
 #define MAGIC_BILEVEL           GEN_MAGIC('M','G','B','I')
 #define MAGIC_TIC               GEN_MAGIC('M','G','T','C')
-#define IS_MAGIC(a) ((((u_long)(a)) & 0xffff0000) == MAGIC_XXXX)
+#define IS_MAGIC(a) ((((mg_u_long)(a)) & 0xffff0000) == MAGIC_XXXX)
 /* --------------------------------------- */
 
@@ -68,7 +68,7 @@
 void readline (char str[], FILE * fp);
 
-void magic_write (FILE * fp, u_long magic_num);
-void magic_check (FILE * fp, u_long magic_num);
-u_long magic_read (FILE * fp);
+void magic_write (FILE * fp, mg_u_long magic_num);
+void magic_check (FILE * fp, mg_u_long magic_num);
+mg_u_long magic_read (FILE * fp);
 /* kerry's code */
 
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/Makefile.in
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/Makefile.in	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/Makefile.in	(revision 25147)
@@ -38,5 +38,5 @@
 AR = ar
 CC = @CC@
-CFLAGS = @CFLAGS@ @COMPAT32BITFLAGS@ -fpic
+CFLAGS = @CFLAGS@ -fpic
 DEFS = @DEFS@
 RANLIB = @RANLIB@
@@ -44,5 +44,5 @@
 INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
-LDFLAGS = @LDFLAGS@ @COMPAT32BITFLAGS@
+LDFLAGS = @LDFLAGS@
 LIBS = ../../lib/libmglib.a @LIBS@
 TOUCH = echo timestamp >
@@ -53,5 +53,5 @@
 # Uncomment for compiling for the nzdl project
 #
-CFLAGS = @CFLAGS@ @COMPAT32BITFLAGS@ -fpic -DNZDL -DQUIET -DSHORT_SUFFIX -DPARADOCNUM
+CFLAGS = @CFLAGS@ -fpic -DNZDL -DQUIET -DSHORT_SUFFIX -DPARADOCNUM
 ##########################################
 
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/backend.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/backend.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/backend.c	(revision 25147)
@@ -47,5 +47,5 @@
 
 static File *
-OpenFile (char *base, char *suffix, unsigned long magic, int *ok)
+OpenFile (char *base, char *suffix, mg_u_long magic, int *ok)
 {
   char FileName[512];
@@ -62,5 +62,5 @@
   if (magic)
     {
-      unsigned long m;
+      mg_u_long m;
       if (fread ((char *) &m, sizeof (m), 1, F->f) == 0)
 	{
@@ -475,5 +475,5 @@
   if (qd->id->ifh.InvfLevel == 3)
     {
-      unsigned long magic;
+      mg_u_long magic;
       FILE *paragraph;
       int i;
@@ -507,5 +507,5 @@
   {
     extern char *trec_ids;
-    extern long *trec_paras;
+    extern mg_s_long *trec_paras;
     int size;
     char FileName[512];
@@ -533,6 +533,6 @@
       {
 	int i, d;
-	unsigned long magic;
-	trec_paras = Xmalloc (qd->sd->sdh.num_of_docs * sizeof (long));
+	mg_u_long magic;
+	trec_paras = Xmalloc (qd->sd->sdh.num_of_docs * sizeof (mg_s_long));
 	if (!trec_paras)
 	  {
@@ -598,5 +598,5 @@
  */
 void 
-ChangeMemInUse (query_data * qd, long delta)
+ChangeMemInUse (query_data * qd, mg_s_long delta)
 {
   qd->mem_in_use += delta;
@@ -775,5 +775,5 @@
 }
 
-long 
+mg_s_long 
 GetDocCompLength (query_data * qd)
 {
@@ -785,5 +785,5 @@
 
 u_char *
-GetDocText (query_data * qd, unsigned long *len)
+GetDocText (query_data * qd, mg_u_long *len)
 {
   DocEntry *DE;
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/backend.h
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/backend.h	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/backend.h	(revision 25147)
@@ -40,6 +40,6 @@
   {
     File *InvfFile;
-    unsigned long N;
-    unsigned long Nstatic;	/* N parameter for decoding inverted file entries */
+    mg_u_long N;
+    mg_u_long Nstatic;	/* N parameter for decoding inverted file entries */
     struct invf_file_header ifh;
   }
@@ -51,8 +51,8 @@
     File *TextIdxFile;
     File *TextIdxWgtFile;
-    long current_pos;
+    mg_s_long current_pos;
     struct
       {
-	unsigned long Start;
+	mg_u_long Start;
 	float Weight;
       }
@@ -78,11 +78,11 @@
     compression_dict_header cdh;
     comp_frags_header *cfh[2];
-    unsigned long MemForCompDict;
+    mg_u_long MemForCompDict;
     u_char ***values[2];
     u_char *escape[2];
     huff_data *chars_huff[2];
-    u_long **chars_vals[2];
+    mg_u_long **chars_vals[2];
     huff_data *lens_huff[2];
-    u_long **lens_vals[2];
+    mg_u_long **lens_vals[2];
     auxiliary_dict *ad;
     int fast_loaded;
@@ -96,8 +96,8 @@
     struct stem_idx_header sih;
     u_char **index;
-    unsigned long *pos;
+    mg_u_long *pos;
     int active;
     u_char *buffer;
-    unsigned long MemForStemIdx;
+    mg_u_long MemForStemIdx;
   }
 stemmed_idx;
@@ -109,8 +109,8 @@
     struct stem_dict_header sdh;
     u_char **index;
-    unsigned long *pos;
+    mg_u_long *pos;
     int active;
     u_char *buffer;
-    unsigned long MemForStemDict;
+    mg_u_long MemForStemDict;
 
     /* [RPAP - Jan 97: Stem Index Change] */
@@ -126,10 +126,10 @@
     double L;
     double B;
-    unsigned long *DocWeights;
+    mg_u_long *DocWeights;
     char bits;
     float *table;
-    unsigned long mask;
-    unsigned long MemForWeights;
-    unsigned long num_of_docs;
+    mg_u_long mask;
+    mg_u_long MemForWeights;
+    mg_u_long num_of_docs;
   }
 approx_weights_data;
@@ -140,12 +140,12 @@
     int QueryFreqs;
     int Exact;           /* use exact weights for ranking or not */
-    long MaxDocsToRetrieve;	/* may be -1 for all */
-    long MaxParasToRetrieve;
+    mg_s_long MaxDocsToRetrieve;	/* may be -1 for all */
+    mg_s_long MaxParasToRetrieve;
     int Sort;        
     char AccumMethod;		/* 'A' = array,  'S' = splay tree,  'H' = hash_table */
-    long MaxAccums;		/* may be -1 for all */
-    long MaxTerms;		/* may be -1 for all */
+    mg_s_long MaxAccums;		/* may be -1 for all */
+    mg_s_long MaxTerms;		/* may be -1 for all */
     int StopAtMaxAccum; /* Stop at maximum accumulator or not */
-    long HashTblSize;
+    mg_s_long HashTblSize;
     char *skip_dump;
   }
@@ -156,5 +156,5 @@
 typedef struct BooleanQueryInfo
   {
-    long MaxDocsToRetrieve;
+    mg_s_long MaxDocsToRetrieve;
   }
 BooleanQueryInfo;
@@ -191,12 +191,12 @@
     File *File_invf;
     File *File_weight_approx;
-    unsigned long mem_in_use, max_mem_in_use;
-    unsigned long num_of_ptrs, tot_num_of_ptrs;
-    unsigned long num_of_terms, tot_num_of_terms;
-    unsigned long num_of_accum, tot_num_of_accum;
-    unsigned long num_of_ans, tot_num_of_ans;
-    unsigned long hops_taken, tot_hops_taken;
-    unsigned long text_idx_lookups, tot_text_idx_lookups;
-    unsigned long max_buffers;
+    mg_u_long mem_in_use, max_mem_in_use;
+    mg_u_long num_of_ptrs, tot_num_of_ptrs;
+    mg_u_long num_of_terms, tot_num_of_terms;
+    mg_u_long num_of_accum, tot_num_of_accum;
+    mg_u_long num_of_ans, tot_num_of_ans;
+    mg_u_long hops_taken, tot_hops_taken;
+    mg_u_long text_idx_lookups, tot_text_idx_lookups;
+    mg_u_long max_buffers;
     unsigned doc_pos;
     unsigned buf_in_use;
@@ -226,5 +226,5 @@
 query_data *InitQuerySystem (char *dir, char *name, char *textname, InitQueryTimes * iqt);
 
-void ChangeMemInUse (query_data * qd, long delta);
+void ChangeMemInUse (query_data * qd, mg_s_long delta);
 
 void FinishQuerySystem (query_data * qd);
@@ -251,7 +251,7 @@
 float GetDocWeight (query_data * qd);
 
-long GetDocCompLength (query_data * qd);
-
-u_char *GetDocText (query_data * qd, unsigned long *len);
+mg_s_long GetDocCompLength (query_data * qd);
+
+u_char *GetDocText (query_data * qd, mg_u_long *len);
 
 DocEntry *GetDocChain (query_data * qd);
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/bool_parser.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/bool_parser.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/bool_parser.c	(revision 25147)
@@ -44,8 +44,8 @@
 static QueryTermList **query_term_list;
 static int word_num;
-static u_long count;
-static u_long doc_count;
-static u_long invf_ptr;
-static u_long invf_len;
+static mg_u_long count;
+static mg_u_long doc_count;
+static mg_u_long invf_ptr;
+static mg_u_long invf_len;
 
 #line 66 "bool_parser.y"
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/bool_parser.y
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/bool_parser.y	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/bool_parser.y	(revision 25147)
@@ -57,8 +57,8 @@
 static QueryTermList **query_term_list;
 static int word_num;
-static u_long count;
-static u_long doc_count;
-static u_long invf_ptr;
-static u_long invf_len;
+static mg_u_long count;
+static mg_u_long doc_count;
+static mg_u_long invf_ptr;
+static mg_u_long invf_len;
 %}
  
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/bool_tester.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/bool_tester.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/bool_tester.c	(revision 25147)
@@ -151,5 +151,5 @@
 	      prompt (str);
 	      te->WE.doc_count = atoi (line);
-	      printf ("doc_count = %ld\n", te->WE.doc_count);
+	      printf ("doc_count = %d\n", te->WE.doc_count);
 	    }			/*for */
 	}			/*if */
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/bool_tree.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/bool_tree.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/bool_tree.c	(revision 25147)
@@ -56,5 +56,5 @@
 bool_tree_node *
 CreateBoolTermNode (TermList ** tl, char *text, int Count, int word_num,
-		    u_long count, u_long doc_count, u_long invf_ptr, u_long invf_len,  /* [RPAP - Feb 97: Term Frequency] */
+		    mg_u_long count, mg_u_long doc_count, mg_u_long invf_ptr, mg_u_long invf_len,  /* [RPAP - Feb 97: Term Frequency] */
 		    int stemmer_num) 
 {
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/bool_tree.h
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/bool_tree.h	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/bool_tree.h	(revision 25147)
@@ -102,6 +102,6 @@
 bool_tree_node *CopyBoolTree (bool_tree_node * tree);
 bool_tree_node *CreateBoolTermNode (TermList ** tl, char *text, int Count, int word_num,
-				    u_long count, u_long doc_count, u_long invf_ptr, 
-				    u_long invf_len, int stemmer_num);
+				    mg_u_long count, mg_u_long doc_count, mg_u_long invf_ptr, 
+				    mg_u_long invf_len, int stemmer_num);
 bool_tree_node *CreateBoolTreeNode (N_Tag tag,
 			     bool_tree_node * left, bool_tree_node * right);
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/build.h
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/build.h	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/build.h	(revision 25147)
@@ -111,15 +111,15 @@
 
 
-extern unsigned long buf_size;
+extern mg_u_long buf_size;
 /*
  * The size of the document input buffer.
  */
 
-extern unsigned long ChunkLimit;
+extern mg_u_long ChunkLimit;
 /*
  * The maximum number of chunks that can be written to disk.
  */
 
-extern unsigned long invf_buffer_size;
+extern mg_u_long invf_buffer_size;
 /*
  * The amount of memory to allocate to the invertion buffer.
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/comp_dict.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/comp_dict.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/comp_dict.c	(revision 25147)
@@ -66,7 +66,7 @@
 huff_data char_huff[2];
 huff_data lens_huff[2];
-u_long *char_codes[2], *lens_codes[2];
-u_long Words_disk = 0;
-u_long Chars_disk = 0;
+mg_u_long *char_codes[2], *lens_codes[2];
+mg_u_long Words_disk = 0;
+mg_u_long Chars_disk = 0;
 
 
@@ -79,5 +79,5 @@
   dict_hash_table *ht;
   u_char **words;
-  u_long ht_size;
+  mg_u_long ht_size;
 
   ht_size = prime (cfh->hd.num_codes * HASH_RATIO);
@@ -133,5 +133,5 @@
 	  register u_char **wptr;
 	  register int tsize = ht->size;
-	  register unsigned long hashval, step;
+	  register mg_u_long hashval, step;
 
 	  HASH (hashval, step, allwords, tsize);
@@ -163,5 +163,5 @@
     return COMPERROR;
 
-  Words_disk = sizeof (u_long);
+  Words_disk = sizeof (mg_u_long);
 
   if (Read_cdh (dict, &cdh, NULL, &Words_disk) == -1)
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/comp_dict.h
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/comp_dict.h	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/comp_dict.h	(revision 25147)
@@ -32,7 +32,7 @@
 typedef struct dict_hash_table
   {
-    u_long size;
+    mg_u_long size;
     huff_data *hd;
-    u_long *codes;
+    mg_u_long *codes;
     u_char **words;
     u_char **table[1];
@@ -51,7 +51,7 @@
 extern huff_data char_huff[2];
 extern huff_data lens_huff[2];
-extern u_long *char_codes[2], *lens_codes[2];
-extern u_long Words_disk;
-extern u_long Chars_disk;
+extern mg_u_long *char_codes[2], *lens_codes[2];
+extern mg_u_long Words_disk;
+extern mg_u_long Chars_disk;
 
 
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/environment.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/environment.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/environment.c	(revision 25147)
@@ -347,8 +347,8 @@
  * or default on a error
  */
-long 
-IntEnv (char *data, long def)
-{
-  long val;
+mg_s_long 
+IntEnv (char *data, mg_s_long def)
+{
+  mg_s_long val;
   char *ptr;
   if (!data)
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/environment.h
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/environment.h	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/environment.h	(revision 25147)
@@ -54,5 +54,5 @@
 char *GetEnvName (int i);
 int BooleanEnv (char *data, int def);
-long IntEnv (char *data, long def);
+mg_s_long IntEnv (char *data, mg_s_long def);
 
 void InitEnv (void);
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/hash.h
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/hash.h	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/hash.h	(revision 25147)
@@ -31,6 +31,6 @@
 	do {						\
 		register u_char *p=wd;			\
-		register long len = *p++;		\
-		register unsigned long hval;		\
+		register mg_s_long len = *p++;		\
+		register mg_u_long hval;		\
 		if (len>25) len = 25;			\
 		for (hval=0; len; --len)		\
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/invf.h
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/invf.h	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/invf.h	(revision 25147)
@@ -30,38 +30,38 @@
 struct invf_dict_header
   {
-    unsigned long lookback;
-    unsigned long dict_size;
-    unsigned long total_bytes;
-    unsigned long index_string_bytes;
+    mg_u_long lookback;
+    mg_u_long dict_size;
+    mg_u_long total_bytes;
+    mg_u_long index_string_bytes;
     double input_bytes; /* [RJM 07/97: 4G limit] */
-    unsigned long num_of_docs;
-    unsigned long static_num_of_docs;
-    unsigned long num_of_words;
-    unsigned long stemmer_num;
-    unsigned long stem_method;
+    mg_u_long num_of_docs;
+    mg_u_long static_num_of_docs;
+    mg_u_long num_of_words;
+    mg_u_long stemmer_num;
+    mg_u_long stem_method;
   };
 
 struct stem_dict_header
   {
-    unsigned long lookback;
-    unsigned long block_size;
-    unsigned long num_blocks;
-    unsigned long blocks_start;
-    unsigned long index_chars;
-    unsigned long num_of_docs;
-    unsigned long static_num_of_docs;
-    unsigned long num_of_words;
-    unsigned long stemmer_num;
-    unsigned long stem_method;
-    unsigned long indexed;       /* [RPAP - Jan 97: Stem Index Change] */
+    mg_u_long lookback;
+    mg_u_long block_size;
+    mg_u_long num_blocks;
+    mg_u_long blocks_start;
+    mg_u_long index_chars;
+    mg_u_long num_of_docs;
+    mg_u_long static_num_of_docs;
+    mg_u_long num_of_words;
+    mg_u_long stemmer_num;
+    mg_u_long stem_method;
+    mg_u_long indexed;       /* [RPAP - Jan 97: Stem Index Change] */
   };
 
 struct invf_file_header
   {
-    unsigned long no_of_words;
-    unsigned long no_of_ptrs;
-    unsigned long skip_mode;
-    unsigned long params[16];
-    unsigned long InvfLevel;
+    mg_u_long no_of_words;
+    mg_u_long no_of_ptrs;
+    mg_u_long skip_mode;
+    mg_u_long params[16];
+    mg_u_long InvfLevel;
   };
 
@@ -69,10 +69,10 @@
 struct stem_idx_header
   {
-    unsigned long lookback;
-    unsigned long block_size;
-    unsigned long num_blocks;
-    unsigned long blocks_start;
-    unsigned long index_chars;
-    unsigned long num_of_words;
+    mg_u_long lookback;
+    mg_u_long block_size;
+    mg_u_long num_blocks;
+    mg_u_long blocks_start;
+    mg_u_long index_chars;
+    mg_u_long num_of_words;
   };
 
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/invf_get.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/invf_get.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/invf_get.c	(revision 25147)
@@ -166,5 +166,5 @@
 
 static void 
-HT_Sup_Add (Hash_Table * HT, unsigned long DN, float Sum)
+HT_Sup_Add (Hash_Table * HT, mg_u_long DN, float Sum)
 {
   Invf_Doc_EntryH *IDEH;
@@ -176,5 +176,5 @@
 
 Invf_Doc_Entry *
-HT_find (Hash_Table * HT, unsigned long DN)
+HT_find (Hash_Table * HT, mg_u_long DN)
 {
   Invf_Doc_EntryH *IDEH;
@@ -194,5 +194,5 @@
 static int 
 HT_insert (Hash_Table * HT,
-	   unsigned long DN, float Sum)
+	   mg_u_long DN, float Sum)
 {
   Invf_Doc_EntryH **IDEH;
@@ -316,5 +316,5 @@
 
 Invf_Doc_Entry *
-LT_find (List_Table * LT, unsigned long DN)
+LT_find (List_Table * LT, mg_u_long DN)
 {
   int l = 0;
@@ -337,5 +337,5 @@
 static List_Table *
 LT_add (query_data * qd, List_Table * LT,
-	unsigned long DN, float Sum)
+	mg_u_long DN, float Sum)
 {
   Invf_Doc_Entry *ide;
@@ -472,5 +472,5 @@
     case 1:
       {
-	unsigned long len;
+	mg_u_long len;
 	if (*p <= qd->id->ifh.params[0])
 	  *k = 0;
@@ -488,5 +488,5 @@
     case 2:
       {
-	unsigned long len;
+	mg_u_long len;
 	if (*p <= qd->id->ifh.params[1])
 	  *k = 0;
@@ -533,5 +533,5 @@
   DocEntry *src = NULL, *dest = NULL;
   int i;			/* index counter into inverted list */
-  unsigned long pos;
+  mg_u_long pos;
   int next_start, next_doc_num, next_i;
   int block_counter;		/* within counter in block */
@@ -540,5 +540,5 @@
   int blk;			/* bblock control parameter */
   int ft;			/* The number of documents the word occurs in */
-  unsigned long CurrDoc = 0;	/* NOTE: Document numbers start at 1 */
+  mg_u_long CurrDoc = 0;	/* NOTE: Document numbers start at 1 */
   float Weight;
 
@@ -582,5 +582,5 @@
   while (i < ft && ((op == op_term) || src - L->DE < L->num))
     {
-      unsigned long diff, Temp;
+      mg_u_long diff, Temp;
 
       if (have_skipping)
@@ -754,8 +754,8 @@
       u_char *buffer;
       int i, kd;
-      unsigned long next_mjr_dn = 0;
-      unsigned long CurrDocNum = 0;	/* NOTE: Document numbers start at 1 */
-      unsigned long LastDocNum = 0; /* [RJM 07/97: Ranked Required Terms] */
-      unsigned long TempDocNum = 0; /* [RJM 07/97: Ranked Required Terms] */
+      mg_u_long next_mjr_dn = 0;
+      mg_u_long CurrDocNum = 0;	/* NOTE: Document numbers start at 1 */
+      mg_u_long LastDocNum = 0; /* [RJM 07/97: Ranked Required Terms] */
+      mg_u_long TempDocNum = 0; /* [RJM 07/97: Ranked Required Terms] */
       double Wqt, WordLog;
       int dn_blk = 0, len_blk = 0, k;
@@ -787,5 +787,5 @@
 	  int Count;		/* The number of times the word occurs in a document */
 	  double Wdt;
-	  unsigned long diff;
+	  mg_u_long diff;
 	  if (kd == k)
 	    {
@@ -919,13 +919,13 @@
 	  skip_header = 1;
 	  fprintf (sk, "%s", skip_header_text[qd->id->ifh.skip_mode]);
-	  fprintf (sk, "\nSkipping method %ld\n", qd->id->ifh.skip_mode);
+	  fprintf (sk, "\nSkipping method %d\n", qd->id->ifh.skip_mode);
 	  switch (qd->id->ifh.skip_mode)
 	    {
 	    case 1:
-	      fprintf (sk, "Skipping is every %ld docnums\n",
+	      fprintf (sk, "Skipping is every %d docnums\n",
 		       qd->id->ifh.params[0]);
 	      break;
 	    case 2:
-	      fprintf (sk, "Max nodes = %ld\nNo skips smaller or equal to %ld\n",
+	      fprintf (sk, "Max nodes = %d\nNo skips smaller or equal to %d\n",
 		       qd->id->ifh.params[0], qd->id->ifh.params[1]);
 	      break;
@@ -958,5 +958,5 @@
       u_char *buffer;
       int pos, i;
-      unsigned long CurrDocNum = 0;	/* NOTE: Document numbers start at 1 */
+      mg_u_long CurrDocNum = 0;	/* NOTE: Document numbers start at 1 */
       double Wqt, WordLog;
       int dn_blk = 0, len_blk = 0, k, kd;
@@ -971,5 +971,5 @@
       if (sk)
 	{
-	  fprintf (sk, "%3d : %8ld %6ld \"%.*s\"%*s", j, we->count,
+	  fprintf (sk, "%3d : %8d %6d \"%.*s\"%*s", j, we->count,
 		 we->doc_count, Terms->TE[j].Word[0], Terms->TE[j].Word + 1,
 		   indent - Terms->TE[j].Word[0], "");
@@ -1010,5 +1010,5 @@
 	  int Count;		/* The number of times the occurs in a document */
 	  double Wdt;
-	  unsigned long diff;
+	  mg_u_long diff;
 	  Invf_Doc_Entry ent, *mem;
 	  if (k)
@@ -1026,4 +1026,5 @@
 		}
 	      if (kd == k - 1)
+		{
 		if (i + k < p)
 		  {
@@ -1036,5 +1037,8 @@
 		  }
 		else
+		  {
 		  next_doc_num = -1;
+		  }
+		}
 	      if (Anding && i + k < p && next->DocNum > next_doc_num &&
 		  next_doc_num >= 0)
@@ -1149,13 +1153,13 @@
 	  skip_header = 1;
 	  fprintf (sk, "%s", skip_header_text[qd->id->ifh.skip_mode]);
-	  fprintf (sk, "\nSkipping method %ld\n", qd->id->ifh.skip_mode);
+	  fprintf (sk, "\nSkipping method %d\n", qd->id->ifh.skip_mode);
 	  switch (qd->id->ifh.skip_mode)
 	    {
 	    case 1:
-	      fprintf (sk, "Skipping is every %ld docnums\n",
+	      fprintf (sk, "Skipping is every %d docnums\n",
 		       qd->id->ifh.params[0]);
 	      break;
 	    case 2:
-	      fprintf (sk, "Max nodes = %ld\nNo skips smaller or equal to %ld\n",
+	      fprintf (sk, "Max nodes = %d\nNo skips smaller or equal to %d\n",
 		       qd->id->ifh.params[0], qd->id->ifh.params[1]);
 	      break;
@@ -1188,5 +1192,5 @@
       int pos;
       int i;
-      unsigned long CurrDocNum = 0;	/* NOTE: Document numbers start at 1 */
+      mg_u_long CurrDocNum = 0;	/* NOTE: Document numbers start at 1 */
       double Wqt, WordLog;
       int dn_blk = 0, len_blk = 0, k, kd;
@@ -1201,5 +1205,5 @@
       if (sk)
 	{
-	  fprintf (sk, "%3d : %8ld %6ld \"%.*s\"%*s", j, we->count,
+	  fprintf (sk, "%3d : %8d %6d \"%.*s\"%*s", j, we->count,
 		 we->doc_count, Terms->TE[j].Word[0], Terms->TE[j].Word + 1,
 		   indent - Terms->TE[j].Word[0], "");
@@ -1245,5 +1249,5 @@
 	  int Count;		/* The number of times the occurs in a document */
 	  double Wdt;
-	  unsigned long diff;
+	  mg_u_long diff;
 	  Invf_Doc_Entry *mem;
 	  if (k)
@@ -1391,13 +1395,13 @@
 	  skip_header = 1;
 	  fprintf (sk, "%s", skip_header_text[qd->id->ifh.skip_mode]);
-	  fprintf (sk, "\nSkipping method %ld\n", qd->id->ifh.skip_mode);
+	  fprintf (sk, "\nSkipping method %d\n", qd->id->ifh.skip_mode);
 	  switch (qd->id->ifh.skip_mode)
 	    {
 	    case 1:
-	      fprintf (sk, "Skipping is every %ld docnums\n",
+	      fprintf (sk, "Skipping is every %d docnums\n",
 		       qd->id->ifh.params[0]);
 	      break;
 	    case 2:
-	      fprintf (sk, "Max nodes = %ld\nNo skips smaller or equal to %ld\n",
+	      fprintf (sk, "Max nodes = %d\nNo skips smaller or equal to %d\n",
 		       qd->id->ifh.params[0], qd->id->ifh.params[1]);
 	      break;
@@ -1431,6 +1435,6 @@
       int pos;
       int i, n = 0;
-      unsigned long CurrDocNum = 0;	/* NOTE: Document numbers start at 1 */
-      unsigned long LastDocNum = 0;	/* [RJM 07/97: Ranked Required Match] */
+      mg_u_long CurrDocNum = 0;	/* NOTE: Document numbers start at 1 */
+      mg_u_long LastDocNum = 0;	/* [RJM 07/97: Ranked Required Match] */
       int this_item = 0; /* [RJM 07/97: Ranked Required Match] points to the next possible LT to delete */
       double Wqt, WordLog;
@@ -1448,5 +1452,5 @@
       if (sk)
 	{
-	  fprintf (sk, "%3d : %8ld %6ld \"%.*s\"%*s", j, we->count,
+	  fprintf (sk, "%3d : %8d %6d \"%.*s\"%*s", j, we->count,
 		 we->doc_count, Terms->TE[j].Word[0], Terms->TE[j].Word + 1,
 		   indent - Terms->TE[j].Word[0], "");
@@ -1511,5 +1515,5 @@
 	  int Count;		/* The number of times the occurs in a document */
 	  double Wdt;
-	  unsigned long diff;
+	  mg_u_long diff;
 	  Invf_Doc_Entry *mem;
 
@@ -1530,4 +1534,5 @@
 		}
 	      if (kd == k - 1)
+		{
 		if (i + k < p)
 		  {
@@ -1540,6 +1545,8 @@
 		  }
 		else
+		  {
 		  next_doc_num = -1;
-
+		  }
+		}
 	      /* should we take another skip? */
 	      if (Anding && i + k < p && next->DocNum > next_doc_num &&
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/invf_get.h
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/invf_get.h	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/invf_get.h	(revision 25147)
@@ -75,5 +75,5 @@
 Op_types;
 
-/*Invf_Doc_Entry *HT_find(Hash_Table *HT, unsigned long DN); */
+/*Invf_Doc_Entry *HT_find(Hash_Table *HT, mg_u_long DN); */
 void HT_free (query_data * qd, Hash_Table * HT);
 void LT_free (query_data * qd, List_Table * LT);
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/ivf.pass1.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/ivf.pass1.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/ivf.pass1.c	(revision 25147)
@@ -117,19 +117,19 @@
 typedef struct hash_rec
   {
-    unsigned long fcnt;		/* fragment frequency */
-    unsigned long lfcnt;	/* local fragment frequency */
-    unsigned long fnum;		/* last fragment to use stem */
-    unsigned long wcnt;		/* stem frequency */
-    unsigned long lwcnt;	/* local stem frequency */
+    mg_u_long fcnt;		/* fragment frequency */
+    mg_u_long lfcnt;	/* local fragment frequency */
+    mg_u_long fnum;		/* last fragment to use stem */
+    mg_u_long wcnt;		/* stem frequency */
+    mg_u_long lwcnt;	/* local stem frequency */
     u_char *word;
   }
 hash_rec;
 
-static unsigned long words_read = 0, words_diff = 0, bytes_diff = 0;
-static unsigned long outputbytes = 0;
-static unsigned long inputbytes = 0;
-static unsigned long MaxMemInUse = 0;
-static unsigned long MemInUse = 0;
-static unsigned long ChunksWritten = 0;
+static mg_u_long words_read = 0, words_diff = 0, bytes_diff = 0;
+static mg_u_long outputbytes = 0;
+static mg_u_long inputbytes = 0;
+static mg_u_long MaxMemInUse = 0;
+static mg_u_long MemInUse = 0;
+static mg_u_long ChunksWritten = 0;
 
 
@@ -138,6 +138,6 @@
 
 static hash_rec **HashTable;
-static unsigned long HashSize=0;
-static unsigned long HashUsed=0;
+static mg_u_long HashSize=0;
+static mg_u_long HashUsed=0;
 static u_char *Pool;
 static int PoolLeft=0;
@@ -152,11 +152,11 @@
 static mg_ullong L2_bits = 0;
 static mg_ullong L3_bits = 0;
-static unsigned long L1_ohead = 0;
-static unsigned long L2_ohead = 0;
-static unsigned long L3_ohead = 0;
-static unsigned long callnum = 0, lcallnum = 0, wordnum = 0, lwordnum = 0;
-static unsigned long ptrcnt = 0;
-static unsigned long checknum=0;
-static long max_mem = 0;
+static mg_u_long L1_ohead = 0;
+static mg_u_long L2_ohead = 0;
+static mg_u_long L3_ohead = 0;
+static mg_u_long callnum = 0, lcallnum = 0, wordnum = 0, lwordnum = 0;
+static mg_u_long ptrcnt = 0;
+static mg_u_long checknum=0;
+static mg_s_long max_mem = 0;
 
 
@@ -211,5 +211,5 @@
 			  MG_MESSAGE)))  /* [RPAP - Feb 97: WIN32 Port] */
     return (COMPERROR);
-  fwrite ("    ", sizeof (u_long), 1, ic);	/* Space for the maxmem */
+  fwrite ("    ", sizeof (mg_u_long), 1, ic);	/* Space for the maxmem */
   ENCODE_START (ic)
     ENCODE_PAUSE (sbs)
@@ -256,16 +256,16 @@
 
 
-static unsigned long 
+static mg_u_long 
 mem_reqd (void)
 {
   register int i;
-  register unsigned long total = 0;
-/*  register unsigned long N = InvfLevel == 3 ? lwordnum : lcallnum; */
-  register unsigned long N = lcallnum;
+  register mg_u_long total = 0;
+/*  register mg_u_long N = InvfLevel == 3 ? lwordnum : lcallnum; */
+  register mg_u_long N = lcallnum;
   for (i = 0; i < HashUsed; i++)
     {
       register hash_rec *ent = first_occr[i];
-/*      register unsigned long p = InvfLevel == 3 ? ent->lwcnt : ent->lfcnt; */
-      register unsigned long p = ent->lfcnt;
+/*      register mg_u_long p = InvfLevel == 3 ? ent->lwcnt : ent->lfcnt; */
+      register mg_u_long p = ent->lfcnt;
       if (p)
 	total += BIO_Bblock_Bound (N, p);
@@ -278,16 +278,16 @@
 }
 
-static unsigned long 
+static mg_u_long 
 max_mem_reqd (void)
 {
   register int i;
-  register unsigned long total = 0;
-/*  register unsigned long N = InvfLevel == 3 ? wordnum : callnum; */
-  register unsigned long N = callnum;
+  register mg_u_long total = 0;
+/*  register mg_u_long N = InvfLevel == 3 ? wordnum : callnum; */
+  register mg_u_long N = callnum;
   for (i = 0; i < HashUsed; i++)
     {
       register hash_rec *ent = first_occr[i];
-/*      register unsigned long p = InvfLevel == 3 ? ent->wcnt : ent->fcnt; */
-      register unsigned long p = ent->fcnt;
+/*      register mg_u_long p = InvfLevel == 3 ? ent->wcnt : ent->fcnt; */
+      register mg_u_long p = ent->fcnt;
       if (p)
 	total += BIO_Bblock_Bound (N, p);
@@ -302,5 +302,5 @@
 
 static void 
-dump_dict (unsigned long mem)
+dump_dict (mg_u_long mem)
 {
   int i;
@@ -367,5 +367,5 @@
       /* Search the hash table for Word */
       {
-	register unsigned long hashval, step;
+	register mg_u_long hashval, step;
 	register int hsize = HashSize;
 	HASH (hashval, step, Word, hsize);
@@ -464,6 +464,6 @@
 	{
 	  hash_rec **ht;
-	  unsigned long size;
-	  unsigned long i;
+	  mg_u_long size;
+	  mg_u_long i;
 	  size = prime (HashSize * 2);
 	  if (!(ht = Xmalloc (sizeof (hash_rec *) * size)))
@@ -480,5 +480,5 @@
 		register u_char *wptr;
 		hash_rec *ent;
-		register unsigned long hashval, step;
+		register mg_u_long hashval, step;
 
 		wptr = HashTable[i]->word;
@@ -504,5 +504,5 @@
   if (ptrcnt >= checknum)
     {
-      unsigned long mem;
+      mg_u_long mem;
       /*fprintf(stderr, "Checking at %u . . . ", ptrcnt); */
       mem = mem_reqd ();
@@ -617,5 +617,5 @@
       /* check for overflow */
       if (L1_bits + L2_bits < oldL12_bits) {
-	fprintf(stderr, "ERROR: Inverted file size will probably overflow %d byte unsigned integer\n", sizeof (mg_ullong));
+	fprintf(stderr, "ERROR: Inverted file size will probably overflow %lu byte unsigned integer\n", sizeof (mg_ullong));
 	fprintf(stderr, "       counter in pass 2.\n");
 	if (sizeof (mg_ullong) < 8) {
@@ -659,10 +659,10 @@
 write_stem_file (char *file_name)
 {
-  long j;
+  mg_s_long j;
   struct invf_dict_header idh;
-  long lookback = (1 << LOGLOOKBACK);	/* ???? */
-  long totalbytes = 0;		/* The sum of the length of all words, including 
+  mg_s_long lookback = (1 << LOGLOOKBACK);	/* ???? */
+  mg_s_long totalbytes = 0;		/* The sum of the length of all words, including 
 				   the length byte */
-  long indexstringbytes = 0;	/* The amount of space required to store the 
+  mg_s_long indexstringbytes = 0;	/* The amount of space required to store the 
 				   words in the diction, this takes into account 
 				   the prefixes */
@@ -706,5 +706,5 @@
     {
       int i;
-      unsigned long wcnt, fcnt;  /* [RPAP - Jan 97: Endian Ordering] */
+      mg_u_long wcnt, fcnt;  /* [RPAP - Jan 97: Endian Ordering] */
       hash_rec *ent = HashTable[j];
       if (lastword != NULL)
@@ -750,5 +750,5 @@
 write_codes (char *file_name)
 {
-  unsigned long dicts = 0;
+  mg_u_long dicts = 0;
   outputbytes = 0;
   write_stem_file (file_name);
@@ -805,7 +805,7 @@
     {
       /* [RPAP - Jan 97: Endian Ordering] */
-      unsigned long fnum;
+      mg_u_long fnum;
       HTONUL2(first_occur[i]->fnum, fnum);
-      fwrite ((char *) &fnum, sizeof (unsigned long), 1, f);
+      fwrite ((char *) &fnum, sizeof (mg_u_long), 1, f);
     }
 #endif
@@ -837,5 +837,5 @@
     GAMMA_ENCODE (1);
   ENCODE_DONE
-    fseek (ic, sizeof (long), 0);
+    fseek (ic, sizeof (mg_s_long), 0);
   
   HTONSL(max_mem);  /* [RPAP - Jan 97: Endian Ordering] */
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/ivf.pass2.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/ivf.pass2.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/ivf.pass2.c	(revision 25147)
@@ -39,5 +39,5 @@
  * Revision 1.2  1997/08/02  05:01:57  wew
  * changed literal values of 32 for the bit size of magic numbers of
- * files to sizeof (unsigned long) * 8, increased the gap at the start
+ * files to sizeof (mg_u_long) * 8, increased the gap at the start
  * of the invf during processing to 200 bytes
 
@@ -127,11 +127,11 @@
     struct stat file_state;\
     fstat(fileno(invf_out), &file_state);\
-    Message("len(invf) = %ld", file_state.st_size);\
+    Message("len(invf) = %d", file_state.st_size);\
   }while(0)
 
 typedef struct word_rec
   {
-    unsigned long ptr;
-    unsigned long last;
+    mg_u_long ptr;
+    mg_u_long last;
   }
 word_rec;
@@ -141,5 +141,5 @@
     mg_ullong Disk_Ptr;
     mg_ullong Disk_Last;
-    unsigned long Disk_B;
+    mg_u_long Disk_B;
   }
 invf_state_rec;
@@ -147,8 +147,8 @@
 typedef struct chunk
   {
-    unsigned long start_doc;
-    unsigned long params_pos;
-    unsigned long disk_pos;
-    unsigned long N;
+    mg_u_long start_doc;
+    mg_u_long params_pos;
+    mg_u_long disk_pos;
+    mg_u_long N;
   }
 chunk;
@@ -175,5 +175,5 @@
 
 static int docs_left = 0, next_docs_left = 0;
-static unsigned long N;
+static mg_u_long N;
 
 static word_rec *WordRecs;
@@ -182,27 +182,27 @@
 
 static char *MemoryBuffer = NULL;
-static unsigned long MemBufSize;
-static unsigned long BufToUse;
+static mg_u_long MemBufSize;
+static mg_u_long BufToUse;
 static struct invf_dict_header idh;
 
 static perf_hash_data *phd;
 
-static unsigned long *word_list = NULL;
-static unsigned long wl_size = 0;
-
-static unsigned long dict_size;
-static unsigned long no_of_ptrs = 0;
-static unsigned long chunks_read = 0;
-static unsigned long Disk_pos = 0;
-static unsigned long callnum = 0;
-static unsigned long wordnum = 0;
-
-static unsigned long totalIbytes = 0;
-static unsigned long totalDbytes = 0;
-static unsigned long totalHbytes = 0;
-
-static unsigned long MemInUse = 0;
-static unsigned long MaxMemInUse = 0;
-static unsigned long max_buffer_len;
+static mg_u_long *word_list = NULL;
+static mg_u_long wl_size = 0;
+
+static mg_u_long dict_size;
+static mg_u_long no_of_ptrs = 0;
+static mg_u_long chunks_read = 0;
+static mg_u_long Disk_pos = 0;
+static mg_u_long callnum = 0;
+static mg_u_long wordnum = 0;
+
+static mg_u_long totalIbytes = 0;
+static mg_u_long totalDbytes = 0;
+static mg_u_long totalHbytes = 0;
+
+static mg_u_long MemInUse = 0;
+static mg_u_long MaxMemInUse = 0;
+static mg_u_long max_buffer_len;
 
 void 
@@ -292,6 +292,6 @@
       return (COMPERROR);
 
-  sprintf (FName, FILE_NAME_FORMAT ".%ld", get_basepath (), file_name,
-	   ".invf.state", (long) getpid ());  /* [RPAP - Feb 97: WIN32 Port] */
+  sprintf (FName, FILE_NAME_FORMAT ".%d", get_basepath (), file_name,
+	   ".invf.state", (mg_s_long) getpid ());  /* [RPAP - Feb 97: WIN32 Port] */
   if (!(invf_state = fopen (FName, "w+b")))  /* [RPAP - Feb 97: WIN32 Port] */
     {
@@ -301,6 +301,6 @@
   unlink (FName);
 
-  sprintf (FName, FILE_NAME_FORMAT ".%ld", get_basepath (), file_name,
-	   ".chunk.state", (long) getpid ());  /* [RPAP - Feb 97: WIN32 Port] */
+  sprintf (FName, FILE_NAME_FORMAT ".%d", get_basepath (), file_name,
+	   ".chunk.state", (mg_s_long) getpid ());  /* [RPAP - Feb 97: WIN32 Port] */
   if (!(chunk_state = fopen (FName, "w+b")))  /* [RPAP - Feb 97: WIN32 Port] */
     {
@@ -312,6 +312,6 @@
   ChangeMemInUse (RND_BUF_SIZE);
 
-  sprintf (FName, FILE_NAME_FORMAT ".%ld", get_basepath (), file_name,
-	   ".chunks", (long) getpid ());  /* [RPAP - Feb 97: WIN32 Port] */
+  sprintf (FName, FILE_NAME_FORMAT ".%d", get_basepath (), file_name,
+	   ".chunks", (mg_s_long) getpid ());  /* [RPAP - Feb 97: WIN32 Port] */
   if (!(chunks = fopen (FName, "w+b")))  /* [RPAP - Feb 97: WIN32 Port] */
     {
@@ -329,5 +329,5 @@
 
 #define ISR_CACHE 1024
-#define ISR_ENTRY_SIZE (sizeof(mg_ullong)*2 + sizeof(unsigned long))
+#define ISR_ENTRY_SIZE (sizeof(mg_ullong)*2 + sizeof(mg_u_long))
 
 invf_state_rec *
@@ -360,8 +360,8 @@
 
 
-unsigned long 
-occur_to_lexical (long occ, int clear_state)
-{
-  static long pos = -1;
+mg_u_long 
+occur_to_lexical (mg_s_long occ, int clear_state)
+{
+  static mg_s_long pos = -1;
   static random_bitio_state rbs;
   static int val = 0;
@@ -383,5 +383,5 @@
 	  return 0;
 	}
-      BIO_Random_Seek_X (sizeof (unsigned long) * 8, &rbs);
+      BIO_Random_Seek_X (sizeof (mg_u_long) * 8, &rbs);
       pos = 0;
     }
@@ -396,6 +396,6 @@
 
 void 
-add_chunk_state (unsigned long pos, unsigned long start_doc,
-		 unsigned long N)
+add_chunk_state (mg_u_long pos, mg_u_long start_doc,
+		 mg_u_long N)
 {
   chunk_data[chunks_read].params_pos = pos;
@@ -448,5 +448,5 @@
   totalHbytes = sizeof (perf_hash_data) + sizeof (u_char) * 256 +
     sizeof (int) * (phd->MAX_N + 1) + sizeof (int *) * 3 * phd->MAX_CH +
-    sizeof (long) * phd->MAX_CH * phd->MAX_L;
+    sizeof (mg_s_long) * phd->MAX_CH * phd->MAX_L;
 
   if (!(WordRecs = Xmalloc (sizeof (word_rec) * idh.dict_size)))
@@ -488,5 +488,5 @@
   totalDbytes += sizeof (chunk) * (ChunkLimit + 2);
 
-  totalIbits = sizeof (unsigned long) * 8;		/* The magic number */
+  totalIbits = sizeof (mg_u_long) * 8;		/* The magic number */
   totalIbits += 8 * 200;	/* A 200 byte gap */
 
@@ -506,6 +506,6 @@
     {
       invf_state_rec *isr;
-      register unsigned long copy, suff, p;
-      unsigned long fcnt, wcnt;
+      register mg_u_long copy, suff, p;
+      mg_u_long fcnt, wcnt;
 
       lasttotalIbits = totalIbits;
@@ -551,5 +551,5 @@
 
       if (totalIbits < lasttotalIbits) {
-	fprintf(stderr, "ERROR: The totalIbits counter (%d byte unsigned integer) has overflowed.\n", sizeof (mg_ullong));
+	fprintf(stderr, "ERROR: The totalIbits counter (%lu byte unsigned integer) has overflowed.\n", sizeof (mg_ullong));
 	if (sizeof (mg_ullong) < 8) {
 	  fprintf(stderr, "       Try compiling with GCC to enable use of 8 bytes for this counter.\n");
@@ -578,13 +578,13 @@
 LoadCounts (void)
 {
-  unsigned long numwords, i, last_total;
-  static unsigned long local_N = 0;
-  unsigned long totalIbits, crbs_pos;
+  mg_u_long numwords, i, last_total;
+  static mg_u_long local_N = 0;
+  mg_u_long totalIbits, crbs_pos;
   word_rec *wr;
-  unsigned long *counts;
+  mg_u_long *counts;
 
   if (MemoryBuffer == NULL)
     {
-      MemBufSize = sizeof (unsigned long) * dict_size;
+      MemBufSize = sizeof (mg_u_long) * dict_size;
       if (max_buffer_len > MemBufSize) 
 	MemBufSize = max_buffer_len;
@@ -593,6 +593,6 @@
       ChangeMemInUse (MemBufSize);
     }
-  counts = (unsigned long *) MemoryBuffer;
-/*   bzero ((char *) counts, sizeof (unsigned long) * dict_size); */
+  counts = (mg_u_long *) MemoryBuffer;
+/*   bzero ((char *) counts, sizeof (mg_u_long) * dict_size); */
   bzero ((char *) counts, MemBufSize);
   docs_left = next_docs_left; 
@@ -613,5 +613,5 @@
   for (i = 0; i < numwords; i++)
     {
-      unsigned long word_num, wcnt, fcnt, p;
+      mg_u_long word_num, wcnt, fcnt, p;
       word_num = occur_to_lexical (i,0);
       
@@ -628,5 +628,5 @@
       if (wcnt)
 	{
-	  register unsigned long length;
+	  register mg_u_long length;
 	  counts[word_num] = p;
 	  length = BIO_Bblock_Bound (local_N, p);
@@ -644,5 +644,5 @@
   for (wr = WordRecs, i = 0; i < dict_size; i++, wr++)
     {
-      register unsigned long length;
+      register mg_u_long length;
       length = wr->ptr;
       wr->last = callnum;
@@ -688,12 +688,12 @@
   random_bitio_state *rbsi;
   random_bitio_state *chks = NULL;
-  unsigned long *chunk_ptrs;
+  mg_u_long *chunk_ptrs;
   int i;
 
   BIO_Random_Flush (&crbs);
 
-  chunk_ptrs = Xmalloc (chunks_read * sizeof (unsigned long));
-  ChangeMemInUse (chunks_read * sizeof (unsigned long));
-  bzero ((char *) chunk_ptrs, chunks_read * sizeof (unsigned long));
+  chunk_ptrs = Xmalloc (chunks_read * sizeof (mg_u_long));
+  ChangeMemInUse (chunks_read * sizeof (mg_u_long));
+  bzero ((char *) chunk_ptrs, chunks_read * sizeof (mg_u_long));
 
   rbsi = Xmalloc (chunks_read * sizeof (random_bitio_state));
@@ -752,5 +752,5 @@
 		  for (k = 0; k < p; k++)
 		    {
-		      register unsigned long x, tf;
+		      register mg_u_long x, tf;
 		      BBLOCK_DECODE (x, b);
 		      if (k == 0)
@@ -775,5 +775,5 @@
 		  for (k = 0; k < p; k++)
 		    {
-		      register unsigned long x, tf;
+		      register mg_u_long x, tf;
 		      x = BIO_Random_Bblock_Decode (b, Chks, NULL);
 		      if (k == 0)
@@ -816,5 +816,5 @@
 /*   chunks_read = 0; */
   Xfree (chunk_ptrs);
-  ChangeMemInUse (-chunks_read * sizeof (unsigned long));
+  ChangeMemInUse (-chunks_read * sizeof (mg_u_long));
   chunks_read = 0;
   Disk_pos = 0;
@@ -860,6 +860,6 @@
   int res;
   u_char *end = s_in + l_in - 1;
-  unsigned long tocode;
-  unsigned long wl_pos = 0;
+  mg_u_long tocode;
+  mg_u_long wl_pos = 0;
 
   if (!docs_left)
@@ -934,6 +934,6 @@
       if (wl_pos)
 	{
-	  unsigned long *wl = word_list;
-	  unsigned long i, count, val;
+	  mg_u_long *wl = word_list;
+	  mg_u_long i, count, val;
 	  qsort (wl, wl_pos, sizeof (*wl), wl_comp);
 	  count = 1;
@@ -999,5 +999,5 @@
 
 static void 
-stats (unsigned long len)
+stats (mg_u_long len)
 {
 #ifndef SILENT
@@ -1029,8 +1029,8 @@
 done_ivf_2 (char *FileName)
 {
-  long i;
+  mg_s_long i;
   mg_ullong totalIbits;
-  unsigned long invf_len;
-  unsigned long bytes_output;
+  mg_u_long invf_len;
+  mg_u_long bytes_output;
   struct invf_file_header ifh;
 
@@ -1054,5 +1054,5 @@
   invf_len = ftell (invf);
 
-  fseek (invf_out, sizeof (long), 0);
+  fseek (invf_out, sizeof (mg_s_long), 0);
   /* [RPAP - Jan 97: Endian Ordering] */
   HTONUL2(dict_size, ifh.no_of_words);
@@ -1065,14 +1065,14 @@
   bytes_output = ftell (invf_out);
 
-  totalIbits = sizeof (unsigned long) * 8;		/* The magic number */
+  totalIbits = sizeof (mg_u_long) * 8;		/* The magic number */
   totalIbits += 8 * 200;	/* A 200 byte gap */
 
   /* find the right place in the file to start reading p values */
-  fseek (dict, sizeof (unsigned long) + sizeof (struct invf_dict_header), 0);
+  fseek (dict, sizeof (mg_u_long) + sizeof (struct invf_dict_header), 0);
   for (i = 0; i < dict_size; i++)
     {
       invf_state_rec *isr;
-      unsigned long fcnt, wcnt, s, e;
-      register unsigned long p;
+      mg_u_long fcnt, wcnt, s, e;
+      register mg_u_long p;
       u_char dummy1, dummy2[MAXSTEMLEN + 1];
 
@@ -1147,5 +1147,5 @@
   {
     char *temp_str = msg_prefix;
-    unsigned long total;
+    mg_u_long total;
     msg_prefix = "ivf.pass2";
     stats (invf_len);
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/lists.h
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/lists.h	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/lists.h	(revision 25147)
@@ -32,6 +32,6 @@
     float Weight;
     int DocNum;
-    unsigned long SeekPos;	/* position in the text file in bytes */
-    unsigned long Len;		/* length of the document in bytes */
+    mg_u_long SeekPos;	/* position in the text file in bytes */
+    mg_u_long Len;		/* length of the document in bytes */
     char *CompTextBuffer;
     struct DocEntry *Next;
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/locallib.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/locallib.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/locallib.c	(revision 25147)
@@ -100,5 +100,5 @@
 
 int 
-huffcodebits (unsigned long *A, int n)
+huffcodebits (mg_u_long *A, int n)
 {
   int i, j, tot = 0, bits = 0, v1, v2, *B;
@@ -136,5 +136,5 @@
 
 int 
-modelbits (unsigned long *A, int n)
+modelbits (mg_u_long *A, int n)
 {
   int i, bits = 0, last, N = 0;
@@ -185,6 +185,6 @@
 
 int 
-Read_cdh (FILE * f, compression_dict_header * cdh, u_long * mem,
-	  u_long * disk)
+Read_cdh (FILE * f, compression_dict_header * cdh, mg_u_long * mem,
+	  mg_u_long * disk)
 {
   if (disk)
@@ -212,6 +212,6 @@
 
 int 
-F_Read_cdh (File * f, compression_dict_header * cdh, u_long * mem,
-	    u_long * disk)
+F_Read_cdh (File * f, compression_dict_header * cdh, mg_u_long * mem,
+	    mg_u_long * disk)
 {
   if (disk)
@@ -239,5 +239,5 @@
 
 int 
-Read_cfh (FILE * f, comp_frags_header * cfh, u_long * mem, u_long * disk)
+Read_cfh (FILE * f, comp_frags_header * cfh, mg_u_long * mem, mg_u_long * disk)
 {
   int i;  /* [RPAP - Jan 97: Endian Ordering] */
@@ -274,5 +274,5 @@
 
 int 
-F_Read_cfh (File * f, comp_frags_header * cfh, u_long * mem, u_long * disk)
+F_Read_cfh (File * f, comp_frags_header * cfh, mg_u_long * mem, mg_u_long * disk)
 {
   int i;  /* [RPAP - Jan 97: Endian Ordering] */
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/locallib.h
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/locallib.h	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/locallib.h	(revision 25147)
@@ -33,19 +33,19 @@
 int vecentropy (int *A, int n);
 
-int huffcodebits (unsigned long *A, int n);
+int huffcodebits (mg_u_long *A, int n);
 
-int modelbits (unsigned long *A, int n);
+int modelbits (mg_u_long *A, int n);
 
 int prime (int p);
 
 
-int Read_cdh (FILE * f, compression_dict_header * cdh, u_long * mem, u_long * disk);
+int Read_cdh (FILE * f, compression_dict_header * cdh, mg_u_long * mem, mg_u_long * disk);
 
-int Read_cfh (FILE * f, comp_frags_header * cfh, u_long * mem, u_long * disk);
+int Read_cfh (FILE * f, comp_frags_header * cfh, mg_u_long * mem, mg_u_long * disk);
 
-int F_Read_cdh (File * f, compression_dict_header * cdh, u_long * mem,
-		u_long * disk);
+int F_Read_cdh (File * f, compression_dict_header * cdh, mg_u_long * mem,
+		mg_u_long * disk);
 
-int F_Read_cfh (File * f, comp_frags_header * cfh, u_long * mem, u_long * disk);
+int F_Read_cfh (File * f, comp_frags_header * cfh, mg_u_long * mem, mg_u_long * disk);
 
 
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_compression_dict.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_compression_dict.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_compression_dict.c	(revision 25147)
@@ -41,5 +41,5 @@
 #include "mg.h"
 
-#define MAXBITS (sizeof(unsigned long) * 8)
+#define MAXBITS (sizeof(mg_mg_u_long) * 8)
 
 /*
@@ -98,8 +98,8 @@
 typedef struct WordData
   {
-    u_long freq, occur_num;
+    mg_u_long freq, occur_num;
     float saving;
     float char_bit_cost;
-    u_long num_trans;
+    mg_u_long num_trans;
     u_char *word;
   }
@@ -107,6 +107,6 @@
 
 static WordData *Words[2];
-static u_long Num[2];
-static u_long chars[2];
+static mg_u_long Num[2];
+static mg_u_long chars[2];
 
 #define KIND(p) (((p) >= Words[0] && (p) < Words[0] + Num[0]) ? 0 : 1)
@@ -118,6 +118,6 @@
   {
     WordData **wd;
-    u_long num_wds;
-    u_long chars;
+    mg_u_long num_wds;
+    mg_u_long chars;
   }
 DictData;
@@ -129,5 +129,5 @@
 
 static char *file_name = "";
-static u_long novel_method = MG_NOVEL_HUFFMAN_CHARS;
+static mg_u_long novel_method = MG_NOVEL_HUFFMAN_CHARS;
 
 
@@ -136,5 +136,5 @@
 static void Method3 (int k);
 static void Select_all (void);
-static u_long WriteOutWords (char *, u_long, int);
+static mg_u_long WriteOutWords (char *, mg_u_long, int);
 static int DecFreqIncWL (void *a, void *b);
 static int OccuranceOrder (void *a, void *b);
@@ -150,5 +150,5 @@
   int lookback = 2;
   double k = 0;
-  u_long mem_reqd;
+  mg_u_long mem_reqd;
   opterr = 0;
   msg_prefix = argv[0];
@@ -264,5 +264,5 @@
 {
   FILE *f;
-  unsigned long i;
+  mg_u_long i;
   f = open_file (filename, TEXT_STATS_DICT_SUFFIX, "rb",
 		 MAGIC_STATS_DICT, MG_ABORT);  /* [RPAP - Feb 97: WIN32 Port] */
@@ -468,8 +468,8 @@
 CalcCharCounts (WordData ** wd, int num,
 		char *char_lens[2], char *len_lens[2],
-		u_long escape[2])
-{
-  long char_freqs[2][256];
-  long len_freqs[2][16];
+		mg_u_long escape[2])
+{
+  mg_u_long char_freqs[2][256];
+  mg_u_long len_freqs[2][16];
   huff_data hd;
   int i;
@@ -480,5 +480,5 @@
   for (i = 0; i < num; i++, wd++)
     {
-      u_long freq = (*wd)->freq;
+      mg_u_long freq = (*wd)->freq;
       u_char *buf = (*wd)->word;
       int len = *buf++;
@@ -487,5 +487,5 @@
       escape[idx] += freq;
       for (; len; len--, buf++)
-	char_freqs[idx][(u_long) (*buf)] += freq;
+	char_freqs[idx][(mg_u_long) (*buf)] += freq;
     }
   Generate_Huffman_Data (256, char_freqs[0], &hd, NULL);
@@ -511,5 +511,5 @@
 CalcBitCost (WordData ** discard_word, int discard_num,
 	     WordData ** keep_word, int keep_num, double freqs_trans[2],
-	     u_long escape[2], int num_trans)
+	     mg_u_long escape[2], int num_trans)
 {
   char *char_lens[2];
@@ -525,10 +525,10 @@
       u_char *buf = (*discard_word)->word;
       int len = *buf++;
-      u_long freq = (*discard_word)->freq;
+      mg_u_long freq = (*discard_word)->freq;
       int idx = KIND (*discard_word);
 
       cbc = len_lens[idx][len];
       for (; len; len--, buf++)
-	cbc += char_lens[idx][(u_long) (*buf)];
+	cbc += char_lens[idx][(mg_u_long) (*buf)];
 
       (*discard_word)->char_bit_cost = (cbc + esc[idx]) * freq;
@@ -546,10 +546,10 @@
       u_char *buf = (*keep_word)->word;
       int len = *buf++;
-      u_long freq = (*keep_word)->freq;
+      mg_u_long freq = (*keep_word)->freq;
       int idx = KIND (*keep_word);
 
       cbc = len_lens[idx][len];
       for (; len; len--, buf++)
-	cbc += char_lens[idx][(u_long) (*buf)];
+	cbc += char_lens[idx][(mg_u_long) (*buf)];
 
       (*keep_word)->char_bit_cost = (cbc + esc[idx]) * freq;
@@ -578,5 +578,5 @@
   int recalcs = 0;
   double freqs_trans[2], total;
-  u_long escape[2];
+  mg_u_long escape[2];
   WordData **keep_heap, **discard_heap;
 
@@ -831,14 +831,14 @@
 
 
-static u_long 
+static mg_u_long 
 Write_data (FILE * f, DictData * dd, int lookback)
 {
-  u_long mem_reqd;
+  mg_u_long mem_reqd;
   huff_data *hd;
   int i; 
-  u_long us = dd->num_wds;
-  long *freqs;
-  u_long huff_words_size[MAX_HUFFCODE_LEN + 1];
-  u_long lencounts[MAX_HUFFCODE_LEN + 1];
+  mg_u_long us = dd->num_wds;
+  mg_s_long *freqs;
+  mg_u_long huff_words_size[MAX_HUFFCODE_LEN + 1];
+  mg_u_long lencounts[MAX_HUFFCODE_LEN + 1];
   u_char *lastword[MAX_HUFFCODE_LEN + 1];
 
@@ -932,5 +932,5 @@
 {
   int j;
-  long freqs[256];
+  mg_s_long freqs[256];
   WordData **wd = dd->wd;
   huff_data *hd;
@@ -943,5 +943,5 @@
       int len = *buf++;
       for (; len; len--, buf++)
-	freqs[(u_long) (*buf)] += (*wd)->freq;
+	freqs[(mg_u_long) (*buf)] += (*wd)->freq;
     }
 
@@ -968,5 +968,5 @@
 {
   int j;
-  long freqs[16];
+  mg_s_long freqs[16];
   WordData **wd = dd->wd;
   huff_data *hd;
@@ -995,10 +995,10 @@
 
 
-static u_long 
-WriteOutWords (char *file_name, u_long type, int lookback)
+static mg_u_long 
+WriteOutWords (char *file_name, mg_u_long type, int lookback)
 {
   FILE *f;
   int i;
-  u_long mem_reqd = 0;
+  mg_u_long mem_reqd = 0;
 
   compression_dict_header cdh;
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_decompress_text.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_decompress_text.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_decompress_text.c	(revision 25147)
@@ -34,6 +34,6 @@
 
   int ch;
-  unsigned long start, finish, len;
-  u_long total_chars = 0;
+  mg_u_long start, finish, len;
+  mg_u_long total_chars = 0;
   u_char *c_buffer = 0;
   int buf_len = -1;
@@ -42,5 +42,5 @@
   compression_dict *cd = NULL;
   compressed_text_header cth;
-  u_long doc;
+  mg_u_long doc;
   int count;
   char *filename = "";
@@ -161,5 +161,5 @@
 
 #if 0
-  printf ("\n#Total chars output = %lu\n", total_chars);
+  printf ("\n#Total chars output = %u\n", total_chars);
 #endif
 
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_fast_comp_dict.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_fast_comp_dict.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_fast_comp_dict.c	(revision 25147)
@@ -91,5 +91,5 @@
 
 
-static u_long mem_for_comp_dict (char *filename);
+static mg_u_long mem_for_comp_dict (char *filename);
 static void load_comp_dict (char *filename);
 static void save_fast_dict (char *filename);
@@ -100,5 +100,5 @@
 static void *cur;
 static u_char *fixup;
-static u_long mem, fixup_mem;
+static uintptr_t mem, fixup_mem;
 
 int main (int argc, char **argv)
@@ -142,5 +142,5 @@
   Message ("Actual memory for fast_dict %u", (char *) cur - (char *) buffer);
 
-  if ((u_long) cur > (u_long) buffer + mem)
+  if ((uintptr_t) cur > (uintptr_t) buffer + mem)
     FatalError (1, "The buffer was not big enough for the dictionary");
 
@@ -211,20 +211,20 @@
 unfixup_buffer ()
 {
-  u_long *p;
-  for (p = buffer; (u_long) p < (u_long) cur; p++)
+  uintptr_t *p;
+  for (p = buffer; (uintptr_t) p < (uintptr_t) cur; p++)
     {
       if (IS_FIXUP (p))
-	*p = *p - (u_long) buffer;
-    }
-}
-
-
-
-
-static u_long 
+	*p = *p - (uintptr_t) buffer;
+    }
+}
+
+
+
+
+static mg_u_long 
 mem_for_aux_dict (compression_dict_header * cdh, char *filename)
 {
   int i;
-  u_long mem = sizeof (auxiliary_dict);
+  mg_u_long mem = sizeof (auxiliary_dict);
   FILE *aux;
 
@@ -249,10 +249,10 @@
 
 
-static u_long 
+static mg_u_long 
 mem_for_words (FILE * dict, compression_dict_header * cdh,
 	       comp_frags_header * cfh)
 {
-  u_long mem = 0;
-  u_long i, lookback;
+  mg_u_long mem = 0;
+  mg_u_long i, lookback;
   int ptrs_reqd = 0;
   int mem_reqd = 0;
@@ -282,8 +282,8 @@
 
 
-static u_long 
+static mg_u_long 
 mem_for_comp_dict (char *filename)
 {
-  u_long mem = sizeof (compression_dict);
+  mg_u_long mem = sizeof (compression_dict);
   compression_dict_header cdh;
   comp_frags_header cfh;
@@ -343,6 +343,6 @@
 	  if (hd.clens)
 	    Xfree (hd.clens);
-	  mem += hd.num_codes * sizeof (unsigned long);
-	  mem += (MAX_HUFFCODE_LEN + 1) * sizeof (unsigned long *);
+	  mem += hd.num_codes * sizeof (mg_u_long);
+	  mem += (MAX_HUFFCODE_LEN + 1) * sizeof (mg_u_long *);
 
 	  mem += sizeof (hd);
@@ -350,6 +350,6 @@
 	  if (hd.clens)
 	    Xfree (hd.clens);
-	  mem += hd.num_codes * sizeof (unsigned long);
-	  mem += (MAX_HUFFCODE_LEN + 1) * sizeof (unsigned long *);
+	  mem += hd.num_codes * sizeof (mg_u_long);
+	  mem += (MAX_HUFFCODE_LEN + 1) * sizeof (mg_u_long *);
 	}
 	break;
@@ -377,6 +377,6 @@
 	      if (hd.clens)
 		Xfree (hd.clens);
-	      mem += hd.num_codes * sizeof (unsigned long);
-	      mem += (MAX_HUFFCODE_LEN + 1) * sizeof (unsigned long *);
+	      mem += hd.num_codes * sizeof (mg_u_long);
+	      mem += (MAX_HUFFCODE_LEN + 1) * sizeof (mg_u_long *);
 
 	      mem += sizeof (hd);
@@ -384,6 +384,6 @@
 	      if (hd.clens)
 		Xfree (hd.clens);
-	      mem += hd.num_codes * sizeof (unsigned long);
-	      mem += (MAX_HUFFCODE_LEN + 1) * sizeof (unsigned long *);
+	      mem += hd.num_codes * sizeof (mg_u_long);
+	      mem += (MAX_HUFFCODE_LEN + 1) * sizeof (mg_u_long *);
 	      break;
 	    case MG_NOVEL_BINARY:
@@ -413,11 +413,11 @@
 
 void *
-getmem (u_long size, int align)
+getmem (mg_u_long size, int align)
 {
   void *res;
-  cur = (void *) (((u_long) cur + (align - 1)) & (~(align - 1)));
+  cur = (void *) (((uintptr_t) cur + (align - 1)) & (~(align - 1)));
   res = cur;
   cur = (char *) cur + size;
-  if ((long) cur > (long) buffer + mem)
+  if ((intptr_t) cur > (intptr_t) buffer + mem)
     FatalError (1, "The buffer was not big enough for the dictionary");
   return res;
@@ -592,23 +592,23 @@
 
 
-static unsigned long **
-Generate_Fast_Huffman_Vals (huff_data * data, u_long * mem)
+static mg_u_long **
+Generate_Fast_Huffman_Vals (huff_data * data, mg_u_long * mem)
 {
   int i;
-  unsigned long *fcode[MAX_HUFFCODE_LEN + 1];
-  unsigned long **values;
-  unsigned long *vals;
+  mg_u_long *fcode[MAX_HUFFCODE_LEN + 1];
+  mg_u_long **values;
+  mg_u_long *vals;
 
   if (!data)
     return (NULL);
-  vals = getmem (data->num_codes * sizeof (*vals), sizeof (long *));
-  values = getmem ((MAX_HUFFCODE_LEN + 1) * sizeof (unsigned long *),
-		   sizeof (long *));
-
-  bzero ((char *) values, (MAX_HUFFCODE_LEN + 1) * sizeof (unsigned long *));
+  vals = getmem (data->num_codes * sizeof (*vals), sizeof (mg_s_long *));
+  values = getmem ((MAX_HUFFCODE_LEN + 1) * sizeof (mg_u_long *),
+		   sizeof (mg_s_long *));
+
+  bzero ((char *) values, (MAX_HUFFCODE_LEN + 1) * sizeof (mg_u_long *));
 
   if (mem)
     *mem += data->num_codes * sizeof (*vals) +
-      (MAX_HUFFCODE_LEN + 1) * sizeof (unsigned long *);
+      (MAX_HUFFCODE_LEN + 1) * sizeof (mg_u_long *);
 
   fcode[0] = values[0] = &vals[0];
@@ -661,5 +661,5 @@
 	{
 	  huff_data *hd;
-	  u_long **vals;
+	  mg_u_long **vals;
 	  if (cd->cdh.num_words[which])
 	    {
@@ -702,5 +702,5 @@
 	{
 	  huff_data *hd;
-	  u_long **vals;
+	  mg_u_long **vals;
 	  if (cd->cdh.num_words[which])
 	    {
@@ -776,6 +776,6 @@
 
   {
-    u_long *p;
-    for (p = buffer; (u_long) p < (u_long) cur; p++)
+    uintptr_t *p;
+    for (p = buffer; (uintptr_t) p < (uintptr_t) cur; p++)
       {
 	if (IS_FIXUP (p))
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_files.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_files.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_files.c	(revision 25147)
@@ -110,7 +110,7 @@
 FILE *
 open_named_file (const char *name, const char *mode,
-		 u_long magic_num, int err_mode)
-{
-  unsigned long magic;
+		 mg_u_long magic_num, int err_mode)
+{
+  mg_u_long magic;
   FILE *f = NULL;
   char *err;
@@ -172,5 +172,5 @@
 FILE *
 open_file (const char *name, const char *suffix, const char *mode,
-	   u_long magic_num, int err_mode)
+	   mg_u_long magic_num, int err_mode)
 {
   char path[512];
@@ -200,5 +200,5 @@
 FILE *
 create_named_file (const char *name, const char *mode,
-		   u_long magic_num, int err_mode)
+		   mg_u_long magic_num, int err_mode)
 {
   FILE *f = NULL;
@@ -252,5 +252,5 @@
 FILE *
 create_file (const char *name, const char *suffix, const char *mode,
-	     u_long magic_num, int err_mode)
+	     mg_u_long magic_num, int err_mode)
 {
   char path[512];
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_files.h
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_files.h	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_files.h	(revision 25147)
@@ -29,5 +29,5 @@
 /* Magic numbers for the different types of files */
 
-#define GEN_MAGIC(a,b,c,d) ((unsigned long)(((a)<<24) + ((b)<<16) + \
+#define GEN_MAGIC(a,b,c,d) ((mg_u_long)(((a)<<24) + ((b)<<16) + \
 					    ((c)<<8) + (d)))
 
@@ -55,5 +55,5 @@
 #define MAGIC_STEM_3            GEN_MAGIC('M','G','s','3')
 
-#define IS_MAGIC(a) ((((u_long)(a)) & 0xffff0000) == MAGIC_XXXX)
+#define IS_MAGIC(a) ((((mg_u_long)(a)) & 0xffff0000) == MAGIC_XXXX)
 
 
@@ -268,5 +268,5 @@
    an error message.   */
 FILE *open_named_file (const char *name, const char *mode,
-		       u_long magic_num, int err_mode);
+		       mg_u_long magic_num, int err_mode);
 
 
@@ -286,5 +286,5 @@
    an error message.   */
 FILE *open_file (const char *name, const char *suffix, const char *mode,
-		 u_long magic_num, int err_mode);
+		 mg_u_long magic_num, int err_mode);
 
 
@@ -305,5 +305,5 @@
    an error message.   */
 FILE *create_named_file (const char *name, const char *mode,
-			 u_long magic_num, int err_mode);
+			 mg_u_long magic_num, int err_mode);
 
 
@@ -322,8 +322,8 @@
    an error message.   */
 FILE *create_file (const char *name, const char *suffix, const char *mode,
-		   u_long magic_num, int err_mode);
-
-
-
-
-#endif
+		   mg_u_long magic_num, int err_mode);
+
+
+
+
+#endif
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_invf_dict.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_invf_dict.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_invf_dict.c	(revision 25147)
@@ -115,6 +115,6 @@
 {
   FILE *id, *idb, *tmp, *ii;
-  unsigned long i, pos, num, First_word, invf_ptr, invf_len;
-  unsigned long last_ptr = 0;
+  mg_u_long i, pos, num, First_word, invf_ptr, invf_len;
+  mg_u_long last_ptr = 0;
   char *FName;
   struct invf_dict_header idh;
@@ -179,6 +179,6 @@
   for (i = 0; i < idh.dict_size; i++)
     {
-      register unsigned long extra, copy, suff;
-      unsigned long wcnt, fcnt;
+      register mg_u_long extra, copy, suff;
+      mg_u_long wcnt, fcnt;
 
       /* build a new word on top of prev */
@@ -304,5 +304,5 @@
 
   rewind (tmp);
-  sdh.blocks_start = sdh.index_chars + sizeof (u_long) + sizeof (sdh) +
+  sdh.blocks_start = sdh.index_chars + sizeof (mg_u_long) + sizeof (sdh) +
     sdh.num_blocks * sizeof (pos);
   if (force)
@@ -323,5 +323,5 @@
 
   /* skip over the magic number */
-  fseek (idb, sizeof (u_long), 0);
+  fseek (idb, sizeof (mg_u_long), 0);
 
   /* [RPAP - Jan 97: Endian Ordering] */
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_invf_dump.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_invf_dump.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_invf_dump.c	(revision 25147)
@@ -36,5 +36,5 @@
 #include "invf.h"
 
-extern unsigned long S_btg;
+extern mg_u_long S_btg;
 
 /*
@@ -124,5 +124,5 @@
 process_files (char *name)
 {
-  unsigned long N, Nstatic, k;
+  mg_u_long N, Nstatic, k;
   FILE *dict;
   FILE *invf;
@@ -172,10 +172,10 @@
     }
   else
-    printf ("%ld %ld\n", N, ifh.no_of_words);
+    printf ("%d %d\n", N, ifh.no_of_words);
   for (k = 0; k < ifh.no_of_words; k++)
     {
       int i, blk, doc;
-      register unsigned long suff, prefix;
-      unsigned long fcnt, wcnt;
+      register mg_u_long suff, prefix;
+      mg_u_long fcnt, wcnt;
       char term[MAXSTEMLEN + 1];
 
@@ -196,7 +196,7 @@
 	{
 	  if (term_dump)
-	    printf ("%ld    \"%s\"\n", fcnt, term);
+	    printf ("%d    \"%s\"\n", fcnt, term);
 	  else
-	    printf ("%ld\n", fcnt);
+	    printf ("%d\n", fcnt);
 	}
       blk = BIO_Bblock_Init (Nstatic, fcnt);
@@ -215,8 +215,14 @@
 	      GAMMA_DECODE (count);
 	      if (word_counts)
+		{
 		if (binary)
+		  {
 		  fwrite ((char *) &count, sizeof (count), 1, stdout);
+		  }
 		else
+		  {
 		  printf (" %d", count);
+		  }
+		}
 	    }
 	  if (!binary)
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_invf_merge.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_invf_merge.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_invf_merge.c	(revision 25147)
@@ -58,16 +58,16 @@
     struct invf_dict_header idh;
     struct invf_file_header ifh;
-    u_long nDocs;
+    mg_u_long nDocs;
 
     /* Lexicon processing variables */
-    u_long fcnt, wcnt;
+    mg_u_long fcnt, wcnt;
     int suff, pref;
     unsigned char term[MAXSTEMLEN + 1];
-    u_long term_count;
+    mg_u_long term_count;
     int done;
 
     /* Variables used for merging */
     struct stdio_bitio_state sbs;	/* for bit-based I/O on inverted files */
-    u_long nTerms;		/* = number of invf entries */
+    mg_u_long nTerms;		/* = number of invf entries */
     int *fcntlist;		/* store fcnt values read in from the lexicons */
 
@@ -81,6 +81,6 @@
 
 merge_info m[3];		/*  m[OLD], m[NEW] and m[MERGE] */
-u_long magicsize;		/* how big is magic number? currently always 4 */
-u_long Nstatic;			/* static # of documents in file */
+mg_u_long magicsize;		/* how big is magic number? currently always 4 */
+mg_u_long Nstatic;			/* static # of documents in file */
 
 float *DocWeightBuffer;
@@ -97,9 +97,9 @@
 int fastMerge = 1;		/* True if fast merge selected. Default = true */
 
-u_long oldIdxValue;		/* stores last read value from m[OLD].idx
+mg_u_long oldIdxValue;		/* stores last read value from m[OLD].idx
 				   Used to calculate entry lengths */
-u_long bytes_output;		/* for writing .invf.idx file */
-u_long oldOnlyBits = 0;		/* entries in old only */
-u_long oldMergeBits = 0;	/* entries in old that are merged with 
+mg_u_long bytes_output;		/* for writing .invf.idx file */
+mg_u_long oldOnlyBits = 0;		/* entries in old only */
+mg_u_long oldMergeBits = 0;	/* entries in old that are merged with 
 				   a new entry */
 
@@ -242,5 +242,5 @@
   m[OLD].idx = open_file (m[OLD].fname, INVF_IDX_SUFFIX, "rb",
 			  MAGIC_INVI, MG_ABORT);
-  fread (&oldIdxValue, sizeof (u_long), 1, m[OLD].idx);
+  fread (&oldIdxValue, sizeof (mg_u_long), 1, m[OLD].idx);
   NTOHUL(oldIdxValue);  /* [RPAP - Jan 97: Endian Ordering] */
 
@@ -280,5 +280,5 @@
  *=======================================================================*/
 void 
-procEntry_slow (int tnum, int type, u_long oldN, u_long newN, u_long mergeN)
+procEntry_slow (int tnum, int type, mg_u_long oldN, mg_u_long newN, mg_u_long mergeN)
 /* 
  *  Process an invf entry. 
@@ -295,9 +295,9 @@
   int fcntNEW = m[NEW].fcntlist[tnum];
   int inblk, outblk;
-  u_long inbits = 0, outbits = 0;
+  mg_u_long inbits = 0, outbits = 0;
 
   /* write .invf.idx pointer */
   HTONUL(bytes_output);  /* [RPAP - Jan 97: Endian Ordering] */
-  fwrite (&bytes_output, sizeof (u_long), 1, m[MERGE].idx);
+  fwrite (&bytes_output, sizeof (mg_u_long), 1, m[MERGE].idx);
   NTOHUL(bytes_output);  /* [RPAP - Jan 97: Endian Ordering] */
 
@@ -383,10 +383,10 @@
  */
 {
-  u_long newIdxValue, len = 0;
+  mg_u_long newIdxValue, len = 0;
 
   /* Calculate IFold entry length in bytes if not NEW type */
   if (type != NEW)		/* read in an index number from m[OLD].idx */
     {
-      fread (&newIdxValue, sizeof (u_long), 1, m[OLD].idx);
+      fread (&newIdxValue, sizeof (mg_u_long), 1, m[OLD].idx);
       NTOHUL(newIdxValue);  /* [RPAP - Jan 97: Endian Ordering] */
       len = newIdxValue - oldIdxValue;
@@ -400,5 +400,5 @@
       /* write .invf.idx pointer */
       HTONUL(bytes_output);  /* [RPAP - Jan 97: Endian Ordering] */
-      fwrite (&bytes_output, sizeof (u_long), 1, m[MERGE].idx);
+      fwrite (&bytes_output, sizeof (mg_u_long), 1, m[MERGE].idx);
       NTOHUL(bytes_output);  /* [RPAP - Jan 97: Endian Ordering] */
 
@@ -468,6 +468,6 @@
   m[x].term_count = m[x].term_count + 1;
 
-  fread ((char *) &(m[x].fcnt), sizeof (u_long), 1, m[x].dict);
-  fread ((char *) &(m[x].wcnt), sizeof (u_long), 1, m[x].dict);
+  fread ((char *) &(m[x].fcnt), sizeof (mg_u_long), 1, m[x].dict);
+  fread ((char *) &(m[x].wcnt), sizeof (mg_u_long), 1, m[x].dict);
 
   /* [RPAP - Jan 97: Endian Ordering] */
@@ -620,7 +620,7 @@
   /* print some results about terms */
   {
-    fprintf (stderr, "   Terms: OLD = %ld,  NEW = %ld,  MERGE = %ld\n",
+    fprintf (stderr, "   Terms: OLD = %d,  NEW = %d,  MERGE = %d\n",
 	     m[OLD].nTerms, m[NEW].nTerms, m[MERGE].nTerms);
-    fprintf (stderr, "   In OLD only: %ld,  In NEW only: %ld,  BOTH: %ld\n",
+    fprintf (stderr, "   In OLD only: %d,  In NEW only: %d,  BOTH: %d\n",
 	     (m[MERGE].nTerms - m[NEW].nTerms),
 	     (m[MERGE].nTerms - m[OLD].nTerms),
@@ -645,8 +645,8 @@
     /* write final .invf.idx pointer */
     HTONUL(bytes_output);  /* [RPAP - Jan 97: Endian Ordering] */
-    fwrite (&bytes_output, sizeof (u_long), 1, m[MERGE].idx);
+    fwrite (&bytes_output, sizeof (mg_u_long), 1, m[MERGE].idx);
     NTOHUL(bytes_output);  /* [RPAP - Jan 97: Endian Ordering] */
 
-    fprintf (stderr, "Old invf: old only bits: %ld, merged bits: %ld\n",
+    fprintf (stderr, "Old invf: old only bits: %d, merged bits: %d\n",
 	     oldOnlyBits, oldMergeBits);
   }
@@ -729,7 +729,7 @@
       if (weightfile)
 	{
-	  u_long i;  /* [RPAP - Jan 97: Endian Ordering] */
-
-	  fprintf (stderr, "writing new weights: Nnew = %ld\n", m[NEW].nDocs);
+	  mg_u_long i;  /* [RPAP - Jan 97: Endian Ordering] */
+
+	  fprintf (stderr, "writing new weights: Nnew = %d\n", m[NEW].nDocs);
 	  fseek (weightfile, 0, 2);	/* end of file */
 
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_invf_rebuild.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_invf_rebuild.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_invf_rebuild.c	(revision 25147)
@@ -43,5 +43,5 @@
 typedef struct invf_info
   {
-    unsigned long doc_num, count, bits_so_far, count_bits;
+    mg_u_long doc_num, count, bits_so_far, count_bits;
   }
 invf_info;
@@ -200,6 +200,6 @@
 {
   FILE *in, *out, *idx, *odx, *dict;
-  unsigned long magic, outmode, N, in_k, out_k;
-  unsigned long bits_out, bytes_out, i, j;
+  mg_u_long magic, outmode, N, in_k, out_k;
+  mg_u_long bits_out, bytes_out, i, j;
   stdio_bitio_state out_buf, in_buf;
   struct invf_dict_header idh;
@@ -351,10 +351,10 @@
   for (i = 0; i < ifh_in.no_of_words; i++)
     {
-      unsigned long blk, p;
-      unsigned long odn_blk = 0, olen_blk = 0;
-      unsigned long idn_blk = 0, ilen_blk = 0;
-      register unsigned long suff;
-      unsigned long fcnt, wcnt, doc_num, bits_so_far, last_major;
-      unsigned long next_mjr_dn, kd;
+      mg_u_long blk, p;
+      mg_u_long odn_blk = 0, olen_blk = 0;
+      mg_u_long idn_blk = 0, ilen_blk = 0;
+      register mg_u_long suff;
+      mg_u_long fcnt, wcnt, doc_num, bits_so_far, last_major;
+      mg_u_long next_mjr_dn, kd;
       char dummy2[MAXSTEMLEN + 1];
       invf_info *ii;
@@ -380,5 +380,5 @@
 	case 1:
 	  {
-	    unsigned long len;
+	    mg_u_long len;
 	    if (p <= ifh_out.params[0])
 	      out_k = 0;
@@ -396,5 +396,5 @@
 	case 2:
 	  {
-	    unsigned long len;
+	    mg_u_long len;
 	    if (p <= mins)
 	      out_k = 0;
@@ -421,5 +421,5 @@
 	case 1:
 	  {
-	    unsigned long len;
+	    mg_u_long len;
 	    if (p <= ifh_in.params[0])
 	      in_k = 0;
@@ -437,5 +437,5 @@
 	case 2:
 	  {
-	    unsigned long len;
+	    mg_u_long len;
 	    if (p <= ifh_in.params[1])
 	      {
@@ -469,5 +469,5 @@
 	for (j = 0; j < p; j++, kd++)
 	{
-	  unsigned long doc_diff, count = 0;
+	  mg_u_long doc_diff, count = 0;
 	  if (kd == in_k)
 	    kd = 0;
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_passes.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_passes.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_passes.c	(revision 25147)
@@ -103,7 +103,7 @@
 #define	TERMRECORD	'\002'
 
-unsigned long buf_size = 3 * 1024 * 1024;	/* 3Mb */
-unsigned long invf_buffer_size = 5 * 1024 * 1024;	/* 5Mb */
-unsigned long ChunkLimit = 0;
+mg_u_long buf_size = 3 * 1024 * 1024;	/* 3Mb */
+mg_u_long invf_buffer_size = 5 * 1024 * 1024;	/* 5Mb */
+mg_u_long ChunkLimit = 0;
 char InvfLevel = 2;
 char SkipSGML = 0;
@@ -117,5 +117,5 @@
 
 static char Passes = 0;
-static unsigned long trace = 0;
+static mg_u_long trace = 0;
 static int Dump = 0;
 static char **files = NULL;
@@ -181,8 +181,8 @@
 #if 0
 static char *
-str_comma (unsigned long u)
+str_comma (mg_u_long u)
 {
   static char buf[20];
-  unsigned long a, b, c, d;
+  mg_u_long a, b, c, d;
   a = u / 1000000000;
   u -= a * 1000000000;
@@ -229,6 +229,6 @@
 
   char *buffer = Xmalloc (buf_size);
-  unsigned long num_docs = 0;
-  unsigned long block_bytes = 0;
+  mg_u_long num_docs = 0;
+  mg_u_long block_bytes = 0;
   register int buf_left = buf_size;
   register char *look_pos = buffer;
@@ -358,5 +358,5 @@
 		  }
 		if (Trace)
-		  fprintf (Trace, "%11" ULL_FS " bytes |%7lu docs | %s\n",
+		  fprintf (Trace, "%11" ULL_FS " bytes |%7u docs | %s\n",
 			   bytes_processed, num_docs,
 			   ElapsedTime (&StartTime, NULL));
@@ -383,10 +383,10 @@
 	      mi = mallinfo ();
 	      block_bytes -= trace;
-	      fprintf (Trace, "%11" ULL_FS " bytes |%7lu docs |%7.3f Mb | %s\n",
+	      fprintf (Trace, "%11" ULL_FS " bytes |%7u docs |%7.3f Mb | %s\n",
 		       bytes_processed, num_docs, mi.arena / 1024.0 / 1024.0,
 		       ElapsedTime (&StartTime, NULL));
 #else
 	      block_bytes -= trace;
-	      fprintf (Trace, "%11" ULL_FS " bytes |%7lu docs | %s\n",
+	      fprintf (Trace, "%11" ULL_FS " bytes |%7u docs | %s\n",
 		       bytes_processed, num_docs,
 		       ElapsedTime (&StartTime, NULL));
@@ -439,9 +439,9 @@
       struct mallinfo mi;
       mi = mallinfo ();
-      fprintf (Trace, "%11" ULL_FS " bytes |%7lu docs |%7.3f Mb | %s\n",
+      fprintf (Trace, "%11" ULL_FS " bytes |%7u docs |%7.3f Mb | %s\n",
 	       bytes_processed, num_docs, mi.arena / 1024.0 / 1024.0,
 	       ElapsedTime (&StartTime, NULL));
 #else
-      fprintf (Trace, "%11" ULL_FS " bytes |%7lu docs | %s\n",
+      fprintf (Trace, "%11" ULL_FS " bytes |%7u docs | %s\n",
 	       bytes_processed, num_docs,
 	       ElapsedTime (&StartTime, NULL));
@@ -563,5 +563,5 @@
 	  break;
 	case 't':
-	  trace = (unsigned long) (atof (optarg) * 1024 * 1024);
+	  trace = (mg_u_long) (atof (optarg) * 1024 * 1024);
 	  break;
 	case 'M':
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_passes_4jni.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_passes_4jni.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_passes_4jni.c	(revision 25147)
@@ -57,7 +57,7 @@
 #define	TERMRECORD	'\002'
 
-unsigned long buf_size = 3 * 1024 * 1024;	/* 3Mb */
-unsigned long invf_buffer_size = 5 * 1024 * 1024;	/* 5Mb */
-unsigned long ChunkLimit = 0;
+mg_u_long buf_size = 3 * 1024 * 1024;	/* 3Mb */
+mg_u_long invf_buffer_size = 5 * 1024 * 1024;	/* 5Mb */
+mg_u_long ChunkLimit = 0;
 char InvfLevel = 2;
 char SkipSGML = 0;
@@ -71,9 +71,9 @@
 FILE * Trace;
 char * filename;
-unsigned long num_docs = 0;
-unsigned long block_bytes = 0;
+mg_u_long num_docs = 0;
+mg_u_long block_bytes = 0;
 
 static char Passes = 0;
-static unsigned long trace = 0;
+static mg_u_long trace = 0;
 static int Dump = 0;
 static char **files = NULL;
@@ -193,5 +193,5 @@
 
 /* -b arg to mg_passes */
-void set_buffer_size(long size) {
+void set_buffer_size(mg_s_long size) {
   buf_size = size * 1024;
   if (buf_size <  MIN_BUF) {
@@ -201,5 +201,5 @@
 
 /* -c arg to mg_passes */
-void set_chunk_limit(long chunk_limit) {
+void set_chunk_limit(mg_s_long chunk_limit) {
   ChunkLimit = chunk_limit;
 }
@@ -259,5 +259,5 @@
 /* -t arg to mg_passes */
 void set_trace_point(int tracepos) {
-  trace = (unsigned long) (tracepos * 1024 * 1024);
+  trace = (mg_u_long) (tracepos * 1024 * 1024);
 }
 
@@ -410,5 +410,5 @@
 	      }
 	    if (Trace)
-	      fprintf (Trace, "%11" ULL_FS " bytes |%7lu docs | %s\n",
+	      fprintf (Trace, "%11" ULL_FS " bytes |%7u docs | %s\n",
 		       bytes_processed, num_docs,
 		       ElapsedTime (&StartTime, NULL));
@@ -435,10 +435,10 @@
 	  mi = mallinfo ();
 	  block_bytes -= trace;
-	  fprintf (Trace, "%11" ULL_FS " bytes |%7lu docs |%7.3f Mb | %s\n",
+	  fprintf (Trace, "%11" ULL_FS " bytes |%7u docs |%7.3f Mb | %s\n",
 		   bytes_processed, num_docs, mi.arena / 1024.0 / 1024.0,
 		   ElapsedTime (&StartTime, NULL));
 #else
 	  block_bytes -= trace;
-	  fprintf (Trace, "%11" ULL_FS " bytes |%7lu docs | %s\n",
+	  fprintf (Trace, "%11" ULL_FS " bytes |%7u docs | %s\n",
 		   bytes_processed, num_docs,
 		   ElapsedTime (&StartTime, NULL));
@@ -492,9 +492,9 @@
       struct mallinfo mi;
       mi = mallinfo ();
-      fprintf (Trace, "%11" ULL_FS " bytes |%7lu docs |%7.3f Mb | %s\n",
+      fprintf (Trace, "%11" ULL_FS " bytes |%7u docs |%7.3f Mb | %s\n",
 	       bytes_processed, num_docs, mi.arena / 1024.0 / 1024.0,
 	       ElapsedTime (&StartTime, NULL));
 #else
-      fprintf (Trace, "%11" ULL_FS " bytes |%7lu docs | %s\n",
+      fprintf (Trace, "%11" ULL_FS " bytes |%7u docs | %s\n",
 	       bytes_processed, num_docs,
 	       ElapsedTime (&StartTime, NULL));
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_passes_4jni.h
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_passes_4jni.h	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_passes_4jni.h	(revision 25147)
@@ -40,8 +40,8 @@
 
 /* -b arg to mg_passes */
-void set_buffer_size(long size);
+void set_buffer_size(mg_s_long size);
 
 /* -c arg to mg_passes */
-void set_chunk_limit(long chunk_limit);
+void set_chunk_limit(mg_s_long chunk_limit);
 
 /* -C arg to mg_passes */
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_perf_hash_build.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_perf_hash_build.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_perf_hash_build.c	(revision 25147)
@@ -116,5 +116,5 @@
 {
   FILE *dict, *hash;
-  unsigned long i;
+  mg_u_long i;
   u_char prev[MAXSTEMLEN + 1];
   struct invf_dict_header idh;
@@ -154,6 +154,6 @@
   for (i = 0; i < idh.dict_size; i++)
     {
-      register unsigned long copy, suff, l;
-      unsigned long wcnt, fcnt;
+      register mg_u_long copy, suff, l;
+      mg_u_long wcnt, fcnt;
 
       /* build a new word on top of prev */
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_stem_idx.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_stem_idx.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_stem_idx.c	(revision 25147)
@@ -69,10 +69,10 @@
 
 
-static unsigned long MaxMemInUse = 0;
-static unsigned long MemInUse = 0;
+static mg_u_long MaxMemInUse = 0;
+static mg_u_long MemInUse = 0;
 
 static idx_hash_rec **IdxHashTable;
-static unsigned long IdxHashSize;
-static unsigned long IdxHashUsed;
+static mg_u_long IdxHashSize;
+static mg_u_long IdxHashUsed;
 static u_char *IdxPool;
 static int IdxPoolLeft;
@@ -88,5 +88,5 @@
 int force = 0;
 
-static long lookback = 4;
+static mg_s_long lookback = 4;
 
 static void 
@@ -216,5 +216,5 @@
 ReadStemDictBlk (File * stem_file)
 {
-  unsigned long i;
+  mg_u_long i;
   stemmed_dict *sd;
   u_char *buffer;
@@ -357,5 +357,5 @@
       register unsigned int res;
       int num_indexes;
-      unsigned long *first_word, *last_invf_len;
+      mg_u_long *first_word, *last_invf_len;
       unsigned short *num_words;
       u_char *base;
@@ -368,7 +368,7 @@
 
       /* Move through block header */
-      first_word = (unsigned long *) (sd->buffer);
+      first_word = (mg_u_long *) (sd->buffer);
       NTOHUL(*first_word);  /* [RPAP - Jan 97: Endian Ordering] */
-      last_invf_len = (unsigned long *) (first_word + 1);
+      last_invf_len = (mg_u_long *) (first_word + 1);
       NTOHUL(*last_invf_len);  /* [RPAP - Jan 97: Endian Ordering] */
       num_words = (unsigned short *) (last_invf_len + 1);
@@ -404,7 +404,7 @@
 
 	  /* Skip irrelevant word info */
-	  base += sizeof (u_long);
-	  base += sizeof (u_long);
-	  base += sizeof (u_long);
+	  base += sizeof (mg_u_long);
+	  base += sizeof (mg_u_long);
+	  base += sizeof (mg_u_long);
 
 	  /* Stem word */
@@ -419,5 +419,5 @@
 	    {
 	      /* Search the idx hash table for word */
-	      register unsigned long hashval, step;
+	      register mg_u_long hashval, step;
 	      register int hsize = IdxHashSize;
 	      HASH (hashval, step, word, hsize);
@@ -516,6 +516,6 @@
 	    {
 	      idx_hash_rec **ht;
-	      unsigned long size;
-	      unsigned long i;
+	      mg_u_long size;
+	      mg_u_long i;
 	      size = prime (IdxHashSize * 2);
 	      if (!(ht = Xmalloc (sizeof (idx_hash_rec *) * size)))
@@ -529,5 +529,5 @@
 		    register u_char *wptr;
 		    idx_hash_rec *ent;
-		    register unsigned long hashval, step;
+		    register mg_u_long hashval, step;
 		    
 		    wptr = IdxHashTable[i]->word;
@@ -568,5 +568,5 @@
 {
   char *FName;
-  unsigned long i, j, pos, First_word, num;
+  mg_u_long i, j, pos, First_word, num;
   struct stem_idx_header sih;
   u_char *buffer, *last_word = NULL;
@@ -636,5 +636,5 @@
   for (i = 0; i < IdxHashUsed; i++)
     {
-      register unsigned long extra, copy, suff;
+      register mg_u_long extra, copy, suff;
       register struct idx_hash_rec *ent = IdxHashTable[i];
 
@@ -765,5 +765,5 @@
 
   rewind (tmp);
-  sih.blocks_start = sih.index_chars + sizeof (u_long) + sizeof (sih) +
+  sih.blocks_start = sih.index_chars + sizeof (mg_u_long) + sizeof (sih) +
     sih.num_blocks * sizeof (pos);
   if (force)
@@ -784,5 +784,5 @@
 
   /* skip over the magic number */
-  fseek (idbi, sizeof (u_long), 0);
+  fseek (idbi, sizeof (mg_u_long), 0);
 
   /* [RPAP - Jan 97: Endian Ordering] */
@@ -821,5 +821,5 @@
   sdh.indexed |= 1 << (stem_method - 1);
   HTONUL(sdh.indexed);
-  fseek (idb, sizeof (u_long), 0);
+  fseek (idb, sizeof (mg_u_long), 0);
   fwrite ((char *) &sdh, sizeof (sdh), 1, idb);
   fclose (idb);
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_text_estimate.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_text_estimate.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_text_estimate.c	(revision 25147)
@@ -91,11 +91,11 @@
 typedef struct stats_t
   {
-    u_long freq, occur;
-    u_long len;
+    mg_u_long freq, occur;
+    mg_u_long len;
   }
 stats_t;
 
-static u_long huff_count = 0;
-static u_long escape_count = 0;
+static mg_u_long huff_count = 0;
+static mg_u_long escape_count = 0;
 
 
@@ -106,5 +106,5 @@
 static double ReadInWordsSpecial (char *name, double *num_bytes,
 				  double *num_extra_bytes,
-				  u_long *aux_compressed);
+				  mg_u_long *aux_compressed);
 
 
@@ -116,5 +116,5 @@
   ProgTime StartTime;
   double num_bytes, num_extra_bytes = 0; /* [RJM 07/97: 4G limit] */
-  u_long aux_compressed;
+  mg_u_long aux_compressed;
   int ch;
   double bytes;
@@ -207,5 +207,5 @@
   compression_stats_header csh;
   FILE *f;
-  u_long which;
+  mg_u_long which;
   double bytes, bits = 0;
 
@@ -246,5 +246,5 @@
 	  if (ht[which])
 	    {
-	      register unsigned long hashval, step;
+	      register mg_u_long hashval, step;
 	      register int tsize = ht[which]->size;
 	      register u_char **wptr;
@@ -335,5 +335,5 @@
   bits += 5.5 * csh.num_docs;
 
-  bytes = bits / 8 + sizeof (compressed_text_header) + sizeof (u_long);
+  bytes = bits / 8 + sizeof (compressed_text_header) + sizeof (mg_u_long);
 
   *num_bytes = csh.num_bytes;
@@ -356,9 +356,9 @@
 ReadInWordsSpecial (char *name, double *num_bytes,
 		    double *num_extra_bytes,
-		    u_long *aux_compressed)
+		    mg_u_long *aux_compressed)
 {
   compression_stats_header csh;
   FILE *f;
-  u_long magic, which;
+  mg_u_long magic, which;
   double bytes, bits = 0;
   double size[2];
@@ -386,5 +386,5 @@
       frags_stats_header fsh;
       int j, num = 0;
-      long lens[16], chars[256];
+      mg_s_long lens[16], chars[256];
 
       bzero ((char *) lens, sizeof (lens));
@@ -420,5 +420,5 @@
 	  if (ht[which])
 	    {
-	      register unsigned long hashval, step;
+	      register mg_u_long hashval, step;
 	      register int tsize = ht[which]->size;
 	      register u_char **wptr;
@@ -489,5 +489,5 @@
 	int j, num_buckets = 0;
 	int start[10], end[10];
-	long flens[16], fchars[256];
+	mg_u_long flens[16], fchars[256];
 
 	for (j = 0; j < 256; j++)
@@ -577,5 +577,5 @@
   bits += 5.5 * csh.num_docs;
 
-  bytes = bits / 8 + sizeof (compressed_text_header) + sizeof (u_long);
+  bytes = bits / 8 + sizeof (compressed_text_header) + sizeof (mg_u_long);
 
   *num_bytes = csh.num_bytes;
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_text_merge.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_text_merge.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_text_merge.c	(revision 25147)
@@ -43,5 +43,5 @@
 FileName old_name, new_name, merge_name;
 
-long magicsize;			/* == where the header in a file begins */
+mg_s_long magicsize;			/* == where the header in a file begins */
 
 compressed_text_header cth[3];
@@ -100,5 +100,5 @@
 {
   int i;
-  u_long data, offset;
+  mg_u_long data, offset;
   byte c;
 
@@ -135,10 +135,10 @@
   for (i = 0; i < cth[OLD].num_of_docs; i++)
     {
-      fread (&data, sizeof (u_long), 1, idx[OLD]);
-      fwrite (&data, sizeof (u_long), 1, idx[MERGE]);
+      fread (&data, sizeof (mg_u_long), 1, idx[OLD]);
+      fwrite (&data, sizeof (mg_u_long), 1, idx[MERGE]);
     }
 
   /* offset is the amount to add to each entry from idx[NEW] */
-  fread (&offset, sizeof (u_long), 1, idx[OLD]);
+  fread (&offset, sizeof (mg_u_long), 1, idx[OLD]);
   NTOHUL(offset);  /* [RPAP - Jan 97: Endian Ordering] */
   offset -= (4 + sizeof (cth[OLD]));	/* 4 for the magic number */
@@ -146,16 +146,16 @@
   for (i = 0; i < cth[NEW].num_of_docs; i++)
     {
-      fread (&data, sizeof (u_long), 1, idx[NEW]);
+      fread (&data, sizeof (mg_u_long), 1, idx[NEW]);
       NTOHUL(data);  /* [RPAP - Jan 97: Endian Ordering] */
       data += offset;
       HTONUL(data);  /* [RPAP - Jan 97: Endian Ordering] */
-      fwrite (&data, sizeof (u_long), 1, idx[MERGE]);
+      fwrite (&data, sizeof (mg_u_long), 1, idx[MERGE]);
     }
-  /* write last u_long in idx[MERGE] (= length of file) */
-  fread (&data, sizeof (u_long), 1, idx[NEW]);
+  /* write last mg_u_long in idx[MERGE] (= length of file) */
+  fread (&data, sizeof (mg_u_long), 1, idx[NEW]);
   NTOHUL(data);  /* [RPAP - Jan 97: Endian Ordering] */
   data += offset;
   HTONUL(data);  /* [RPAP - Jan 97: Endian Ordering] */
-  fwrite (&data, sizeof (u_long), 1, idx[MERGE]);
+  fwrite (&data, sizeof (mg_u_long), 1, idx[MERGE]);
 
 /******* update .text *******/
@@ -188,5 +188,5 @@
   fclose (idx[NEW]);
 
-  fprintf (stderr, "mg_text_merge: %ld documents added to %s\n",
+  fprintf (stderr, "mg_text_merge: %d documents added to %s\n",
 	   cth[NEW].num_of_docs, merge_name);
 
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_weights_build.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_weights_build.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/mg_weights_build.c	(revision 25147)
@@ -38,5 +38,5 @@
 #include "words.h"
 
-#define MAXBITS (sizeof(unsigned long) * 8)
+#define MAXBITS (sizeof(mg_u_long) * 8)
 
 /*
@@ -81,9 +81,9 @@
 static char *file_name = "";
 static char *text_file_name = "";
-static unsigned long NumPara = 0;
-static unsigned long StaticNumOfDocs = 0;
-
-unsigned long get_NumPara (void);
-unsigned long get_StaticNumOfDocs (void);
+static mg_u_long NumPara = 0;
+static mg_u_long StaticNumOfDocs = 0;
+
+mg_u_long get_NumPara (void);
+mg_u_long get_StaticNumOfDocs (void);
 void GenerateWeights (void);
 void Make_weight_approx (void);
@@ -141,5 +141,5 @@
 
 
-unsigned long 
+mg_u_long 
 get_NumPara (void)
 {
@@ -158,5 +158,5 @@
 
 
-unsigned long 
+mg_u_long 
 get_StaticNumOfDocs (void)
 /* the static number of documents is the N parameter used to
@@ -253,5 +253,5 @@
     {
       u_char dummy1, dummy2[MAXSTEMLEN + 1];
-      unsigned long fcnt, wcnt, blk, CurrDoc, p, j;
+      mg_u_long fcnt, wcnt, blk, CurrDoc, p, j;
       float idf;
 
@@ -281,5 +281,5 @@
       /* check the inverted file index entry for this word */
       {
-	unsigned long loc;
+	mg_u_long loc;
 	fread ((char *) &loc, sizeof (loc), 1, idx);
 	NTOHUL(loc);  /* [RPAP - Jan 97: Endian Ordering] */
@@ -292,5 +292,5 @@
       for (j = 0; j < p; j++)
 	{
-	  unsigned long x, tf;
+	  mg_u_long x, tf;
 	  BBLOCK_DECODE (x, blk);
 	  CurrDoc += x;
@@ -346,5 +346,5 @@
 {
   int i, pos, max;
-  unsigned long buf;
+  mg_u_long buf;
   double U, L, B;
   FILE *approx, *exact;
@@ -368,5 +368,5 @@
 
     }
-  fseek (exact, sizeof (u_long), SEEK_SET);
+  fseek (exact, sizeof (mg_u_long), SEEK_SET);
 
   B = pow (U / L, pow (2.0, -(double) bits));
@@ -392,5 +392,5 @@
   for (buf = pos = i = 0; i < NumPara; i++)
     {
-      unsigned long fx;
+      mg_u_long fx;
       float wgt;
       fread ((char *) &wgt, sizeof (wgt), 1, exact);
@@ -476,5 +476,5 @@
     struct
       {
-	unsigned long Start;
+	mg_u_long Start;
 	float Weight;
       }
@@ -483,5 +483,5 @@
       {
 	int count;
-	fread ((char *) &data.Start, sizeof (unsigned long), 1, idx);
+	fread ((char *) &data.Start, sizeof (mg_u_long), 1, idx);
 	if (para && i < cth.num_of_docs)
 	  {
@@ -502,5 +502,5 @@
       }
     /* Write out the extra entry for the idx file */
-    fread ((char *) &data.Start, sizeof (unsigned long), 1, idx);
+    fread ((char *) &data.Start, sizeof (mg_u_long), 1, idx);
     data.Weight = 0;
     fwrite((char*)&data, sizeof(data), 1, idx_wgt);
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/mgdictlist.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/mgdictlist.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/mgdictlist.c	(revision 25147)
@@ -73,5 +73,5 @@
 int quick = 0;
 int no_of_words[2];
-u_long maxcodelen[2];
+mg_u_long maxcodelen[2];
 
 char *dictname = "";
@@ -102,15 +102,15 @@
 
   if (quick)
-    printf ("%ld\n", idh.dict_size);
+    printf ("%d\n", idh.dict_size);
   else
     {
-      printf ("# lookback           = %lu\n", idh.lookback);
-      printf ("# dict size          = %lu\n", idh.dict_size);
-      printf ("# total bytes        = %lu\n", idh.total_bytes);
-      printf ("# index string bytes = %lu\n", idh.index_string_bytes);
+      printf ("# lookback           = %u\n", idh.lookback);
+      printf ("# dict size          = %u\n", idh.dict_size);
+      printf ("# total bytes        = %u\n", idh.total_bytes);
+      printf ("# index string bytes = %u\n", idh.index_string_bytes);
       printf ("# input bytes        = %.0f\n", idh.input_bytes); /* [RJM 07/97: 4G limit] */
-      printf ("# num of docs        = %lu\n", idh.num_of_docs);
-      printf ("# static num of docs = %lu\n", idh.static_num_of_docs);
-      printf ("# num of words       = %lu\n", idh.num_of_words);
+      printf ("# num of docs        = %u\n", idh.num_of_docs);
+      printf ("# static num of docs = %u\n", idh.static_num_of_docs);
+      printf ("# num of words       = %u\n", idh.num_of_words);
       printf ("#\n");
     }
@@ -118,6 +118,6 @@
   for (i = 0; i < idh.dict_size; i++)
     {
-      register unsigned long copy, suff;
-      unsigned long wcnt, fcnt;
+      register mg_u_long copy, suff;
+      mg_u_long wcnt, fcnt;
 
       /* build a new word on top of prev */
@@ -137,11 +137,11 @@
       if (!quick)
 	{
-	  printf ("%d: %8ld ", i, wcnt);
-	  printf ("/ %5ld ", fcnt);
-	  printf ("%2d %2ld\t\"", *prev, copy);
+	  printf ("%d: %8d ", i, wcnt);
+	  printf ("/ %5d ", fcnt);
+	  printf ("%2d %2d\t\"", *prev, copy);
 	}
       printf ("%s", word2str (prev));
       if (quick)
-	printf (" %ld %ld\n", wcnt, fcnt);
+	printf (" %d %d\n", wcnt, fcnt);
       else
 	{
@@ -159,5 +159,5 @@
 {
   comp_frags_header cfh;
-  u_long *codes;
+  mg_u_long *codes;
   u_char prev[MAXSTEMLEN + 1];
   int i;
@@ -168,5 +168,5 @@
   printf ("#\n");
   printf ("#   max code len       = %u\n", cfh.hd.maxcodelen);
-  printf ("#   total bytes        = %lu\n", cfh.uncompressed_size);
+  printf ("#   total bytes        = %d\n", cfh.uncompressed_size);
   printf ("#\n");
 
@@ -202,5 +202,5 @@
   int i;
   huff_data hd;
-  u_long *codes;
+  mg_u_long *codes;
 
   if (Read_Huffman_Data (f, &hd, NULL, NULL) == -1)
@@ -232,5 +232,5 @@
   int i;
   huff_data hd;
-  u_long *codes;
+  mg_u_long *codes;
 
   if (Read_Huffman_Data (f, &hd, NULL, NULL) == -1)
@@ -280,9 +280,9 @@
       break;
     }
-  printf ("# num words          = %lu\n", cdh.num_words[1]);
-  printf ("# num word chars     = %lu\n", cdh.num_word_chars[1]);
-  printf ("# num non-words      = %lu\n", cdh.num_words[0]);
-  printf ("# num non-word chars = %lu\n", cdh.num_word_chars[0]);
-  printf ("# lookback           = %lu\n", cdh.lookback);
+  printf ("# num words          = %d\n", cdh.num_words[1]);
+  printf ("# num word chars     = %d\n", cdh.num_word_chars[1]);
+  printf ("# num non-words      = %d\n", cdh.num_words[0]);
+  printf ("# num non-word chars = %d\n", cdh.num_word_chars[0]);
+  printf ("# lookback           = %d\n", cdh.lookback);
 
   for (which = 0; which < 2; which++)
@@ -338,5 +338,5 @@
 
       if (!quick)
-	printf ("#\n# num %9s      = %lu\n#\n", i ? "words" : "non-words",
+	printf ("#\n# num %9s      = %u\n#\n", i ? "words" : "non-words",
 		fsh.num_frags);
 
@@ -344,5 +344,5 @@
 	{
 	  u_char Word[16];
-	  u_long freq, occur_num;
+	  mg_u_long freq, occur_num;
 
 	  fread (&freq, sizeof (freq), 1, f);
@@ -355,5 +355,5 @@
 	  Word[0] = fgetc (f);
 	  fread (Word + 1, Word[0], 1, f);
-	  printf ("%d: %7ld : %7ld : \"%s\"\n", j, freq,
+	  printf ("%d: %7d : %7d : \"%s\"\n", j, freq,
 		  occur_num, word2str (Word));
 	}
@@ -365,5 +365,5 @@
 {
   FILE *fp;
-  unsigned long magic = 0;
+  mg_u_long magic = 0;
 
   if (argc < 2)
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/mgpass.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/mgpass.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/mgpass.c	(revision 25147)
@@ -100,7 +100,7 @@
 #define path_length 256
 
-unsigned long buf_size = 3 * 1024 * 1024;       /* 3Mb */
-unsigned long invf_buffer_size = 5 * 1024 * 1024;       /* 5Mb */
-unsigned long ChunkLimit = 0;
+mg_u_long buf_size = 3 * 1024 * 1024;       /* 3Mb */
+mg_u_long invf_buffer_size = 5 * 1024 * 1024;       /* 5Mb */
+mg_u_long ChunkLimit = 0;
 char InvfLevel = 2;
 char SkipSGML = 0;
@@ -115,5 +115,5 @@
 
 static char Passes = 0;
-static unsigned long trace = 0;
+static mg_u_long trace = 0;
 static int Dump = 0;
 static char **files = NULL;
@@ -237,5 +237,5 @@
 void search(char *dname, char *fname)
 {
-  long dirtag;  struct _finddata_t dirinfo;  int in_fd;  char *res;
+  mg_s_long dirtag;  struct _finddata_t dirinfo;  int in_fd;  char *res;
   char search_name[path_length], found_name[path_length];
 
@@ -433,5 +433,5 @@
 	  break;
 	case 't':
-	  trace = (unsigned long) (atof (optarg) * 1024 * 1024);
+	  trace = (mg_u_long) (atof (optarg) * 1024 * 1024);
 	  break;
 	case 'h':
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/mgquery.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/mgquery.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/mgquery.c	(revision 25147)
@@ -143,5 +143,5 @@
 #ifdef TREC_MODE
 char *trec_ids = NULL;
-long *trec_paras = NULL;
+mg_s_long *trec_paras = NULL;
 #endif
 
@@ -264,5 +264,5 @@
 
 #ifdef USE_PROCESS_MEM
-static u_long 
+static mg_u_long 
 process_mem (void)
 {
@@ -272,5 +272,5 @@
     {
       char buf[128];
-      sprintf (buf, "/proc/%ld", (long) getpid ());
+      sprintf (buf, "/proc/%d", (mg_s_long) getpid ());
       fd = open (buf, O_RDONLY);
     }
@@ -347,8 +347,8 @@
 StatFile (File * F)
 {
-  static unsigned long NumBytes = 0, NumSeeks = 0, NumReads = 0;
+  static mg_u_long NumBytes = 0, NumSeeks = 0, NumReads = 0;
   if (F) 
     {
-      if ((int) F != -1)
+      if ((intptr_t) F != -1)
 	{
 	  if (!BooleanEnv (GetEnv ("briefstats"), 0))
@@ -533,11 +533,11 @@
 /* num should be greater than or equal to 1 */
 int 
-RawDocOutput (query_data * qd, u_long num, FILE * Output)
-{
-  static u_long last_pos = 0;
+RawDocOutput (query_data * qd, mg_u_long num, FILE * Output)
+{
+  static mg_u_long last_pos = 0;
   static u_char *c_buffer = 0;
   static int buf_len = -1;
   static u_char *uc_buffer = 0;
-  u_long pos, len;
+  mg_u_long pos, len;
   int ULen;
 
@@ -570,5 +570,5 @@
 void 
 StringOut (FILE * Output, char *string,
-	   int intvalid, unsigned long intval,
+	   int intvalid, mg_u_long intval,
 	   int floatvalid, double floatval)
 {
@@ -583,5 +583,5 @@
 	  case 'n':
 	    if (intvalid)
-	      fprintf (Output, "%lu", intval);
+	      fprintf (Output, "%d", intval);
 	    else
 	      fprintf (Output, "%%n");
@@ -603,5 +603,5 @@
 
 void 
-HeaderOut (FILE * Output, u_char * UDoc, unsigned long ULen, int heads_length)
+HeaderOut (FILE * Output, u_char * UDoc, mg_u_long ULen, int heads_length)
 {
   int i, space = 1, num = 0;
@@ -688,5 +688,5 @@
     {
       u_char *UDoc = NULL;
-      unsigned long ULen;
+      mg_u_long ULen;
 
       if (need_text)
@@ -760,5 +760,5 @@
 		    }
 #else
-		fprintf (Output, "%7d   %6.4f   %7lu\n", GetDocNum (qd),
+		fprintf (Output, "%7d   %6.4f   %7u\n", GetDocNum (qd),
 			 GetDocWeight (qd), GetDocCompLength (qd));
 #endif
@@ -776,10 +776,10 @@
 	      if (PagerRunning && trec_ids)
 		{
-		  long DN, PN = GetDocNum (qd) - 1;
+		  mg_s_long DN, PN = GetDocNum (qd) - 1;
 		  if (trec_paras)
 		    DN = trec_paras[PN];
 		  else
 		    DN = PN;
-		  fprintf (Output, "%-14.14s  %8ld  %10.5f\n",
+		  fprintf (Output, "%-14.14s  %8d  %10.5f\n",
 			   &trec_ids[DN * 14], PN + 1, GetDocWeight (qd));
 		}
@@ -991,5 +991,5 @@
 	  return;
 	}
-      sprintf (pager, "%s --style=%s --pager=%s --stem_method=%ld --stemmer=%ld %s",
+      sprintf (pager, "%s --style=%s --pager=%s --stem_method=%d --stemmer=%d %s",
 	       HILITE_PAGER,
 	       GetEnv ("hilite_style"),
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/mgstat.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/mgstat.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/mgstat.c	(revision 25147)
@@ -70,5 +70,5 @@
 void ProcessDict (char *);
 void ProcessStem (char *);
-long ProcessStemBlk (char *name);  /* [RPAP - Jan 97: Stem Index Change] */
+mg_s_long ProcessStemBlk (char *name);  /* [RPAP - Jan 97: Stem Index Change] */
 
 static mg_ullong inputbytes = 0;
@@ -86,5 +86,5 @@
   int ch;
   int exact = 0;
-  long indexed = 0; /* [RPAP - Jan 97: Stem Index Change] */
+  mg_s_long indexed = 0; /* [RPAP - Jan 97: Stem Index Change] */
   opterr = 0;
   while ((ch = getopt (argc, argv, "Ehf:d:")) != -1)
@@ -258,9 +258,9 @@
     {
       inputbytes = cth.num_of_bytes;
-      printf ("Input bytes                        : %10" ULL_FS ", %8.2f Mbyte\n",
+      printf ("Input bytes                        : %10f, %8.2f Mbyte\n",
 	      cth.num_of_bytes, (double) cth.num_of_bytes / 1024 / 1024);
-      printf ("Documents                          : %10lu\n", cth.num_of_docs);
-      printf ("Words in collection [dict]         : %10lu\n", cth.num_of_words);
-      printf ("Longest doc in collection [dict]   : %10lu characters\n",
+      printf ("Documents                          : %10d\n", cth.num_of_docs);
+      printf ("Words in collection [dict]         : %10d\n", cth.num_of_words);
+      printf ("Longest doc in collection [dict]   : %10d characters\n",
 	      cth.length_of_longest_doc);
       printf ("Maximum ratio                      : %10.2f\n", cth.ratio);
@@ -269,8 +269,8 @@
   if (have_cdh)
     {
-      printf ("Words in dict                      : %10lu\n", cdh.num_words[1]);
-      printf ("Non-words in dict                  : %10lu\n", cdh.num_words[0]);
-      printf ("Total chars of distinct words      : %10lu\n", cdh.num_word_chars[1]);
-      printf ("Total chars of distinct non-words  : %10lu\n", cdh.num_word_chars[0]);
+      printf ("Words in dict                      : %10d\n", cdh.num_words[1]);
+      printf ("Non-words in dict                  : %10d\n", cdh.num_words[0]);
+      printf ("Total chars of distinct words      : %10d\n", cdh.num_word_chars[1]);
+      printf ("Total chars of distinct non-words  : %10d\n", cdh.num_word_chars[0]);
     }
 
@@ -294,8 +294,8 @@
     return;
   fread ((char *) &idh, sizeof (idh), 1, f);
-  printf ("Words in collection [stem]         : %10ld\n", NTOHUL(idh.num_of_words));  /* [RPAP - Jan 97: Endian Ordering] */
-  printf ("Words in stem                      : %10ld\n", NTOHUL(idh.dict_size));  /* [RPAP - Jan 97: Endian Ordering] */
-  printf ("Indexed fragments                  : %10ld\n", NTOHUL(idh.num_of_docs));  /* [RPAP - Jan 97: Endian Ordering] */
-  printf ("Total chars of stem words          : %10ld\n", NTOHUL(idh.total_bytes));  /* [RPAP - Jan 97: Endian Ordering] */
+  printf ("Words in collection [stem]         : %10d\n", NTOHUL(idh.num_of_words));  /* [RPAP - Jan 97: Endian Ordering] */
+  printf ("Words in stem                      : %10d\n", NTOHUL(idh.dict_size));  /* [RPAP - Jan 97: Endian Ordering] */
+  printf ("Indexed fragments                  : %10d\n", NTOHUL(idh.num_of_docs));  /* [RPAP - Jan 97: Endian Ordering] */
+  printf ("Total chars of stem words          : %10d\n", NTOHUL(idh.total_bytes));  /* [RPAP - Jan 97: Endian Ordering] */
   fclose (f);
 }
@@ -306,5 +306,5 @@
 
 /* [RPAP - Jan 97: Stem Index Change] */
-long 
+mg_s_long 
 ProcessStemBlk (char *name)
 {
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/mgstemidxlist.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/mgstemidxlist.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/mgstemidxlist.c	(revision 25147)
@@ -36,5 +36,5 @@
 read_3_in_4 (FILE * idbi)
 {
-  unsigned long i;
+  mg_u_long i;
   stemmed_idx *si;
   u_char *buffer;
@@ -106,18 +106,18 @@
     }
 
-  printf ("# lookback     = %lu\n", si->sih.lookback);
-  printf ("# block_size   = %lu\n", si->sih.block_size);
-  printf ("# num_blocks   = %lu\n", si->sih.num_blocks);
-  printf ("# blocks_start = %lu\n", si->sih.blocks_start);
-  printf ("# index_chars  = %lu\n", si->sih.index_chars);
-  printf ("# num_of_words = %lu\n", si->sih.num_of_words);
+  printf ("# lookback     = %u\n", si->sih.lookback);
+  printf ("# block_size   = %u\n", si->sih.block_size);
+  printf ("# num_blocks   = %u\n", si->sih.num_blocks);
+  printf ("# blocks_start = %u\n", si->sih.blocks_start);
+  printf ("# index_chars  = %u\n", si->sih.index_chars);
+  printf ("# num_of_words = %u\n", si->sih.num_of_words);
 
   block = 0;
   while (block < si->sih.num_blocks)
     {
-      unsigned long *first_word;
+      mg_u_long *first_word;
       unsigned short *num_words;
       unsigned short *index;
-      long res;
+      mg_s_long res;
       u_char *base;
       int num_indexes;
@@ -128,5 +128,5 @@
       si->active = si->pos[block];
 
-      first_word = (unsigned long *) (si->buffer);
+      first_word = (mg_u_long *) (si->buffer);
       NTOHUL(*first_word);  /* [RPAP - Jan 97: Endian Ordering] */
       num_words = (unsigned short *) (first_word + 1);
@@ -143,5 +143,5 @@
 
       printf ("\n# block      = %d\n", block);
-      printf ("# first_word = %lu\n", *first_word);
+      printf ("# first_word = %u\n", *first_word);
       printf ("# num_words  = %u\n", *num_words);
 
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/query.docnums.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/query.docnums.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/query.docnums.c	(revision 25147)
@@ -64,5 +64,5 @@
 {
   DocList *Docs = MakeDocList (0);
-  unsigned long start = 0, finish;
+  mg_u_long start = 0, finish;
   int range = 0; /* is there a range or not ? */
 
@@ -75,5 +75,5 @@
 	  finish <= qd->sd->sdh.num_of_docs)
 	{
-	  unsigned long i;
+	  mg_u_long i;
 	  if (!range)
 	    start = finish;
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/query.ranked.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/query.ranked.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/query.ranked.c	(revision 25147)
@@ -89,6 +89,6 @@
     float *OrgWeight;
     int DocNum;
-    u_long SeekPos;		/* position in the text file in bytes */
-    u_long Len;			/* length of the document in bytes */
+    mg_u_long SeekPos;		/* position in the text file in bytes */
+    mg_u_long Len;			/* length of the document in bytes */
   }
 HeapEntry;
@@ -290,6 +290,6 @@
     {
       int j;
-      long num_entries, word_num;
-      unsigned long count, doc_count, invf_ptr, invf_len;
+      mg_s_long num_entries, word_num;
+      mg_u_long count, doc_count, invf_ptr, invf_len;
       int weight_to_apply, stem_to_apply;
       int method_using = -1;
@@ -408,5 +408,5 @@
 	    {
 	      int i;
-	      u_long max_doc_count = 0;
+	      mg_u_long max_doc_count = 0;
 
 	      /* get the maximum doc count */
@@ -748,5 +748,5 @@
 	    for (i = 0; i < ST->no_of_items; i++, ide = SP_get_next (ST))
 	      {
-		u_long SeekPos, Len;
+		mg_u_long SeekPos, Len;
 		float Weight;
 		if (!ide->Sum)
@@ -777,5 +777,5 @@
 	    for (i = 0; i < qd->sd->sdh.num_of_docs; i++, fptr++)
 	      {
-		u_long SeekPos, Len;
+		mg_u_long SeekPos, Len;
 		float Weight;
 		if (!*fptr)
@@ -803,5 +803,5 @@
 	    for (ideh = HT->Head; ideh; ideh = ideh->next)
 	      {
-		u_long SeekPos, Len;
+		mg_u_long SeekPos, Len;
 		float Weight;
 		if (!ideh->IDE.Sum)
@@ -829,5 +829,5 @@
 	    for (i = 0; i < LT->num; i++, ide++)
 	      {
-		u_long SeekPos, Len;
+		mg_u_long SeekPos, Len;
 		float Weight;
 		if (!ide->Sum)
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/stem_search.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/stem_search.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/stem_search.c	(revision 25147)
@@ -83,5 +83,5 @@
 ReadStemDictBlk (File * stem_file)
 {
-  unsigned long i;
+  mg_u_long i;
   stemmed_dict *sd;
   u_char *buffer;
@@ -173,5 +173,5 @@
 ReadStemIdxBlk (File * stem_idx_file)
 {
-  unsigned long i;
+  mg_u_long i;
   stemmed_idx *si;
   u_char *buffer;
@@ -300,20 +300,20 @@
  * This function looks up a word in the stemmed dictionary, it returns -1
  * if the word cound not be found, and 0 if it successfully finds the word.
- * If count is non-null the ulong it is pointing to is set to the number of 
+ * If count is non-null the unsigned it is pointing to is set to the number of 
  * occurances of the stemmed word in the collection. i.e wcnt.
- * If doc_count is non-null the ulong it is pointing to is set to the number
+ * If doc_count is non-null the unsigned it is pointing to is set to the number
  * of documents that the word occurs in. i.e fcnt
- * If invf_ptr is non-null the ulong it is pointing to is set to the position
+ * If invf_ptr is non-null the unsigned it is pointing to is set to the position
  * of the inverted file where the entry for this word start.
  */
 int 
-FindWord (stemmed_dict * sd, u_char * Word, unsigned long *count,
-	  unsigned long *doc_count, unsigned long *invf_ptr,
-	  unsigned long *invf_len)
+FindWord (stemmed_dict * sd, u_char * Word, mg_u_long *count,
+	  mg_u_long *doc_count, mg_u_long *invf_ptr,
+	  mg_u_long *invf_len)
 {
   register int lo, hi, mid, c;
   register unsigned int res;
   int block, num_indexes;
-  unsigned long *first_word, *last_invf_len;
+  mg_u_long *first_word, *last_invf_len;
   unsigned short *num_words;
   u_char *base;
@@ -332,7 +332,7 @@
 
       /* [RPAP - Jan 97: Endian Ordering] */
-      first_word = (unsigned long *) (sd->buffer);
+      first_word = (mg_u_long *) (sd->buffer);
       NTOHUL(*first_word);
-      last_invf_len = (unsigned long *) (first_word + 1);
+      last_invf_len = (mg_u_long *) (first_word + 1);
       NTOHUL(*last_invf_len);
       num_words = (unsigned short *) (last_invf_len + 1);
@@ -346,6 +346,6 @@
   else
     {
-      first_word = (unsigned long *) (sd->buffer);
-      last_invf_len = (unsigned long *) (first_word + 1);
+      first_word = (mg_u_long *) (sd->buffer);
+      last_invf_len = (mg_u_long *) (first_word + 1);
       num_words = (unsigned short *) (last_invf_len + 1);
       index = num_words + 1;
@@ -379,5 +379,5 @@
     {
       unsigned copy, suff;
-      unsigned long invfp;
+      mg_u_long invfp;
       if (res >= *num_words)
 	return (-1);
@@ -417,5 +417,5 @@
 	{
 	  /* Calculate invf_len is necessary */
-	  unsigned long next_invfp;
+	  mg_u_long next_invfp;
 	  if (!invf_len)
 	    return (*first_word + res);
@@ -432,5 +432,5 @@
 	  base++;
 	  suff = *base++;
-	  base += suff + sizeof (unsigned long) * 2;
+	  base += suff + sizeof (mg_u_long) * 2;
 	  bcopy ((char *) base, (char *) &next_invfp, sizeof (next_invfp));
 	  NTOHUL(next_invfp);  /* [RPAP - Jan 97: Endian Ordering] */
@@ -453,5 +453,5 @@
 
   int block, num_indexes;
-  unsigned long *first_word, *last_invf_len;
+  mg_u_long *first_word, *last_invf_len;
   unsigned short *num_words;
   u_char *base;
@@ -460,5 +460,5 @@
 
   int idx_block, idx_num_indexes;
-  unsigned long *idx_first_word;
+  mg_u_long *idx_first_word;
   unsigned short *idx_num_words;
   u_char *idx_base;
@@ -512,5 +512,5 @@
       si->active = si->pos[idx_block];
 
-      idx_first_word = (unsigned long *) (si->buffer);
+      idx_first_word = (mg_u_long *) (si->buffer);
       NTOHUL(*idx_first_word);  /* [RPAP - Jan 97: Endian Ordering] */
       idx_num_words = (unsigned short *) (idx_first_word + 1);
@@ -525,5 +525,5 @@
   else
     {
-      idx_first_word = (unsigned long *) (si->buffer);
+      idx_first_word = (mg_u_long *) (si->buffer);
       idx_num_words = (unsigned short *) (idx_first_word + 1);
       idx_index = idx_num_words + 1;
@@ -591,5 +591,5 @@
     {
       unsigned copy, suff;
-      unsigned long invfp;
+      mg_u_long invfp;
       /* Read next stem index pos */
       bcopy ((char *) idx_base, (char *) &num_cases, sizeof (num_cases));
@@ -613,7 +613,7 @@
 	  sd->active = sd->pos[block];
 
-	  first_word = (unsigned long *) (sd->buffer);
+	  first_word = (mg_u_long *) (sd->buffer);
 	  NTOHUL(*first_word);  /* [RPAP - Jan 97: Endian Ordering] */
-	  last_invf_len = (unsigned long *) (first_word + 1);
+	  last_invf_len = (mg_u_long *) (first_word + 1);
 	  NTOHUL(*last_invf_len);  /* [RPAP - Jan 97: Endian Ordering] */
 	  num_words = (unsigned short *) (last_invf_len + 1);
@@ -628,6 +628,6 @@
       else
 	{
-	  first_word = (unsigned long *) (sd->buffer);
-	  last_invf_len = (unsigned long *) (first_word + 1);
+	  first_word = (mg_u_long *) (sd->buffer);
+	  last_invf_len = (mg_u_long *) (first_word + 1);
 	  num_words = (unsigned short *) (last_invf_len + 1);
 	  index = num_words + 1;
@@ -646,7 +646,7 @@
 	  base += suff;
 	  *prev = copy + suff;
-	  base += sizeof (unsigned long);   /* skip doc_count */
-	  base += sizeof (unsigned long);   /* skip count */
-	  base += sizeof (unsigned long);   /* skip invf_ptr */
+	  base += sizeof (mg_u_long);   /* skip doc_count */
+	  base += sizeof (mg_u_long);   /* skip count */
+	  base += sizeof (mg_u_long);   /* skip invf_ptr */
 	  res++;
 	}
@@ -694,5 +694,5 @@
 	  else
 	    {
-	      unsigned long next_invfp;
+	      mg_u_long next_invfp;
 	      u_char *oldbase = base;
 		  
@@ -700,5 +700,5 @@
 	      base++;
 	      suff = *base++;
-	      base += suff + sizeof (unsigned long) * 2;
+	      base += suff + sizeof (mg_u_long) * 2;
 	      bcopy ((char *) base, (char *) &next_invfp, sizeof (next_invfp));
 	      NTOHUL(next_invfp);  /* [RPAP - Jan 97: Endian Ordering] */
@@ -720,7 +720,7 @@
 	      sd->active = sd->pos[block];
 
-	      first_word = (unsigned long *) (sd->buffer);
+	      first_word = (mg_u_long *) (sd->buffer);
 	      NTOHUL(*first_word);  /* [RPAP - Jan 97: Endian Ordering] */
-	      last_invf_len = (unsigned long *) (first_word + 1);
+	      last_invf_len = (mg_u_long *) (first_word + 1);
 	      NTOHUL(*last_invf_len);  /* [RPAP - Jan 97: Endian Ordering] */
 	      num_words = (unsigned short *) (last_invf_len + 1);
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/stem_search.h
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/stem_search.h	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/stem_search.h	(revision 25147)
@@ -29,7 +29,7 @@
 stemmed_idx *ReadStemIdxBlk (File * stem_idx_file);
 
-int FindWord (stemmed_dict * sd, u_char * Word, unsigned long *count,
-	      unsigned long *doc_count, unsigned long *invf_ptr,
-	      unsigned long *invf_len);
+int FindWord (stemmed_dict * sd, u_char * Word, mg_u_long *count,
+	      mg_u_long *doc_count, mg_u_long *invf_ptr,
+	      mg_u_long *invf_len);
 
 /* [RPAP - Jan 97: Stem Index Change] */
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/term_lists.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/term_lists.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/term_lists.c	(revision 25147)
@@ -200,5 +200,5 @@
 int
 AddTerm (TermList ** query_term_list, u_char * Word, int Count, int word_num,
-	 u_long count, u_long doc_count, u_long invf_ptr, u_long invf_len, int stemmer_num)  /* [RPAP - Feb 97: Term Frequency] */
+	 mg_u_long count, mg_u_long doc_count, mg_u_long invf_ptr, mg_u_long invf_len, int stemmer_num)  /* [RPAP - Feb 97: Term Frequency] */
 {
   int j;
@@ -283,9 +283,9 @@
 {
   fprintf (file, "we->word_num = %d\n", we->word_num);
-  fprintf (file, "we->count = %ld\n", we->count);
-  fprintf (file, "we->doc_count = %ld\n", we->doc_count);
-  fprintf (file, "we->max_doc_count = %ld\n", we->max_doc_count);
-  fprintf (file, "we->invf_ptr = %ld\n", we->invf_ptr);
-  fprintf (file, "we->invf_len = %ld\n", we->invf_len);
+  fprintf (file, "we->count = %d\n", we->count);
+  fprintf (file, "we->doc_count = %d\n", we->doc_count);
+  fprintf (file, "we->max_doc_count = %d\n", we->max_doc_count);
+  fprintf (file, "we->invf_ptr = %d\n", we->invf_ptr);
+  fprintf (file, "we->invf_len = %d\n", we->invf_len);
 }
 
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/term_lists.h
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/term_lists.h	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/term_lists.h	(revision 25147)
@@ -59,10 +59,10 @@
   {
     int word_num;		/* Unique number for each different word */
-    u_long count;		/* Number of times the word occurs in the text */
-    u_long doc_count;		/* Number of documents that contain the word */
-    u_long max_doc_count;       /* [RPAP - Jan 97: Stem Index Change] */
-    u_long invf_ptr;		/* This is a byte position of the  
+    mg_u_long count;		/* Number of times the word occurs in the text */
+    mg_u_long doc_count;		/* Number of documents that contain the word */
+    mg_u_long max_doc_count;       /* [RPAP - Jan 97: Stem Index Change] */
+    mg_u_long invf_ptr;		/* This is a byte position of the  
 				   inverted file entry corresponding to the word */
-    u_long invf_len;		/* This is the length of the inverted 
+    mg_u_long invf_len;		/* This is the length of the inverted 
 				   file entry in bytes */
   }
@@ -93,5 +93,5 @@
 int AddTermEntry (TermList ** query_term_list, TermEntry * te);
 int AddTerm (TermList ** query_term_list, u_char * Word, int Count, int word_num,
-	     u_long count, u_long doc_count, u_long invf_ptr, u_long invf_len, /* [RPAP - Feb 97: Term Frequency] */
+	     mg_u_long count, mg_u_long doc_count, mg_u_long invf_ptr, mg_u_long invf_len, /* [RPAP - Feb 97: Term Frequency] */
 	     int stemmer_num);  
 void ResetTermList (TermList ** tl);
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/text.h
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/text.h	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/text.h	(revision 25147)
@@ -117,10 +117,10 @@
 typedef struct compression_dict_header
   {
-    u_long dict_type;
-    u_long novel_method;
-    u_long params[TEXT_PARAMS];
-    u_long num_words[2];
-    u_long num_word_chars[2];
-    u_long lookback;
+    mg_u_long dict_type;
+    mg_u_long novel_method;
+    mg_u_long params[TEXT_PARAMS];
+    mg_u_long num_words[2];
+    mg_u_long num_word_chars[2];
+    mg_u_long lookback;
   }
 compression_dict_header;
@@ -130,6 +130,6 @@
   {
     huff_data hd;
-    u_long uncompressed_size;
-    u_long huff_words_size[MAX_HUFFCODE_LEN + 1];
+    mg_u_long uncompressed_size;
+    mg_u_long huff_words_size[MAX_HUFFCODE_LEN + 1];
   }
 comp_frags_header;
@@ -139,10 +139,10 @@
 typedef struct compressed_text_header
   {
-    u_long num_of_docs;
-    u_long num_of_words;	/* number of words in collection */
+    mg_u_long num_of_docs;
+    mg_u_long num_of_words;	/* number of words in collection */
     double num_of_bytes; /* [RJM 07/97: 4G limit] */
     double ratio;
-    u_long length_of_longest_doc;	/* (characters) */
-    u_long dummy;    /* added to make the structure the same on different architectures */
+    mg_u_long length_of_longest_doc;	/* (characters) */
+    mg_u_long dummy;    /* added to make the structure the same on different architectures */
   }
 compressed_text_header;
@@ -151,6 +151,6 @@
 typedef struct compression_stats_header
   {
-    u_long num_docs;
-    u_long dummy;   /* added to make the structure the same on different architectures */
+    mg_u_long num_docs;
+    mg_u_long dummy;   /* added to make the structure the same on different architectures */
     double num_bytes; /* [RJM 07/97: 4G limit] */
   }
@@ -160,6 +160,6 @@
 typedef struct frags_stats_header
   {
-    u_long num_frags;
-    u_long mem_for_frags;
+    mg_u_long num_frags;
+    mg_u_long mem_for_frags;
   }
 frags_stats_header;
@@ -168,6 +168,6 @@
 typedef struct aux_frags_header
   {
-    u_long num_frags;
-    u_long mem_for_frags;
+    mg_u_long num_frags;
+    mg_u_long mem_for_frags;
   }
 aux_frags_header;
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/text.pass1.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/text.pass1.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/text.pass1.c	(revision 25147)
@@ -50,6 +50,6 @@
 typedef struct hash_rec
   {
-    unsigned long wcnt;		/* word frequency */
-    unsigned long occurance_num;
+    mg_u_long wcnt;		/* word frequency */
+    mg_u_long occurance_num;
     u_char *word;
   }
@@ -59,9 +59,9 @@
   {
     hash_rec *HashTable;
-    unsigned long HashSize;
-    unsigned long HashUsed;
-    unsigned long wordnum;
-    unsigned long words_read;
-    unsigned long bytes_diff;
+    mg_u_long HashSize;
+    mg_u_long HashUsed;
+    mg_u_long wordnum;
+    mg_u_long words_read;
+    mg_u_long bytes_diff;
     huff_data hd;
   }
@@ -70,6 +70,6 @@
 
 
-static unsigned long LongestDoc = 0;
-static unsigned long occurance_num = 0;
+static mg_u_long LongestDoc = 0;
+static mg_u_long occurance_num = 0;
 static dict_data DictData[2];
 
@@ -77,6 +77,6 @@
 static int PoolLeft;
 static double inputbytes = 0; /* [RJM 07/97: 4G limit] */
-static unsigned long MaxMemInUse = 0;
-static unsigned long MemInUse = 0;
+static mg_u_long MaxMemInUse = 0;
+static mg_u_long MemInUse = 0;
 static compression_stats_header csh =
 {0, 0.0}; /* [RJM 07/97: 4G limit] */
@@ -131,5 +131,5 @@
 	register u_char *wptr;
 	register int hsize = dd->HashSize;
-	register unsigned long hashval, step;
+	register mg_u_long hashval, step;
 
 	HASH (hashval, step, word, hsize);
@@ -189,5 +189,5 @@
       /* Search the hash table for Word */
       {
-	register unsigned long hashval, step;
+	register mg_u_long hashval, step;
 	register int hsize = dd->HashSize;
 	HASH (hashval, step, Word, hsize);
@@ -248,6 +248,6 @@
 	{
 	  hash_rec *ht;
-	  unsigned long size;
-	  unsigned long i;
+	  mg_u_long size;
+	  mg_u_long i;
 	  size = prime (dd->HashSize * 2);
 	  if (!(ht = Xmalloc (sizeof (hash_rec) * size)))
@@ -263,5 +263,5 @@
 	      {
 		register u_char *wptr;
-		register unsigned long hashval, step;
+		register mg_u_long hashval, step;
 
 		wptr = dd->HashTable[i].word;
@@ -325,5 +325,5 @@
 {
   frags_stats_header fsh;
-  u_long j = 0;
+  mg_u_long j = 0;
   u_char *curr;
 
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/text.pass2.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/text.pass2.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/text.pass2.c	(revision 25147)
@@ -82,5 +82,5 @@
   {
     struct char_pool *next;
-    u_long left;
+    mg_u_long left;
     u_char *ptr;
     u_char pool[POOL_SIZE];
@@ -90,5 +90,5 @@
 typedef struct novel_hash_rec
   {
-    u_long ordinal_num;
+    mg_u_long ordinal_num;
     u_char *word;
   }
@@ -102,8 +102,8 @@
   {
     novel_hash_rec *HashTable;
-    u_long HashSize, HashUsed;
+    mg_u_long HashSize, HashUsed;
     char_pool *first_pool;
     char_pool *pool;
-    u_long next_num, binary_start;
+    mg_u_long next_num, binary_start;
     novel_hash_rec **code_to_nhr;
   }
@@ -115,5 +115,5 @@
 static u_char *comp_buffer;
 
-static u_long text_length;
+static mg_u_long text_length;
 
 /* [RJM 07/97: 4G limit] */
@@ -125,5 +125,5 @@
 static novel_hash_table nht[2];
 
-static u_long prefix_len = 0;
+static mg_u_long prefix_len = 0;
 
 int blk_start[2][33], blk_end[2][33];
@@ -165,5 +165,5 @@
     return COMPERROR;
 
-  text_length = sizeof (u_long) + sizeof (cth);
+  text_length = sizeof (mg_u_long) + sizeof (cth);
 
   if (!(text_idx = create_file (file_name, TEXT_IDX_SUFFIX, "w+b",
@@ -287,5 +287,5 @@
       if (ht[which])
 	{
-	  register unsigned long hashval, step;
+	  register mg_u_long hashval, step;
 	  register int tsize = ht[which]->size;
 	  register u_char **wptr;
@@ -336,5 +336,5 @@
 	  if (cdh.dict_type == MG_PARTIAL_DICTIONARY)
 	    {
-	      u_long i;
+	      mg_u_long i;
 	      if (ht[which])
 		{
@@ -358,5 +358,5 @@
 		case MG_NOVEL_HUFFMAN_CHARS:
 		  {
-		    u_long i;
+		    mg_u_long i;
 		    HUFF_ENCODE (Word[0], lens_codes[which],
 				 lens_huff[which].clens);
@@ -371,5 +371,5 @@
 		case MG_NOVEL_HYBRID_MTF:
 		  {
-		    register unsigned long hashval, step;
+		    register mg_u_long hashval, step;
 		    register novel_hash_table *h = &nht[which];
 		    register int hsize = h->HashSize;
@@ -481,6 +481,6 @@
 		      {
 			novel_hash_rec *ht;
-			unsigned long size;
-			unsigned long i;
+			mg_u_long size;
+			mg_u_long i;
 			size = prime (h->HashSize * 2);
 			if (cdh.novel_method == MG_NOVEL_HYBRID_MTF)
@@ -501,5 +501,5 @@
 			    {
 			      register u_char *wptr;
-			      register unsigned long hashval, step;
+			      register mg_u_long hashval, step;
 
 			      wptr = h->HashTable[i].word;
@@ -674,10 +674,10 @@
 {
   int i;
-  u_long aux_compressed = 0, total_uncomp = 0;
+  mg_u_long aux_compressed = 0, total_uncomp = 0;
   for (i = 0; i <= 1; i++)
     {
       int j;
-      long chars[256], fchars[256];
-      long lens[16], flens[16];
+      mg_s_long chars[256], fchars[256];
+      mg_s_long lens[16], flens[16];
       char_pool *cp;
       bzero ((char *) chars, sizeof (chars));
@@ -743,10 +743,10 @@
   HTOND(cth.ratio);
 
-  if (fseek (text_idx, sizeof (u_long), SEEK_SET) == -1 ||
+  if (fseek (text_idx, sizeof (mg_u_long), SEEK_SET) == -1 ||
       fwrite (&cth, sizeof (cth), 1, text_idx) != 1)
     return COMPERROR;
   fclose (text_idx);
 
-  if (fseek (text, sizeof (u_long), SEEK_SET) == -1 ||
+  if (fseek (text, sizeof (mg_u_long), SEEK_SET) == -1 ||
       fwrite (&cth, sizeof (cth), 1, text) != 1)
     return COMPERROR;
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/text_get.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/text_get.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/text_get.c	(revision 25147)
@@ -84,12 +84,12 @@
 
 static double 
-FetchDocStartLev1 (text_data * td, u_long DN,
-		   u_long * seek_pos, u_long * len)
-{
-  unsigned long data[2];
+FetchDocStartLev1 (text_data * td, mg_u_long DN,
+		   mg_u_long * seek_pos, mg_u_long * len)
+{
+  mg_u_long data[2];
   /* [TS:Sep/94] Fixed up the seek call to give the correct offset */
   Fseek (td->TextIdxFile,
-	 sizeof (unsigned long) * (DN - 1) +	/* the doc offsets */
-	 sizeof (unsigned long) +	/* the magic number */
+	 sizeof (mg_u_long) * (DN - 1) +	/* the doc offsets */
+	 sizeof (mg_u_long) +	/* the magic number */
 	 sizeof (compressed_text_header),	/* the header */
 	 0);
@@ -108,5 +108,5 @@
 
 static int 
-LoadIdx (text_data * td, unsigned long DN)
+LoadIdx (text_data * td, mg_u_long DN)
 {
   if (!td->idx_data)
@@ -121,9 +121,9 @@
       int i, num;  /* [RPAP - Jan 97: Endian Ordering] */
 
-      long rn = (long) DN - (MG_PAGE_SIZE >> 1);
+      mg_s_long rn = (mg_s_long) DN - (MG_PAGE_SIZE >> 1);
       if (rn < 1)
 	rn = 1;
-      Fseek (td->TextIdxWgtFile, (sizeof (unsigned long) + sizeof (float)) *
-	       (rn - 1) + sizeof (unsigned long), 0);
+      Fseek (td->TextIdxWgtFile, (sizeof (mg_u_long) + sizeof (float)) *
+	       (rn - 1) + sizeof (mg_u_long), 0);
       num = Fread ((char *) td->idx_data, sizeof (*(td->idx_data)), MG_PAGE_SIZE, /* [RPAP - Jan 97: Endian Ordering] */
 		   td->TextIdxWgtFile);
@@ -142,7 +142,7 @@
 
 static double 
-FDSL2 (text_data * td, unsigned long DN, unsigned long *Pos)
-{
-  unsigned long pos = LoadIdx (td, DN);
+FDSL2 (text_data * td, mg_u_long DN, mg_u_long *Pos)
+{
+  mg_u_long pos = LoadIdx (td, DN);
   *Pos = td->idx_data[pos].Start;
   return (td->idx_data[pos].Weight);
@@ -151,9 +151,9 @@
 
 static double 
-FetchDocStartLev2 (text_data * td, u_long DN,
-		   u_long * seek_pos, u_long * len)
+FetchDocStartLev2 (text_data * td, mg_u_long DN,
+		   mg_u_long * seek_pos, mg_u_long * len)
 {
   double Weight;
-  unsigned long s1, s2;
+  mg_u_long s1, s2;
   Weight = FDSL2 (td, DN, &s1);
   do
@@ -172,5 +172,5 @@
 
 double 
-FetchDocStart (query_data * qd, u_long DN, u_long * seek_pos, u_long * len)
+FetchDocStart (query_data * qd, mg_u_long DN, mg_u_long * seek_pos, mg_u_long * len)
 {
   qd->text_idx_lookups++;
@@ -181,11 +181,11 @@
 }
 
-unsigned long 
-FetchInitialParagraph (text_data * td, unsigned long ParaNum)
+mg_u_long 
+FetchInitialParagraph (text_data * td, mg_u_long ParaNum)
 {
   if (td->TextIdxWgtFile)
     {
-      unsigned long pos;
-      unsigned long start;
+      mg_u_long pos;
+      mg_u_long start;
       int PN = ParaNum - 1;
       pos = LoadIdx (td, ParaNum);
@@ -583,5 +583,5 @@
 	{
 	  huff_data *hd;
-	  u_long **vals;
+	  mg_u_long **vals;
 	  if (cd->cdh.num_words[which])
 	    {
@@ -625,5 +625,5 @@
 	{
 	  huff_data *hd;
-	  u_long **vals;
+	  mg_u_long **vals;
 	  if (cd->cdh.num_words[which])
 	    {
@@ -716,8 +716,8 @@
 {
   compression_dict *cd;
-  u_long *p, *end;
+  uintptr_t *p, *end;
   u_char *fixup;
-  u_long mem;
-  u_long fixup_mem;
+  mg_u_long mem;
+  mg_u_long fixup_mem;
   int i;  /* [RPAP - Jan 97: Endian Ordering] */
 
@@ -732,5 +732,5 @@
     }
 
-  end = (u_long *) (((u_char *) cd) + mem);
+  end = (uintptr_t *) (((u_char *) cd) + mem);
   Fread (cd, sizeof (u_char), mem, text_fast_comp_dict);
 
@@ -743,9 +743,9 @@
   Fread (fixup, fixup_mem, sizeof (u_char), text_fast_comp_dict);
 
-  for (p = (u_long *) cd; (u_long) p < (u_long) end; p++)
+  for (p = (uintptr_t *) cd; (uintptr_t) p < (uintptr_t) end; p++)
     if (IS_FIXUP (p))
       {
 	NTOHUL(*p);  /* [RPAP - Jan 97: Endian Ordering] */
-	*p = *p + (u_long) cd;
+	*p = *p + (uintptr_t) cd;
       }
 
@@ -863,7 +863,7 @@
 #define MY_HUFF_DECODE(len, code, mcodes)				\
   do {									\
-    register unsigned long *__min_code = (mcodes);			\
-    register unsigned long *__mclen = __min_code;			\
-    register unsigned long __code = 0;					\
+    register mg_u_long *__min_code = (mcodes);			\
+    register mg_u_long *__mclen = __min_code;			\
+    register mg_u_long __code = 0;					\
     do									\
       {									\
@@ -886,8 +886,8 @@
   auxiliary_dict *ad = cd->ad;
   int which;
-  u_long num_bits, bits;
+  mg_u_long num_bits, bits;
   u_char *ptr = s_out;
   static int num = 0;
-  u_long binary_start[2];
+  mg_u_long binary_start[2];
   int novels_used[2];
   int swaps[2][MAX_SWAPS];
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/text_get.h
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/text_get.h	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/text_get.h	(revision 25147)
@@ -32,7 +32,7 @@
  * It returns the true weight of the document.
  */
-double FetchDocStart (query_data * qd, u_long DN, u_long * seek_pos, u_long * len);
+double FetchDocStart (query_data * qd, mg_u_long DN, mg_u_long * seek_pos, mg_u_long * len);
 
-unsigned long FetchInitialParagraph (text_data * td, unsigned long ParaNum);
+mg_u_long FetchInitialParagraph (text_data * td, mg_u_long ParaNum);
 
 
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/weights.c
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/weights.c	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/weights.c	(revision 25147)
@@ -39,5 +39,5 @@
 #include "mg_errors.h"
 
-#define MAXBITS (sizeof(unsigned long) * 8)
+#define MAXBITS (sizeof(mg_u_long) * 8)
 
 /*
@@ -63,5 +63,5 @@
 approx_weights_data *
 LoadDocWeights (File * weight_file,
-		unsigned long num_of_docs)
+		mg_u_long num_of_docs)
 {
   approx_weights_data *awd;
@@ -74,5 +74,5 @@
     }
 
-  Fseek (weight_file, sizeof (long), 0);
+  Fseek (weight_file, sizeof (mg_s_long), 0);
   Fread (&awd->bits, sizeof (awd->bits), 1, weight_file);
   Fread (&awd->L, sizeof (awd->L), 1, weight_file);
@@ -84,5 +84,5 @@
 
   num = (num_of_docs * awd->bits + 31) / 32;
-  if (!(awd->DocWeights = Xmalloc (sizeof (unsigned long) * num)))
+  if (!(awd->DocWeights = Xmalloc (sizeof (mg_u_long) * num)))
     {
       Xfree (awd);
@@ -91,13 +91,13 @@
     }
 
-  Fread (awd->DocWeights, sizeof (unsigned long), num, weight_file);
+  Fread (awd->DocWeights, sizeof (mg_u_long), num, weight_file);
   {
     /* [RPAP - Jan 97: Endian Ordering] */
-    unsigned long i;
+    mg_u_long i;
     for (i = 0; i < num; i++)
       NTOHUL(awd->DocWeights[i]);
   }
 
-  awd->MemForWeights = num * sizeof (unsigned long);
+  awd->MemForWeights = num * sizeof (mg_u_long);
   awd->num_of_docs = num_of_docs;
 
@@ -129,6 +129,6 @@
 GetLowerApproxDocWeight (approx_weights_data * awd, register int DocNum)
 {
-  register unsigned long c, Pos;
-  register unsigned long *dw;
+  register mg_u_long c, Pos;
+  register mg_u_long *dw;
   if (awd == NULL)
     return 1.0;
Index: main/trunk/greenstone2/common-src/indexers/mg/src/text/weights.h
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/src/text/weights.h	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/src/text/weights.h	(revision 25147)
@@ -26,5 +26,5 @@
 
 approx_weights_data *LoadDocWeights (File * weight_file,
-				     unsigned long num_of_docs);
+				     mg_u_long num_of_docs);
 
 float GetLowerApproxDocWeight (approx_weights_data * awd, register int DocNum);
Index: main/trunk/greenstone2/common-src/indexers/mg/sysfuncs.h
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mg/sysfuncs.h	(revision 23431)
+++ main/trunk/greenstone2/common-src/indexers/mg/sysfuncs.h	(revision 25147)
@@ -351,12 +351,9 @@
 #endif
 
-/* [RPAP - Feb 97: WIN32 Port] */
-#ifndef u_long
-# define u_long unsigned long
-#endif
+#include "mglong.h"
+
 #ifndef u_char
 # define u_char unsigned char
 #endif
 
-
 #endif /* SYSFUNCS_H */
