<commit_before>/* Copyright (c) 1997 L.W.McVoy */
#include "system.h"
#include "sccs.h"
WHATSTR("@(#)%K%");
/* undocumented:
   -n		preserve gfile, kill pfile; SCCS compat\n\
   -r		obsolete, SCCS compat\n\
   -R		respect rev (?)\n\
   -s		same as -q\n\
*/
char	*delta_help = "\n\
usage: delta [-iluYpq] [-S<sym>] [-Z<alg>] [-y<c>] [files...]\n\n\
   -a		check in new work automatically\n\
   -c		don't verify file checksum\n\
   -D<file>	take diffs from <file>\n\
   -E		set file encoding (like admin)\n\
   -f		force creation of a null delta when invoked as ci\n\
   -h		invert sense of file's hash flag\n\
   -i		initial checkin, create a new revision history\n\
   -I<file>	use init file for meta data\n\
   -l		follow check in with a locked check out like ``get -e''\n\
   -p		print differences before prompting for comments\n\
   -q		run silently.\n\
   -S<sym>	set the symbol <sym> to be the revision created\n\
   -u		follow check in with an unlocked check out like ``get''\n\
   -Y		prompt for one comment, then use it for all the files\n\n\
   -y<comment>	sets the revision comment to <comment>\n\
   -Z, -Z<alg>	compress stored s.file with <alg>, which may be:\n\
		gzip	like gzip(1)\n\
		none	no compression\n";

#include "comments.c"
int	newrev(sccs *s, pfile *pf);
project	*proj;

