diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2010-05-25 21:15:16 +0200 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2013-10-29 16:30:52 +0100 |
commit | a971aeabb4caf06339d9c53265b034d3cd9349bd (patch) | |
tree | 028409a225d3fae4ac56b615d79f0ea1d333cff7 /bcc/table.c | |
parent | 34f2fd6c579bf4d59f08820711ff8a3e2bf20429 (diff) | |
download | dev86-a971aeabb4caf06339d9c53265b034d3cd9349bd.tar.gz |
Add support for K&R-style anonymous structures and unions
Diffstat (limited to 'bcc/table.c')
-rw-r--r-- | bcc/table.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/bcc/table.c b/bcc/table.c index 166c143..e863fb5 100644 --- a/bcc/table.c +++ b/bcc/table.c @@ -691,3 +691,41 @@ PUBLIC void syminit() addkeyword(kwptr->kwname, kwptr->kwcode); constemplate.type = itype; } + +#ifndef VERY_SMALL_MEMORY +PUBLIC struct symstruct *findstrm(type, name) +struct typestruct *type; +char *name; +{ + struct symstruct *symptr; + int i; + char anon[2 + NAMESIZE]; + struct typelist *tl; + + /* Look for a struct member named as given */ + name[0] = type->structkey[0]; + name[1] = type->structkey[1]; + if ((symptr = findlorg(name)) != NULL) + return symptr; + + /* No match? Fine, let's see if there are any anynymous structures + * or unions that we could recurse into */ + for (i = 0; i < lastanon(); i++) + { + anon[0] = type->structkey[0]; + anon[1] = type->structkey[1]; + anonname(&anon[2], i); + if ((symptr = findlorg(anon)) != NULL) + { + /* Found an anonymous struture */ + if (!(symptr->type->constructor & STRUCTU)) + error("Anonymous structure not a structure?!"); + /* Look for the member */ + strcpy(&anon[2], &name[2]); + if ((symptr = findstrm(symptr->type, anon)) != NULL) + return symptr; + } + } + return NULL; +} +#endif |