From db88505152ad5b29d4cf4b0b57f75edd29fe3f05 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Sun, 12 Nov 2023 18:20:18 +0100 Subject: [PATCH] Removed stray token check in preproc --- doc/ulas.man | 2 +- src/ulas.c | 28 ---------------------------- 2 files changed, 1 insertion(+), 29 deletions(-) diff --git a/doc/ulas.man b/doc/ulas.man index d3a6a20..9efe742 100644 --- a/doc/ulas.man +++ b/doc/ulas.man @@ -20,7 +20,7 @@ .SH PREPROCESSOR The preprocessor is a text based way of modifying the input before -the assembly step. +the assembly step. Stray tokens after a directive are ignored! Preprocessor directives start with a # and have to be the first non-space character in a line. All lines that are not a preprocessor directive, or are not part of a preprocessor block (macro, or if) diff --git a/src/ulas.c b/src/ulas.c index 6c92348..d00856d 100644 --- a/src/ulas.c +++ b/src/ulas.c @@ -424,18 +424,6 @@ int ulas_preprocdef(struct ulas_preproc *pp, struct ulas_ppdef def) { return 0; } -int ulas_preprochasstray(struct ulas_preproc *pp, const char *pline, size_t n) { - - // the end of a directive should have no further tokens! - if (ulas_tok(&pp->tok, &pline, n) != 0) { - ULASERR("Stray tokens '%s' at end of preprocessor directive\n", - pp->tok.buf); - return 1; - } - - return 0; -} - void ulas_trimend(char c, char *buf, size_t n) { size_t buflen = strnlen(buf, n); // remove trailing new line if present @@ -522,11 +510,6 @@ found: } char *name = strdup(pp->tok.buf); - if (ulas_preprochasstray(pp, pline, n)) { - free(name); - return -1; - } - struct ulas_str val = ulas_str(32); memset(val.buf, 0, 32); @@ -580,12 +563,6 @@ found: struct ulas_ppdef *def = ulas_preprocgetdef(pp, pp->tok.buf, pp->tok.maxlen); - // the end of a directive should have no further tokens! - if (ulas_preprochasstray(pp, pline, n)) { - ULASERR("Stray token at end of preprocessor directive!"); - return -1; - } - char buf[ULAS_LINEMAX]; memset(buf, 0, ULAS_LINEMAX); @@ -629,11 +606,6 @@ found: break; } - // the end of a directive should have no further tokens! - if (ulas_preprochasstray(pp, pline, n)) { - ULASERR("Stray token at end of preprocessor directive!"); - return -1; - } dirdone: return found_dir; } else if (dst) { -- 2.30.2