hyphenated Unix user names

Fix for $USER, $LOGNAME, getlogin() values that have dashes in them:
keep dash and whatever follows as part of the name instead of stripping
it off for role/race/gender/alignment.

Before:
% USER=test-bar-fem ./nethack
|Shall I pick your female Barbarian's race and alignment for you?
and character ended up named 'test'.

After:
% USER=test-bar-fem ./nethack
|Shall I pick character's race, role, gender and alignment for you?
and character ends up named 'test-bar-fem'.  However,
% ./nethack -u test-bar-fem
still behaves like the 'before' case.
|Shall I pick your female Barbarian's race and alignment for you?

Dash handling is only changed when the dash comes from user name (or
from envionment overriding user name), not from direct player input
or run-time config file.
This commit is contained in:
PatR
2020-05-12 16:38:12 -07:00
parent 1afa961416
commit 41ae223585
6 changed files with 26 additions and 30 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 decl.h $NHDT-Date: 1586815081 2020/04/13 21:58:01 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.230 $ */
/* NetHack 3.6 decl.h $NHDT-Date: 1589326665 2020/05/12 23:37:45 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.236 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Michael Allison, 2007. */
/* NetHack may be freely redistributed. See license for details. */
@@ -735,6 +735,7 @@ struct instance_globals {
#define DOMOVE_RUSH 0x00000002
const char *nomovemsg;
char plname[PL_NSIZ]; /* player name */
int plnamelen; /* length of plname[] if that came from getlogin() */
char pl_character[PL_CSIZ];
char pl_race; /* character's race */
char pl_fruit[PL_FSIZ];