diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2003-09-22 14:49:17 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2003-09-22 14:49:17 +0000 |
commit | 0c8af744189276589d7546762406019a754e9aca (patch) | |
tree | d4953dc4c8022837b697c2f32ac370c9641a7d2a /usr.bin/dc | |
parent | 85b5b8c48f19fca2671a26db950b6da254d0680c (diff) |
Make registers contain zero initially. Needed for new bc(1) and original dc(1)
compatible.
Diffstat (limited to 'usr.bin/dc')
-rw-r--r-- | usr.bin/dc/bcode.c | 14 | ||||
-rw-r--r-- | usr.bin/dc/dc.1 | 7 |
2 files changed, 10 insertions, 11 deletions
diff --git a/usr.bin/dc/bcode.c b/usr.bin/dc/bcode.c index a53898f7eab..4e5e3f2ed36 100644 --- a/usr.bin/dc/bcode.c +++ b/usr.bin/dc/bcode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bcode.c,v 1.4 2003/09/20 06:28:24 otto Exp $ */ +/* $OpenBSD: bcode.c,v 1.5 2003/09/22 14:49:16 otto Exp $ */ /* * Copyright (c) 2003, Otto Moerbeek <otto@drijf.net> @@ -17,7 +17,7 @@ */ #ifndef lint -static const char rcsid[] = "$OpenBSD: bcode.c,v 1.4 2003/09/20 06:28:24 otto Exp $"; +static const char rcsid[] = "$OpenBSD: bcode.c,v 1.5 2003/09/22 14:49:16 otto Exp $"; #endif /* not lint */ #include <ssl/ssl.h> @@ -652,13 +652,16 @@ load(void) { int index; struct value *v, copy; + struct number *n; index = readch(); if (0 <= index && index < UCHAR_MAX) { v = stack_tos(&bmachine.reg[index]); - if (v == NULL) - warnx("register '%c' (0%o) is empty", index, index); - else + if (v == NULL) { + n = new_number(); + bn_check(BN_zero(n->number)); + push_number(n); + } else push(stack_dup_value(v, ©)); } else warnx("internal error: reg num = %d", index); @@ -693,7 +696,6 @@ load_stack(void) stack = &bmachine.reg[index]; value = NULL; if (stack_size(stack) > 0) { - /*frame_free(stack);*/ value = stack_pop(stack); } if (value != NULL) diff --git a/usr.bin/dc/dc.1 b/usr.bin/dc/dc.1 index 3b30e721cef..29c1bc0804f 100644 --- a/usr.bin/dc/dc.1 +++ b/usr.bin/dc/dc.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: dc.1,v 1.2 2003/09/22 04:59:00 jmc Exp $ +.\" $OpenBSD: dc.1,v 1.3 2003/09/22 14:49:16 otto Exp $ .\" .\" Copyright (C) Caldera International Inc. 2001-2002. .\" All rights reserved. @@ -146,6 +146,7 @@ is pushed on the stack. The register .Ar x is not altered. +Initally, all registers contain the value zero. If the .Ar l is capitalized, @@ -297,10 +298,6 @@ will reset the input base to decimal 10. an undefined operation was called. .It stack empty for not enough elements on the stack to do what was asked. -.It register '%c' (0%o) is empty -for an -.Ar l -operation from a register that was never written. .It stack register '%c' (0%o) is empty for an .Ar L |