Hi Bruno,

The mb_putc function in mbchar.h is defined as:

    #define mb_putc(mbc, stream)  fwrite ((mbc).ptr, 1, (mbc).bytes, (stream))

but documented as:

    extern void           mb_putc (const mbchar_t mbc, FILE *stream);

If someone wanted to check that the character was written, they could
check the that the return value of the fwrite is correct, equal to
mb_len (mbc).

I haven't pushed the attached patch yet, since maybe you never intended
for it to be used this way. Let me know what you think.

Collin

>From 573e404d66b0e7b7c5b849aca3bb4e3f026c56df Mon Sep 17 00:00:00 2001
Message-ID: <573e404d66b0e7b7c5b849aca3bb4e3f026c56df.1755416747.git.collin.fu...@gmail.com>
From: Collin Funk <[email protected]>
Date: Sun, 17 Aug 2025 00:43:05 -0700
Subject: [PATCH] mbchar: Correct return type for mb_putc in documentation.

* lib/mbchar.h: Document that mb_putc returns an int since it is a macro
which calls fwrite.
---
 ChangeLog    | 6 ++++++
 lib/mbchar.h | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 29897dc8c5..7a5b11836e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2025-08-17  Collin Funk  <[email protected]>
+
+	mbchar: Correct return type for mb_putc in documentation.
+	* lib/mbchar.h: Document that mb_putc returns an int since it is a macro
+	which calls fwrite.
+
 2025-08-15  Bruno Haible  <[email protected]>
 
 	Reduce risk of compilation errors within include files.
diff --git a/lib/mbchar.h b/lib/mbchar.h
index d77168e717..a38d1cf5ff 100644
--- a/lib/mbchar.h
+++ b/lib/mbchar.h
@@ -136,7 +136,7 @@
    extern bool          mb_isupper (const mbchar_t mbc);
    extern bool          mb_isxdigit (const mbchar_t mbc);
    extern int           mb_width (const mbchar_t mbc);
-   extern void          mb_putc (const mbchar_t mbc, FILE *stream);
+   extern int           mb_putc (const mbchar_t mbc, FILE *stream);
    extern void          mb_setascii (mbchar_t *new, char sc);
    extern void          mb_copy (mbchar_t *new, const mbchar_t *old);
  */
-- 
2.50.1

Reply via email to