Fixed a few bugs

This commit is contained in:
ceriel 1990-10-31 15:56:51 +00:00
parent 162c1c81e9
commit 9aee9cb62f
7 changed files with 48 additions and 12 deletions

View file

@ -73,6 +73,7 @@ static int
printchar(c, esc)
int c;
{
c &= 0377;
switch(c) {
case '\n':
fputs("\\n", db_out);

View file

@ -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 */
}
|
]
;

View file

@ -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;

View file

@ -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;
}

View file

@ -72,6 +72,7 @@ static int
print_char(c)
int c;
{
c &= 0377;
fprintf(db_out, (c >= 040 && c < 0177) ? "'%c'" : "%oC", c);
}

View file

@ -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;
}

View file

@ -5,6 +5,7 @@
#include <alloc.h>
#include <assert.h>
#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);
}
}