]> git.eshelyaron.com Git - emacs.git/commitdiff
Minor format_string tuneup
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 27 Jan 2025 06:15:50 +0000 (22:15 -0800)
committerEshel Yaron <me@eshelyaron.com>
Thu, 30 Jan 2025 18:07:11 +0000 (19:07 +0100)
* 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

index 2603a2f4334f87333233af8f3a097f5292522a51..ce59fdd80e3d6e53641efe86ea532d429c7b1fb1 100644 (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;
 }