<commit_before>#include "../system.h"
#include "../sccs.h"

/*
 * Copyright (c) 2001 <NAME> & <NAME>       All rights reserved.
 */

static	char	*s;
static	uid_t	u = (uid_t)-1;

char	*
sccs_getuser(void)
{
#ifndef WIN32 /* win32 have no effective uid */
	uid_t	cur = geteuid();

	if (s && (cur == u)) return (s);
	u = cur;
#endif
	s = getenv("BK_USER");
	unless (s && s[0]) s = getenv("SUDO_USER");
	unless (s && s[0]) s = getenv("USER");
	unless (s && s[0]) s = getlogin();
#ifndef WIN32 /* win32 have no getpwuid() */
	unless (s && s[0]) {
		struct	passwd	*p = getpwuid(cur);

		s = p->pw_name;
	}
#endif
	unless (s && s[0]) s = UNKNOWN_USER;
	if (strchr(s, '\n') || strchr(s, '\r')) {
		fprintf(stderr,
		    "bad user name: user name cannot contain LR or CR "
		    "character\n");
		s = NULL;
	}

#ifdef WIN32 /* win32 have no effective uid */
       /*
	* Change all space in user name to dot
	*/
	_switch_char(s, s, ' ', '.');
#endif
	return (s);
}

void
sccs_resetuser()
{
	s = 0;
}

char	*
sccs_realuser(void)
{
	char	*s;

	s = getenv("SUDO_USER");
	unless (s && s[0]) s = getenv("USER");
	unless (s && s[0]) s = getlogin();
#ifndef WIN32 /* win32 have no getpwuid() */
	unless (s && s[0]) {<commit_msg>Allow LOGNAME to be used to set bk user. This allows the correct username to be found when doing a 'su'.<commit_after>#include "../system.h"
#include "../sccs.h"

/*
 * Copyright (c) 2001 <NAME> & <NAME>       All rights reserved.
 */

static	char	*s;
static	uid_t	u = (uid_t)-1;

char	*
sccs_getuser(void)
{
#ifndef WIN32 /* win32 have no effective uid */
	uid_t	cur = geteuid();

	if (s && (cur == u)) return (s);
	u = cur;
#endif
	s = getenv("BK_USER");
	unless (s && s[0]) s = getenv("SUDO_USER");
	unless (s && s[0]) s = getenv("LOGNAME");
	unless (s && s[0]) s = getenv("USER");
	unless (s && s[0]) s = getlogin();
#ifndef WIN32 /* win32 have no getpwuid() */
	unless (s && s[0]) {
		struct	passwd	*p = getpwuid(cur);

		s = p->pw_name;
	}
#endif
	unless (s && s[0]) s = UNKNOWN_USER;
	if (strchr(s, '\n') || strchr(s, '\r')) {
		fprintf(stderr,
		    "bad user name: user name cannot contain LR or CR "
		    "character\n");
		s = NULL;
	}

#ifdef WIN32 /* win32 have no effective uid */
       /*
	* Change all space in user name to dot
	*/
	_switch_char(s, s, ' ', '.');
#endif
	return (s);
}

void
sccs_resetuser()
{
	s = 0;
}

char	*
sccs_realuser(void)
{
	char	*s;

	s = getenv("SUDO_USER");
	unless (s && s[0]) s = getenv("LOGNAME");
	unless (s && s[0]) s = getenv("USER");
	unless (s && s[0]) s = getlogin();
#ifndef WIN32 /* win32 have no getpwuid() */
	unless (s && s[0]) {
{'fraction_non_alphanumeric': 0.20069204152249134, 'fraction_numerical': 0.023836985774702037, 'mean_word_length': 3.136724960254372, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3272528', 'n_tokens_mistral': 1152, 'n_tokens_neox': 1083, 'n_words': 324}