all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Matthias.Habl@physik.uni-regensburg.de
To: 16428@debbugs.gnu.org
Subject: bug#16428: Bug fix for update-game-score.c: consider -m MAX
Date: Sun, 12 Jan 2014 21:11:09 +0100 (CET)	[thread overview]
Message-ID: <alpine.DEB.2.02.1401122109050.4511@mhamd64> (raw)

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)
       {





             reply	other threads:[~2014-01-12 20:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-12 20:11 Matthias.Habl [this message]
2014-01-19  8:51 ` bug#16428: Bug fix for update-game-score.c: consider -m MAX Paul Eggert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.02.1401122109050.4511@mhamd64 \
    --to=matthias.habl@physik.uni-regensburg.de \
    --cc=16428@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.