mirror of
https://github.com/openbsd/src.git
synced 2025-01-10 06:47:55 -08:00
Prefer $LOGNAME over $USER, since the latter is deprecated,
see environ(7). Pointed out by millert@. Fall back to getlogin(2) before defaulting to ???. looks good to deraadt@
This commit is contained in:
parent
5d6a366bf2
commit
fa83b6130f
@ -1,4 +1,4 @@
|
||||
.\" $OpenBSD: snake.6,v 1.12 2015/11/27 09:37:56 tb Exp $
|
||||
.\" $OpenBSD: snake.6,v 1.13 2015/11/29 14:31:01 tb Exp $
|
||||
.\" $NetBSD: snake.6,v 1.5 1995/04/22 08:34:35 cgd Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1980, 1993
|
||||
@ -30,7 +30,7 @@
|
||||
.\"
|
||||
.\" @(#)snake.6 8.1 (Berkeley) 5/31/93
|
||||
.\"
|
||||
.Dd $Mdocdate: November 27 2015 $
|
||||
.Dd $Mdocdate: November 29 2015 $
|
||||
.Dt SNAKE 6
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -116,7 +116,7 @@ To see who wastes time playing snake, run
|
||||
.Fl s .
|
||||
.Sh ENVIRONMENT
|
||||
.Bl -tag -width Ds
|
||||
.It Ev USER
|
||||
.It Ev LOGNAME
|
||||
Name displayed in high score file.
|
||||
.El
|
||||
.Sh FILES
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: snake.c,v 1.17 2015/11/27 09:37:56 tb Exp $ */
|
||||
/* $OpenBSD: snake.c,v 1.18 2015/11/29 14:31:01 tb Exp $ */
|
||||
/* $NetBSD: snake.c,v 1.8 1995/04/29 00:06:41 mycroft Exp $ */
|
||||
|
||||
/*
|
||||
@ -985,7 +985,7 @@ int
|
||||
readscores(int create)
|
||||
{
|
||||
const char *home;
|
||||
const char *user;
|
||||
const char *name;
|
||||
const char *modstr;
|
||||
int modint;
|
||||
int ret;
|
||||
@ -1019,13 +1019,17 @@ readscores(int create)
|
||||
if (ferror(sf))
|
||||
err(1, "error reading %s", scorepath);
|
||||
|
||||
user = getenv("USER");
|
||||
if (user == NULL || *user == '\0')
|
||||
user = "???";
|
||||
name = getenv("LOGNAME");
|
||||
if (name == NULL || *name == '\0')
|
||||
name = getenv("USER");
|
||||
if (name == NULL || *name == '\0')
|
||||
name = getlogin();
|
||||
if (name == NULL || *name == '\0')
|
||||
name = " ???";
|
||||
|
||||
if (nscores > TOPN)
|
||||
nscores = TOPN;
|
||||
strlcpy(scores[nscores].name, user, sizeof(scores[nscores].name));
|
||||
strlcpy(scores[nscores].name, name, sizeof(scores[nscores].name));
|
||||
scores[nscores].score = 0;
|
||||
|
||||
return 1;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: scores.c,v 1.15 2015/11/26 14:43:18 tb Exp $ */
|
||||
/* $OpenBSD: scores.c,v 1.16 2015/11/29 14:31:02 tb Exp $ */
|
||||
/* $NetBSD: scores.c,v 1.2 1995/04/22 07:42:38 cgd Exp $ */
|
||||
|
||||
/*-
|
||||
@ -217,10 +217,13 @@ thisuser(void)
|
||||
|
||||
if (u[0])
|
||||
return (u);
|
||||
p = getlogin();
|
||||
if (p == NULL || *p == '\0') {
|
||||
p = getenv("LOGNAME");
|
||||
if (p == NULL || *p == '\0')
|
||||
p = getenv("USER");
|
||||
if (p == NULL || *p == '\0')
|
||||
p = getlogin();
|
||||
if (p == NULL || *p == '\0')
|
||||
p = " ???";
|
||||
}
|
||||
strlcpy(u, p, sizeof(u));
|
||||
return (u);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" $OpenBSD: tetris.6,v 1.18 2015/11/25 16:15:06 tb Exp $
|
||||
.\" $OpenBSD: tetris.6,v 1.19 2015/11/29 14:31:02 tb Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1992, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@ -32,7 +32,7 @@
|
||||
.\"
|
||||
.\" @(#)tetris.6 8.1 (Berkeley) 5/31/93
|
||||
.\"
|
||||
.Dd $Mdocdate: November 25 2015 $
|
||||
.Dd $Mdocdate: November 29 2015 $
|
||||
.Dt TETRIS 6
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -145,6 +145,11 @@ name, score, and how many points were scored on what level.
|
||||
Scores which are the highest on a given level
|
||||
are marked with asterisks
|
||||
.Dq * .
|
||||
.Sh ENVIRONMENT
|
||||
.Bl -tag -width Ds
|
||||
.It Ev LOGNAME
|
||||
Name displayed in high score file.
|
||||
.El
|
||||
.Sh FILES
|
||||
.Bl -tag -width $HOME/.tetris.scores
|
||||
.It Pa $HOME/.tetris.scores
|
||||
|
Loading…
Reference in New Issue
Block a user