}
}
+void ulas_preprocexpand_rec(struct ulas_preproc *pp) {
+ // expand macro result again to allow
+ // defines to appear in the macro
+ ulas_strensr(&pp->line2, strlen(pp->line.buf) + 1);
+ sprintf(pp->line2.buf, "%s", pp->line.buf);
+ unsigned long n = strlen(pp->line.buf);
+ pp->exp_depth++;
+ if (pp->exp_depth > ULAS_PREPROC_MAX_MACRO_DEPTH) {
+ ULASERR("Max macro recursion depth reached\n");
+ return;
+ }
+ ulas_preprocexpand(pp, pp->line2.buf, &n);
+ pp->exp_depth--;
+}
+
char *ulas_preprocexpand(struct ulas_preproc *pp, const char *raw_line,
unsigned long *n) {
const char *praw_line = raw_line;
} else {
strncat(pp->line.buf, def->value, val_len);
}
+ ulas_preprocexpand_rec(pp);
}
break;
}
strncat(pp->line.buf, tocat, tocatlen);
}
}
- // expand macro result again to allow
- // defines to appear in the macro
- ulas_strensr(&pp->line2, strlen(pp->line.buf) + 1);
- sprintf(pp->line2.buf, "%s", pp->line.buf);
- unsigned long n = strlen(pp->line.buf);
- pp->exp_depth++;
- if (pp->exp_depth > ULAS_PREPROC_MAX_MACRO_DEPTH) {
- ULASERR("Max macro recursion depth reached\n");
- goto end;
- }
- ulas_preprocexpand(pp, pp->line2.buf, &n);
- pp->exp_depth--;
+ ulas_preprocexpand_rec(pp);
goto end;
}
}