import tradcpp-0.5.3
tradcpp is a K&R-style ("traditional") C preprocessor. It was written to support historical uses of the C preprocessor for preprocessing things that aren't C, as the preprocessors that ship with C compilers are increasingly unsuitable for this task and/or don't provide a traditional mode at all. In particular, tradcpp preserves whitespace as much as possible, so it can be used in contexts where whitespace is significant and/or rearranging whitespace causes things to break, such as makefiles. Preprocessing makefiles with cpp is a fairly common property of sufficiently old legacy build systems, including old versions of Emacs and anything that uses imake. this port is imported to replace tradcpp from base which is not used there anymore and also include all the modifications we had, including pledge(2) support ok aja@, jsg@
This commit is contained in:
parent
ac9071ec17
commit
07ce55ef25
22
deve/tradcpp/Makefile
Normal file
22
deve/tradcpp/Makefile
Normal file
@ -0,0 +1,22 @@
|
||||
# $OpenBSD: Makefile,v 1.1.1.1 2021/12/12 11:26:44 robert Exp $
|
||||
|
||||
COMMENT = traditional (K&R-style) C preprocessor
|
||||
|
||||
V = 0.5.3
|
||||
DISTNAME = tradcpp-${V}
|
||||
|
||||
CATEGORIES = devel
|
||||
|
||||
HOMEPAGE = https://www.netbsd.org/~dholland/tradcpp/
|
||||
MASTER_SITES = https://ftp.NetBSD.org/pub/NetBSD/misc/dholland/
|
||||
|
||||
# BSD
|
||||
PERMIT_PACKAGE = Yes
|
||||
|
||||
# uses pledge()
|
||||
WANTLIB = c
|
||||
|
||||
MAKE_FLAGS = BINDIR=${PREFIX}/bin MANDIR=${PREFIX}/man/man
|
||||
NO_TEST = Yes
|
||||
|
||||
.include <bsd.port.mk>
|
2
deve/tradcpp/distinfo
Normal file
2
deve/tradcpp/distinfo
Normal file
@ -0,0 +1,2 @@
|
||||
SHA256 (tradcpp-0.5.3.tar.gz) = 4XufQs90s2DVaRvFn7U/N+QVgcRbdfzWS7ll5eL+TF4=
|
||||
SIZE (tradcpp-0.5.3.tar.gz) = 38683
|
27
deve/tradcpp/patches/patch-files_c
Normal file
27
deve/tradcpp/patches/patch-files_c
Normal file
@ -0,0 +1,27 @@
|
||||
$OpenBSD: patch-files_c,v 1.1.1.1 2021/12/12 11:26:44 robert Exp $
|
||||
|
||||
Index: files.c
|
||||
--- files.c.orig
|
||||
+++ files.c
|
||||
@@ -334,11 +334,7 @@ mkfilename(struct place *place, const char *dir, const
|
||||
|
||||
rlen = dlen + (needslash ? 1 : 0) + flen;
|
||||
ret = domalloc(rlen + 1);
|
||||
- strcpy(ret, dir);
|
||||
- if (needslash) {
|
||||
- strcat(ret, "/");
|
||||
- }
|
||||
- strcat(ret, file);
|
||||
+ snprintf(ret, rlen+1, "%s%s%s", dir, needslash ? "/" : "", file);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -351,7 +347,7 @@ file_tryopen(const char *file)
|
||||
/* XXX check for non-regular files */
|
||||
|
||||
fd = open(file, O_RDONLY);
|
||||
- if (fd < 0) {
|
||||
+ if (fd == -1) {
|
||||
if (errno != ENOENT && errno != ENOTDIR) {
|
||||
complain(NULL, "%s: %s", file, strerror(errno));
|
||||
}
|
32
deve/tradcpp/patches/patch-macro_c
Normal file
32
deve/tradcpp/patches/patch-macro_c
Normal file
@ -0,0 +1,32 @@
|
||||
$OpenBSD: patch-macro_c,v 1.1.1.1 2021/12/12 11:26:44 robert Exp $
|
||||
|
||||
Index: macro.c
|
||||
--- macro.c.orig
|
||||
+++ macro.c
|
||||
@@ -850,20 +850,20 @@ expand_substitute(struct place *p, struct expstate *es
|
||||
ei = expansionitemarray_get(&es->curmacro->expansion, i);
|
||||
switch (ei->itemtype) {
|
||||
case EI_STRING:
|
||||
- strcat(ret, ei->ei_string);
|
||||
+ strlcat(ret, ei->ei_string, len + 1);
|
||||
break;
|
||||
case EI_PARAM:
|
||||
arg = stringarray_get(&es->args, ei->ei_param);
|
||||
- strcat(ret, arg);
|
||||
+ strlcat(ret, arg, len + 1);
|
||||
break;
|
||||
case EI_FILE:
|
||||
- strcat(ret, "\"");
|
||||
- strcat(ret, place_getname(p));
|
||||
- strcat(ret, "\"");
|
||||
+ strlcat(ret, "\"", len + 1);
|
||||
+ strlcat(ret, place_getname(p), len + 1);
|
||||
+ strlcat(ret, "\"", len + 1);
|
||||
break;
|
||||
case EI_LINE:
|
||||
snprintf(numbuf, sizeof(numbuf), "%u", p->line);
|
||||
- strcat(ret, numbuf);
|
||||
+ strlcat(ret, numbuf, len + 1);
|
||||
break;
|
||||
}
|
||||
}
|
25
deve/tradcpp/patches/patch-main_c
Normal file
25
deve/tradcpp/patches/patch-main_c
Normal file
@ -0,0 +1,25 @@
|
||||
$OpenBSD: patch-main_c,v 1.1.1.1 2021/12/12 11:26:44 robert Exp $
|
||||
|
||||
Index: main.c
|
||||
--- main.c.orig
|
||||
+++ main.c
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
+#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
@@ -1053,6 +1054,11 @@ main(int argc, char *argv[])
|
||||
progname = strrchr(argv[0], '/');
|
||||
progname = progname == NULL ? argv[0] : progname + 1;
|
||||
complain_init(progname);
|
||||
+
|
||||
+ if (pledge("stdio rpath wpath cpath", NULL) == -1) {
|
||||
+ fprintf(stderr, "%s: pledge: %s", progname, strerror(errno));
|
||||
+ exit(1);
|
||||
+ }
|
||||
|
||||
init();
|
||||
|
43
deve/tradcpp/patches/patch-utils_c
Normal file
43
deve/tradcpp/patches/patch-utils_c
Normal file
@ -0,0 +1,43 @@
|
||||
$OpenBSD: patch-utils_c,v 1.1.1.1 2021/12/12 11:26:44 robert Exp $
|
||||
|
||||
Index: utils.c
|
||||
--- utils.c.orig
|
||||
+++ utils.c
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
+#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "utils.h"
|
||||
@@ -170,7 +171,7 @@ dostrdup(const char *s)
|
||||
|
||||
len = strlen(s);
|
||||
ret = domalloc(len+1);
|
||||
- strcpy(ret, s);
|
||||
+ strlcpy(ret, s, len+1);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -182,8 +183,7 @@ dostrdup2(const char *s, const char *t)
|
||||
|
||||
len = strlen(s) + strlen(t);
|
||||
ret = domalloc(len+1);
|
||||
- strcpy(ret, s);
|
||||
- strcat(ret, t);
|
||||
+ snprintf(ret, len+1, "%s%s", s, t);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -195,9 +195,7 @@ dostrdup3(const char *s, const char *t, const char *u)
|
||||
|
||||
len = strlen(s) + strlen(t) + strlen(u);
|
||||
ret = domalloc(len+1);
|
||||
- strcpy(ret, s);
|
||||
- strcat(ret, t);
|
||||
- strcat(ret, u);
|
||||
+ snprintf(ret, len+1, "%s%s%s", s, t, u);
|
||||
return ret;
|
||||
}
|
||||
|
10
deve/tradcpp/pkg/DESCR
Normal file
10
deve/tradcpp/pkg/DESCR
Normal file
@ -0,0 +1,10 @@
|
||||
tradcpp is a K&R-style ("traditional") C preprocessor. It was written to
|
||||
support historical uses of the C preprocessor for preprocessing things that
|
||||
aren't C, as the preprocessors that ship with C compilers are increasingly
|
||||
unsuitable for this task and/or don't provide a traditional mode at all.
|
||||
|
||||
In particular, tradcpp preserves whitespace as much as possible, so it can be
|
||||
used in contexts where whitespace is significant and/or rearranging whitespace
|
||||
causes things to break, such as makefiles. Preprocessing makefiles with cpp is
|
||||
a fairly common property of sufficiently old legacy build systems, including
|
||||
old versions of Emacs and anything that uses imake.
|
3
deve/tradcpp/pkg/PLIST
Normal file
3
deve/tradcpp/pkg/PLIST
Normal file
@ -0,0 +1,3 @@
|
||||
@comment $OpenBSD: PLIST,v 1.1.1.1 2021/12/12 11:26:44 robert Exp $
|
||||
@bin bin/tradcpp
|
||||
@man man/man1/tradcpp.1
|
Loading…
x
Reference in New Issue
Block a user