bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#4397: marked as done (23.0.60; update-game-score doesn't update when


From: Emacs bug Tracking System
Subject: bug#4397: marked as done (23.0.60; update-game-score doesn't update when MAX_SCORES entries are present)
Date: Fri, 11 Sep 2009 19:20:04 +0000

Your message dated Fri, 11 Sep 2009 15:11:20 -0400
with message-id <address@hidden>
and subject line Re: bug#4397: 23.0.60; update-game-score doesn't update when 
MAX_SCORES entries are present
has caused the Emacs bug report #4397,
regarding 23.0.60; update-game-score doesn't update when MAX_SCORES entries are 
present
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact address@hidden
immediately.)


-- 
4397: http://emacsbugs.donarmstrong.com/cgi-bin/bugreport.cgi?bug=4397
Emacs Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: 23.0.60; update-game-score doesn't update when MAX_SCORES entries are present Date: Thu, 10 Sep 2009 16:53:38 -0700 User-agent: Mutt/1.5.13 (2006-08-11)
When attempting to run "update-game-score," when there are 200 entries
in the score file, the new score is never included.  Apparently, the
INTENDED behavior is that the new score is included if it is larger
than the minimum entry, pushing out the minimum entry, but this doesn't
happen.  

I have isolated the cause to the following lines in update-game-score.c
(pulled from the latest git tree):

(starts at line 255)
  push_score (&scores, &scorecount, newscore, user_id, newdata);
  /* Limit the number of scores.  If we're using reverse sorting, then
     we should increment the beginning of the array, to skip over the
     *smallest* scores.  Otherwise, we just decrement the number of
     scores, since the smallest will be at the end. */
  if (scorecount > MAX_SCORES)
    scorecount -= (scorecount - MAX_SCORES);
  if (reverse)
    scores += (scorecount - MAX_SCORES);
  sort_scores (scores, scorecount, reverse);

As push_score adds the new score at the end of the score list, when the
scorecount gets decremented, there is no chance for the new score to
ever get included (when reverse is zero, that is).  Really the decrement
of scorecount should happen after the scores have been sorted.

Regards,
Jason Feng



--- End Message ---
--- Begin Message --- Subject: Re: bug#4397: 23.0.60; update-game-score doesn't update when MAX_SCORES entries are present Date: Fri, 11 Sep 2009 15:11:20 -0400 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux)
> ever get included (when reverse is zero, that is).  Really the decrement
> of scorecount should happen after the scores have been sorted.

Indeed, thank you.  I've just installed the patch below,


        Stefan


Index: lib-src/ChangeLog
===================================================================
RCS file: /sources/emacs/emacs/lib-src/ChangeLog,v
retrieving revision 2.541
diff -u -r2.541 ChangeLog
--- lib-src/ChangeLog   9 Sep 2009 02:32:25 -0000       2.541
+++ lib-src/ChangeLog   11 Sep 2009 19:10:04 -0000
@@ -1,3 +1,8 @@
+2009-09-11  Stefan Monnier  <address@hidden>
+
+       * update-game-score.c (main): Sort scores before trimming them,
+       reported by Jason Feng <address@hidden> (bug#4397).
+
 2009-09-09  Glenn Morris  <address@hidden>
 
        * Makefile.in ($(DESTDIR)${archlibdir}): Set umask to world-readable
Index: lib-src/update-game-score.c
===================================================================
RCS file: /sources/emacs/emacs/lib-src/update-game-score.c,v
retrieving revision 1.27
diff -u -r1.27 update-game-score.c
--- lib-src/update-game-score.c 8 Jan 2009 03:38:53 -0000       1.27
+++ lib-src/update-game-score.c 11 Sep 2009 19:10:04 -0000
@@ -254,6 +254,7 @@
       lose_syserr ("Failed to read scores file");
     }
   push_score (&scores, &scorecount, newscore, user_id, newdata);
+  sort_scores (scores, scorecount, reverse);
   /* Limit the number of scores.  If we're using reverse sorting, then
      we should increment the beginning of the array, to skip over the
      *smallest* scores.  Otherwise, we just decrement the number of
@@ -262,7 +263,6 @@
     scorecount -= (scorecount - MAX_SCORES);
     if (reverse)
       scores += (scorecount - MAX_SCORES);
-  sort_scores (scores, scorecount, reverse);
   if (write_scores (scorefile, scores, scorecount) < 0)
     {
       unlock_file (scorefile, lockstate);


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]