[Tux4kids-commits] r405 - in tuxmath/trunk: data/images/sprites doc nsis src

dbruce-guest at alioth.debian.org dbruce-guest at alioth.debian.org
Wed Jan 2 18:11:09 UTC 2008


Author: dbruce-guest
Date: 2008-01-02 18:11:08 +0000 (Wed, 02 Jan 2008)
New Revision: 405

Modified:
   tuxmath/trunk/data/images/sprites/Makefile
   tuxmath/trunk/doc/changelog
   tuxmath/trunk/nsis/tuxmath.nsi
   tuxmath/trunk/nsis/tuxmath_with_conf.nsi
   tuxmath/trunk/src/mathcards.c
   tuxmath/trunk/src/scandir.h
Log:
Further refinement of randomize_list() in mathcards.c; updated changelog to reflect author of new scandir.c; 


Modified: tuxmath/trunk/data/images/sprites/Makefile
===================================================================
--- tuxmath/trunk/data/images/sprites/Makefile	2008-01-02 13:36:54 UTC (rev 404)
+++ tuxmath/trunk/data/images/sprites/Makefile	2008-01-02 18:11:08 UTC (rev 405)
@@ -30,9 +30,9 @@
 NORMAL_UNINSTALL = :
 PRE_UNINSTALL = :
 POST_UNINSTALL = :
-build_triplet = i386-pc-linux-gnu
-host_triplet = i586-pc-mingw32
-target_triplet = i586-pc-mingw32
+build_triplet = i686-pc-linux-gnu
+host_triplet = i686-pc-linux-gnu
+target_triplet = i686-pc-linux-gnu
 subdir = data/images/sprites
 DIST_COMMON = $(dist_sprites_DATA) $(srcdir)/Makefile.am \
 	$(srcdir)/Makefile.in
@@ -78,14 +78,14 @@
 AUTOHEADER = ${SHELL} /home/dbruce/tux4kids/tuxmath/trunk/missing --run autoheader
 AUTOMAKE = ${SHELL} /home/dbruce/tux4kids/tuxmath/trunk/missing --run automake-1.10
 AWK = mawk
-BUILD_INCLUDED_LIBINTL = yes
+BUILD_INCLUDED_LIBINTL = no
 CATOBJEXT = .gmo
-CC = i586-pc-mingw32-gcc
+CC = gcc
 CCDEPMODE = depmode=gcc3
-CFLAGS = -g -O2 -I/usr/local/mingw/i586-pc-mingw32/include/SDL -D_GNU_SOURCE=1 -Dmain=SDL_main -D__GW32__
-CFLAG_VISIBILITY = 
-CPP = i586-pc-mingw32-gcc -E
-CPPFLAGS = -I/usr/local/mingw/i586-pc-mingw32/include -idirafter /usr/local/mingw/i586-pc-mingw32/include/glibc
+CFLAGS = -g -O2 -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT
+CFLAG_VISIBILITY = -fvisibility=hidden
+CPP = gcc -E
+CPPFLAGS = 
 CYGPATH_W = echo
 DATADIRNAME = share
 DEFS = -DHAVE_CONFIG_H
@@ -94,17 +94,17 @@
 ECHO_N = -n
 ECHO_T = 
 EGREP = /bin/grep -E
-EXEEXT = .exe
+EXEEXT = 
 GENCAT = gencat
-GLIBC2 = no
-GLIBC21 = no
+GLIBC2 = yes
+GLIBC21 = yes
 GMSGFMT = /usr/bin/msgfmt
 GMSGFMT_015 = /usr/bin/msgfmt
 GREP = /bin/grep
-HAVE_ASPRINTF = 0
-HAVE_POSIX_PRINTF = 0
+HAVE_ASPRINTF = 1
+HAVE_POSIX_PRINTF = 1
 HAVE_SNPRINTF = 1
