From: Paul Eggert Date: Mon, 27 Jan 2025 06:15:50 +0000 (-0800) Subject: Minor format_string tuneup X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=7d887720cca88a4af6105230980f0a17be3b714d;p=emacs.git Minor format_string tuneup * src/comp.c (format_string): Prefer strcpy to doing things by hand in a place where strcpy is easier to read, generates more-efficient code, and similar parts of Emacs do strcpy. (cherry picked from commit f8b8dddce90f5cbf6ca0be2e72b4e11cdcf581fe) --- diff --git a/src/comp.c b/src/comp.c index 2603a2f4334..ce59fdd80e3 100644 --- a/src/comp.c +++ b/src/comp.c @@ -720,11 +720,7 @@ format_string (const char *format, ...) va_start (va, format); int res = vsnprintf (scratch_area, sizeof (scratch_area), format, va); if (res >= sizeof (scratch_area)) - { - scratch_area[sizeof (scratch_area) - 4] = '.'; - scratch_area[sizeof (scratch_area) - 3] = '.'; - scratch_area[sizeof (scratch_area) - 2] = '.'; - } + strcpy (scratch_area + sizeof scratch_area - 4, "..."); va_end (va); return scratch_area; }