<commit_before>/* $Id$ */

#include <sys/types.h>
#include <sys/stat.h>

#include <dirent.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>

#include "pfl/cdefs.h"

#define		 DEFAULT_SEED		123456

unsigned int	 seed = DEFAULT_SEED;
char		*progname;

char		 workdir[1024];

__dead void
usage(void)
{
	fprintf(stderr,
	    "usage: %s [-s seed] directory\n",
	    progname);
	exit(1);
}

struct bug_history {
	char		 *descp;
	int		(*funcp)(void);
};

int
test_rename(void)
{
	int rc;
	char *tmpname1 = "test-rename1.dir";
	char *tmpname2 = "test-rename2.dir";

	rc = mkdir(tmpname1, S_IRWXU);
	if (rc) {
		printf("Fail to create directory %s, errno = %d at line %d!\n", tmpname1, errno, __LINE__);
		return (1);
	}
	rc = rename(tmpname1, tmpname2);
	if (rc) {
		printf("Fail to rename directory %s, errno = %d at line %d!\n", tmpname1, errno, __LINE__);
		return (1);
	}
	rc = mkdir(tmpname1, S_IRWXU);
	if (rc) {
		printf("Fail to create directory %s, errno = %d at line %d!\n", tmpname1, errno, __LINE__);
		return (1);
	}
	rc = rmdir(tmpname1);
	if (rc) {
		printf("Fail to remove directory %s, errno = %d at line %d!\n", tmpname1, errno, __LINE__);
		return (1);
	}
	rc = rmdir(tmpname2);
	if (rc) {
		printf("Fail to remove directory %s, errno = %d at line %d!\n", tmpname1, errno, __LINE__);<commit_msg>this guy works<commit_after>/* $Id$ */

#include <sys/types.h>
#include <sys/stat.h>

#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dirent.h>
#include <unistd.h>

#include "pfl/cdefs.h"

#define		 DEFAULT_SEED		123456

unsigned int	 seed = DEFAULT_SEED;
char		*progname;

char		 workdir[1024];

__dead void
usage(void)
{
	fprintf(stderr,
	    "usage: %s [-s seed] directory\n",
	    progname);
	exit(1);
}

struct bug_history {
	char		 *descp;
	int		(*funcp)(void);
};

int
test_rename(void)
{
	int rc;
	DIR *dp;
	struct dirent *dirp;
	char *tmpname1 = "test-rename1.dir";
	char *tmpname2 = "test-rename2.dir";

	rc = mkdir(tmpname1, S_IRWXU);
	if (rc) {
		printf("Fail to create directory %s, errno = %d at line %d!\n", tmpname1, errno, __LINE__);
		return (1);
	}
	/* mimic the tab-completion behavior by reading the current directory */
	dp = opendir(".");
	if (dp == NULL) {
		printf("Fail to open current directory, errno = %d at line %d!\n", errno, __LINE__);
		return (1);
	}
	while ((dirp = readdir(dp)) != NULL);
	rc = closedir(dp);
	if (rc < 0) {
		printf("Fail to close current directory, errno = %d at line %d!\n", errno, __LINE__);
		return (1);
	}
	rc = rename(tmpname1, tmpname2);
	if (rc) {
		printf("Fail to rename directory %s, errno = %d at line %d!\n", tmpname1, errno, __LINE__);
		return (1);
	}
	/* the bug causes the following to fail with EEXIST */
	rc = mkdir(tmpname1, S_IRWXU);
	if (rc) {
		printf("Fail to create directory %s, errno = %d at line %d!\n", tmpname1, errno, __LINE__);
		return (1);
	}
	rc = rmdir(tmpname1);
	if (rc) {
		printf("Fail to remove directory %s, errno = %d at line %d!\n", tmpname1, errno, __LINE__);
		return (1);
	}
	rc = rmdir(tmpname2);
	if (rc) {
		printf("Fail to remove directory %s, errno = %d at line %d!\n", tmpname2, errno, __LINE__);
{'fraction_non_alphanumeric': 0.1721237608891559, 'fraction_numerical': 0.018924601982577352, 'mean_word_length': 3.8826979472140764, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 26, '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': '896694', 'n_tokens_mistral': 1447, 'n_tokens_neox': 1378, 'n_words': 388}