More indentation, spacing, and style fixes in sc1.c.

This commit is contained in:
David Anderson 2014-07-20 11:50:57 -07:00
parent 16177e9ecc
commit 8aa28e2c8d

View File

@ -2913,100 +2913,81 @@ static void check_struct_name(const char *name)
*/ */
static void declstruct(void) static void declstruct(void)
{ {
cell val; cell val;
char *str; char *str;
int tok; int tok;
pstruct_t *pstruct; pstruct_t *pstruct;
int size; int size;
/* get the explicit tag (required!) */ /* get the explicit tag (required!) */
tok = lex(&val,&str); tok = lex(&val,&str);
if (tok != tSYMBOL) if (tok != tSYMBOL)
{ error(93);
error(93);
}
check_struct_name(str); check_struct_name(str);
pstruct = pstructs_add(str); pstruct = pstructs_add(str);
int flags = STRUCTTAG; int flags = STRUCTTAG;
if (isupper(*pstruct->name)) if (isupper(*pstruct->name))
flags |= FIXEDTAG; flags |= FIXEDTAG;
pc_addtag_flags(pstruct->name, flags); pc_addtag_flags(pstruct->name, flags);
needtoken('{'); needtoken('{');
do do {
{ structarg_t arg;
structarg_t arg; if (matchtoken('}')) {
if (matchtoken('}')) /* Quick exit */
{ lexpush();
/* Quick exit */ break;
lexpush(); }
break; memset(&arg, 0, sizeof(structarg_t));
} tok = lex(&val,&str);
memset(&arg, 0, sizeof(structarg_t)); if (tok == tCONST) {
tok = lex(&val,&str); arg.fconst = 1;
if (tok == tCONST) tok = lex(&val,&str);
{ }
arg.fconst = 1; arg.ident = 0;
tok = lex(&val,&str); if (tok == '&') {
} arg.ident = iREFERENCE;
arg.ident = 0; tok = lex(&val,&str);
if (tok == '&') }
{ if (tok == tLABEL) {
arg.ident = iREFERENCE; arg.tag = pc_addtag(str);
tok = lex(&val,&str); tok = lex(&val,&str);
} }
if (tok == tLABEL) if (tok != tSYMBOL) {
{ error(1, "-identifier-", str);
arg.tag = pc_addtag(str); continue;
tok = lex(&val,&str); }
} strcpy(arg.name, str);
if (tok != tSYMBOL) if (matchtoken('[')) {
{ if (arg.ident == iREFERENCE)
error(1, "-identifier-", str); error(67, arg.name);
continue; arg.ident = iARRAY;
} do {
strcpy(arg.name, str); constvalue *enumroot;
if (matchtoken('[')) int ignore_tag;
{ if (arg.dimcount == sDIMEN_MAX) {
if (arg.ident == iREFERENCE) error(53);
{ break;
error(67, arg.name); }
} size = needsub(&ignore_tag, &enumroot);
arg.ident = iARRAY; arg.dims[arg.dimcount++] = size;
do } while (matchtoken('['));
{ /* Handle strings */
constvalue *enumroot; if (arg.tag == pc_tag_string && arg.dims[arg.dimcount-1])
int ignore_tag; arg.dims[arg.dimcount-1] = (size + sizeof(cell)-1) / sizeof(cell);
if (arg.dimcount == sDIMEN_MAX) if (arg.dimcount == 1 && !arg.dims[arg.dimcount-1])
{ arg.ident = iREFARRAY;
error(53); } else if (!arg.ident) {
break; arg.ident = iVARIABLE;
} }
size = needsub(&ignore_tag, &enumroot); if (pstructs_addarg(pstruct, &arg) == NULL)
arg.dims[arg.dimcount++] = size; error(103, arg.name, layout_spec_name(Layout_PawnStruct));
} while (matchtoken('[')); } while (matchtoken(','));
/* Handle strings */ needtoken('}');
if (arg.tag == pc_tag_string && arg.dims[arg.dimcount-1]) matchtoken(';'); /* eat up optional semicolon */
{
arg.dims[arg.dimcount-1] = (size + sizeof(cell)-1) / sizeof(cell);
}
if (arg.dimcount == 1 && !arg.dims[arg.dimcount-1])
{
arg.ident = iREFARRAY;
}
} else if (!arg.ident) {
arg.ident = iVARIABLE;
}
if (pstructs_addarg(pstruct, &arg) == NULL)
{
error(103, arg.name, layout_spec_name(Layout_PawnStruct));
}
} while (matchtoken(','));
needtoken('}');
matchtoken(';'); /* eat up optional semicolon */
} }
// Consumes a line, returns FALSE if EOF hit. // Consumes a line, returns FALSE if EOF hit.