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.
This commit is contained in:
Paul Eggert 2025-01-26 22:15:50 -08:00
parent 8d8272d02e
commit f8b8dddce9

View file

@ -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;
}