Merge branch 'cleanup'

This commit is contained in:
Cyrill Gorcunov 2010-11-11 23:09:22 +03:00
commit 5eaff1d2ca
2 changed files with 811 additions and 822 deletions

View File

@ -152,5 +152,14 @@ if test $ac_cv_prog_make_vpathok = no; then
done
fi
dnl
dnl support cchace
dnl
AC_ARG_WITH([ccache],
[AC_HELP_STRING([--with-ccache],
[Compile with ccache])],
[CC="ccache $CC"],
[])
AC_OUTPUT_COMMANDS([mkdir -p output])
AC_OUTPUT(Makefile rdoff/Makefile doc/Makefile)

View File

@ -483,6 +483,24 @@ static ExpInv *new_ExpInv(int exp_type, ExpDef *ed);
#define tok_is_(x,v) (tok_type_((x), TOK_OTHER) && !strcmp((x)->text,(v)))
#define tok_isnt_(x,v) ((x) && ((x)->type!=TOK_OTHER || strcmp((x)->text,(v))))
#ifdef NASM_TRACE
#define dump_token(t) raw_dump_token(t, __FILE__, __LINE__, __func__);
static void raw_dump_token(Token *token, const char *file, int line, const char *func)
{
printf("---[%s (%s:%d): %p]---\n", func, file, line, (void *)token);
if (token) {
Token *t;
list_for_each(t, token) {
if (t->text)
printf("'%s' ", t->text);
}
printf("\n");
}
}
#endif
/*
* nasm_unquote with error if the string contains NUL characters.
* If the string contains NUL characters, issue an error and return
@ -1376,7 +1394,7 @@ static char *detoken(Token * tlist, bool expand_locals)
/*
* Initialize a new Line
*/
static Line *new_Line(void)
static inline Line *new_Line(void)
{
Line *l = nasm_malloc(sizeof(Line));
l->next = NULL;
@ -1390,29 +1408,11 @@ static Line *new_Line(void)
*/
static ExpDef *new_ExpDef(int exp_type)
{
ExpDef *ed = (ExpDef*)nasm_malloc(sizeof(ExpDef));
ed->prev = NULL;
ed->next = NULL;
ExpDef *ed = (ExpDef*)nasm_zalloc(sizeof(ExpDef));
ed->type = exp_type;
ed->name = NULL;
ed->nparam_min = 0;
ed->nparam_max = 0;
ed->casesense = true;
ed->plus = false;
ed->prepend = 0;
ed->label = NULL;
ed->line = NULL;
ed->last = NULL;
ed->linecount = 0;
ed->dlist = NULL;
ed->defaults = NULL;
ed->ndefs = 0;
ed->state = COND_NEVER;
ed->nolist = false;
ed->def_depth = 0;
ed->cur_depth = 0;
ed->max_depth = 0;
ed->ignoring = false;
return ed;
}
@ -1422,22 +1422,11 @@ static ExpDef *new_ExpDef(int exp_type)
*/
static ExpInv *new_ExpInv(int exp_type, ExpDef *ed)
{
ExpInv *ei = (ExpInv*)nasm_malloc(sizeof(ExpInv));
ei->prev = NULL;
ExpInv *ei = (ExpInv*)nasm_zalloc(sizeof(ExpInv));
ei->type = exp_type;
ei->def = ed;
ei->name = NULL;
ei->label = NULL;
ei->label_text = NULL;
ei->current = NULL;
ei->params = NULL;
ei->iline = NULL;
ei->nparam = 0;
ei->rotate = 0;
ei->paramlen = NULL;
ei->unique = ++unique;
ei->emitting = false;
ei->lineno = 0;
if ((istk->mmac_depth < 1) &&
(istk->expansion == NULL) &&
(ed != NULL) &&
@ -1687,11 +1676,11 @@ static FILE *inc_fopen(const char *file, StrList **dhead, StrList ***dtail,
while (1) {
sl = nasm_malloc(prefix_len+len+1+sizeof sl->next);
sl->next = NULL;
memcpy(sl->str, prefix, prefix_len);
memcpy(sl->str+prefix_len, file, len+1);
fp = fopen(sl->str, "r");
if (fp && dhead && !in_list(*dhead, sl->str)) {
sl->next = NULL;
**dtail = sl;
*dtail = &sl->next;
} else {
@ -1978,14 +1967,9 @@ static bool if_condition(Token * tline, enum preproc_token ct)
"`%s' expects a macro name", pp_directives[ct]);
goto fail;
}
memset(&searching, 0, sizeof(searching));
searching.name = nasm_strdup(tline->text);
searching.casesense = true;
searching.plus = false;
searching.nolist = false;
//searching.in_progress = 0;
searching.max_depth = 0;
//searching.rep_nest = NULL;
searching.nparam_min = 0;
searching.nparam_max = INT_MAX;
tline = expand_smacro(tline->next);
skip_white_(tline);
@ -2028,10 +2012,8 @@ static bool if_condition(Token * tline, enum preproc_token ct)
ed = (ExpDef *) hash_findix(&expdefs, searching.name);
while (ed != NULL) {
if (!strcmp(ed->name, searching.name) &&
(ed->nparam_min <= searching.nparam_max
|| searching.plus)
&& (searching.nparam_min <= ed->nparam_max
|| ed->plus)) {
(ed->nparam_min <= searching.nparam_max || searching.plus) &&
(searching.nparam_min <= ed->nparam_max || ed->plus)) {
found = true;
break;
}
@ -2156,7 +2138,7 @@ static bool define_smacro(Context *ctx, const char *mname, bool casesense,
} else {
smtbl = ctx ? &ctx->localmac : &smacros;
smhead = (SMacro **) hash_findi_add(smtbl, mname);
smac = nasm_malloc(sizeof(SMacro));
smac = nasm_zalloc(sizeof(SMacro));
smac->next = *smhead;
*smhead = smac;
}
@ -2676,7 +2658,7 @@ static int do_directive(Token * tline)
}
if (i == PP_PUSH) {
ctx = nasm_malloc(sizeof(Context));
ctx = nasm_zalloc(sizeof(Context));
ctx->next = cstk;
hash_init(&ctx->localmac, HASH_SMALL);
ctx->name = p;
@ -2913,10 +2895,8 @@ issue_error:
eed = (ExpDef *) hash_findix(&expdefs, ed->name);
while (eed) {
if (!strcmp(eed->name, ed->name) &&
(eed->nparam_min <= ed->nparam_max
|| ed->plus)
&& (ed->nparam_min <= eed->nparam_max
|| eed->plus)) {
(eed->nparam_min <= ed->nparam_max || ed->plus) &&
(ed->nparam_min <= eed->nparam_max || eed->plus)) {
error(ERR_WARNING|ERR_PASS1,
"redefining multi-line macro `%s'", ed->name);
return DIRECTIVE_FOUND;
@ -4948,11 +4928,11 @@ static bool expand_mmacro(Token * tline)
*/
ei = new_ExpInv(EXP_MMACRO, ed);
ei->name = nasm_strdup(mname);
// ei->label = label;
// ei->label_text = detoken(label, false);
//ei->label = label;
//ei->label_text = detoken(label, false);
ei->current = ed->line;
ei->emitting = true;
// ei->iline = tline;
//ei->iline = tline;
ei->params = params;
ei->nparam = nparam;
ei->rotate = 0;