From f71959588febf4a1ffbf5bc34cd411ebdd63912b Mon Sep 17 00:00:00 2001 From: ketmar Date: Thu, 25 Jun 2020 10:10:43 +0000 Subject: [PATCH] added "$warning" FossilOrigin-Name: b8154a7e63b5f616f183aa54def9a1818bad9f3a9627b2dfda65121dbb143d90 --- src/urasm.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/urasm.c b/src/urasm.c index 268f6f9..8ead9f1 100644 --- a/src/urasm.c +++ b/src/urasm.c @@ -443,16 +443,16 @@ static void processCurrentLine (void); // only one, will skip to next one static jmp_buf errJP; -static void errorWriteFile (void) { +static void errorWriteFile (FILE *fo) { if (curSrcLine) { - fprintf(stderr, "at file %s, line %d\n%s\n*", curSrcLine->fname, curSrcLine->lineNo, curSrcLine->line); + fprintf(fo, "at file %s, line %d\n%s\n*", curSrcLine->fname, curSrcLine->lineNo, curSrcLine->line); } else { - fprintf(stderr, "somewhere in time: "); + fprintf(fo, "somewhere in time: "); } } static void errorMsgV (const char *fmt, va_list ap) { - errorWriteFile(); + errorWriteFile(stderr); vfprintf(stderr, fmt, ap); va_end(ap); fputc('\n', stderr); @@ -2248,6 +2248,21 @@ static int piERROR (void) { } +static int piWARNING (void) { + int len = 0; + char *res = getStrArg(&len); + fprintf(stdout, "*** USER WARNING "); + if (curSrcLine) { + fprintf(stdout, "at file %s, line %d: ", curSrcLine->fname, curSrcLine->lineNo); + } else { + fprintf(stdout, "somewhere in time: "); + } + processPrintf(stdout, res); + fputc('\n', stdout); + return PI_SKIP_LINE; +} + + /////////////////////////////////////////////////////////////////////////////// // user warnings // @@ -3410,6 +3425,7 @@ static void registerInstructions (void) { urAddOp("DEFC", piDEFC); urAddOp("DC", piDEFC); urAddOp("$ERROR", piERROR); + urAddOp("$WARNING", piWARNING); urAddOp("$PRINTF", piPRINTF); urAddOp("$PRINTF0", piPRINTF0); -- 2.11.4.GIT