[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#16428: Bug fix for update-game-score.c: consider -m MAX
From: |
Matthias . Habl |
Subject: |
bug#16428: Bug fix for update-game-score.c: consider -m MAX |
Date: |
Sun, 12 Jan 2014 21:11:09 +0100 (CET) |
User-agent: |
Alpine 2.02 (DEB 1266 2009-07-14) |
The auxiliary program update-game-score claims:
-m MAX Limit the maximum number of scores to MAX.
However, this numeric option is not considered at all. The limiting
routine refers just to the fixed value
#define MAX_SCORES 200
The following patch establishes the usage of the variable 'max' which
is set by '-m MAX'. The macro for MAX_SCORES is not necessary any
longer.
2013-01-12 Matthias Habl <matthias.habl@ur.de>
* update-game-score.c (MAX_SCORES, max): omit MAX_SCORES, use
variable 'max' according to option '-m MAX' instead
Patch against the current Savannah code:
diff -cp update-game-score-trunk.c update-game-score.c
*** update-game-score-trunk.c 2014-01-12 15:04:32.582660242 +0100
--- update-game-score.c 2014-01-12 15:09:16.227157027 +0100
*************** along with GNU Emacs. If not, see <http
*** 51,57 ****
#endif
#define MAX_ATTEMPTS 5
- #define MAX_SCORES 200
#define MAX_DATA_LEN 1024
#ifndef HAVE_DIFFTIME
--- 51,56 ----
*************** main (int argc, char **argv)
*** 143,149 ****
const char *prefix, *user_prefix = NULL;
struct stat buf;
struct score_entry *scores;
! int newscore, scorecount, reverse = 0, max = MAX_SCORES;
char *newdata;
srand (time (0));
--- 142,148 ----
const char *prefix, *user_prefix = NULL;
struct stat buf;
struct score_entry *scores;
! int newscore, scorecount, reverse = 0, max = INT_MAX;
char *newdata;
srand (time (0));
*************** main (int argc, char **argv)
*** 162,169 ****
break;
case 'm':
max = atoi (optarg);
- if (max > MAX_SCORES)
- max = MAX_SCORES;
break;
default:
usage (EXIT_FAILURE);
--- 161,166 ----
*************** main (int argc, char **argv)
*** 209,219 ****
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)
{
if (reverse)
! scores += (scorecount - MAX_SCORES);
! scorecount = MAX_SCORES;
}
if (write_scores (scorefile, scores, scorecount) < 0)
{
--- 206,216 ----
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)
{
if (reverse)
! scores += (scorecount - max);
! scorecount = max;
}
if (write_scores (scorefile, scores, scorecount) < 0)
{
- bug#16428: Bug fix for update-game-score.c: consider -m MAX,
Matthias . Habl <=