diff options
Diffstat (limited to 'usr.bin/dc/inout.c')
-rw-r--r-- | usr.bin/dc/inout.c | 52 |
1 files changed, 24 insertions, 28 deletions
diff --git a/usr.bin/dc/inout.c b/usr.bin/dc/inout.c index 1afbbd888c9..9518bce82f7 100644 --- a/usr.bin/dc/inout.c +++ b/usr.bin/dc/inout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: inout.c,v 1.13 2005/12/14 08:10:02 otto Exp $ */ +/* $OpenBSD: inout.c,v 1.14 2006/01/15 19:11:59 otto Exp $ */ /* * Copyright (c) 2003, Otto Moerbeek <otto@drijf.net> @@ -17,7 +17,7 @@ */ #ifndef lint -static const char rcsid[] = "$OpenBSD: inout.c,v 1.13 2005/12/14 08:10:02 otto Exp $"; +static const char rcsid[] = "$OpenBSD: inout.c,v 1.14 2006/01/15 19:11:59 otto Exp $"; #endif /* not lint */ #include <ssl/ssl.h> @@ -33,11 +33,11 @@ static int lastchar; static int charcount; static int src_getcharstream(struct source *); -static int src_ungetcharstream(struct source *); +static void src_ungetcharstream(struct source *); static char *src_getlinestream(struct source *); static void src_freestream(struct source *); static int src_getcharstring(struct source *); -static int src_ungetcharstring(struct source *); +static void src_ungetcharstring(struct source *); static char *src_getlinestring(struct source *); static void src_freestring(struct source *); static void flushwrap(FILE *); @@ -80,12 +80,13 @@ src_getcharstream(struct source *src) return src->lastchar = getc(src->u.stream); } -static int +static void src_ungetcharstream(struct source *src) { - return ungetc(src->lastchar, src->u.stream); + (void)ungetc(src->lastchar, src->u.stream); } +/* ARGSUSED */ static void src_freestream(struct source *src) { @@ -113,18 +114,13 @@ src_getcharstring(struct source *src) } } -static int +static void src_ungetcharstring(struct source *src) { - int ch; - if (src->u.string.pos > 0) { if (src->lastchar != '\0') --src->u.string.pos; - ch = src->u.string.buf[src->u.string.pos]; - return ch == '\0' ? EOF : ch; - } else - return EOF; + } } static char * @@ -156,7 +152,7 @@ static void flushwrap(FILE *f) { if (lastchar != -1) - putc(lastchar, f); + (void)putc(lastchar, f); } static void @@ -164,11 +160,11 @@ putcharwrap(FILE *f, int ch) { if (charcount >= MAX_CHARS_PER_LINE) { charcount = 0; - fputs("\\\n", f); + (void)fputs("\\\n", f); } if (lastchar != -1) { charcount++; - putc(lastchar, f); + (void)putc(lastchar, f); } lastchar = ch; } @@ -179,7 +175,7 @@ printwrap(FILE *f, const char *p) char buf[12]; char *q = buf; - strlcpy(buf, p, sizeof(buf)); + (void)strlcpy(buf, p, sizeof(buf)); while (*q) putcharwrap(f, *q++); } @@ -229,7 +225,7 @@ readnumber(struct source *src, u_int base) if (base != 10) { scale_number(n->number, n->scale); for (i = 0; i < n->scale; i++) - BN_div_word(n->number, base); + (void)BN_div_word(n->number, base); } if (sign) negate(n); @@ -341,11 +337,11 @@ printnumber(FILE *f, const struct number *b, u_int base) putcharwrap(f, '.'); num_base = new_number(); - BN_set_word(num_base->number, base); + bn_check(BN_set_word(num_base->number, base)); BN_init(&mult); - BN_one(&mult); + bn_check(BN_one(&mult)); BN_init(&stop); - BN_one(&stop); + bn_check(BN_one(&stop)); scale_number(&stop, b->scale); i = 0; @@ -362,11 +358,11 @@ printnumber(FILE *f, const struct number *b, u_int base) p = get_digit(rem, digits, base); int_part->scale = 0; normalize(int_part, fract_part->scale); - BN_sub(fract_part->number, fract_part->number, - int_part->number); + bn_check(BN_sub(fract_part->number, fract_part->number, + int_part->number)); printwrap(f, p); free(p); - BN_mul_word(&mult, base); + bn_check(BN_mul_word(&mult, base)); } free_number(num_base); BN_free(&mult); @@ -380,17 +376,17 @@ printnumber(FILE *f, const struct number *b, u_int base) void print_value(FILE *f, const struct value *value, const char *prefix, u_int base) { - fputs(prefix, f); + (void)fputs(prefix, f); switch (value->type) { case BCODE_NONE: if (value->array != NULL) - fputs("<array>", f); + (void)fputs("<array>", f); break; case BCODE_NUMBER: printnumber(f, value->u.num, base); break; case BCODE_STRING: - fputs(value->u.string, f); + (void)fputs(value->u.string, f); break; } } @@ -412,7 +408,7 @@ print_ascii(FILE *f, const struct number *n) ch = 0; for (i = 0; i < 8; i++) ch |= BN_is_bit_set(v, numbits-i-1) << (7 - i); - putc(ch, f); + (void)putc(ch, f); numbits -= 8; } BN_free(v); |