From: ceriel Date: Wed, 31 Oct 1990 15:56:51 +0000 (+0000) Subject: Fixed a few bugs X-Git-Tag: release-5-5~1458 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=9aee9cb62f9f7d91104f5ffab0c25a6ed497345a;p=ack.git Fixed a few bugs --- diff --git a/util/grind/c.c b/util/grind/c.c index 4f8e7534f..3c6370997 100644 --- a/util/grind/c.c +++ b/util/grind/c.c @@ -73,6 +73,7 @@ static int printchar(c, esc) int c; { + c &= 0377; switch(c) { case '\n': fputs("\\n", db_out); diff --git a/util/grind/commands.g b/util/grind/commands.g index d1c7eeeb2..dd0fffb22 100644 --- a/util/grind/commands.g +++ b/util/grind/commands.g @@ -45,6 +45,7 @@ commands int give_prompt; } : + { errorgiven = 0; } [ %persistent command_line(&com) [ '\n' { give_prompt = 1; } | %default ';' { give_prompt = 0; } @@ -109,7 +110,9 @@ command_line(p_tree *p;) | FIND qualified_name(p){ *p = mknode(OP_FIND, *p); } | WHICH qualified_name(p){ *p = mknode(OP_WHICH, *p); } | able_command(p) -| '!' { shellescape(); } +| '!' { shellescape(); + errorgiven = 1; /* to prevent execution of lastcomm */ + } | ] ; diff --git a/util/grind/db_symtab.g b/util/grind/db_symtab.g index fb3cc4853..0a856b04f 100644 --- a/util/grind/db_symtab.g +++ b/util/grind/db_symtab.g @@ -786,6 +786,7 @@ DbRead(f) /* another N_SO follows ... */ break; } + clean_tp_tab(); while (CurrentScope != PervasiveScope) { close_scope(); } @@ -796,7 +797,6 @@ DbRead(f) open_scope(sym, 0); sym->sy_file->f_scope = CurrentScope; FileScope = CurrentScope; - clean_tp_tab(); /* fall through */ case N_SOL: if (! line_file) line_file = n; diff --git a/util/grind/expr.c b/util/grind/expr.c index 6410ef751..40cf34c52 100644 --- a/util/grind/expr.c +++ b/util/grind/expr.c @@ -158,7 +158,7 @@ convert(pbuf, psize, ptp, tp, size) malloc_succeeded(*pbuf); } if ((*ptp)->ty_class == T_SUBRANGE) *ptp = (*ptp)->ty_base; - switch((*ptp)->ty_class) { + if (tp && *ptp) switch((*ptp)->ty_class) { case T_INTEGER: case T_UNSIGNED: case T_POINTER: @@ -1154,6 +1154,12 @@ eval_expr(p, pbuf, psize, ptp) } *psize = 0; } + else { + if ((*ptp)->ty_class == T_CROSS) { + *ptp = (*ptp)->ty_cross; + if (! *ptp) *ptp = void_type; + } + } return retval; } @@ -1222,5 +1228,17 @@ eval_desig(p, paddr, psize, ptp) if (! retval) { *psize = 0; } + else { + if ((*ptp)->ty_class == T_CROSS) { + *ptp = (*ptp)->ty_cross; + if (! *ptp) { + *ptp = void_type; + print_node(p, 0); + fputs(" designator has unknown type\n", db_out); + retval = 0; + *psize = 0; + } + } + } return retval; } diff --git a/util/grind/modula-2.c b/util/grind/modula-2.c index 3a47719ff..ac5569530 100644 --- a/util/grind/modula-2.c +++ b/util/grind/modula-2.c @@ -72,6 +72,7 @@ static int print_char(c) int c; { + c &= 0377; fprintf(db_out, (c >= 040 && c < 0177) ? "'%c'" : "%oC", c); } diff --git a/util/grind/symbol.c b/util/grind/symbol.c index afd85faf5..94439d16b 100644 --- a/util/grind/symbol.c +++ b/util/grind/symbol.c @@ -350,6 +350,7 @@ resolve_cross(tp) sym->sy_type->ty_size == tp->ty_class && scope_encloses(tp->ty_sym->sy_scope, sym->sy_scope)) { sym->sy_type->ty_cross = tp; + sym->sy_type->ty_size = tp->ty_size; } sym = sym->sy_next; } diff --git a/util/grind/type.c b/util/grind/type.c index eef2aa20d..c4d5de695 100644 --- a/util/grind/type.c +++ b/util/grind/type.c @@ -5,6 +5,7 @@ #include #include +#include "idf.h" #include "type.h" #include "sizes.h" #include "symbol.h" @@ -275,7 +276,7 @@ init_types() */ static struct tp_index { unsigned len; - p_type *row; + p_type **row; } *list_row; static unsigned list_len; @@ -301,16 +302,19 @@ tp_lookup(type_index) } p = &list_row[type_index[0]]; while (type_index[1] >= p->len) { + int indx = p->len/NINCR; + p->len += NINCR; if (p->len) { - p->row = (p_type *) Realloc((char *) p->row, - (p->len += NINCR) * sizeof(p_type)); + p->row = (p_type **) Realloc((char *) p->row, + (unsigned) (indx + 1) * sizeof(p_type *)); } - else p->row = (p_type *) Malloc((p->len = NINCR) * sizeof(p_type)); - for (i = NINCR; i > 0; i--) { - p->row[p->len - i] = 0; + else p->row = (p_type **) Malloc(sizeof(p_type *)); + p->row[indx] = (p_type *) Malloc(NINCR * sizeof(p_type)); + for (i = NINCR-1; i >= 0; i--) { + p->row[indx][i] = 0; } } - return &(p->row[type_index[1]]); + return &(p->row[type_index[1]/NINCR][type_index[1]%NINCR]); } clean_tp_tab() @@ -322,11 +326,19 @@ clean_tp_tab() register int j = list_row[i].len; if (j) { while (--j > 0) { - p_type p = list_row[i].row[j]; + p_type p = list_row[i].row[j/NINCR][j%NINCR]; if (p && p->ty_class == 0) { - error("incomplete type (%d,%d) 0x%x", i, j, &list_row[i].row[j]); + error("%s: incomplete type (%d,%d)", + listfile->sy_idf->id_text, + i, + j); } } + j = list_row[i].len; + while (j > 0) { + free((char *) list_row[i].row[j/NINCR-1]); + j -= NINCR; + } free((char *) list_row[i].row); } }