From 7d887720cca88a4af6105230980f0a17be3b714d Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 26 Jan 2025 22:15:50 -0800 Subject: [PATCH] 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) --- src/comp.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) 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; } -- 2.39.5