73 lines
2.4 KiB
Text
73 lines
2.4 KiB
Text
$NetBSD: patch-ah,v 1.2 2009/09/28 11:29:32 martin Exp $
|
|
|
|
--- score.c.orig 1996-08-27 21:23:58.000000000 +0200
|
|
+++ score.c 2009-09-28 13:15:32.000000000 +0200
|
|
@@ -633,10 +633,11 @@ static short WriteScore()
|
|
char tempfile[MAXPATHLEN];
|
|
strcpy(tempfile, tempnm);
|
|
|
|
- (void)mktemp(tempfile);
|
|
- scorefile = fopen(tempfile, "w");
|
|
+ sfdbn = mkstemp(tempfile);
|
|
+ if (sfdbn < 0)
|
|
+ return E_FOPENSCORE;
|
|
+ scorefile = fdopen(sfdbn, "w");
|
|
if (!scorefile) return E_FOPENSCORE;
|
|
- sfdbn = fileno(scorefile);
|
|
|
|
scoreentries = htons(scoreentries);
|
|
if (fwrite(SCORE_VERSION, 4, 1, scorefile) != 1) {
|
|
@@ -797,7 +798,7 @@ static void CopyEntry(short i1, short i2
|
|
}
|
|
|
|
/* Extract one line from "text". Return 0 if there is no line to extract. */
|
|
-char *getline(char *text, char *linebuf, int bufsiz)
|
|
+char *scoregetline(char *text, char *linebuf, int bufsiz)
|
|
{
|
|
if (*text == 0) {
|
|
*linebuf = 0;
|
|
@@ -938,7 +939,7 @@ char *skip_past_header(char *text)
|
|
{
|
|
char line[256];
|
|
do {
|
|
- text = getline(text, line, sizeof(line));
|
|
+ text = scoregetline(text, line, sizeof(line));
|
|
if (!text) return 0;
|
|
} while (0 != strcmp(line, ""));
|
|
return text;
|
|
@@ -982,7 +983,7 @@ static short ParseUserLevel(char *text,
|
|
char line[256];
|
|
text = skip_past_header(text);
|
|
if (!text) return E_READSCORE;
|
|
- text = getline(text, line, sizeof(line));
|
|
+ text = scoregetline(text, line, sizeof(line));
|
|
if (!text) return E_READSCORE;
|
|
if (0 == strncmp(line, "Level: ", 7)) {
|
|
*lv = atoi(&line[7]);
|
|
@@ -999,7 +1000,7 @@ static void DeleteAllEntries()
|
|
}
|
|
|
|
#define GRAB(tag, stmt) \
|
|
- text = getline(text, line, sizeof(line)); \
|
|
+ text = scoregetline(text, line, sizeof(line)); \
|
|
if (!text) return E_READSCORE; \
|
|
if (0 == strncmp(line, tag, strlen(tag))) { stmt; } \
|
|
else return E_READSCORE;
|
|
@@ -1070,7 +1071,7 @@ static short ParseScoreText(char *text,
|
|
{
|
|
char line[256];
|
|
do {
|
|
- text = getline(text, line, sizeof(line));
|
|
+ text = scoregetline(text, line, sizeof(line));
|
|
if (!text) return E_READSCORE;
|
|
} while (line[0] != '=');
|
|
scoreentries = 0;
|
|
@@ -1091,7 +1092,7 @@ static short ParseScoreLine(int i, char
|
|
int rank;
|
|
char rank_s[4];
|
|
char line[256];
|
|
- *text = getline(*text, line, sizeof(line));
|
|
+ *text = scoregetline(*text, line, sizeof(line));
|
|
if (!*text) return 0;
|
|
strncpy(rank_s, line, 4);
|
|
rank = atoi(rank_s);
|