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

int
fix_main(int ac,  char **av)
{
	int	c, i;
	char	buf[MAXLINE];
	char	fix_file[MAXPATH];
	char	*qflag = "-q", *p;
	sccs	*s;
	delta	*d;

	while ((c = getopt(ac, av, "qv")) != -1) {
		switch (c) {
		    case 'q': break;
		    case 'v': qflag = ""; break;
		    default :
			fprintf(stderr, "unknow option <%c>\n", c);
			exit(1);
		}
	}
	i =  optind - 1;
	while (av[++i]) {
		if (writable(av[i])) {
			printf("%s is already edited\n", av[i]);
			continue;
		}
		sprintf(fix_file, "%s-fix", av[i]);
		if (exists(fix_file)) {
			printf("%s exists, skipping that file", fix_file);
			continue;
		}
		if (sccs_filetype(av[i]) == 's') {
			p = strdup(av[i]);
		} else {
			p = name2sccs(av[i]);
		}
		get(p, SILENT|PRINT, fix_file);
		s = sccs_init(p, SILENT, 0);
		assert(s);
		d = findrev(s, NULL);
		assert(d);
		sprintf(buf, "bk stripdel %s -r%s %s", qflag, d->rev, av[i]);
		sccs_free(s);
		if (system(buf) == 0) {
			int gflags = SILENT|GET_SKIPGET|GET_EDIT;
			s = sccs_init(p, SILENT, 0);
			assert(s);
			if (sccs_get(s, 0, 0, 0, 0, gflags, "-")) {
				fprintf(stderr, "can not lock %s\n", av[i]);
			}
			sccs_free(s);
			unlink(av[i]);
			if (rename(fix_file, av[i]) == -1) {
				perror(av[i]);
				free(p);
				exit(1);
			}
		} else {
			unlink(fix_file);
		}
	};
	free(p);
	return (0);
}<commit_msg>fix "bk fix" core dump problem<commit_after>#include "system.h"
#include "sccs.h"

int
fix_main(int ac,  char **av)
{
	int	c, i;
	char	buf[MAXLINE];
	char	fix_file[MAXPATH];
	char	*qflag = "-q", *p = 0;
	sccs	*s;
	delta	*d;

	while ((c = getopt(ac, av, "qv")) != -1) {
		switch (c) {
		    case 'q': break;
		    case 'v': qflag = ""; break;
		    default :
			fprintf(stderr, "unknow option <%c>\n", c);
			exit(1);
		}
	}
	i =  optind - 1;
	while (av[++i]) {
		if (writable(av[i])) {
			printf("%s is already edited\n", av[i]);
			continue;
		}
		sprintf(fix_file, "%s-fix", av[i]);
		if (exists(fix_file)) {
			printf("%s exists, skipping that file", fix_file);
			continue;
		}
		if (sccs_filetype(av[i]) == 's') {
			p = strdup(av[i]);
		} else {
			p = name2sccs(av[i]);
		}
		get(p, SILENT|PRINT, fix_file);
		s = sccs_init(p, SILENT, 0);
		assert(s);
		d = findrev(s, NULL);
		assert(d);
		sprintf(buf, "bk stripdel %s -r%s %s", qflag, d->rev, av[i]);
		sccs_free(s);
		if (system(buf) == 0) {
			int gflags = SILENT|GET_SKIPGET|GET_EDIT;
			s = sccs_init(p, SILENT, 0);
			assert(s);
			if (sccs_get(s, 0, 0, 0, 0, gflags, "-")) {
				fprintf(stderr, "can not lock %s\n", av[i]);
			}
			sccs_free(s);
			unlink(av[i]);
			if (rename(fix_file, av[i]) == -1) {
				perror(av[i]);
				free(p);
				exit(1);
			}
		} else {
			unlink(fix_file);
		}
	};
	if (p) free(p);
	return (0);
}
{'fraction_non_alphanumeric': 0.21984011627906977, 'fraction_numerical': 0.010537790697674418, 'mean_word_length': 3.013119533527697, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '1001386', 'n_tokens_mistral': 1462, 'n_tokens_neox': 1298, 'n_words': 286}