diff options
| author | Stefan Monnier | 2009-09-11 19:11:07 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2009-09-11 19:11:07 +0000 |
| commit | 24e9e99693f9c9425a41fd1d879ef2827523537c (patch) | |
| tree | 4ca47079079216d2b8e7a847421f4f88c6e1e27b /lib-src | |
| parent | 2efb64a86a51d47f8f23418bbdfd20b11e3bae91 (diff) | |
| download | emacs-24e9e99693f9c9425a41fd1d879ef2827523537c.tar.gz emacs-24e9e99693f9c9425a41fd1d879ef2827523537c.zip | |
(main): Sort scores before trimming them,
reported by Jason Feng <jfeng@ozbert.com> (bug#4397).
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/ChangeLog | 5 | ||||
| -rw-r--r-- | lib-src/update-game-score.c | 6 |
2 files changed, 8 insertions, 3 deletions
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog index 7970ee5aae2..93cd999509e 100644 --- a/lib-src/ChangeLog +++ b/lib-src/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2009-09-11 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * update-game-score.c (main): Sort scores before trimming them, | ||
| 4 | reported by Jason Feng <jfeng@ozbert.com> (bug#4397). | ||
| 5 | |||
| 1 | 2009-09-09 Glenn Morris <rgm@gnu.org> | 6 | 2009-09-09 Glenn Morris <rgm@gnu.org> |
| 2 | 7 | ||
| 3 | * Makefile.in ($(DESTDIR)${archlibdir}): Set umask to world-readable | 8 | * Makefile.in ($(DESTDIR)${archlibdir}): Set umask to world-readable |
diff --git a/lib-src/update-game-score.c b/lib-src/update-game-score.c index d85f426cbf6..e4ddb79247f 100644 --- a/lib-src/update-game-score.c +++ b/lib-src/update-game-score.c | |||
| @@ -254,15 +254,15 @@ main (argc, argv) | |||
| 254 | lose_syserr ("Failed to read scores file"); | 254 | lose_syserr ("Failed to read scores file"); |
| 255 | } | 255 | } |
| 256 | push_score (&scores, &scorecount, newscore, user_id, newdata); | 256 | push_score (&scores, &scorecount, newscore, user_id, newdata); |
| 257 | sort_scores (scores, scorecount, reverse); | ||
| 257 | /* Limit the number of scores. If we're using reverse sorting, then | 258 | /* Limit the number of scores. If we're using reverse sorting, then |
| 258 | we should increment the beginning of the array, to skip over the | 259 | we should increment the beginning of the array, to skip over the |
| 259 | *smallest* scores. Otherwise, we just decrement the number of | 260 | *smallest* scores. Otherwise, we just decrement the number of |
| 260 | scores, since the smallest will be at the end. */ | 261 | scores, since the smallest will be at the end. */ |
| 261 | if (scorecount > MAX_SCORES) | 262 | if (scorecount > MAX_SCORES) |
| 262 | scorecount -= (scorecount - MAX_SCORES); | 263 | scorecount -= (scorecount - MAX_SCORES); |
| 263 | if (reverse) | 264 | if (reverse) |
| 264 | scores += (scorecount - MAX_SCORES); | 265 | scores += (scorecount - MAX_SCORES); |
| 265 | sort_scores (scores, scorecount, reverse); | ||
| 266 | if (write_scores (scorefile, scores, scorecount) < 0) | 266 | if (write_scores (scorefile, scores, scorecount) < 0) |
| 267 | { | 267 | { |
| 268 | unlock_file (scorefile, lockstate); | 268 | unlock_file (scorefile, lockstate); |