Changing domain name
[llvm-complete.git] / utils / Burg / string.c
blob351d5383a51acbf503a20e72f8f55343d701226e
1 char rcsid_string[] = "$Id$";
3 #include <stdio.h>
4 #include <string.h>
5 #include "b.h"
6 #include "fe.h"
8 static StrTableElement newStrTableElement ARGS((void));
10 StrTable
11 newStrTable()
13 return (StrTable) zalloc(sizeof(struct strTable));
16 static StrTableElement
17 newStrTableElement()
19 return (StrTableElement) zalloc(sizeof(struct strTableElement));
22 void
23 dumpStrTable(t) StrTable t;
25 List e;
26 IntList r;
28 printf("Begin StrTable\n");
29 for (e = t->elems; e; e = e->next) {
30 StrTableElement el = (StrTableElement) e->x;
31 printf("%s: ", el->str);
32 for (r = el->erulenos; r; r = r->next) {
33 int i = r->x;
34 printf("(%d)", i);
36 printf("\n");
38 printf("End StrTable\n");
41 StrTableElement
42 addString(t, s, eruleno, new) StrTable t; char *s; int eruleno; int *new;
44 List l;
45 StrTableElement ste;
47 assert(t);
48 for (l = t->elems; l; l = l->next) {
49 StrTableElement e = (StrTableElement) l->x;
51 assert(e);
52 if (!strcmp(s, e->str)) {
53 e->erulenos = newIntList(eruleno, e->erulenos);
54 *new = 0;
55 return e;
58 ste = newStrTableElement();
59 ste->erulenos = newIntList(eruleno, 0);
60 ste->str = (char *) zalloc(strlen(s) + 1);
61 strcpy(ste->str, s);
62 t->elems = newList(ste, t->elems);
63 *new = 1;
64 return ste;