Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/dc build fixes.



details:   https://anonhg.NetBSD.org/src/rev/81a2d055401d
branches:  trunk
changeset: 822855:81a2d055401d
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Apr 10 16:37:48 2017 +0000

description:
build fixes.

diffstat:

 usr.bin/dc/Makefile         |  20 +++++++++++-
 usr.bin/dc/USD.doc/Makefile |  11 +----
 usr.bin/dc/bcode.c          |  24 ++++++++------
 usr.bin/dc/dc.1             |   3 +-
 usr.bin/dc/dc.c             |  11 ++++-
 usr.bin/dc/inout.c          |  23 ++++++++------
 usr.bin/dc/main.c           |   5 +++
 usr.bin/dc/mem.c            |  13 ++++---
 usr.bin/dc/misc.c           |  73 +++++++++++++++++++++++++++++++++++++++++++++
 usr.bin/dc/stack.c          |   7 +++-
 10 files changed, 147 insertions(+), 43 deletions(-)

diffs (truncated from 474 to 300 lines):

diff -r bb759b4b28ba -r 81a2d055401d usr.bin/dc/Makefile
--- a/usr.bin/dc/Makefile       Mon Apr 10 16:34:18 2017 +0000
+++ b/usr.bin/dc/Makefile       Mon Apr 10 16:37:48 2017 +0000
@@ -1,9 +1,25 @@
-#      $OpenBSD: Makefile,v 1.3 2015/10/10 19:28:54 deraadt Exp $
+#      $NetBSD: Makefile,v 1.2 2017/04/10 16:37:48 christos Exp $
+
+.include <bsd.own.mk>
 
 PROG=  dc
 SRCS=  main.c dc.c bcode.c inout.c mem.c stack.c
-COPTS+= -Wall
+
+.if ${MKCRYPTO:Uno} == "yes"
+WARNS=6
 LDADD= -lcrypto
 DPADD= ${LIBCRYPTO}
+.else
+OPENSSL=${NETBSDSRCDIR}/crypto/external/bsd/openssl/dist
+.PATH: ${OPENSSL}/crypto/bn
+CPPFLAGS+=-I${OPENSSL} -I${OPENSSL}/crypto
+SRCS+= bn_lib.c bn_add.c bn_mul.c bn_div.c bn_asm.c bn_word.c bn_shift.c
+SRCS+= bn_ctx.c bn_exp.c bn_mod.c bn_sqr.c bn_mont.c bn_recp.c bn_gcd.c
+SRCS+= misc.c
+COPTS.bn_lib.c += -Wno-cast-qual
+.endif
+
+SUBDIR+=USD.doc
 
 .include <bsd.prog.mk>
+.include <bsd.subdir.mk>
diff -r bb759b4b28ba -r 81a2d055401d usr.bin/dc/USD.doc/Makefile
--- a/usr.bin/dc/USD.doc/Makefile       Mon Apr 10 16:34:18 2017 +0000
+++ b/usr.bin/dc/USD.doc/Makefile       Mon Apr 10 16:37:48 2017 +0000
@@ -1,13 +1,8 @@
-#      $OpenBSD: Makefile,v 1.2 2004/02/01 15:18:01 jmc Exp $
+#      $NetBSD: Makefile,v 1.2 2017/04/10 16:37:48 christos Exp $
 
-DIR=   usd/05.dc
+SECTION=reference/ref1
+ARTICLE=dc
 SRCS=  dc
 MACROS=        -ms
 
-paper.ps: ${SRCS}
-       ${EQN} ${SRCS} | ${ROFF} > ${.TARGET}
-
-paper.txt: ${SRCS}
-       ${EQN} -Tascii ${SRCS} | ${ROFF} -Tascii > ${.TARGET}
-
 .include <bsd.doc.mk>
