From: Chris Hanson Date: Sun, 20 Mar 2011 09:25:38 +0000 (-0700) Subject: For some reason, fatal_buf doesn't have a NUL under certain circumstances on my Mac... X-Git-Tag: 20110426-Gtk~2^2~30 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=720b47ee0533802a61de8baafce44188e413bf93;p=mit-scheme.git For some reason, fatal_buf doesn't have a NUL under certain circumstances on my Mac. Instead of calling strlen, do a more careful scan that stops at the end of the buffer. --- diff --git a/src/microcode/outf.c b/src/microcode/outf.c index 1daa0b1ea..c8ffeffb7 100644 --- a/src/microcode/outf.c +++ b/src/microcode/outf.c @@ -168,10 +168,22 @@ outf_flush_error (void) fflush (stderr); } +static unsigned int +find_fatal_buf_nul (void) +{ + unsigned int scan = 0; + while (scan < MAX_FATAL_BUF) + if ((fatal_buf[scan++]) == '\0') + return (scan - 1); + /* There's no NUL character in the buffer. */ + (fatal_buf[0]) = '\0'; + return (0); +} + void voutf_fatal (const char * format, va_list args) { - unsigned int end = (strlen (fatal_buf)); + unsigned int end = (find_fatal_buf_nul ()); VSNPRINTF ((& (fatal_buf[end])), (MAX_FATAL_BUF - end), format, args); }