-# $OpenBSD: Makefile,v 1.7 2013/09/19 16:12:00 otto Exp $
+# $OpenBSD: Makefile,v 1.8 2015/10/10 19:28:54 deraadt Exp $
PROG= bc
-SRCS= bc.y scan.l tty.c
+SRCS= bc.y scan.l tty.c dc.c bcode.c inout.c mem.c stack.c
CPPFLAGS+= -I. -I${.CURDIR}
CFLAGS+= -Wall -Wno-unused
YFLAGS+=
-LDADD+= -ledit -lcurses
-DPADD+= ${LIBEDIT} ${LIBCURSES}
+LDADD+= -ledit -lcurses -lcrypto
+DPADD+= ${LIBEDIT} ${LIBCURSES} ${LIBCRYPTO}
+.PATH: ${.CURDIR}/../dc
beforeinstall:
install -c -o ${BINOWN} -g ${BINGRP} -m 444 ${.CURDIR}/bc.library \
%{
-/* $OpenBSD: bc.y,v 1.47 2014/11/26 18:34:51 millert Exp $ */
+/* $OpenBSD: bc.y,v 1.48 2015/10/10 19:28:54 deraadt Exp $ */
/*
* Copyright (c) 2003, Otto Moerbeek <otto@drijf.net>
int p[2];
char *q;
+ if (pledge("stdio rpath proc tty", NULL) == -1)
+ err(1, "pledge");
+
init();
setvbuf(stdout, NULL, _IOLBF, 0);
close(p[0]);
close(p[1]);
} else {
+ char *dc_argv[] = { "dc", "-x", NULL };
+ extern int dc_main(int, char **);
+
+ if (pledge("stdio", NULL) == -1)
+ err(1, "pledge");
+
close(STDIN_FILENO);
dup(p[0]);
close(p[0]);
close(p[1]);
- execl(_PATH_DC, "dc", "-x", (char *)NULL);
- err(1, "cannot find dc");
+
+ exit (dc_main(2, dc_argv));
}
}
if (interactive) {
el_set(el, EL_BIND, "^D", "bc_eof", NULL);
el_source(el, NULL);
}
+
+ if (pledge("stdio rpath tty", NULL) == -1)
+ err(1, "pledge");
+
yywrap();
return yyparse();
}
-# $OpenBSD: Makefile,v 1.2 2006/11/26 11:31:09 deraadt Exp $
+# $OpenBSD: Makefile,v 1.3 2015/10/10 19:28:54 deraadt Exp $
PROG= dc
-SRCS= dc.c bcode.c inout.c mem.c stack.c
+SRCS= main.c dc.c bcode.c inout.c mem.c stack.c
COPTS+= -Wall
LDADD= -lcrypto
DPADD= ${LIBCRYPTO}
-/* $OpenBSD: dc.c,v 1.15 2015/10/09 01:37:07 deraadt Exp $ */
+/* $OpenBSD: dc.c,v 1.16 2015/10/10 19:28:54 deraadt Exp $ */
/*
* Copyright (c) 2003, Otto Moerbeek <otto@drijf.net>
}
int
-main(int argc, char *argv[])
+dc_main(int argc, char *argv[])
{
int ch;
bool extended_regs = false;
char *buf, *p;
struct stat st;
- if (pledge("stdio rpath", NULL) == -1)
- err(1, "pledge");
-
if ((buf = strdup("")) == NULL)
err(1, NULL);
/* accept and ignore a single dash to be 4.4BSD dc(1) compatible */
-/* $OpenBSD: extern.h,v 1.4 2014/12/01 13:13:00 deraadt Exp $ */
+/* $OpenBSD: extern.h,v 1.5 2015/10/10 19:28:54 deraadt Exp $ */
/*
* Copyright (c) 2003, Otto Moerbeek <otto@drijf.net>
void frame_assign(struct stack *, size_t, const struct value *);
struct value * frame_retrieve(const struct stack *, size_t);
/* void frame_free(struct stack *); */
+
+int dc_main(int, char **);
--- /dev/null
+/* $OpenBSD: main.c,v 1.1 2015/10/10 19:28:54 deraadt Exp $ */
+
+/*
+ * Copyright (c) 2003, Otto Moerbeek <otto@drijf.net>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <err.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "extern.h"
+
+int
+main(int argc, char *argv[])
+{
+ setproctitle("dc");
+
+ if (pledge("stdio rpath", NULL) == -1)
+ err(1, "pledge");
+
+ return dc_main(argc, argv);
+}