diff -r bb759b4b28ba -r 81a2d055401d usr.bin/dc/bcode.c
--- a/usr.bin/dc/bcode.c        Mon Apr 10 16:34:18 2017 +0000
+++ b/usr.bin/dc/bcode.c        Mon Apr 10 16:37:48 2017 +0000
@@ -1,3 +1,4 @@
+/*     $NetBSD: bcode.c,v 1.2 2017/04/10 16:37:48 christos Exp $       */
 /*     $OpenBSD: bcode.c,v 1.51 2017/02/26 11:29:55 otto Exp $ */
 
 /*
@@ -15,6 +16,8 @@
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: bcode.c,v 1.2 2017/04/10 16:37:48 christos Exp $");
 
 #include <err.h>
 #include <limits.h>
@@ -227,7 +230,7 @@
 void
 init_bmachine(bool extended_registers)
 {
-       int i;
+       size_t i;
 
        bmachine.extended_regs = extended_registers;
        bmachine.reg_array_size = bmachine.extended_regs ?
@@ -342,12 +345,12 @@
 void
 scale_number(BIGNUM *n, int s)
 {
-       int abs_scale;
+       size_t abs_scale;
 
        if (s == 0)
                return;
 
-       abs_scale = s > 0 ? s : -s;
+       abs_scale = (size_t)(s > 0 ? s : -s);
 
        if (abs_scale < sizeof(factors)/sizeof(factors[0])) {
                if (s > 0)
@@ -415,7 +418,7 @@
 void
 normalize(struct number *n, u_int s)
 {
-       scale_number(n->number, s - n->scale);
+       scale_number(n->number, (int)(s - n->scale));
        n->scale = s;
 }
 
@@ -785,7 +788,7 @@
                } else
                        idx = (ch1 << 8) + ch2 + UCHAR_MAX + 1;
        }
-       if (idx < 0 || idx >= bmachine.reg_array_size) {
+       if (idx < 0 || (size_t)idx >= bmachine.reg_array_size) {
                warnx("internal error: reg num = %d", idx);
                idx = -1;
        }
@@ -1244,7 +1247,7 @@
                        bn_check(BN_one(one));
                        ctx = BN_CTX_new();
                        bn_checkp(ctx);
-                       scale_number(one, r->scale + rscale);
+                       scale_number(one, (int)(r->scale + rscale));
 
                        if (BN_is_zero(r->number))
                                warnx("divide by zero");
@@ -1683,11 +1686,10 @@
        }
        if (bmachine.readsp == bmachine.readstack_sz - 1) {
                size_t newsz = bmachine.readstack_sz * 2;
-               struct source *stack;
-               stack = reallocarray(bmachine.readstack, newsz,
-                   sizeof(struct source));
-               if (stack == NULL)
-                       err(1, "recursion too deep");
+               struct source *stack = bmachine.readstack;
+               int ret = reallocarr(&stack, newsz, sizeof(struct source));
+               if (ret)
+                       errc(1, ret, "recursion too deep");
                bmachine.readstack_sz = newsz;
                bmachine.readstack = stack;
        }
diff -r bb759b4b28ba -r 81a2d055401d usr.bin/dc/dc.1
--- a/usr.bin/dc/dc.1   Mon Apr 10 16:34:18 2017 +0000
+++ b/usr.bin/dc/dc.1   Mon Apr 10 16:37:48 2017 +0000
@@ -1,3 +1,4 @@
+.\"    $NetBSD: dc.1,v 1.2 2017/04/10 16:37:48 christos Exp $
 .\"    $OpenBSD: dc.1,v 1.30 2017/02/23 06:40:17 otto Exp $
 .\"
 .\" Copyright (C) Caldera International Inc.  2001-2002.
@@ -34,7 +35,7 @@
 .\"
 .\"    @(#)dc.1        8.1 (Berkeley) 6/6/93
 .\"
-.Dd $Mdocdate: February 23 2017 $
+.Dd February 23, 2017
 .Dt DC 1
 .Os
 .Sh NAME
diff -r bb759b4b28ba -r 81a2d055401d usr.bin/dc/dc.c
--- a/usr.bin/dc/dc.c   Mon Apr 10 16:34:18 2017 +0000
+++ b/usr.bin/dc/dc.c   Mon Apr 10 16:37:48 2017 +0000
@@ -1,3 +1,4 @@
+/*     $NetBSD: dc.c,v 1.2 2017/04/10 16:37:48 christos Exp $  */
 /*     $OpenBSD: dc.c,v 1.18 2016/07/17 17:30:47 otto Exp $    */
 
 /*
@@ -15,6 +16,8 @@
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: dc.c,v 1.2 2017/04/10 16:37:48 christos Exp $");
 
 #include <sys/stat.h>
 #include <err.h>
@@ -27,13 +30,11 @@
 
 static __dead void     usage(void);
 
-extern char            *__progname;
-
 static __dead void
 usage(void)
 {
        (void)fprintf(stderr, "usage: %s [-x] [-e expression] [file]\n",
-           __progname);
+           getprogname());
        exit(1);
 }
 
@@ -91,8 +92,10 @@
                if (file == NULL)
                        err(1, "cannot open file %s", argv[0]);
 
+#ifdef __OpenBSD__
                if (pledge("stdio", NULL) == -1)
                        err(1, "pledge");
+#endif
 
                if (fstat(fileno(file), &st) == -1)
                        err(1, "%s", argv[0]);
@@ -109,8 +112,10 @@
                 return (0);
        }
 
+#ifdef __OpenBSD__
        if (pledge("stdio", NULL) == -1)
                err(1, "pledge");
+#endif
 
        src_setstream(&src, stdin);
        reset_bmachine(&src);
diff -r bb759b4b28ba -r 81a2d055401d usr.bin/dc/inout.c
--- a/usr.bin/dc/inout.c        Mon Apr 10 16:34:18 2017 +0000
+++ b/usr.bin/dc/inout.c        Mon Apr 10 16:37:48 2017 +0000
@@ -1,3 +1,4 @@
+/*     $NetBSD: inout.c,v 1.2 2017/04/10 16:37:48 christos Exp $       */
 /*     $OpenBSD: inout.c,v 1.20 2017/02/26 11:29:55 otto Exp $ */
 
 /*
@@ -15,6 +16,8 @@
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: inout.c,v 1.2 2017/04/10 16:37:48 christos Exp $");
 
 #include <ctype.h>
 #include <err.h>
@@ -129,7 +132,7 @@
                ch = src_getcharstring(src);
                if (ch == EOF)
                        break;
-               buf[i++] = ch;
+               buf[i++] = (char)ch;
                if (ch == '\n')
                        break;
        }
@@ -191,9 +194,9 @@
        while ((ch = (*src->vtable->readchar)(src)) != EOF) {
 
                if ('0' <= ch && ch <= '9')
-                       v = ch - '0';
+                       v = (BN_ULONG)(ch - '0');
                else if ('A' <= ch && ch <= 'F')
-                       v = ch - 'A' + 10;
+                       v = (BN_ULONG)(ch - 'A' + 10);
                else if (ch == '_') {
                        sign = true;
                        continue;
@@ -218,7 +221,7 @@
                        bn_check(BN_add_word(n->number, v));
        }
        if (base != 10) {
-               scale_number(n->number, n->scale);
+               scale_number(n->number, (int)n->scale);
                for (i = 0; i < n->scale; i++)
                        (void)BN_div_word(n->number, base);
        }
@@ -230,7 +233,8 @@
 char *
 read_string(struct source *src)
 {
-       int count, i, sz, new_sz, ch;
+       size_t count, i, sz, new_sz;
+       int ch;
        char *p;
        bool escape;
 
@@ -258,7 +262,7 @@
                                p = breallocarray(p, 1, new_sz + 1);
                                sz = new_sz;
                        }
-                       p[i++] = ch;
+                       p[i++] = (char)ch;
                }
        }
        p[i] = '\0';
@@ -272,7 +276,7 @@
 
        if (base <= 16) {
                p = bmalloc(2);
-               p[0] = num >= 10 ? num + 'A' - 10 : num + '0';
+               p[0] = (char)(num >= 10 ? num + 'A' - 10 : num + '0');
                p[1] = '\0';
        } else {
                if (asprintf(&p, "%0*lu", digits, num) == -1)
@@ -287,8 +291,7 @@
        struct number   *int_part, *fract_part;
        int             digits;
        char            buf[11];
-       size_t          sz;
-       int             i;
+       size_t          sz, i;
        struct stack    stack;
        char            *p;
 
@@ -337,7 +340,7 @@
                bn_check(BN_one(&mult));
                BN_init(&stop);
                bn_check(BN_one(&stop));
-               scale_number(&stop, b->scale);
+               scale_number(&stop, (int)b->scale);
 
                i = 0;
                while (BN_cmp(&mult, &stop) < 0) {



Home | Main Index | Thread Index | Old Index