From 1ebfdcb6eff7ebe4cf5ef3426944513a2ecdfacf Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 10 Apr 2011 12:47:49 -0700 Subject: [PATCH] * xdisp.c (vmessage): Use memchr, not strnlen, which some hosts lack. --- src/ChangeLog | 2 ++ src/xdisp.c | 11 +++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 74e47927b0c..3b5f00a542d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,7 @@ 2011-04-10 Paul Eggert + * xdisp.c (vmessage): Use memchr, not strnlen, which some hosts lack. + Fix more problems found by GCC 4.6.0's static checks. * xdisp.c (vmessage): Use a better test for character truncation. diff --git a/src/xdisp.c b/src/xdisp.c index 6fd3945511b..b0d4b2308a9 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -8417,10 +8417,13 @@ vmessage (const char *m, va_list ap) /* Do any truncation at a character boundary. */ if (! (0 <= len && len < bufsize)) - for (len = strnlen (buf, bufsize); - len && ! CHAR_HEAD_P (buf[len - 1]); - len--) - continue; + { + char *end = memchr (buf, 0, bufsize); + for (len = end ? end - buf : bufsize; + len && ! CHAR_HEAD_P (buf[len - 1]); + len--) + continue; + } message2 (FRAME_MESSAGE_BUF (f), len, 0); } -- 2.39.2