From 7121df6349476d73276d4e51b4de6774cad003ca Mon Sep 17 00:00:00 2001 From: Gabor Kovesdan Date: Wed, 3 Feb 2010 21:06:13 +0000 Subject: [PATCH] - style(9) Approved by: delphij (mentor) --- usr.bin/bc/bc.y | 61 ++++++------ usr.bin/bc/scan.l | 12 +-- usr.bin/dc/bcode.c | 228 ++++++++++++++++++++++----------------------- usr.bin/dc/bcode.h | 6 +- usr.bin/dc/dc.c | 9 +- usr.bin/dc/inout.c | 54 +++++------ usr.bin/dc/mem.c | 10 +- usr.bin/dc/stack.c | 28 +++--- 8 files changed, 206 insertions(+), 202 deletions(-) diff --git a/usr.bin/bc/bc.y b/usr.bin/bc/bc.y index e6393b955d8..b00d1405772 100644 --- a/usr.bin/bc/bc.y +++ b/usr.bin/bc/bc.y @@ -60,11 +60,11 @@ extern char *yytext; extern FILE *yyin; struct tree { - ssize_t index; union { char *astr; const char *cstr; } u; + ssize_t index; }; int yyparse(void); @@ -143,10 +143,10 @@ const struct option long_options[] = %start program %union { - ssize_t node; struct lvalue lvalue; const char *str; char *astr; + ssize_t node; } %token COMMA SEMICOLON LPAR RPAR LBRACE RBRACE LBRACKET RBRACKET DOT @@ -299,7 +299,7 @@ statement : expression } | QUIT { - sigset_t mask; + sigset_t mask; putchar('q'); fflush(stdout); @@ -321,7 +321,7 @@ statement : expression opt_relational_expression SEMICOLON opt_expression RPAR opt_statement pop_nesting { - ssize_t n; + ssize_t n; if (st_has_continue) n = node($10, cs("M"), $8, cs("s."), @@ -351,7 +351,7 @@ statement : expression | WHILE LPAR alloc_macro relational_expression RPAR opt_statement pop_nesting { - ssize_t n; + ssize_t n; if (st_has_continue) n = node($6, cs("M"), $4, $3, END_NODE); @@ -766,8 +766,8 @@ print_expression static void grow(void) { - struct tree *p; - size_t newsize; + struct tree *p; + size_t newsize; if (current == instr_sz) { newsize = instr_sz * 2 + 1; @@ -784,6 +784,7 @@ grow(void) static ssize_t cs(const char *str) { + grow(); instructions[current].index = CONST_STRING; instructions[current].u.cstr = str; @@ -793,6 +794,7 @@ cs(const char *str) static ssize_t as(const char *str) { + grow(); instructions[current].index = ALLOC_STRING; instructions[current].u.astr = strdup(str); @@ -804,8 +806,8 @@ as(const char *str) static ssize_t node(ssize_t arg, ...) { - va_list ap; - ssize_t ret; + va_list ap; + ssize_t ret; va_start(ap, arg); @@ -826,6 +828,7 @@ node(ssize_t arg, ...) static void emit(ssize_t i) { + if (instructions[i].index >= 0) while (instructions[i].index != END_NODE) emit(instructions[i++].index); @@ -836,6 +839,7 @@ emit(ssize_t i) static void emit_macro(int nodeidx, ssize_t code) { + putchar('['); emit(code); printf("]s%s\n", instructions[nodeidx].u.cstr); @@ -845,7 +849,7 @@ emit_macro(int nodeidx, ssize_t code) static void free_tree(void) { - ssize_t i; + ssize_t i; for (i = 0; i < current; i++) if (instructions[i].index == ALLOC_STRING) @@ -856,7 +860,7 @@ free_tree(void) static ssize_t numnode(int num) { - const char *p; + const char *p; if (num < 10) p = str_table['0' + num]; @@ -871,9 +875,9 @@ numnode(int num) static ssize_t lookup(char * str, size_t len, char type) { - ENTRY entry, *found; - u_short num; - u_char *p; + ENTRY entry, *found; + u_char *p; + u_short num; /* The scanner allocated an extra byte already */ if (str[len-1] != type) { @@ -908,7 +912,7 @@ lookup(char * str, size_t len, char type) static ssize_t letter_node(char *str) { - size_t len; + size_t len; len = strlen(str); if (len == 1 && str[0] != '_') @@ -920,7 +924,7 @@ letter_node(char *str) static ssize_t array_node(char *str) { - size_t len; + size_t len; len = strlen(str); if (len == 1 && str[0] != '_') @@ -932,7 +936,7 @@ array_node(char *str) static ssize_t function_node(char *str) { - size_t len; + size_t len; len = strlen(str); if (len == 1 && str[0] != '_') @@ -944,6 +948,7 @@ function_node(char *str) static void add_par(ssize_t n) { + prologue = node(cs("S"), n, prologue, END_NODE); epilogue = node(epilogue, cs("L"), n, cs("s."), END_NODE); } @@ -951,6 +956,7 @@ add_par(ssize_t n) static void add_local(ssize_t n) { + prologue = node(cs("0S"), n, prologue, END_NODE); epilogue = node(epilogue, cs("L"), n, cs("s."), END_NODE); } @@ -958,8 +964,8 @@ add_local(ssize_t n) void yyerror(const char *s) { - char *str, *p; - int n; + char *p, *str; + int n; if (yyin != NULL && feof(yyin)) n = asprintf(&str, "%s: %s:%d: %s: unexpected EOF", @@ -987,19 +993,21 @@ yyerror(const char *s) void fatal(const char *s) { + errx(1, "%s:%d: %s", filename, lineno, s); } static void warning(const char *s) { + warnx("%s:%d: %s", filename, lineno, s); } static void init(void) { - unsigned int i; + unsigned int i; for (i = 0; i < UCHAR_MAX; i++) { str_table[i][0] = i; @@ -1013,6 +1021,7 @@ init(void) static void usage(void) { + fprintf(stderr, "usage: %s [-chlqv] [-e expression] [file ...]\n", __progname); exit(1); @@ -1021,7 +1030,7 @@ usage(void) static char * escape(const char *str) { - char *ret, *p; + char *p, *ret; ret = malloc(strlen(str) + 1); if (ret == NULL) @@ -1077,8 +1086,8 @@ escape(const char *str) void sigchld(int signo) { - pid_t pid; - int status; + pid_t pid; + int status; switch (signo) { default: @@ -1100,9 +1109,9 @@ sigchld(int signo) int main(int argc, char *argv[]) { - int i, ch; - int p[2]; - char *q; + char *q; + int p[2]; + int ch, i; init(); setlinebuf(stdout); diff --git a/usr.bin/bc/scan.l b/usr.bin/bc/scan.l index 9c21fc20bf6..81dd862b281 100644 --- a/usr.bin/bc/scan.l +++ b/usr.bin/bc/scan.l @@ -193,6 +193,7 @@ ALPHANUM [a-z_0-9] static void init_strbuf(void) { + if (strbuf == NULL) { strbuf = malloc(strbuf_sz); if (strbuf == NULL) @@ -204,7 +205,7 @@ init_strbuf(void) static void add_str(const char *str) { - size_t arglen; + size_t arglen; arglen = strlen(str); @@ -228,8 +229,8 @@ add_str(const char *str) void abort_line(int sig) { - static const char str[] = "[\n]P\n"; - int save_errno; + static const char str[] = "[\n]P\n"; + int save_errno; switch (sig) { default: @@ -243,8 +244,8 @@ abort_line(int sig) int yywrap(void) { - static int state; - static YY_BUFFER_STATE buf; + static YY_BUFFER_STATE buf; + static int state; if (fileindex == 0 && sargc > 0 && strcmp(sargv[0], _PATH_LIBB) == 0) { filename = sargv[fileindex++]; @@ -285,4 +286,3 @@ yywrap(void) } return (1); } - diff --git a/usr.bin/dc/bcode.c b/usr.bin/dc/bcode.c index 8be43b9043a..e80c63587a3 100644 --- a/usr.bin/dc/bcode.c +++ b/usr.bin/dc/bcode.c @@ -41,17 +41,17 @@ BIGNUM zero; #define REG_ARRAY_SIZE_BIG (UCHAR_MAX + 1 + USHRT_MAX + 1) struct bmachine { + struct source *readstack; + struct stack *reg; struct stack stack; + volatile sig_atomic_t interrupted; u_int scale; u_int obase; u_int ibase; size_t readsp; - bool extended_regs; size_t reg_array_size; - struct stack *reg; - volatile sig_atomic_t interrupted; - struct source *readstack; size_t readstack_sz; + bool extended_regs; }; static struct bmachine bmachine; @@ -236,7 +236,7 @@ sighandler(int ignored) void init_bmachine(bool extended_registers) { - unsigned int i; + unsigned int i; bmachine.extended_regs = extended_registers; bmachine.reg_array_size = bmachine.extended_regs ? @@ -280,7 +280,7 @@ reset_bmachine(struct source *src) static __inline int readch(void) { - struct source *src = &bmachine.readstack[bmachine.readsp]; + struct source *src = &bmachine.readstack[bmachine.readsp]; return (src->vtable->readchar(src)); } @@ -288,7 +288,7 @@ readch(void) static __inline void unreadch(void) { - struct source *src = &bmachine.readstack[bmachine.readsp]; + struct source *src = &bmachine.readstack[bmachine.readsp]; src->vtable->unreadchar(src); } @@ -296,7 +296,7 @@ unreadch(void) static __inline char * readline(void) { - struct source *src = &bmachine.readstack[bmachine.readsp]; + struct source *src = &bmachine.readstack[bmachine.readsp]; return (src->vtable->readline(src)); } @@ -304,7 +304,7 @@ readline(void) static __inline void src_free(void) { - struct source *src = &bmachine.readstack[bmachine.readsp]; + struct source *src = &bmachine.readstack[bmachine.readsp]; src->vtable->free(src); } @@ -313,7 +313,7 @@ src_free(void) void pn(const char *str, const struct number *n) { - char *p = BN_bn2dec(n->number); + char *p = BN_bn2dec(n->number); if (p == NULL) err(1, "BN_bn2dec failed"); @@ -325,7 +325,7 @@ pn(const char *str, const struct number *n) void pbn(const char *str, const BIGNUM *n) { - char *p = BN_bn2dec(n); + char *p = BN_bn2dec(n); if (p == NULL) err(1, "BN_bn2dec failed"); @@ -351,7 +351,7 @@ static unsigned long factors[] = { void scale_number(BIGNUM *n, int s) { - unsigned int abs_scale; + unsigned int abs_scale; if (s == 0) return; @@ -364,8 +364,8 @@ scale_number(BIGNUM *n, int s) else BN_div_word(n, factors[abs_scale]); } else { - BIGNUM *a, *p; - BN_CTX *ctx; + BIGNUM *a, *p; + BN_CTX *ctx; a = BN_new(); bn_checkp(a); @@ -390,7 +390,7 @@ scale_number(BIGNUM *n, int s) void split_number(const struct number *n, BIGNUM *i, BIGNUM *f) { - u_long rem; + u_long rem; bn_checkp(BN_copy(i, n->number)); @@ -510,7 +510,7 @@ print_stack(void) static __inline void print_tos(void) { - struct value *value = tos(); + struct value *value = tos(); if (value != NULL) { print_value(stdout, value, "", bmachine.obase); @@ -523,7 +523,7 @@ print_tos(void) static void pop_print(void) { - struct value *value = pop(); + struct value *value = pop(); if (value != NULL) { switch (value->type) { @@ -546,7 +546,7 @@ pop_print(void) static void pop_printn(void) { - struct value *value = pop(); + struct value *value = pop(); if (value != NULL) { print_value(stdout, value, "", bmachine.obase); @@ -572,7 +572,7 @@ swap(void) static void drop(void) { - struct value *v = pop(); + struct value *v = pop(); if (v != NULL) stack_free_value(v); } @@ -580,7 +580,7 @@ drop(void) static void get_scale(void) { - struct number *n; + struct number *n; n = new_number(); bn_check(BN_set_word(n->number, bmachine.scale)); @@ -590,8 +590,8 @@ get_scale(void) static void set_scale(void) { - struct number *n; - u_long scale; + struct number *n; + u_long scale; n = pop_number(); if (n != NULL) { @@ -611,7 +611,7 @@ set_scale(void) static void get_obase(void) { - struct number *n; + struct number *n; n = new_number(); bn_check(BN_set_word(n->number, bmachine.obase)); @@ -621,8 +621,8 @@ get_obase(void) static void set_obase(void) { - struct number *n; - u_long base; + struct number *n; + u_long base; n = pop_number(); if (n != NULL) { @@ -638,7 +638,7 @@ set_obase(void) static void get_ibase(void) { - struct number *n; + struct number *n; n = new_number(); bn_check(BN_set_word(n->number, bmachine.ibase)); @@ -648,8 +648,8 @@ get_ibase(void) static void set_ibase(void) { - struct number *n; - u_long base; + struct number *n; + u_long base; n = pop_number(); if (n != NULL) { @@ -666,8 +666,8 @@ set_ibase(void) static void stackdepth(void) { - size_t i; - struct number *n; + struct number *n; + size_t i; i = stack_size(&bmachine.stack); n = new_number(); @@ -678,10 +678,9 @@ stackdepth(void) static void push_scale(void) { - struct value *value; - u_int scale = 0; - struct number *n; - + struct number *n; + struct value *value; + u_int scale = 0; value = pop(); if (value != NULL) { @@ -704,8 +703,8 @@ push_scale(void) static u_int count_digits(const struct number *n) { - struct number *int_part, *fract_part; - u_int i; + struct number *int_part, *fract_part; + u_int i; if (BN_is_zero(n->number)) return (1); @@ -728,9 +727,9 @@ count_digits(const struct number *n) static void num_digits(void) { - struct value *value; - size_t digits; - struct number *n = NULL; + struct number *n = NULL; + struct value *value; + size_t digits; value = pop(); if (value != NULL) { @@ -756,9 +755,9 @@ num_digits(void) static void to_ascii(void) { - char str[2]; - struct value *value; - struct number *n; + struct number *n; + struct value *value; + char str[2]; value = pop(); if (value != NULL) { @@ -785,7 +784,7 @@ to_ascii(void) static int readreg(void) { - int idx, ch1, ch2; + int ch1, ch2, idx; idx = readch(); if (idx == 0xff && bmachine.extended_regs) { @@ -807,9 +806,10 @@ readreg(void) static void load(void) { - int idx; - struct value *v, copy; - struct number *n; + struct number *n; + struct value *v; + struct value copy; + int idx; idx = readreg(); if (idx >= 0) { @@ -826,8 +826,8 @@ load(void) static void store(void) { - int idx; - struct value *val; + struct value *val; + int idx; idx = readreg(); if (idx >= 0) { @@ -842,9 +842,9 @@ store(void) static void load_stack(void) { - int idx; - struct stack *stack; - struct value *value; + struct stack *stack; + struct value *value; + int idx; idx = readreg(); if (idx >= 0) { @@ -864,8 +864,8 @@ load_stack(void) static void store_stack(void) { - int idx; - struct value *value; + struct value *value; + int idx; idx = readreg(); if (idx >= 0) { @@ -879,11 +879,12 @@ store_stack(void) static void load_array(void) { - int reg; - struct number *inumber, *n; - u_long idx; - struct stack *stack; - struct value *v, copy; + struct number *inumber, *n; + struct stack *stack; + struct value *v; + struct value copy; + u_long idx; + int reg; reg = readreg(); if (reg >= 0) { @@ -913,11 +914,11 @@ load_array(void) static void store_array(void) { - int reg; - struct number *inumber; - u_long idx; - struct value *value; - struct stack *stack; + struct number *inumber; + struct value *value; + struct stack *stack; + u_long idx; + int reg; reg = readreg(); if (reg >= 0) { @@ -969,8 +970,7 @@ bexec(char *line) static void badd(void) { - struct number *a, *b; - struct number *r; + struct number *a, *b, *r; a = pop_number(); if (a == NULL) { @@ -997,8 +997,7 @@ badd(void) static void bsub(void) { - struct number *a, *b; - struct number *r; + struct number *a, *b, *r; a = pop_number(); if (a == NULL) { @@ -1026,7 +1025,7 @@ bsub(void) void bmul_number(struct number *r, struct number *a, struct number *b) { - BN_CTX *ctx; + BN_CTX *ctx; /* Create copies of the scales, since r might be equal to a or b */ u_int ascale = a->scale; @@ -1048,8 +1047,7 @@ bmul_number(struct number *r, struct number *a, struct number *b) static void bmul(void) { - struct number *a, *b; - struct number *r; + struct number *a, *b, *r; a = pop_number(); if (a == NULL) { @@ -1072,10 +1070,9 @@ bmul(void) static void bdiv(void) { - struct number *a, *b; - struct number *r; - u_int scale; - BN_CTX *ctx; + struct number *a, *b, *r; + BN_CTX *ctx; + u_int scale; a = pop_number(); if (a == NULL) { @@ -1110,10 +1107,9 @@ bdiv(void) static void bmod(void) { - struct number *a, *b; - struct number *r; - u_int scale; - BN_CTX *ctx; + struct number *a, *b, *r; + BN_CTX *ctx; + u_int scale; a = pop_number(); if (a == NULL) { @@ -1148,10 +1144,9 @@ bmod(void) static void bdivmod(void) { - struct number *a, *b; - struct number *rdiv, *rmod; - u_int scale; - BN_CTX *ctx; + struct number *a, *b, *rdiv, *rmod; + BN_CTX *ctx; + u_int scale; a = pop_number(); if (a == NULL) { @@ -1190,10 +1185,9 @@ bdivmod(void) static void bexp(void) { - struct number *a, *p; - struct number *r; - bool neg; - u_int scale; + struct number *a, *p, *r; + u_int scale; + bool neg; p = pop_number(); if (p == NULL) { @@ -1216,8 +1210,8 @@ bexp(void) scale = bmachine.scale; } else { /* Posix bc says min(a.scale * b, max(a.scale, scale) */ - u_long b; - u_int m; + u_long b; + u_int m; b = BN_get_word(p->number); m = max(a->scale, bmachine.scale); @@ -1249,8 +1243,8 @@ bexp(void) } if (neg) { - BN_CTX *ctx; - BIGNUM *one; + BN_CTX *ctx; + BIGNUM *one; one = BN_new(); bn_checkp(one); @@ -1273,8 +1267,8 @@ bexp(void) static bool bsqrt_stop(const BIGNUM *x, const BIGNUM *y, u_int *onecount) { - BIGNUM *r; - bool ret; + BIGNUM *r; + bool ret; r = BN_new(); bn_checkp(r); @@ -1289,11 +1283,10 @@ bsqrt_stop(const BIGNUM *x, const BIGNUM *y, u_int *onecount) static void bsqrt(void) { - struct number *n; - struct number *r; - BIGNUM *x, *y; - u_int scale, onecount; - BN_CTX *ctx; + struct number *n, *r; + BIGNUM *x, *y; + BN_CTX *ctx; + u_int onecount, scale; onecount = 0; n = pop_number(); @@ -1337,7 +1330,7 @@ bsqrt(void) static void not(void) { - struct number *a; + struct number *a; a = pop_number(); if (a == NULL) { @@ -1358,7 +1351,7 @@ equal(void) static void equal_numbers(void) { - struct number *a, *b, *r; + struct number *a, *b, *r; a = pop_number(); if (a == NULL) { @@ -1378,7 +1371,7 @@ equal_numbers(void) static void less_numbers(void) { - struct number *a, *b, *r; + struct number *a, *b, *r; a = pop_number(); if (a == NULL) { @@ -1398,7 +1391,7 @@ less_numbers(void) static void lesseq_numbers(void) { - struct number *a, *b, *r; + struct number *a, *b, *r; a = pop_number(); if (a == NULL) { @@ -1432,6 +1425,7 @@ less(void) static void not_compare(void) { + switch (readch()) { case '<': not_less(); @@ -1473,8 +1467,8 @@ not_greater(void) static bool compare_numbers(enum bcode_compare type, struct number *a, struct number *b) { - u_int scale; - int cmp; + u_int scale; + int cmp; scale = max(a->scale, b->scale); @@ -1508,10 +1502,10 @@ compare_numbers(enum bcode_compare type, struct number *a, struct number *b) static void compare(enum bcode_compare type) { - int idx, elseidx; - struct number *a, *b; - bool ok; - struct value *v; + struct number *a, *b; + struct value *v; + int idx, elseidx; + bool ok; elseidx = NO_ELSE; idx = readreg(); @@ -1558,11 +1552,13 @@ compare(enum bcode_compare type) static void nop(void) { + } static void quit(void) { + if (bmachine.readsp < 2) exit(0); src_free(); @@ -1574,8 +1570,8 @@ quit(void) static void quitN(void) { - struct number *n; - u_long i; + struct number *n; + u_long i; n = pop_number(); if (n == NULL) @@ -1597,8 +1593,8 @@ quitN(void) static void skipN(void) { - struct number *n; - u_long i; + struct number *n; + u_long i; n = pop_number(); if (n == NULL) @@ -1687,7 +1683,7 @@ unknown(void) static void eval_string(char *p) { - int ch; + int ch; if (bmachine.readsp > 0) { /* Check for tail call. Do not recurse in that case. */ @@ -1716,8 +1712,8 @@ static void eval_line(void) { /* Always read from stdin */ - struct source in; - char *p; + struct source in; + char *p; clearerr(stdin); src_setstream(&in, stdin); @@ -1728,7 +1724,7 @@ eval_line(void) static void eval_tos(void) { - char *p; + char *p; p = pop_string(); if (p == NULL) @@ -1739,7 +1735,7 @@ eval_tos(void) void eval(void) { - int ch; + int ch; for (;;) { ch = readch(); diff --git a/usr.bin/dc/bcode.h b/usr.bin/dc/bcode.h index df175fe1bcb..9290cf1b68c 100644 --- a/usr.bin/dc/bcode.h +++ b/usr.bin/dc/bcode.h @@ -58,8 +58,8 @@ struct array { struct stack { struct value *stack; - ssize_t sp; ssize_t size; + ssize_t sp; }; struct source; @@ -72,14 +72,14 @@ struct vtable { }; struct source { - struct vtable *vtable; union { - FILE *stream; struct { u_char *buf; size_t pos; } string; + FILE *stream; } u; + struct vtable *vtable; int lastchar; }; diff --git a/usr.bin/dc/dc.c b/usr.bin/dc/dc.c index 08a95522b86..13766539bdd 100644 --- a/usr.bin/dc/dc.c +++ b/usr.bin/dc/dc.c @@ -59,8 +59,8 @@ usage(void) static void procfile(char *fname) { - FILE *file; - struct stat st; + struct stat st; + FILE *file; file = fopen(fname, "r"); if (file == NULL) @@ -80,9 +80,8 @@ procfile(char *fname) { int main(int argc, char *argv[]) { - int ch; - bool extended_regs = false; - bool preproc_done = false; + int ch; + bool extended_regs = false, preproc_done = false; /* accept and ignore a single dash to be 4.4BSD dc(1) compatible */ while ((ch = getopt_long(argc, argv, "e:f:Vx", long_options, NULL)) != -1) { diff --git a/usr.bin/dc/inout.c b/usr.bin/dc/inout.c index b3239bc8ecf..4a2bb701be6 100644 --- a/usr.bin/dc/inout.c +++ b/usr.bin/dc/inout.c @@ -91,7 +91,7 @@ src_ungetcharstream(struct source *src) static char * src_getlinestream(struct source *src) { - char buf[BUFSIZ]; + char buf[BUFSIZ]; if (fgets(buf, BUFSIZ, src->u.stream) == NULL) return (bstrdup("")); @@ -124,8 +124,8 @@ src_ungetcharstring(struct source *src) static char * src_getlinestring(struct source *src) { - char buf[BUFSIZ]; - int ch, i; + char buf[BUFSIZ]; + int i, ch; i = 0; while (i < BUFSIZ-1) { @@ -173,9 +173,10 @@ putcharwrap(FILE *f, int ch) static void printwrap(FILE *f, const char *p) { - char buf[12]; - char *q = buf; + char *q; + char buf[12]; + q = buf; strlcpy(buf, p, sizeof(buf)); while (*q) putcharwrap(f, *q++); @@ -184,12 +185,11 @@ printwrap(FILE *f, const char *p) struct number * readnumber(struct source *src, u_int base) { - struct number *n; - int ch; - bool sign = false; - bool dot = false; - BN_ULONG v; - u_int i; + struct number *n; + BN_ULONG v; + u_int i; + int ch; + bool dot = false, sign = false; n = new_number(); bn_check(BN_zero(n->number)); @@ -236,9 +236,9 @@ readnumber(struct source *src, u_int base) char * read_string(struct source *src) { - int count, i, sz, new_sz, ch; - char *p; - bool escape; + char *p; + int count, ch, i, new_sz, sz; + bool escape; escape = false; count = 1; @@ -274,7 +274,7 @@ read_string(struct source *src) static char * get_digit(u_long num, int digits, u_int base) { - char *p; + char *p; if (base <= 16) { p = bmalloc(2); @@ -290,13 +290,13 @@ get_digit(u_long num, int digits, u_int base) void printnumber(FILE *f, const struct number *b, u_int base) { - struct number *int_part, *fract_part; - int digits; - char buf[11]; - size_t sz; - unsigned int i; - struct stack stack; - char *p; + struct number *fract_part, *int_part; + struct stack stack; + char *p; + char buf[11]; + size_t sz; + unsigned int i; + int digits; charcount = 0; lastchar = -1; @@ -333,8 +333,8 @@ printnumber(FILE *f, const struct number *b, u_int base) } stack_clear(&stack); if (b->scale > 0) { - struct number *num_base; - BIGNUM mult, stop; + struct number *num_base; + BIGNUM mult, stop; putcharwrap(f, '.'); num_base = new_number(); @@ -347,7 +347,7 @@ printnumber(FILE *f, const struct number *b, u_int base) i = 0; while (BN_cmp(&mult, &stop) < 0) { - u_long rem; + u_long rem; if (i && base > 16) putcharwrap(f, ' '); @@ -396,8 +396,8 @@ print_value(FILE *f, const struct value *value, const char *prefix, u_int base) void print_ascii(FILE *f, const struct number *n) { - BIGNUM *v; - int numbits, i, ch; + BIGNUM *v; + int ch, i, numbits; v = BN_dup(n->number); bn_checkp(v); diff --git a/usr.bin/dc/mem.c b/usr.bin/dc/mem.c index 364d6743cfa..78fb429e260 100644 --- a/usr.bin/dc/mem.c +++ b/usr.bin/dc/mem.c @@ -30,7 +30,7 @@ __FBSDID("$FreeBSD$"); struct number * new_number(void) { - struct number *n; + struct number *n; n = bmalloc(sizeof(*n)); n->scale = 0; @@ -51,7 +51,7 @@ free_number(struct number *n) struct number * dup_number(const struct number *a) { - struct number *n; + struct number *n; n = bmalloc(sizeof(*n)); n->scale = a->scale; @@ -63,7 +63,7 @@ dup_number(const struct number *a) void * bmalloc(size_t sz) { - void *p; + void *p; p = malloc(sz); if (p == NULL) @@ -74,7 +74,7 @@ bmalloc(size_t sz) void * brealloc(void *p, size_t sz) { - void *q; + void *q; q = realloc(p, sz); if (q == NULL) @@ -85,7 +85,7 @@ brealloc(void *p, size_t sz) char * bstrdup(const char *p) { - char *q; + char *q; q = strdup(p); if (q == NULL) diff --git a/usr.bin/dc/stack.c b/usr.bin/dc/stack.c index 775c563f074..950b4e5fdbf 100644 --- a/usr.bin/dc/stack.c +++ b/usr.bin/dc/stack.c @@ -46,7 +46,7 @@ stack_init(struct stack *stack) static __inline bool stack_empty(const struct stack *stack) { - bool empty = stack->sp == -1; + bool empty = stack->sp == -1; if (empty) warnx("stack empty"); @@ -109,8 +109,8 @@ stack_size(const struct stack *stack) void stack_dup(struct stack *stack) { - struct value *value; - struct value copy; + struct value *value; + struct value copy; value = stack_tos(stack); if (value == NULL) { @@ -123,7 +123,7 @@ stack_dup(struct stack *stack) void stack_swap(struct stack *stack) { - struct value copy; + struct value copy; if (stack->sp < 1) { warnx("stack empty"); @@ -137,7 +137,7 @@ stack_swap(struct stack *stack) static void stack_grow(struct stack *stack) { - size_t new_size, i; + size_t i, new_size; if (++stack->sp == stack->size) { new_size = stack->size * 2 + 1; @@ -267,7 +267,7 @@ stack_clear(struct stack *stack) void stack_print(FILE *f, const struct stack *stack, const char *prefix, u_int base) { - ssize_t i; + ssize_t i; for (i = stack->sp; i >= 0; i--) { print_value(f, &stack->stack[i], prefix, base); @@ -279,7 +279,7 @@ stack_print(FILE *f, const struct stack *stack, const char *prefix, u_int base) static struct array * array_new(void) { - struct array *a; + struct array *a; a = bmalloc(sizeof(*a)); a->data = NULL; @@ -290,7 +290,7 @@ array_new(void) static __inline void array_free(struct array *a) { - size_t i; + size_t i; if (a == NULL) return; @@ -303,8 +303,8 @@ array_free(struct array *a) static struct array * array_dup(const struct array *a) { - struct array *n; - size_t i; + struct array *n; + size_t i; if (a == NULL) return (NULL); @@ -318,7 +318,7 @@ array_dup(const struct array *a) static __inline void array_grow(struct array *array, size_t newsize) { - size_t i; + size_t i; array->data = brealloc(array->data, newsize * sizeof(*array->data)); for (i = array->size; i < newsize; i++) { @@ -350,8 +350,8 @@ array_retrieve(const struct array *array, size_t i) void frame_assign(struct stack *stack, size_t i, const struct value *v) { - struct array *a; - struct value n; + struct array *a; + struct value n; if (stack->sp == -1) { n.type = BCODE_NONE; @@ -368,7 +368,7 @@ frame_assign(struct stack *stack, size_t i, const struct value *v) struct value * frame_retrieve(const struct stack *stack, size_t i) { - struct array *a; + struct array *a; if (stack->sp == -1) return (NULL);