err(1, name);
err(1, "%s", name);
FILE	*file __P((char *, char *));void	 show __P((FILE *, char *));char	*skip __P((char *));void	 obsolete __P((char *[]));void	 usage __P((void));intmain (argc, argv)	int argc;	char *argv[];{	register char *t1, *t2;	FILE *ifp, *ofp;	int ch;	char *prevline, *thisline, *p;	obsolete(argv);	while ((ch = getopt(argc, argv, "-cdf:s:u")) != -1)		switch (ch) {		case '-':			--optind;			goto done;		case 'c':			cflag = 1;			break;		case 'd':			dflag = 1;			break;		case 'f':			numfields = strtol(optarg, &p, 10);			if (numfields < 0 || *p)				errx(1, "illegal field skip value: %s", optarg);			break;		case 's':			numchars = strtol(optarg, &p, 10);			if (numchars < 0 || *p)				errx(1, "illegal character skip value: %s", optarg);			break;		case 'u':			uflag = 1;			break;		case '?':		default:			usage();	}done:	argc -= optind;	argv +=optind;	/* If no flags are set, default is -d -u. */	if (cflag) {		if (dflag || uflag)			usage();	} else if (!dflag && !uflag)		dflag = uflag = 1;	switch(argc) {	case 0:		ifp = stdin;		ofp = stdout;		break;	case 1:		ifp = file(argv[0], "r");		ofp = stdout;		break;	case 2:		ifp = file(argv[0], "r");		ofp = file(argv[1], "w");		break;	default:		usage();	}	prevline = malloc(MAXLINELEN);	thisline = malloc(MAXLINELEN);	if (prevline == NULL || thisline == NULL)		err(1, "malloc");	if (fgets(prevline, MAXLINELEN, ifp) == NULL)		exit(0);	while (fgets(thisline, MAXLINELEN, ifp)) {		/* If requested get the chosen fields + character offsets. */		if (numfields || numchars) {			t1 = skip(thisline);			t2 = skip(prevline);		} else {			t1 = thisline;			t2 = prevline;		}		/* If different, print; set previous to new value. */		if (strcmp(t1, t2)) {			show(ofp, prevline);			t1 = prevline;			prevline = thisline;			thisline = t1;			repeats = 0;		} else			++repeats;	}	show(ofp, prevline);	exit(0);}/* * show -- *	Output a line depending on the flags and number of repetitions *	of the line. */voidshow(ofp, str)	FILE *ofp;	char *str;{	if (cflag && *str)		(void)fprintf(ofp, "%4d %s", repeats + 1, str);	if (dflag && repeats || uflag && !repeats)		(void)fprintf(ofp, "%s", str);}char *skip(str)	register char *str;{	register int infield, nchars, nfields;	for (nfields = numfields, infield = 0; nfields && *str; ++str)		if (isspace(*str)) {			if (infield) {				infield = 0;				--nfields;			}		} else if (!infield)			infield = 1;	for (nchars = numchars; nchars-- && *str; ++str);	return(str);}FILE *file(name, mode)	char *name, *mode;{	FILE *fp;	if ((fp = fopen(name, mode)) == NULL)		err(1, name);	return(fp);}