aboutsummaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorConrad Meyer <cem@FreeBSD.org>2019-11-19 03:15:06 +0000
committerConrad Meyer <cem@FreeBSD.org>2019-11-19 03:15:06 +0000
commit3cbfa41a57b76bb5afe9ffca73715ea4a2ede610 (patch)
tree1a55f82f6c485c9cf3fcee4738f635ac5d119d53 /usr.bin
parent12f7c1e8de814f8f45b46414b254e6c33ed6e66e (diff)
downloadsrc-3cbfa41a57b76bb5afe9ffca73715ea4a2ede610.tar.gz
src-3cbfa41a57b76bb5afe9ffca73715ea4a2ede610.zip
unifdef(1): Kill totally useless header
No functional change.
Notes
Notes: svn path=/head/; revision=354843
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/unifdef/unifdef.c32
-rw-r--r--usr.bin/unifdef/unifdef.h54
2 files changed, 28 insertions, 58 deletions
diff --git a/usr.bin/unifdef/unifdef.c b/usr.bin/unifdef/unifdef.c
index c354b31bcd7c..616f93a621eb 100644
--- a/usr.bin/unifdef/unifdef.c
+++ b/usr.bin/unifdef/unifdef.c
@@ -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;
diff --git a/usr.bin/unifdef/unifdef.h b/usr.bin/unifdef/unifdef.h
deleted file mode 100644
index 8d061c80aadc..000000000000
--- a/usr.bin/unifdef/unifdef.h
+++ /dev/null
@@ -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"));
-}