From f137cc0c5cf2dc8e3b2c26f709e8de851c3d9fc0 Mon Sep 17 00:00:00 2001 From: Brian Taylor Date: Tue, 27 Dec 2022 20:48:53 -0800 Subject: [PATCH] Ensure that amatch output is not binary data. --- src/frontend/logicexp.c | 6 +++--- src/frontend/udevices.c | 16 +++++++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/frontend/logicexp.c b/src/frontend/logicexp.c index 479dbceb9..d611ba851 100644 --- a/src/frontend/logicexp.c +++ b/src/frontend/logicexp.c @@ -721,6 +721,7 @@ static void aerror(char *s) { LEXER lx = parse_lexer; printf("%s [%s]\n", s, lx->lexer_line + lx->lexer_pos); + fflush(stdout); cleanup_parser(); } @@ -735,12 +736,11 @@ char *get_temp_name(void) static BOOL amatch(int t) { - LEXER lx = parse_lexer; if (lookahead == t) { lookahead = lex_scan(); } else { - printf("expect = '%c' [%d] lookahead = '%c' [%d] lexer_buf %s\n", - t, t, lookahead, lookahead, lx->lexer_buf); + printf("expect = %d lookahead = %d lexer_buf \"%s\"\n", + t, lookahead, parse_lexer->lexer_buf); aerror("amatch: syntax error"); return FALSE; } diff --git a/src/frontend/udevices.c b/src/frontend/udevices.c index a9ae798fb..da5ceb19f 100644 --- a/src/frontend/udevices.c +++ b/src/frontend/udevices.c @@ -3593,7 +3593,7 @@ BOOL u_check_instance(char *line) } if (ps_udevice_msgs >= 1) { if (current_subckt && subckt_msg_count == 0) { - printf("%s\n", current_subckt); + printf("\nWARNING in %s\n", current_subckt); } subckt_msg_count++; printf("WARNING "); @@ -3630,22 +3630,24 @@ BOOL u_process_instance(char *nline) if (eq(itype, "logicexp")) { delete_instance_hdr(hdr); behav_ret = f_logicexp(nline); - if (!behav_ret && current_subckt && ps_udevice_msgs >= 1) { + if (!behav_ret && current_subckt) { printf("ERROR in %s\n", current_subckt); } if (!behav_ret && ps_udevice_exit) { fprintf(stderr, "ERROR bad syntax in logicexp\n"); + fflush(stdout); controlled_exit(EXIT_FAILURE); } return behav_ret; } else if (eq(itype, "pindly")) { delete_instance_hdr(hdr); behav_ret = f_pindly(nline); - if (!behav_ret && current_subckt && ps_udevice_msgs >= 1) { + if (!behav_ret && current_subckt) { printf("ERROR in %s\n", current_subckt); } if (!behav_ret && ps_udevice_exit) { fprintf(stderr, "ERROR bad syntax in pindly\n"); + fflush(stdout); controlled_exit(EXIT_FAILURE); } return behav_ret; @@ -3676,7 +3678,11 @@ BOOL u_process_instance(char *nline) } else { delete_instance_hdr(hdr); if (ps_udevice_exit) { + if (current_subckt) { + printf("ERROR in %s\n", current_subckt); + } fprintf(stderr, "ERROR unknown U* device\n"); + fflush(stdout); controlled_exit(EXIT_FAILURE); } return FALSE; @@ -3687,7 +3693,11 @@ BOOL u_process_instance(char *nline) return TRUE; } else { if (ps_udevice_exit) { + if (current_subckt) { + printf("ERROR in %s\n", current_subckt); + } fprintf(stderr, "ERROR U* device syntax error\n"); + fflush(stdout); controlled_exit(EXIT_FAILURE); } return FALSE;