From: Peter Johnson Date: Sun, 19 Aug 2001 05:41:01 +0000 (-0000) Subject: Use STAILQ's for datavals and bytecodes. X-Git-Tag: v0.1.0~365 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ae600ce4425b48a59b940b520bc9b3241ac4a673;p=yasm Use STAILQ's for datavals and bytecodes. svn path=/trunk/yasm/; revision=146 --- diff --git a/frontends/yasm/yasm.c b/frontends/yasm/yasm.c index f1075991..54eba8f4 100644 --- a/frontends/yasm/yasm.c +++ b/frontends/yasm/yasm.c @@ -1,4 +1,4 @@ -/* $Id: yasm.c,v 1.7 2001/08/19 03:52:58 peter Exp $ +/* $Id: yasm.c,v 1.8 2001/08/19 05:41:01 peter Exp $ * Program entry point, command line parsing * * Copyright (C) 2001 Peter Johnson @@ -19,9 +19,14 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include #include #include +#include "util.h" #include "bytecode.h" #include "section.h" #include "outfmt.h" diff --git a/libyasm/bytecode.c b/libyasm/bytecode.c index b86e86e7..22612e8d 100644 --- a/libyasm/bytecode.c +++ b/libyasm/bytecode.c @@ -1,4 +1,4 @@ -/* $Id: bytecode.c,v 1.16 2001/08/19 03:52:58 peter Exp $ +/* $Id: bytecode.c,v 1.17 2001/08/19 05:41:01 peter Exp $ * Bytecode utility functions * * Copyright (C) 2001 Peter Johnson @@ -19,9 +19,14 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include #include #include +#include "util.h" #include "globals.h" #include "bytecode.h" #include "errwarn.h" @@ -255,7 +260,6 @@ BuildBC_Insn(bytecode *bc, unsigned char im_len, unsigned char im_sign) { - bc->next = (bytecode *)NULL; bc->type = BC_INSN; if (ea_ptr) { @@ -306,7 +310,6 @@ BuildBC_JmpRel(bytecode *bc, unsigned char near_op2, unsigned char addrsize) { - bc->next = (bytecode *)NULL; bc->type = BC_JMPREL; bc->data.jmprel.target = target->val; @@ -341,9 +344,9 @@ BuildBC_JmpRel(bytecode *bc, } void -BuildBC_Data(bytecode *bc, dataval *data, unsigned long size) +BuildBC_Data(bytecode *bc, datavalhead *datahead, unsigned long size) { - dataval *cur = data; + dataval *cur; /* First check to see if all the data elements are valid for the size * being set. @@ -359,7 +362,7 @@ BuildBC_Data(bytecode *bc, dataval *data, unsigned long size) * constants (equ's) should always be legal, but labels should raise * warnings when used in db or dq context at the minimum). */ - while (cur) { + STAILQ_FOREACH(cur, datahead, link) { switch (cur->type) { case DV_EMPTY: case DV_STRING: @@ -376,13 +379,11 @@ BuildBC_Data(bytecode *bc, dataval *data, unsigned long size) Error(ERR_DECLDATA_EXPR, (char *)NULL, "DT"); break; } - cur = cur->next; } - bc->next = (bytecode *)NULL; bc->type = BC_DATA; - bc->data.data.data = data; + bc->data.data.datahead = *datahead; bc->data.data.size = size; BuildBC_Common(bc); @@ -391,7 +392,6 @@ BuildBC_Data(bytecode *bc, dataval *data, unsigned long size) void BuildBC_Reserve(bytecode *bc, expr *numitems, unsigned long itemsize) { - bc->next = (bytecode *)NULL; bc->type = BC_RESERVE; bc->data.reserve.numitems = numitems; @@ -502,7 +502,7 @@ DebugPrintBC(bytecode *bc) printf("Final Element Size=%u\n", (unsigned int)bc->data.data.size); printf("Elements:\n"); - dataval_print(bc->data.data.data); + dataval_print(&bc->data.data.datahead); break; case BC_RESERVE: printf("_Reserve_\n"); @@ -528,8 +528,6 @@ dataval_new_expr(expr *exp) if (!retval) Fatal(FATAL_NOMEM); - retval->next = (dataval *)NULL; - retval->last = retval; retval->type = DV_EXPR; retval->data.exp = exp; @@ -544,8 +542,6 @@ dataval_new_float(double float_val) if (!retval) Fatal(FATAL_NOMEM); - retval->next = (dataval *)NULL; - retval->last = retval; retval->type = DV_FLOAT; retval->data.float_val = float_val; @@ -560,39 +556,18 @@ dataval_new_string(char *str_val) if (!retval) Fatal(FATAL_NOMEM); - retval->next = (dataval *)NULL; - retval->last = retval; retval->type = DV_STRING; retval->data.str_val = str_val; return retval; } -dataval * -dataval_append(dataval *list, dataval *item) -{ - if (item) - item->next = (dataval *)NULL; - - if (!list) { - item->last = item; - return item; - } else { - if (item) { - list->last->next = item; - list->last = item; - item->last = (dataval *)NULL; - } - return list; - } -} - void -dataval_print(dataval *start) +dataval_print(datavalhead *head) { - dataval *cur = start; + dataval *cur; - while (cur) { + STAILQ_FOREACH(cur, head, link) { switch (cur->type) { case DV_EMPTY: printf(" Empty\n"); @@ -609,7 +584,5 @@ dataval_print(dataval *start) printf(" String=%s\n", cur->data.str_val); break; } - - cur = cur->next; } } diff --git a/libyasm/bytecode.h b/libyasm/bytecode.h index f6874c01..bb69f8db 100644 --- a/libyasm/bytecode.h +++ b/libyasm/bytecode.h @@ -1,4 +1,4 @@ -/* $Id: bytecode.h,v 1.16 2001/08/19 03:52:58 peter Exp $ +/* $Id: bytecode.h,v 1.17 2001/08/19 05:41:01 peter Exp $ * Bytecode utility functions header file * * Copyright (C) 2001 Peter Johnson @@ -47,8 +47,10 @@ typedef struct immval_s { unsigned char f_sign; /* 1 if final imm should be signed */ } immval; +typedef STAILQ_HEAD(datavalhead_s, dataval_s) datavalhead; + typedef struct dataval_s { - struct dataval_s *next, *last; + STAILQ_ENTRY(dataval_s) link; enum { DV_EMPTY, DV_EXPR, DV_FLOAT, DV_STRING } type; @@ -74,7 +76,7 @@ typedef struct targetval_s { } targetval; typedef struct bytecode_s { - struct bytecode_s *next; + STAILQ_ENTRY(bytecode_s) link; enum { BC_EMPTY, BC_INSN, BC_JMPREL, BC_DATA, BC_RESERVE } type; @@ -109,7 +111,8 @@ typedef struct bytecode_s { unsigned char lockrep_pre; /* 0 indicates no prefix */ } jmprel; struct { - dataval *data; /* non-converted data (linked list) */ + /* non-converted data (linked list) */ + datavalhead datahead; /* final (converted) size of each element (in bytes) */ unsigned char size; @@ -173,7 +176,7 @@ void BuildBC_JmpRel(bytecode *bc, unsigned char near_op2, unsigned char addrsize); -void BuildBC_Data(bytecode *bc, dataval *data, unsigned long size); +void BuildBC_Data(bytecode *bc, datavalhead *datahead, unsigned long size); void BuildBC_Reserve(bytecode *bc, struct expr_s *numitems, @@ -187,6 +190,6 @@ dataval *dataval_new_string(char *str_val); dataval *dataval_append(dataval *list, dataval *item); -void dataval_print(dataval *start); +void dataval_print(datavalhead *head); #endif diff --git a/modules/parsers/nasm/bison.y.in b/modules/parsers/nasm/bison.y.in index d0903e66..28590b86 100644 --- a/modules/parsers/nasm/bison.y.in +++ b/modules/parsers/nasm/bison.y.in @@ -1,4 +1,4 @@ -/* $Id: bison.y.in,v 1.23 2001/08/19 02:15:18 peter Exp $ +/* $Id: bison.y.in,v 1.24 2001/08/19 05:41:01 peter Exp $ * Main bison parser * * Copyright (C) 2001 Peter Johnson, Michael Urman @@ -20,8 +20,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ %{ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include #include +#include "util.h" #include "symrec.h" #include "globals.h" #include "bytecode.h" @@ -52,6 +57,7 @@ void nasm_parser_error(char *); expr *exp; immval im_val; targetval tgt_val; + datavalhead datahead; dataval *data; bytecode bc; } @@ -93,7 +99,8 @@ void nasm_parser_error(char *); %type explabel %type label_id %type target -%type dataval datavals +%type dataval +%type datavals %left '|' %left '^' @@ -121,12 +128,18 @@ line: '\n' { $$.type = BC_EMPTY; } ; exp: instr - | DECLARE_DATA datavals { BuildBC_Data(&$$, $2, $1); } + | DECLARE_DATA datavals { BuildBC_Data(&$$, &$2, $1); } | RESERVE_SPACE expr { BuildBC_Reserve(&$$, $2, $1); } ; -datavals: dataval - | datavals ',' dataval { $$ = dataval_append($1, $3); } +datavals: dataval { + STAILQ_INIT(&$$); + STAILQ_INSERT_TAIL(&$$, $1, link); + } + | datavals ',' dataval { + STAILQ_INSERT_TAIL(&$1, $3, link); + $$ = $1; + } ; dataval: expr_no_string { $$ = dataval_new_expr($1); } diff --git a/modules/parsers/nasm/nasm-bison.y b/modules/parsers/nasm/nasm-bison.y index d5ff200a..1516e866 100644 --- a/modules/parsers/nasm/nasm-bison.y +++ b/modules/parsers/nasm/nasm-bison.y @@ -1,4 +1,4 @@ -/* $Id: nasm-bison.y,v 1.23 2001/08/19 02:15:18 peter Exp $ +/* $Id: nasm-bison.y,v 1.24 2001/08/19 05:41:01 peter Exp $ * Main bison parser * * Copyright (C) 2001 Peter Johnson, Michael Urman @@ -20,8 +20,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ %{ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include #include +#include "util.h" #include "symrec.h" #include "globals.h" #include "bytecode.h" @@ -52,6 +57,7 @@ void nasm_parser_error(char *); expr *exp; immval im_val; targetval tgt_val; + datavalhead datahead; dataval *data; bytecode bc; } @@ -93,7 +99,8 @@ void nasm_parser_error(char *); %type explabel %type label_id %type target -%type dataval datavals +%type dataval +%type datavals %left '|' %left '^' @@ -121,12 +128,18 @@ line: '\n' { $$.type = BC_EMPTY; } ; exp: instr - | DECLARE_DATA datavals { BuildBC_Data(&$$, $2, $1); } + | DECLARE_DATA datavals { BuildBC_Data(&$$, &$2, $1); } | RESERVE_SPACE expr { BuildBC_Reserve(&$$, $2, $1); } ; -datavals: dataval - | datavals ',' dataval { $$ = dataval_append($1, $3); } +datavals: dataval { + STAILQ_INIT(&$$); + STAILQ_INSERT_TAIL(&$$, $1, link); + } + | datavals ',' dataval { + STAILQ_INSERT_TAIL(&$1, $3, link); + $$ = $1; + } ; dataval: expr_no_string { $$ = dataval_new_expr($1); } diff --git a/modules/parsers/nasm/nasm-parser.c b/modules/parsers/nasm/nasm-parser.c index 15a24c3a..92a2df18 100644 --- a/modules/parsers/nasm/nasm-parser.c +++ b/modules/parsers/nasm/nasm-parser.c @@ -1,4 +1,4 @@ -/* $Id: nasm-parser.c,v 1.3 2001/08/19 02:57:02 peter Exp $ +/* $Id: nasm-parser.c,v 1.4 2001/08/19 05:41:01 peter Exp $ * NASM-compatible parser * * Copyright (C) 2001 Peter Johnson @@ -19,7 +19,12 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include +#include "util.h" #include "bytecode.h" #include "section.h" #include "outfmt.h" diff --git a/modules/parsers/nasm/parser.c b/modules/parsers/nasm/parser.c index ccfcf2a2..feaddd1d 100644 --- a/modules/parsers/nasm/parser.c +++ b/modules/parsers/nasm/parser.c @@ -1,4 +1,4 @@ -/* $Id: parser.c,v 1.3 2001/08/19 02:57:02 peter Exp $ +/* $Id: parser.c,v 1.4 2001/08/19 05:41:01 peter Exp $ * NASM-compatible parser * * Copyright (C) 2001 Peter Johnson @@ -19,7 +19,12 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include +#include "util.h" #include "bytecode.h" #include "section.h" #include "outfmt.h" diff --git a/src/bytecode.c b/src/bytecode.c index b86e86e7..22612e8d 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -1,4 +1,4 @@ -/* $Id: bytecode.c,v 1.16 2001/08/19 03:52:58 peter Exp $ +/* $Id: bytecode.c,v 1.17 2001/08/19 05:41:01 peter Exp $ * Bytecode utility functions * * Copyright (C) 2001 Peter Johnson @@ -19,9 +19,14 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include #include #include +#include "util.h" #include "globals.h" #include "bytecode.h" #include "errwarn.h" @@ -255,7 +260,6 @@ BuildBC_Insn(bytecode *bc, unsigned char im_len, unsigned char im_sign) { - bc->next = (bytecode *)NULL; bc->type = BC_INSN; if (ea_ptr) { @@ -306,7 +310,6 @@ BuildBC_JmpRel(bytecode *bc, unsigned char near_op2, unsigned char addrsize) { - bc->next = (bytecode *)NULL; bc->type = BC_JMPREL; bc->data.jmprel.target = target->val; @@ -341,9 +344,9 @@ BuildBC_JmpRel(bytecode *bc, } void -BuildBC_Data(bytecode *bc, dataval *data, unsigned long size) +BuildBC_Data(bytecode *bc, datavalhead *datahead, unsigned long size) { - dataval *cur = data; + dataval *cur; /* First check to see if all the data elements are valid for the size * being set. @@ -359,7 +362,7 @@ BuildBC_Data(bytecode *bc, dataval *data, unsigned long size) * constants (equ's) should always be legal, but labels should raise * warnings when used in db or dq context at the minimum). */ - while (cur) { + STAILQ_FOREACH(cur, datahead, link) { switch (cur->type) { case DV_EMPTY: case DV_STRING: @@ -376,13 +379,11 @@ BuildBC_Data(bytecode *bc, dataval *data, unsigned long size) Error(ERR_DECLDATA_EXPR, (char *)NULL, "DT"); break; } - cur = cur->next; } - bc->next = (bytecode *)NULL; bc->type = BC_DATA; - bc->data.data.data = data; + bc->data.data.datahead = *datahead; bc->data.data.size = size; BuildBC_Common(bc); @@ -391,7 +392,6 @@ BuildBC_Data(bytecode *bc, dataval *data, unsigned long size) void BuildBC_Reserve(bytecode *bc, expr *numitems, unsigned long itemsize) { - bc->next = (bytecode *)NULL; bc->type = BC_RESERVE; bc->data.reserve.numitems = numitems; @@ -502,7 +502,7 @@ DebugPrintBC(bytecode *bc) printf("Final Element Size=%u\n", (unsigned int)bc->data.data.size); printf("Elements:\n"); - dataval_print(bc->data.data.data); + dataval_print(&bc->data.data.datahead); break; case BC_RESERVE: printf("_Reserve_\n"); @@ -528,8 +528,6 @@ dataval_new_expr(expr *exp) if (!retval) Fatal(FATAL_NOMEM); - retval->next = (dataval *)NULL; - retval->last = retval; retval->type = DV_EXPR; retval->data.exp = exp; @@ -544,8 +542,6 @@ dataval_new_float(double float_val) if (!retval) Fatal(FATAL_NOMEM); - retval->next = (dataval *)NULL; - retval->last = retval; retval->type = DV_FLOAT; retval->data.float_val = float_val; @@ -560,39 +556,18 @@ dataval_new_string(char *str_val) if (!retval) Fatal(FATAL_NOMEM); - retval->next = (dataval *)NULL; - retval->last = retval; retval->type = DV_STRING; retval->data.str_val = str_val; return retval; } -dataval * -dataval_append(dataval *list, dataval *item) -{ - if (item) - item->next = (dataval *)NULL; - - if (!list) { - item->last = item; - return item; - } else { - if (item) { - list->last->next = item; - list->last = item; - item->last = (dataval *)NULL; - } - return list; - } -} - void -dataval_print(dataval *start) +dataval_print(datavalhead *head) { - dataval *cur = start; + dataval *cur; - while (cur) { + STAILQ_FOREACH(cur, head, link) { switch (cur->type) { case DV_EMPTY: printf(" Empty\n"); @@ -609,7 +584,5 @@ dataval_print(dataval *start) printf(" String=%s\n", cur->data.str_val); break; } - - cur = cur->next; } } diff --git a/src/bytecode.h b/src/bytecode.h index f6874c01..bb69f8db 100644 --- a/src/bytecode.h +++ b/src/bytecode.h @@ -1,4 +1,4 @@ -/* $Id: bytecode.h,v 1.16 2001/08/19 03:52:58 peter Exp $ +/* $Id: bytecode.h,v 1.17 2001/08/19 05:41:01 peter Exp $ * Bytecode utility functions header file * * Copyright (C) 2001 Peter Johnson @@ -47,8 +47,10 @@ typedef struct immval_s { unsigned char f_sign; /* 1 if final imm should be signed */ } immval; +typedef STAILQ_HEAD(datavalhead_s, dataval_s) datavalhead; + typedef struct dataval_s { - struct dataval_s *next, *last; + STAILQ_ENTRY(dataval_s) link; enum { DV_EMPTY, DV_EXPR, DV_FLOAT, DV_STRING } type; @@ -74,7 +76,7 @@ typedef struct targetval_s { } targetval; typedef struct bytecode_s { - struct bytecode_s *next; + STAILQ_ENTRY(bytecode_s) link; enum { BC_EMPTY, BC_INSN, BC_JMPREL, BC_DATA, BC_RESERVE } type; @@ -109,7 +111,8 @@ typedef struct bytecode_s { unsigned char lockrep_pre; /* 0 indicates no prefix */ } jmprel; struct { - dataval *data; /* non-converted data (linked list) */ + /* non-converted data (linked list) */ + datavalhead datahead; /* final (converted) size of each element (in bytes) */ unsigned char size; @@ -173,7 +176,7 @@ void BuildBC_JmpRel(bytecode *bc, unsigned char near_op2, unsigned char addrsize); -void BuildBC_Data(bytecode *bc, dataval *data, unsigned long size); +void BuildBC_Data(bytecode *bc, datavalhead *datahead, unsigned long size); void BuildBC_Reserve(bytecode *bc, struct expr_s *numitems, @@ -187,6 +190,6 @@ dataval *dataval_new_string(char *str_val); dataval *dataval_append(dataval *list, dataval *item); -void dataval_print(dataval *start); +void dataval_print(datavalhead *head); #endif diff --git a/src/main.c b/src/main.c index e5c9b535..53c288bc 100644 --- a/src/main.c +++ b/src/main.c @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.7 2001/08/19 03:52:58 peter Exp $ +/* $Id: main.c,v 1.8 2001/08/19 05:41:01 peter Exp $ * Program entry point, command line parsing * * Copyright (C) 2001 Peter Johnson @@ -19,9 +19,14 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include #include #include +#include "util.h" #include "bytecode.h" #include "section.h" #include "outfmt.h" diff --git a/src/parsers/nasm/bison.y.in b/src/parsers/nasm/bison.y.in index d0903e66..28590b86 100644 --- a/src/parsers/nasm/bison.y.in +++ b/src/parsers/nasm/bison.y.in @@ -1,4 +1,4 @@ -/* $Id: bison.y.in,v 1.23 2001/08/19 02:15:18 peter Exp $ +/* $Id: bison.y.in,v 1.24 2001/08/19 05:41:01 peter Exp $ * Main bison parser * * Copyright (C) 2001 Peter Johnson, Michael Urman @@ -20,8 +20,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ %{ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include #include +#include "util.h" #include "symrec.h" #include "globals.h" #include "bytecode.h" @@ -52,6 +57,7 @@ void nasm_parser_error(char *); expr *exp; immval im_val; targetval tgt_val; + datavalhead datahead; dataval *data; bytecode bc; } @@ -93,7 +99,8 @@ void nasm_parser_error(char *); %type explabel %type label_id %type target -%type dataval datavals +%type dataval +%type datavals %left '|' %left '^' @@ -121,12 +128,18 @@ line: '\n' { $$.type = BC_EMPTY; } ; exp: instr - | DECLARE_DATA datavals { BuildBC_Data(&$$, $2, $1); } + | DECLARE_DATA datavals { BuildBC_Data(&$$, &$2, $1); } | RESERVE_SPACE expr { BuildBC_Reserve(&$$, $2, $1); } ; -datavals: dataval - | datavals ',' dataval { $$ = dataval_append($1, $3); } +datavals: dataval { + STAILQ_INIT(&$$); + STAILQ_INSERT_TAIL(&$$, $1, link); + } + | datavals ',' dataval { + STAILQ_INSERT_TAIL(&$1, $3, link); + $$ = $1; + } ; dataval: expr_no_string { $$ = dataval_new_expr($1); } diff --git a/src/parsers/nasm/nasm-bison.y b/src/parsers/nasm/nasm-bison.y index d5ff200a..1516e866 100644 --- a/src/parsers/nasm/nasm-bison.y +++ b/src/parsers/nasm/nasm-bison.y @@ -1,4 +1,4 @@ -/* $Id: nasm-bison.y,v 1.23 2001/08/19 02:15:18 peter Exp $ +/* $Id: nasm-bison.y,v 1.24 2001/08/19 05:41:01 peter Exp $ * Main bison parser * * Copyright (C) 2001 Peter Johnson, Michael Urman @@ -20,8 +20,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ %{ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include #include +#include "util.h" #include "symrec.h" #include "globals.h" #include "bytecode.h" @@ -52,6 +57,7 @@ void nasm_parser_error(char *); expr *exp; immval im_val; targetval tgt_val; + datavalhead datahead; dataval *data; bytecode bc; } @@ -93,7 +99,8 @@ void nasm_parser_error(char *); %type explabel %type label_id %type target -%type dataval datavals +%type dataval +%type datavals %left '|' %left '^' @@ -121,12 +128,18 @@ line: '\n' { $$.type = BC_EMPTY; } ; exp: instr - | DECLARE_DATA datavals { BuildBC_Data(&$$, $2, $1); } + | DECLARE_DATA datavals { BuildBC_Data(&$$, &$2, $1); } | RESERVE_SPACE expr { BuildBC_Reserve(&$$, $2, $1); } ; -datavals: dataval - | datavals ',' dataval { $$ = dataval_append($1, $3); } +datavals: dataval { + STAILQ_INIT(&$$); + STAILQ_INSERT_TAIL(&$$, $1, link); + } + | datavals ',' dataval { + STAILQ_INSERT_TAIL(&$1, $3, link); + $$ = $1; + } ; dataval: expr_no_string { $$ = dataval_new_expr($1); } diff --git a/src/parsers/nasm/nasm-parser.c b/src/parsers/nasm/nasm-parser.c index 15a24c3a..92a2df18 100644 --- a/src/parsers/nasm/nasm-parser.c +++ b/src/parsers/nasm/nasm-parser.c @@ -1,4 +1,4 @@ -/* $Id: nasm-parser.c,v 1.3 2001/08/19 02:57:02 peter Exp $ +/* $Id: nasm-parser.c,v 1.4 2001/08/19 05:41:01 peter Exp $ * NASM-compatible parser * * Copyright (C) 2001 Peter Johnson @@ -19,7 +19,12 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include +#include "util.h" #include "bytecode.h" #include "section.h" #include "outfmt.h" diff --git a/src/parsers/nasm/parser.c b/src/parsers/nasm/parser.c index ccfcf2a2..feaddd1d 100644 --- a/src/parsers/nasm/parser.c +++ b/src/parsers/nasm/parser.c @@ -1,4 +1,4 @@ -/* $Id: parser.c,v 1.3 2001/08/19 02:57:02 peter Exp $ +/* $Id: parser.c,v 1.4 2001/08/19 05:41:01 peter Exp $ * NASM-compatible parser * * Copyright (C) 2001 Peter Johnson @@ -19,7 +19,12 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include +#include "util.h" #include "bytecode.h" #include "section.h" #include "outfmt.h"