<commit_before>/*
 * POSIX library for Lua 5.1, 5.2 & 5.3.
 * Copyright (C) 2013-2018 <NAME>
 * Copyright (C) 2010-2013 <NAME> <<EMAIL>>
 * Copyright (C) 2008-2010 <NAME> <<EMAIL>>
 * Clean up and bug fixes by <NAME> <<EMAIL>> 2006-10-11
 * <NAME> <<EMAIL>> 07 Apr 2006 23:17:49
 * Based on original by Claudio Terra for Lua 3.x.
 * With contributions by <NAME>.
 * With documentation from <NAME> 2012
 */
/***
 Unix Standard APIs.

 Where the underlying system does not support one of these functions, it
 will have a `nil` value in the module table.

@module posix.unistd
*/

#if HAVE_CRYPT_H
#  include <crypt.h>
#endif
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>

#include "_helpers.c"

static uid_t
mygetuid(lua_State *L, int i)
{
	if (lua_isnoneornil(L, i))
		return (uid_t)-1;
	else if (lua_isinteger(L, i))
		return (uid_t) lua_tointeger(L, i);
	else if (lua_isstring(L, i))
	{
		struct passwd *p = getpwnam(lua_tostring(L, i));
		return (p == NULL) ? (uid_t) -1 : p->pw_uid;
	}<commit_msg>unistd.c uses grp.h and pwd.h.<commit_after>/*
 * POSIX library for Lua 5.1, 5.2 & 5.3.
 * Copyright (C) 2013-2018 <NAME>
 * Copyright (C) 2010-2013 <NAME> <<EMAIL>>
 * Copyright (C) 2008-2010 <NAME> <<EMAIL>>
 * Clean up and bug fixes by <NAME> <<EMAIL>> 2006-10-11
 * <NAME> <<EMAIL>> 07 Apr 2006 23:17:49
 * Based on original by <NAME> for Lua 3.x.
 * With contributions by <NAME>.
 * With documentation from <NAME> 2012
 */
/***
 Unix Standard APIs.

 Where the underlying system does not support one of these functions, it
 will have a `nil` value in the module table.

@module posix.unistd
*/

#if HAVE_CRYPT_H
#  include <crypt.h>
#endif
#include <sys/stat.h>
#include <sys/types.h>
#include <grp.h>
#include <pwd.h>
#include <unistd.h>

#include "_helpers.c"

static uid_t
mygetuid(lua_State *L, int i)
{
	if (lua_isnoneornil(L, i))
		return (uid_t)-1;
	else if (lua_isinteger(L, i))
		return (uid_t) lua_tointeger(L, i);
	else if (lua_isstring(L, i))
	{
		struct passwd *p = getpwnam(lua_tostring(L, i));
		return (p == NULL) ? (uid_t) -1 : p->pw_uid;
	}
{'fraction_non_alphanumeric': 0.1575408261287224, 'fraction_numerical': 0.05475504322766571, 'mean_word_length': 3.821759259259259, 'pattern_counts': {'":': 0, '<': 44, '<?xml version=': 0, '>': 46, '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': '5479300', 'n_tokens_mistral': 941, 'n_tokens_neox': 826, 'n_words': 263}