unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#16428: Bug fix for update-game-score.c: consider -m MAX
@ 2014-01-12 20:11 Matthias.Habl
  2014-01-19  8:51 ` Paul Eggert
  0 siblings, 1 reply; 2+ messages in thread
From: Matthias.Habl @ 2014-01-12 20:11 UTC (permalink / raw)
  To: 16428

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





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

* bug#16428: Bug fix for update-game-score.c: consider -m MAX
  2014-01-12 20:11 bug#16428: Bug fix for update-game-score.c: consider -m MAX Matthias.Habl
@ 2014-01-19  8:51 ` Paul Eggert
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Eggert @ 2014-01-19  8:51 UTC (permalink / raw)
  To: 16428-done

Thanks for the bug report; I installed a much-fancier fix as trunk bzr 
116068.





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

end of thread, other threads:[~2014-01-19  8:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-12 20:11 bug#16428: Bug fix for update-game-score.c: consider -m MAX Matthias.Habl
2014-01-19  8:51 ` Paul Eggert

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