aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src/update-game-score.c
diff options
context:
space:
mode:
authorPaul Eggert2011-02-21 10:06:25 -0800
committerPaul Eggert2011-02-21 10:06:25 -0800
commitb23b5a5b7dca39b708015979ed8c25901390ac14 (patch)
tree7a84c8534ce93629c091c9d0db52ddaa5f4b9215 /lib-src/update-game-score.c
parent6d7132563c23774dddcd825797a29ce7ae94253a (diff)
downloademacs-b23b5a5b7dca39b708015979ed8c25901390ac14.tar.gz
emacs-b23b5a5b7dca39b708015979ed8c25901390ac14.zip
Declare file-scope functions and variables static if not exported.
This is more consistent, and is nicer with gcc -Wstrict-prototypes. * ebrowse.c, emacsclient.c, fakemail.c, make-docfile.c, movemail.c: * profile.c, test-distrib.c, update-game-score.c: Declare non-'main' functions and variables to be static. * ebrowse.c: Omit redundant function prototypes.
Diffstat (limited to 'lib-src/update-game-score.c')
-rw-r--r--lib-src/update-game-score.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/lib-src/update-game-score.c b/lib-src/update-game-score.c
index 9466bf7b149..70b79a64f91 100644
--- a/lib-src/update-game-score.c
+++ b/lib-src/update-game-score.c
@@ -57,7 +57,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
57extern char *optarg; 57extern char *optarg;
58extern int optind, opterr; 58extern int optind, opterr;
59 59
60int usage (int err) NO_RETURN; 60static int usage (int err) NO_RETURN;
61 61
62#define MAX_ATTEMPTS 5 62#define MAX_ATTEMPTS 5
63#define MAX_SCORES 200 63#define MAX_SCORES 200
@@ -68,7 +68,7 @@ int usage (int err) NO_RETURN;
68#define difftime(t1, t0) (double)((t1) - (t0)) 68#define difftime(t1, t0) (double)((t1) - (t0))
69#endif 69#endif
70 70
71int 71static int
72usage (int err) 72usage (int err)
73{ 73{
74 fprintf (stdout, "Usage: update-game-score [-m MAX ] [ -r ] game/scorefile SCORE DATA\n"); 74 fprintf (stdout, "Usage: update-game-score [-m MAX ] [ -r ] game/scorefile SCORE DATA\n");
@@ -80,8 +80,8 @@ usage (int err)
80 exit (err); 80 exit (err);
81} 81}
82 82
83int lock_file (const char *filename, void **state); 83static int lock_file (const char *filename, void **state);
84int unlock_file (const char *filename, void *state); 84static int unlock_file (const char *filename, void *state);
85 85
86struct score_entry 86struct score_entry
87{ 87{
@@ -90,24 +90,24 @@ struct score_entry
90 char *data; 90 char *data;
91}; 91};
92 92
93int read_scores (const char *filename, struct score_entry **scores, 93static int read_scores (const char *filename, struct score_entry **scores,
94 int *count); 94 int *count);
95int push_score (struct score_entry **scores, int *count, 95static int push_score (struct score_entry **scores, int *count,
96 int newscore, char *username, char *newdata); 96 int newscore, char *username, char *newdata);
97void sort_scores (struct score_entry *scores, int count, int reverse); 97static void sort_scores (struct score_entry *scores, int count, int reverse);
98int write_scores (const char *filename, const struct score_entry *scores, 98static int write_scores (const char *filename,
99 int count); 99 const struct score_entry *scores, int count);
100 100
101void lose (const char *msg) NO_RETURN; 101static void lose (const char *msg) NO_RETURN;
102 102
103void 103static void
104lose (const char *msg) 104lose (const char *msg)
105{ 105{
106 fprintf (stderr, "%s\n", msg); 106 fprintf (stderr, "%s\n", msg);
107 exit (EXIT_FAILURE); 107 exit (EXIT_FAILURE);
108} 108}
109 109
110void lose_syserr (const char *msg) NO_RETURN; 110static void lose_syserr (const char *msg) NO_RETURN;
111 111
112/* Taken from sysdep.c. */ 112/* Taken from sysdep.c. */
113#ifndef HAVE_STRERROR 113#ifndef HAVE_STRERROR
@@ -126,14 +126,14 @@ strerror (errnum)
126#endif /* not WINDOWSNT */ 126#endif /* not WINDOWSNT */
127#endif /* ! HAVE_STRERROR */ 127#endif /* ! HAVE_STRERROR */
128 128
129void 129static void
130lose_syserr (const char *msg) 130lose_syserr (const char *msg)
131{ 131{
132 fprintf (stderr, "%s: %s\n", msg, strerror (errno)); 132 fprintf (stderr, "%s: %s\n", msg, strerror (errno));
133 exit (EXIT_FAILURE); 133 exit (EXIT_FAILURE);
134} 134}
135 135
136char * 136static char *
137get_user_id (void) 137get_user_id (void)
138{ 138{
139 char *name; 139 char *name;
@@ -154,7 +154,7 @@ get_user_id (void)
154 return buf->pw_name; 154 return buf->pw_name;
155} 155}
156 156
157const char * 157static const char *
158get_prefix (int running_suid, const char *user_prefix) 158get_prefix (int running_suid, const char *user_prefix)
159{ 159{
160 if (!running_suid && user_prefix == NULL) 160 if (!running_suid && user_prefix == NULL)
@@ -258,7 +258,7 @@ main (int argc, char **argv)
258 exit (EXIT_SUCCESS); 258 exit (EXIT_SUCCESS);
259} 259}
260 260
261int 261static int
262read_score (FILE *f, struct score_entry *score) 262read_score (FILE *f, struct score_entry *score)
263{ 263{
264 int c; 264 int c;
@@ -342,7 +342,7 @@ read_score (FILE *f, struct score_entry *score)
342 return 0; 342 return 0;
343} 343}
344 344
345int 345static int
346read_scores (const char *filename, struct score_entry **scores, int *count) 346read_scores (const char *filename, struct score_entry **scores, int *count)
347{ 347{
348 int readval, scorecount, cursize; 348 int readval, scorecount, cursize;
@@ -375,7 +375,7 @@ read_scores (const char *filename, struct score_entry **scores, int *count)
375 return 0; 375 return 0;
376} 376}
377 377
378int 378static int
379score_compare (const void *a, const void *b) 379score_compare (const void *a, const void *b)
380{ 380{
381 const struct score_entry *sa = (const struct score_entry *) a; 381 const struct score_entry *sa = (const struct score_entry *) a;
@@ -383,7 +383,7 @@ score_compare (const void *a, const void *b)
383 return (sb->score > sa->score) - (sb->score < sa->score); 383 return (sb->score > sa->score) - (sb->score < sa->score);
384} 384}
385 385
386int 386static int
387score_compare_reverse (const void *a, const void *b) 387score_compare_reverse (const void *a, const void *b)
388{ 388{
389 const struct score_entry *sa = (const struct score_entry *) a; 389 const struct score_entry *sa = (const struct score_entry *) a;
@@ -407,14 +407,14 @@ push_score (struct score_entry **scores, int *count, int newscore, char *usernam
407 return 0; 407 return 0;
408} 408}
409 409
410void 410static void
411sort_scores (struct score_entry *scores, int count, int reverse) 411sort_scores (struct score_entry *scores, int count, int reverse)
412{ 412{
413 qsort (scores, count, sizeof (struct score_entry), 413 qsort (scores, count, sizeof (struct score_entry),
414 reverse ? score_compare_reverse : score_compare); 414 reverse ? score_compare_reverse : score_compare);
415} 415}
416 416
417int 417static int
418write_scores (const char *filename, const struct score_entry *scores, int count) 418write_scores (const char *filename, const struct score_entry *scores, int count)
419{ 419{
420 FILE *f; 420 FILE *f;
@@ -443,7 +443,7 @@ write_scores (const char *filename, const struct score_entry *scores, int count)
443 return 0; 443 return 0;
444} 444}
445 445
446int 446static int
447lock_file (const char *filename, void **state) 447lock_file (const char *filename, void **state)
448{ 448{
449 int fd; 449 int fd;
@@ -484,7 +484,7 @@ lock_file (const char *filename, void **state)
484 return 0; 484 return 0;
485} 485}
486 486
487int 487static int
488unlock_file (const char *filename, void *state) 488unlock_file (const char *filename, void *state)
489{ 489{
490 char *lockpath = (char *) state; 490 char *lockpath = (char *) state;