]> code.delx.au - gnu-emacs/blobdiff - lib-src/update-game-score.c
* lib/unistd.in.h, m4/getloadavg.m4: Merge from gnulib.
[gnu-emacs] / lib-src / update-game-score.c
index 70b79a64f91ca2878f5dcc9ed7f072a0878dc0e6..e95e2ce259d479f4f0d8dc832fe7fd992f021caf 100644 (file)
@@ -242,13 +242,15 @@ main (int argc, char **argv)
   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
-     scores, since the smallest will be at the end. */
+     also increment the beginning of the array, to skip over the
+     *smallest* scores.  Otherwise, just decrementing the number of
+     scores suffices, since the smallest is at the end. */
   if (scorecount > MAX_SCORES)
-    scorecount -= (scorecount - MAX_SCORES);
-  if (reverse)
-    scores += (scorecount - MAX_SCORES);
+    {
+      if (reverse)
+       scores += (scorecount - MAX_SCORES);
+      scorecount = MAX_SCORES;
+    }
   if (write_scores (scorefile, scores, scorecount) < 0)
     {
       unlock_file (scorefile, lockstate);