From dd86bdee46257ed4afc6a2588b4a02283066a5a9 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Wed, 28 Oct 2020 11:37:58 +0100 Subject: [PATCH] Enlarge the buffer size for command 'listing' from 512 to 4096 bytes. --- src/frontend/inp.c | 8 +++++--- src/include/ngspice/defines.h | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/frontend/inp.c b/src/frontend/inp.c index 2e43a1048..a4c2c3c11 100644 --- a/src/frontend/inp.c +++ b/src/frontend/inp.c @@ -184,11 +184,13 @@ com_listing(wordlist *wl) static char * upper(char *string) { - static char buf[BSIZE_SP]; + static char buf[LBSIZE_SP]; if (string) { - strncpy(buf, string, BSIZE_SP - 1); - buf[BSIZE_SP - 1] = '\0'; + if (strlen(string) > LBSIZE_SP - 1) + fprintf(stderr, "Warning: output of command 'listing' will be truncated\n"); + strncpy(buf, string, LBSIZE_SP - 1); + buf[LBSIZE_SP - 1] = '\0'; inp_casefix(buf); } else { strcpy(buf, ""); diff --git a/src/include/ngspice/defines.h b/src/include/ngspice/defines.h index 732a44677..66ce42375 100644 --- a/src/include/ngspice/defines.h +++ b/src/include/ngspice/defines.h @@ -114,6 +114,7 @@ #endif #define BSIZE_SP 512 +#define LBSIZE_SP 4096 #define EXIT_NORMAL 0