-HAVE_VISIBILITY = 0
+HAVE_VISIBILITY = 1
 HAVE_WPRINTF = 0
 INSTALL = /usr/bin/install -c
 INSTALL_DATA = ${INSTALL} -m 644
@@ -113,22 +113,22 @@
 INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
 INSTOBJEXT = .mo
 INTLBISON = bison
-INTLLIBS = ${top_builddir}/intl/libintl.a  
-INTLOBJS = $(GETTOBJS)
+INTLLIBS = 
+INTLOBJS = 
 INTL_LIBTOOL_SUFFIX_PREFIX = 
 INTL_MACOSX_LIBS = 
-LDFLAGS = -L/usr/local/mingw/i586-pc-mingw32/lib
+LDFLAGS = 
 LIBICONV = 
-LIBINTL = ${top_builddir}/intl/libintl.a  
-LIBMULTITHREAD = 
-LIBOBJS =  ${LIBOBJDIR}strtod$U.o
+LIBINTL = 
+LIBMULTITHREAD = -lpthread
+LIBOBJS = 
 LIBPTH = 
-LIBS =  -lmingw32 -lSDLmain -lSDL -lSDL_image -lSDL_mixer -lSDL_ttf -luuid -lole32 -lwsock32 -mwindows
+LIBS =  -L/usr/lib -lSDL -lSDL_image -lSDL_mixer -lSDL_ttf
 LIBTHREAD = 
 LTLIBICONV = 
-LTLIBINTL = ${top_builddir}/intl/libintl.a  
-LTLIBMULTITHREAD = 
-LTLIBOBJS =  ${LIBOBJDIR}strtod$U.lo
+LTLIBINTL = 
+LTLIBMULTITHREAD = -lpthread
+LTLIBOBJS = 
 LTLIBPTH = 
 LTLIBTHREAD = 
 MAKEINFO = ${SHELL} /home/dbruce/tux4kids/tuxmath/trunk/missing --run makeinfo
@@ -136,34 +136,33 @@
 MSGFMT = /usr/bin/msgfmt
 MSGFMT_015 = /usr/bin/msgfmt
 MSGMERGE = /usr/bin/msgmerge
-NAME_VERSION = tuxmath-1.5.9
+NAME_VERSION = tuxmath-1.6.0
 NSIS = /usr/bin/makensis
 NSI_DLL_DIR = /home/dbruce/tuxmath_dll
 NSI_INSTALL_DIR = mingw32
-NSI_TUXMATH_CONF_DIR = no
 OBJEXT = o
 PACKAGE = tuxmath
 PACKAGE_BUGREPORT = tuxmath-devel at lists.sourceforge.net
 PACKAGE_DATA_DIR = data
 PACKAGE_NAME = Tux Of Math Command
-PACKAGE_STRING = Tux Of Math Command 1.5.9
+PACKAGE_STRING = Tux Of Math Command 1.6.0
 PACKAGE_TARNAME = tuxmath
-PACKAGE_VERSION = 1.5.9
+PACKAGE_VERSION = 1.6.0
 PATH_SEPARATOR = :
 POSUB = po
 POW_LIB = 
 PRI_MACROS_BROKEN = 0
-RANLIB = i586-pc-mingw32-ranlib
-SDL_CFLAGS = -I/usr/local/mingw/i586-pc-mingw32/include/SDL -D_GNU_SOURCE=1 -Dmain=SDL_main
-SDL_CONFIG = /usr/local/mingw/i586-pc-mingw32/bin/sdl-config
-SDL_LIBS = -L/usr/local/mingw/i586-pc-mingw32/lib -lmingw32 -lSDLmain -lSDL -mwindows
+RANLIB = ranlib
+SDL_CFLAGS = -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT
+SDL_CONFIG = /usr/bin/sdl-config
+SDL_LIBS = -L/usr/lib -lSDL
 SET_MAKE = 
-SHELL = /bin/sh
-STRIP = i586-pc-mingw32-strip
-USE_INCLUDED_LIBINTL = yes
+SHELL = /bin/bash
+STRIP = 
+USE_INCLUDED_LIBINTL = no
 USE_NLS = yes
