unifdef(1): Kill totally useless header

No functional change.
This commit is contained in:
Conrad Meyer 2019-11-19 03:15:06 +00:00
parent 12f7c1e8de
commit 3cbfa41a57
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=354843
2 changed files with 28 additions and 58 deletions

View File

@ -45,7 +45,16 @@
* it possible to handle all "dodgy" directives correctly.
*/
#include "unifdef.h"
#include <sys/stat.h>
#include <ctype.h>
#include <err.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
static const char copyright[] =
"@(#) $Version: unifdef-2.11 $\n"
@ -250,6 +259,21 @@ static const char *xstrdup(const char *, const char *);
#define endsym(c) (!isalnum((unsigned char)c) && c != '_')
static FILE *
mktempmode(char *tmp, int mode)
{
int rc, fd;
mode &= (S_IRWXU|S_IRWXG|S_IRWXO);
fd = mkstemp(tmp);
if (fd < 0)
err(2, "can't create %s", tmp);
rc = fchmod(fd, mode);
if (rc < 0)
err(2, "can't fchmod %s mode=0o%o", tmp, mode);
return (fdopen(fd, "wb"));
}
/*
* The main program.
*/
@ -388,7 +412,7 @@ processinout(const char *ifn, const char *ofn)
if (ifn == NULL || strcmp(ifn, "-") == 0) {
filename = "[stdin]";
linefile = NULL;
input = fbinmode(stdin);
input = stdin;
} else {
filename = ifn;
linefile = ifn;
@ -397,7 +421,7 @@ processinout(const char *ifn, const char *ofn)
err(2, "can't open %s", ifn);
}
if (strcmp(ofn, "-") == 0) {
output = fbinmode(stdout);
output = stdout;
process();
return;
}
@ -426,7 +450,7 @@ processinout(const char *ifn, const char *ofn)
if (!altered && backext == NULL) {
if (remove(tempname) < 0)
warn("can't remove \"%s\"", tempname);
} else if (replace(tempname, ofn) < 0)
} else if (rename(tempname, ofn) < 0)
err(2, "can't rename \"%s\" to \"%s\"", tempname, ofn);
free(tempname);
tempname = NULL;

View File

@ -1,54 +0,0 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (c) 2012 - 2013 Tony Finch <dot@dotat.at>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#include <sys/stat.h>
#include <ctype.h>
#include <err.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
/* portability stubs */
#define fbinmode(fp) (fp)
#define replace(old,new) rename(old,new)
static FILE *
mktempmode(char *tmp, int mode)
{
int fd = mkstemp(tmp);
if (fd < 0) return (NULL);
fchmod(fd, mode & (S_IRWXU|S_IRWXG|S_IRWXO));
return (fdopen(fd, "wb"));
}