unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#4397: 23.0.60; update-game-score doesn't update when MAX_SCORES entries are present
@ 2009-09-10 23:53 ` Jason Feng
  2009-09-11 19:20   ` bug#4397: marked as done (23.0.60; update-game-score doesn't update when MAX_SCORES entries are present) Emacs bug Tracking System
  0 siblings, 1 reply; 2+ messages in thread
From: Jason Feng @ 2009-09-10 23:53 UTC (permalink / raw)
  To: bug-gnu-emacs

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






^ permalink raw reply	[flat|nested] 2+ messages in thread

* bug#4397: marked as done (23.0.60; update-game-score doesn't update when MAX_SCORES entries are present)
  2009-09-10 23:53 ` bug#4397: 23.0.60; update-game-score doesn't update when MAX_SCORES entries are present Jason Feng
@ 2009-09-11 19:20   ` Emacs bug Tracking System
  0 siblings, 0 replies; 2+ messages in thread
From: Emacs bug Tracking System @ 2009-09-11 19:20 UTC (permalink / raw)
  To: Stefan Monnier

[-- Attachment #1: Type: text/plain, Size: 969 bytes --]

Your message dated Fri, 11 Sep 2009 15:11:20 -0400
with message-id <jwvocphnvqs.fsf-monnier+emacsbugreports@gnu.org>
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 owner@emacsbugs.donarmstrong.com
immediately.)


-- 
4397: http://emacsbugs.donarmstrong.com/cgi-bin/bugreport.cgi?bug=4397
Emacs Bug Tracking System
Contact owner@emacsbugs.donarmstrong.com with problems

[-- Attachment #2: Type: message/rfc822, Size: 3369 bytes --]

From: Jason Feng <jfeng@ozbert.com>
To: bug-gnu-emacs@gnu.org
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
Message-ID: <20090910235338.GA29473@ozbert.com>

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



[-- Attachment #3: Type: message/rfc822, Size: 3828 bytes --]

From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Jason Feng <jfeng@ozbert.com>
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
Message-ID: <jwvocphnvqs.fsf-monnier+emacsbugreports@gnu.org>

> 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  <monnier@iro.umontreal.ca>
+
+	* update-game-score.c (main): Sort scores before trimming them,
+	reported by Jason Feng <jfeng@ozbert.com> (bug#4397).
+
 2009-09-09  Glenn Morris  <rgm@gnu.org>
 
 	* 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);


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-09-11 19:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <jwvocphnvqs.fsf-monnier+emacsbugreports@gnu.org>
2009-09-10 23:53 ` bug#4397: 23.0.60; update-game-score doesn't update when MAX_SCORES entries are present Jason Feng
2009-09-11 19:20   ` bug#4397: marked as done (23.0.60; update-game-score doesn't update when MAX_SCORES entries are present) Emacs bug Tracking System

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).