From: Paul Eggert Date: Sun, 10 Apr 2011 19:47:49 +0000 (-0700) Subject: * xdisp.c (vmessage): Use memchr, not strnlen, which some hosts lack. X-Git-Tag: emacs-pretest-24.0.90~104^2~275^2~283^2~29 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=1ebfdcb6eff7ebe4cf5ef3426944513a2ecdfacf;p=emacs.git * xdisp.c (vmessage): Use memchr, not strnlen, which some hosts lack. --- 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); }