games/tetris/scores.c
/*
 * Get login name, or if that fails, get something suitable.
 * The result is always trimmed to fit in a score.
 */
Get login name, or if that fails, get something suitable.
The result is always trimmed to fit in a score.
Get login name or if that fails get something suitable . The result is always trimmed to fit in a score .
static char *
thisuser()
{
	register const char *p;
	register struct passwd *pw;
	register size_t l;
	static char u[sizeof(scores[0].hs_name)];
	if (u[0])
		return (u);
	p = getlogin();
	if (p == NULL || *p == '\0') {
		pw = getpwuid(getuid());
		if (pw != NULL)
			p = pw->pw_name;
		else
			p = "  ???";
	}
	l = strlen(p);
	if (l >= sizeof(u))
		l = sizeof(u) - 1;
	bcopy(p, u, l);
	u[l] = '\0';
	return (u);
}
static char * thisuser ( ) { register const char * p ; register struct passwd * pw ; register size_t l ; static char u [ sizeof ( scores [ 0 ] . hs_name ) ] ; if ( u [ 0 ] ) return ( u ) ; p = getlogin ( ) ; if ( p == NULL || * p == ' \0 ' ) { pw = getpwuid ( getuid ( ) ) ; if ( pw != NULL ) p = pw -> pw_name ; else p = " " ; } l = strlen ( p ) ; if ( l >= sizeof ( u ) ) l = sizeof ( u ) - 1 ; bcopy ( p , u , l ) ; u [ l ] = ' \0 ' ; return ( u ) ; }
Get login name, or if that fails, get something suitable.
Get login name or if that fails get something suitable .