-VERSION = 1.5.9
-WINDRES = /usr/local/mingw/bin/i586-pc-mingw32-windres
+VERSION = 1.6.0
+WINDRES = 
 WOE32DLL = no
 XGETTEXT = /usr/bin/xgettext
 XGETTEXT_015 = /usr/bin/xgettext
@@ -173,16 +172,16 @@
 abs_srcdir = /home/dbruce/tux4kids/tuxmath/trunk/data/images/sprites
 abs_top_builddir = /home/dbruce/tux4kids/tuxmath/trunk
 abs_top_srcdir = /home/dbruce/tux4kids/tuxmath/trunk
-ac_ct_CC = 
+ac_ct_CC = gcc
 am__include = include
 am__leading_dot = .
 am__quote = 
 am__tar = ${AMTAR} chof - "$$tardir"
 am__untar = ${AMTAR} xf -
 bindir = ${exec_prefix}/bin
-build = i386-pc-linux-gnu
-build_alias = i386-linux
-build_cpu = i386
+build = i686-pc-linux-gnu
+build_alias = 
+build_cpu = i686
 build_os = linux-gnu
 build_vendor = pc
 builddir = .
@@ -191,10 +190,10 @@
 docdir = ${datarootdir}/doc/${PACKAGE_TARNAME}
 dvidir = ${docdir}
 exec_prefix = ${prefix}
-host = i586-pc-mingw32
-host_alias = i586-pc-mingw32
-host_cpu = i586
-host_os = mingw32
+host = i686-pc-linux-gnu
+host_alias = 
+host_cpu = i686
+host_os = linux-gnu
 host_vendor = pc
 htmldir = ${docdir}
 includedir = ${prefix}/include
@@ -208,17 +207,17 @@
 mkdir_p = /bin/mkdir -p
 oldincludedir = /usr/include
 pdfdir = ${docdir}
-prefix = /usr/local/mingw/i586-pc-mingw32
-program_transform_name = s&^&i586-pc-mingw32-&
+prefix = /usr/local
+program_transform_name = s,x,x,
 psdir = ${docdir}
 sbindir = ${exec_prefix}/sbin
 sharedstatedir = ${prefix}/com
 srcdir = .
 sysconfdir = ${prefix}/etc
-target = i586-pc-mingw32
-target_alias = i586-pc-mingw32
-target_cpu = i586
-target_os = mingw32
+target = i686-pc-linux-gnu
+target_alias = 
+target_cpu = i686
+target_os = linux-gnu
 target_vendor = pc
 top_builddir = ../../..
 top_srcdir = ../../..

Modified: tuxmath/trunk/doc/changelog
===================================================================
--- tuxmath/trunk/doc/changelog	2008-01-02 13:36:54 UTC (rev 404)
+++ tuxmath/trunk/doc/changelog	2008-01-02 18:11:08 UTC (rev 405)
@@ -1,7 +1,20 @@
-200.Jan.01 (svn.debian.org/tux4kids - revision 402)
+2008.Jan.02 (svn.debian.org/tux4kids - revision 405)
+      Code:
+        A little more refinement of randomize_list() - now just
+        rearranges pointers to existing nodes rather than allocating
+        new list and deleting old one. Sort time for full Ace list (~16,000 
+        questions) has gone from over 7 sec to 0.012 sec! (on 3.2 GHz P4)
+        Even on much slower machines in schools, expect this will be quick enough. 
+	
+      David Bruce <dbruce at tampabay.rr.com>
+
+2008.Jan.02 (svn.debian.org/tux4kids - revision 402)
       Build:
         New files scandir.h, .c with better cross-platform scandir()
         and alphasort().  New code is from Hatari project at SF.net.
+        Thanks to Thomas Huth <thothy at users.sourceforge.net> - dev/maintainer
+        of Hatari project, and to contributers to that project.
+
         Better use of autoconf to detect need for replacement functions
         like this when building on various platforms.
 	

