Fixed a few bugs
authorceriel <none@none>
Wed, 31 Oct 1990 15:56:51 +0000 (15:56 +0000)
committerceriel <none@none>
Wed, 31 Oct 1990 15:56:51 +0000 (15:56 +0000)
util/grind/c.c
util/grind/commands.g
util/grind/db_symtab.g
util/grind/expr.c
util/grind/modula-2.c
util/grind/symbol.c
util/grind/type.c

index 4f8e753..3c63709 100644 (file)
@@ -73,6 +73,7 @@ static int
 printchar(c, esc)
   int  c;
 {
+  c &= 0377;
   switch(c) {
   case '\n':
        fputs("\\n", db_out);
index d1c7eee..dd0fffb 100644 (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 */
+                       }
 |
 ]
 ;
index fb3cc48..0a856b0 100644 (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;
index 6410ef7..40cf34c 100644 (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;
 }
index 3a47719..ac55695 100644 (file)
@@ -72,6 +72,7 @@ static int
 print_char(c)
   int  c;
 {
+  c &= 0377;
   fprintf(db_out, (c >= 040 && c < 0177) ? "'%c'" : "%oC", c);
 }
 
index afd85fa..94439d1 100644 (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;
   }
index eef2aa2..c4d5de6 100644 (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);
                }
        }