Subject: Re: bug#43439: [PATCH] doprnt improvements
From: Paul Eggert <[email-masked]>
To: Eli Zaretskii <[email-masked]>
Cc: [email-masked]
Date: Sat, 24 Oct 2020 14:02:25 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

OK, I installed the patch, followed by the attached minor cleanups. Closing the 
bug report.
From 28d2931b4bc934d06f449c01e067258d76a16738 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email-masked]>
Date: Sat, 24 Oct 2020 13:46:46 -0700
Subject: [PATCH 1/2] Rename doprnt_nul to doprnt_non_null_end

* src/doprnt.c (doprnt_non_null_end): Rename from doprnt_nul,
as the old name was misleading (left over from a previous proposal).
Caller changed.
---
 src/doprnt.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/doprnt.c b/src/doprnt.c
index 07c4d8d797..be256f4497 100644
--- a/src/doprnt.c
+++ b/src/doprnt.c
@@ -150,8 +150,8 @@ parse_format_integer (char const *fmt, int *value)
    Emacs version contains doprnt callers that need such formats.
    Having a separate function helps GCC optimize doprnt better.  */
 static ptrdiff_t
-doprnt_nul (char *buffer, ptrdiff_t bufsize, char const *format,
-	    char const *format_end, va_list ap)
+doprnt_non_null_end (char *buffer, ptrdiff_t bufsize, char const *format,
+		     char const *format_end, va_list ap)
 {
   USE_SAFE_ALLOCA;
   ptrdiff_t fmtlen = format_end - format;
@@ -182,7 +182,7 @@ doprnt (char *buffer, ptrdiff_t bufsize, const char *format,
 	const char *format_end, va_list ap)
 {
   if (format_end && !memchr (format, 0, format_end - format))
-    return doprnt_nul (buffer, bufsize, format, format_end, ap);
+    return doprnt_non_null_end (buffer, bufsize, format, format_end, ap);
 
   const char *fmt = format;	/* Pointer into format string.  */
   char *bufptr = buffer;	/* Pointer into output buffer.  */
-- 
2.25.1

From 32e427cca112f5471356c1fa95ba1ed256d200b6 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email-masked]>
Date: Sat, 24 Oct 2020 13:50:29 -0700
Subject: [PATCH 2/2] Minor doprnt cleanup: remove memchr call

* src/doprnt.c (doprnt): Remove unnecessary call to memchr.
---
 src/doprnt.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/doprnt.c b/src/doprnt.c
index be256f4497..ce259d07cf 100644
--- a/src/doprnt.c
+++ b/src/doprnt.c
@@ -144,10 +144,10 @@ parse_format_integer (char const *fmt, int *value)
   return fmt;
 }
 
-/* Like doprnt, except FORMAT must not contain NUL bytes and
-   FORMAT_END must be non-null.  Although this function is never
-   exercised in current Emacs, it is retained in case some future
-   Emacs version contains doprnt callers that need such formats.
+/* Like doprnt, except FORMAT_END must be non-null.
+   Although this function is never exercised in current Emacs,
+   it is retained in case some future Emacs version
+   contains doprnt callers that need such formats.
    Having a separate function helps GCC optimize doprnt better.  */
 static ptrdiff_t
 doprnt_non_null_end (char *buffer, ptrdiff_t bufsize, char const *format,
@@ -181,7 +181,7 @@ doprnt_non_null_end (char *buffer, ptrdiff_t bufsize, char const *format,
 doprnt (char *buffer, ptrdiff_t bufsize, const char *format,
 	const char *format_end, va_list ap)
 {
-  if (format_end && !memchr (format, 0, format_end - format))
+  if (format_end)
     return doprnt_non_null_end (buffer, bufsize, format, format_end, ap);
 
   const char *fmt = format;	/* Pointer into format string.  */
-- 
2.25.1