Modified: tuxmath/trunk/nsis/tuxmath.nsi
===================================================================
--- tuxmath/trunk/nsis/tuxmath.nsi	2008-01-02 13:36:54 UTC (rev 404)
+++ tuxmath/trunk/nsis/tuxmath.nsi	2008-01-02 18:11:08 UTC (rev 405)
@@ -3,7 +3,7 @@
 # modified for tuxmath by Yves Combe (yves at ycombe.net)
 # modified more for tuxmath by David Bruce <dbruce at tampabay.rr.com>
 
-!define PKG_VERSION "1.5.9"
+!define PKG_VERSION "1.6.0"
 !define PKG_PREFIX  "tuxmath"
 
 !define APP_PREFIX  "TuxMath"

Modified: tuxmath/trunk/nsis/tuxmath_with_conf.nsi
===================================================================
--- tuxmath/trunk/nsis/tuxmath_with_conf.nsi	2008-01-02 13:36:54 UTC (rev 404)
+++ tuxmath/trunk/nsis/tuxmath_with_conf.nsi	2008-01-02 18:11:08 UTC (rev 405)
@@ -2,7 +2,7 @@
 # with a few tiny modifications by Phil Harper(philh at theopencd.org)
 # modified for tuxmath by Yves Combe (yves at ycombe.net)
 
-!define PKG_VERSION "1.5.9"
+!define PKG_VERSION "1.6.0"
 !define PKG_PREFIX  "tuxmath"
 
 !define APP_PREFIX  "TuxMath"

Modified: tuxmath/trunk/src/mathcards.c
===================================================================
--- tuxmath/trunk/src/mathcards.c	2008-01-02 13:36:54 UTC (rev 404)
+++ tuxmath/trunk/src/mathcards.c	2008-01-02 18:11:08 UTC (rev 405)
@@ -17,6 +17,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
+#include <sys/time.h>
 
 #include "mathcards.h"
 
@@ -55,8 +56,8 @@
 static MC_MathQuestion* delete_list(MC_MathQuestion* list);
 static int copy_node(MC_MathQuestion* original, MC_MathQuestion* copy);
 static int list_length(MC_MathQuestion* list);
+static int randomize_list(MC_MathQuestion** list);
 
-static MC_MathQuestion* randomize_list(MC_MathQuestion* list);
 int comp_randomizer(const void *a, const void *b);
 static MC_MathQuestion* pick_random(int length, MC_MathQuestion* list);
 static int compare_node(MC_MathQuestion* first, MC_MathQuestion* other);
@@ -2452,7 +2453,11 @@
   /*  now shuffle list if desired: */
   if (math_opts->randomize)
   {
-    top_of_list = randomize_list(top_of_list); 
+    if(!randomize_list(&top_of_list))
+    { 
+      fprintf(stderr, "Error during list randomization!\n");
+      return NULL;
+    }
   }
 
   #ifdef MC_DEBUG
@@ -2859,60 +2864,44 @@
 
 
 
