ofn = xmalloc(strlen(bn) + (bn == suff ? 4 : 2)); len = bn == suff ? strlen(bn) : (suff - 1) - bn; (void)sprintf(ofn, "%.*s", (int)len, bn); (void)strcat(ofn, ".ln");
len = strlen(bn) + (bn == suff ? 4 : 2); ofn = xmalloc(len); (void)snprintf(ofn, len, "%.*s", bn == suff ? strlen(bn) : (suff - 1) - bn, bn); (void)strlcat(ofn, ".ln", len);
fname(name, last)	const	char *name;	int	last;{	const	char *bn, *suff;	char	**args, *ofn, *path;	size_t	len;	bn = basename(name, '/');	suff = basename(bn, '.');	if (strcmp(suff, "ln") == 0) {		/* only for lint2 */		if (!iflag)			appcstrg(&p2in, name);		return;	}	if (strcmp(suff, "c") != 0 &&	    (strncmp(bn, "llib-l", 6) != 0 || bn != suff)) {		warnx("unknown file type: %s", name);		return;	}	if (!iflag || !first || !last)		(void)printf("%s:\n", Fflag ? name : bn);	/* build the name of the output file of lint1 */	if (oflag) {		ofn = outputfn;		outputfn = NULL;		oflag = 0;	} else if (iflag) {		ofn = xmalloc(strlen(bn) + (bn == suff ? 4 : 2));		len = bn == suff ? strlen(bn) : (suff - 1) - bn;		(void)sprintf(ofn, "%.*s", (int)len, bn);		(void)strcat(ofn, ".ln");	} else {		ofn = xmalloc(strlen(tmpdir) + sizeof ("lint1.XXXXXXXXXX"));		(void)sprintf(ofn, "%slint1.XXXXXXXXXX", tmpdir);		if (mktemp(ofn) == NULL) {			warn("can't make temp");			terminate(-1);		}	}	if (!iflag)		appcstrg(&p1out, ofn);	args = xcalloc(1, sizeof (char *));	/* run cpp */	path = xmalloc(strlen(PATH_LIBEXEC) + sizeof ("/cpp"));	(void)sprintf(path, "%s/cpp", PATH_LIBEXEC);	appcstrg(&args, path);	applst(&args, cppflags);	applst(&args, lcppflgs);	appcstrg(&args, name);	appcstrg(&args, cppout);	runchild(path, args, cppout);	free(path);	freelst(&args);	/* run lint1 */	path = xmalloc(strlen(PATH_LIBEXEC) + sizeof ("/lint1"));	(void)sprintf(path, "%s/lint1", PATH_LIBEXEC);	appcstrg(&args, path);	applst(&args, l1flags);	appcstrg(&args, cppout);	appcstrg(&args, ofn);	runchild(path, args, ofn);	free(path);	freelst(&args);	appcstrg(&p2in, ofn);	free(ofn);	free(args);}