int
main(int ac, char **av)
{
	sccs	*s;
	int	iflags = INIT_SAVEPROJ;
	int	dflags = 0;
	int	gflags = 0;
	int	sflags = SF_GFILE|SF_WRITE_OK;
	int	isci = 0;
	int	checkout = 0;
	int	c, rc, enc;
	char	*initFile = 0;
	char	*diffsFile = 0;
	char	*name;
	char	**syms = 0;
	char	*compp = 0, *encp = 0;
	MMAP	*diffs = 0;
	MMAP	*init = 0;
	pfile	pf;
	int	dash;

	debug_main(av);
	name = strrchr(av[0], '/');
	if (name) name++;
	else name = av[0];
	if (streq(name, "ci")) {
		if (!isdir("SCCS") && isdir("RCS")) {
			rcs("ci", ac, av);
			/* NOTREACHED */
		}
		isci = 1;
	} else if (streq(name, "delta")) {
		dflags = DELTA_FORCE;
	}

	if (ac > 1 && streq("--help", av[1])) {
help:		fputs(delta_help, stderr);
		return (1);
	}
	while ((c = getopt(ac, av,
			   "acD:E|fg;GhI;ilm|npqRrS;suy|YZ|")) != -1) {
		switch (c) {
		    /* SCCS flags */
		    case 'n': dflags |= DELTA_SAVEGFILE; break;
		    case 'p': dflags |= PRINT; break;
		    case 'y':
		    comment:
			comment = optarg;
			gotComment = 1;
			dflags |= DELTA_DONTASK;
			break;
		    case 's': /* fall through */

		    /* RCS flags */
		    case 'q': dflags |= SILENT; gflags |= SILENT; break;
		    case 'f': dflags |= DELTA_FORCE; break;
		    case 'i': dflags |= NEWFILE;
			      sflags |= SF_NODIREXPAND;
			      break;
		    case 'l': gflags |= GET_SKIPGET|GET_EDIT;
		    	      dflags |= DELTA_SAVEGFILE;
			      checkout = 1;
			      break;
		    case 'u': gflags |= GET_EXPAND;
			      checkout = 1;
			      break;

		    /* flags with different meaning in RCS and SCCS */
		    case 'm':
			    if (isci) goto comment;
			    /* else fall through */

		    /* obsolete SCCS flags */
		    case 'g':
		    case 'r':
			    fprintf(stderr, "-%c not implemented.\n", c);
			    goto help;

		    /* LM flags */
		    case 'a':
		    	dflags |= DELTA_AUTO;
			dflags &= ~DELTA_FORCE;
			break;
		    case 'c': iflags |= INIT_NOCKSUM; break;
		    case 'D': diffsFile = optarg;
			      sflags = ~(SF_GFILE | SF_WRITE_OK);
			      break;
		    case 'G': iflags |= INIT_GTIME; break;
		    case 'h': dflags |= DELTA_HASH; break;
		    case 'I': initFile = optarg; break;
		    case 'R': dflags |= DELTA_PATCH; break;
		    case 'S': syms = addLine(syms, strdup(optarg)); break;
		    case 'Y': dflags |= DELTA_DONTASK; break;
		    case 'Z': compp = optarg ? optarg : "gzip"; break;
		    case 'E': encp = optarg; break;

		    default:
usage:			fprintf(stderr, "%s: usage error, try --help.\n",
				av[0]);
			return (1);
		}
	}
	enc = sccs_encoding(0, encp, compp);
	if (enc == -1) goto usage;

	dash = av[optind] && streq(av[optind], "-");
	name = sfileFirst(av[0], &av[optind], sflags);
	/* They can only have an initFile for one file...
	 * So we go get the next file and error if there
	 * is one.
	 */
	if ((initFile || diffsFile) && name && sfileNext()) {
		fprintf(stderr,
"%s: only one file may be specified with init or diffs file.\n", av[0]);
		goto usage;
	}

	/* force them to do something sane */
	if (!comment && dash && name && sfileNext()) {
		fprintf(stderr,
"%s: only one file may be specified without a checkin comment\n", av[0]);
		goto usage;
	}
	if (initFile && (dflags & DELTA_DONTASK)) {
		fprintf(stderr,
		    "%s: only init file or comment, not both.\n", av[0]);
		goto usage;
	}
	if ((gflags & GET_EXPAND) && (gflags & GET_EDIT)) {
		fprintf(stderr, "%s: -l and -u are mutually exclusive.\n",
			av[0]);<commit_msg>Regression test caught a bug in the last fix.<commit_after>/* Copyright (c) 1997 L.W.McVoy */
#include "system.h"
#include "sccs.h"
WHATSTR("@(#)%K%");
/* undocumented:
   -n		preserve gfile, kill pfile; SCCS compat\n\
   -r		obsolete, SCCS compat\n\
   -R		respect rev (?)\n\
   -s		same as -q\n\
*/
char	*delta_help = "\n\
usage: delta [-iluYpq] [-S<sym>] [-Z<alg>] [-y<c>] [files...]\n\n\
   -a		check in new work automatically\n\
   -c		don't verify file checksum\n\
   -D<file>	take diffs from <file>\n\
   -E		set file encoding (like admin)\n\
   -f		force creation of a null delta when invoked as ci\n\
   -h		invert sense of file's hash flag\n\
   -i		initial checkin, create a new revision history\n\
   -I<file>	use init file for meta data\n\
   -l		follow check in with a locked check out like ``get -e''\n\
   -p		print differences before prompting for comments\n\
   -q		run silently.\n\
   -S<sym>	set the symbol <sym> to be the revision created\n\
   -u		follow check in with an unlocked check out like ``get''\n\
   -Y		prompt for one comment, then use it for all the files\n\n\
   -y<comment>	sets the revision comment to <comment>\n\
   -Z, -Z<alg>	compress stored s.file with <alg>, which may be:\n\
		gzip	like gzip(1)\n\
		none	no compression\n";

#include "comments.c"
int	newrev(sccs *s, pfile *pf);
project	*proj;

int
main(int ac, char **av)
{
	sccs	*s;
	int	iflags = INIT_SAVEPROJ;
	int	dflags = 0;
	int	gflags = 0;
	int	sflags = SF_GFILE|SF_WRITE_OK;
	int	isci = 0;
	int	checkout = 0;
	int	c, rc, enc;
	char	*initFile = 0;
	char	*diffsFile = 0;
	char	*name;
	char	**syms = 0;
	char	*compp = 0, *encp = 0;
	MMAP	*diffs = 0;
	MMAP	*init = 0;
	pfile	pf;
	int	dash;

	debug_main(av);
	name = strrchr(av[0], '/');
	if (name) name++;
	else name = av[0];
	if (streq(name, "ci")) {
		if (!isdir("SCCS") && isdir("RCS")) {
			rcs("ci", ac, av);
			/* NOTREACHED */
		}
		isci = 1;
	} else if (streq(name, "delta")) {
		dflags = DELTA_FORCE;
	}

	if (ac > 1 && streq("--help", av[1])) {
help:		fputs(delta_help, stderr);
		return (1);
	}
	while ((c = getopt(ac, av,
			   "acD:E|fg;GhI;ilm|npqRrS;suy|YZ|")) != -1) {
		switch (c) {
		    /* SCCS flags */
		    case 'n': dflags |= DELTA_SAVEGFILE; break;
		    case 'p': dflags |= PRINT; break;
		    case 'y':
		    comment:
			comment = optarg;
			gotComment = 1;
			dflags |= DELTA_DONTASK;
			break;
		    case 's': /* fall through */

		    /* RCS flags */
		    case 'q': dflags |= SILENT; gflags |= SILENT; break;
		    case 'f': dflags |= DELTA_FORCE; break;
		    case 'i': dflags |= NEWFILE;
			      sflags |= SF_NODIREXPAND;
			      break;
		    case 'l': gflags |= GET_SKIPGET|GET_EDIT;
		    	      dflags |= DELTA_SAVEGFILE;
			      checkout = 1;
			      break;
		    case 'u': gflags |= GET_EXPAND;
			      checkout = 1;
			      break;

		    /* flags with different meaning in RCS and SCCS */
		    case 'm':
			    if (isci) goto comment;
			    /* else fall through */

		    /* obsolete SCCS flags */
		    case 'g':
		    case 'r':
			    fprintf(stderr, "-%c not implemented.\n", c);
			    goto help;

		    /* LM flags */
		    case 'a':
		    	dflags |= DELTA_AUTO;
			dflags &= ~DELTA_FORCE;
			break;
		    case 'c': iflags |= INIT_NOCKSUM; break;
		    case 'D': diffsFile = optarg;
			      sflags = ~(SF_GFILE | SF_WRITE_OK);
			      break;
		    case 'G': iflags |= INIT_GTIME; break;
		    case 'h': dflags |= DELTA_HASH; break;
		    case 'I': initFile = optarg; break;
		    case 'R': dflags |= DELTA_PATCH; break;
		    case 'S': syms = addLine(syms, strdup(optarg)); break;
		    case 'Y': dflags |= DELTA_DONTASK; break;
		    case 'Z': compp = optarg ? optarg : "gzip"; break;
		    case 'E': encp = optarg; break;

		    default:
usage:			fprintf(stderr, "%s: usage error, try --help.\n",
				av[0]);
			return (1);
		}
	}
	enc = sccs_encoding(0, encp, compp);
	if (enc == -1) goto usage;

	dash = av[optind] && streq(av[optind], "-");
	name = sfileFirst(av[0], &av[optind], sflags);
	/* They can only have an initFile for one file...
	 * So we go get the next file and error if there
	 * is one.
	 */
	if ((initFile || diffsFile) && name && sfileNext()) {
		fprintf(stderr,
"%s: only one file may be specified with init or diffs file.\n", av[0]);
		goto usage;
	}

	/* force them to do something sane */
	if (!comment && dash && name && !(dflags & NEWFILE) && sfileNext()) {
		fprintf(stderr,
"%s: only one file may be specified without a checkin comment\n", av[0]);
		goto usage;
	}
	if (initFile && (dflags & DELTA_DONTASK)) {
		fprintf(stderr,
		    "%s: only init file or comment, not both.\n", av[0]);
		goto usage;
	}
	if ((gflags & GET_EXPAND) && (gflags & GET_EDIT)) {
		fprintf(stderr, "%s: -l and -u are mutually exclusive.\n",
			av[0]);
{'fraction_non_alphanumeric': 0.16171965775852962, 'fraction_numerical': 0.007394105841343614, 'mean_word_length': 2.532835820895522, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 29, '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': '1616946', 'n_tokens_mistral': 4128, 'n_tokens_neox': 3714, 'n_words': 1143}