-/* This is a new implementation written in an attempt to avoid */
-/* the O(n^2) performance problems seen with the old randomization */
-/* function. The list is created as a vector, but is for now still */
-/* made a linked list to minimize changes needed elsewhere.        */
-/* NOTE - the function frees the old list and returns a pointer to */
-/* a newly allocated shuffled list - maybe this is confusing.  As  */
-/* long as it is used as in "ptr = new_randomize_list(ptr);", it */
-/* should not cause problems. */
-MC_MathQuestion* randomize_list(MC_MathQuestion* old_list)
+/* This is a new implementation written in an attempt to avoid       */
+/* the O(n^2) performance problems seen with the old randomization   */
+/* function. The list is created as a vector, but is for now still   */
+/* made a linked list to minimize changes needed elsewhere.          */
+/* The argument is a pointer to the top of the old list.  This extra */
+/* level of indirection allows the list to be shuffled "in-place".   */
+/* The function returns 1 if successful, 0 on errors.                */
+
+static int randomize_list(MC_MathQuestion** old_list)
 {
-  MC_MathQuestion* old_tmp = old_list;
+  MC_MathQuestion* old_tmp = *old_list;
   MC_MathQuestion** tmp_vect = NULL;
-  MC_MathQuestion* new_list_head = NULL;
 
   int i = 0;
-  int old_length = list_length(old_list);
+  int old_length = list_length(old_tmp);
 
   /* set random seed: */
   srand(time(0));  
 
-  /* Allocate vector and copy in old list - this is needed because old_list */
-  /* may have "holes" in it from deletions: */
 
-  /* This just allocates the list of pointers, not space for the nodes themselves: */
-  tmp_vect = (MC_MathQuestion**)malloc(sizeof(MC_MathQuestion*) * old_length);
+  /* Allocate vector and set ptrs to nodes in old list: */
 
+  /* Allocate a list of pointers, not space for the nodes themselves: */
+  tmp_vect = (MC_MathQuestion**)malloc(sizeof(MC_MathQuestion*) * old_length);
+  /* Set each pointer in the vector to the corresponding node: */
   for (i = 0; i < old_length; i++)
   {
-    tmp_vect[i] = (MC_MathQuestion*)malloc(sizeof(MC_MathQuestion));
-
-    if (!copy_node(old_tmp, tmp_vect[i]))
-    {
-      int j = 0;
-      fprintf(stderr, "Error during copying - cannot randomize list!\n");
-      fprintf(stderr, "Problem occurred for i = %d\n", i);
-      for (j = 0; j <= i; j++)
-        free(tmp_vect[j]);
-      free(tmp_vect);
-      return NULL;
-    }
-
+    tmp_vect[i] = old_tmp;
     tmp_vect[i]->randomizer = rand();
     old_tmp = old_tmp->next;
   }
 
-  /* free arg list now that copy made: */
-  delete_list(old_list);
-
-  /* Now just sort on 'tmp_vect[i]->randomizer' to shuffle list: */
+  /* Now simply sort on 'tmp_vect[i]->randomizer' to shuffle list: */
   qsort(tmp_vect, old_length,
         sizeof(MC_MathQuestion*),
         comp_randomizer);
 
-  /* Set pointers, as rest of program uses this as a linked list */
+  /* Re-create pointers to provide linked-list functionality:      */
   /* (stop at 'old_length-1' because we dereference tmp_vect[i+1]) */
   for(i = 0; i < old_length - 1; i++)
   {
@@ -2924,15 +2913,18 @@
     tmp_vect[i]->next = tmp_vect[i+1];
     tmp_vect[i+1]->previous = tmp_vect[i];
   }
+  /* Handle end cases: */
   tmp_vect[0]->previous = NULL;
   tmp_vect[old_length-1]->next = NULL;
 
-  /* Now just return pointer to first element! */
-  new_list_head = tmp_vect[0];
+  /* Now arrange for arg pointer to indirectly point to first element! */
+  *old_list = tmp_vect[0];
   free(tmp_vect);
-  return new_list_head;
+  return 1;
 }
 
+
+
 /* This is needed for qsort(): */
 int comp_randomizer (const void* a, const void* b)
 {

Modified: tuxmath/trunk/src/scandir.h
===================================================================
--- tuxmath/trunk/src/scandir.h	2008-01-02 13:36:54 UTC (rev 404)
+++ tuxmath/trunk/src/scandir.h	2008-01-02 18:11:08 UTC (rev 405)
@@ -1,3 +1,7 @@
+/* Brought to tuxmath from the Hatari project under the terms of the GPLv2+ */
+/* It should only be included if scandir is not found by Autoconf - e.g.: */
+/* #ifndef HAVE_SCANDIR (from autoconf's config.h)    - DSB               */
+
 /*
   Hatari - scandir.h
 




More information about the Tux4kids-commits mailing list