These two patches update the dummy textstyle.h to the gettext 0.22 API.

2023-06-29  Bruno Haible  <[email protected]>

        libtextstyle-optional: Update to gettext 0.22.
        * lib/textstyle.in.h: Declare all functions that were added in
        textstyle.h from gettext-0.22.

        libtextstyle-optional: Update to gettext 0.21.
        * lib/textstyle.in.h: Declare all functions that exist in textstyle.h
        from gettext-0.21, independently of iconv.

>From ab4cd32d3db52b807bc8f02cabd0d1390f7762fd Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Thu, 29 Jun 2023 17:31:55 +0200
Subject: [PATCH 1/2] libtextstyle-optional: Update to gettext 0.21.

* lib/textstyle.in.h: Declare all functions that exist in textstyle.h
from gettext-0.21, independently of iconv.
---
 ChangeLog          |   6 +++
 lib/textstyle.in.h | 113 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 119 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 08c0b31070..a35fd0ee12 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2023-06-29  Bruno Haible  <[email protected]>
+
+	libtextstyle-optional: Update to gettext 0.21.
+	* lib/textstyle.in.h: Declare all functions that exist in textstyle.h
+	from gettext-0.21, independently of iconv.
+
 2023-06-28  Bruno Haible  <[email protected]>
 
 	doc: Mention c8rtomb and mbrtoc8 from ISO C 23.
diff --git a/lib/textstyle.in.h b/lib/textstyle.in.h
index c87fa38059..b45f56287e 100644
--- a/lib/textstyle.in.h
+++ b/lib/textstyle.in.h
@@ -301,6 +301,15 @@ typedef ostream_t term_ostream_t;
 #define term_ostream_flush ostream_flush
 #define term_ostream_free ostream_free
 
+static inline term_color_t
+term_ostream_rgb_to_color (_GL_ATTRIBUTE_MAYBE_UNUSED term_ostream_t stream,
+                           _GL_ATTRIBUTE_MAYBE_UNUSED int red,
+                           _GL_ATTRIBUTE_MAYBE_UNUSED int green,
+                           _GL_ATTRIBUTE_MAYBE_UNUSED int blue)
+{
+  return COLOR_DEFAULT;
+}
+
 static inline term_color_t
 term_ostream_get_color (_GL_ATTRIBUTE_MAYBE_UNUSED term_ostream_t stream)
 {
@@ -409,6 +418,75 @@ term_ostream_create (int fd, const char *filename,
   return fd_ostream_create (fd, filename, true);
 }
 
+/* ------------------------- From memory-ostream.h ------------------------- */
+
+typedef ostream_t memory_ostream_t;
+
+#define memory_ostream_write_mem ostream_write_mem
+#define memory_ostream_flush ostream_flush
+#define memory_ostream_free ostream_free
+
+static inline void
+memory_ostream_contents (_GL_ATTRIBUTE_MAYBE_UNUSED memory_ostream_t stream,
+                         const void **bufp, size_t *buflenp)
+{
+  *bufp = NULL;
+  *buflenp = 0;
+}
+
+static inline memory_ostream_t
+memory_ostream_create (void)
+{
+  /* Not supported without the real libtextstyle.  */
+  abort ();
+  return NULL;
+}
+
+/* -------------------------- From html-ostream.h -------------------------- */
+
+typedef ostream_t html_ostream_t;
+
+#define html_ostream_write_mem ostream_write_mem
+#define html_ostream_flush ostream_flush
+#define html_ostream_free ostream_free
+
+static inline void
+html_ostream_begin_span (_GL_ATTRIBUTE_MAYBE_UNUSED html_ostream_t stream,
+                         _GL_ATTRIBUTE_MAYBE_UNUSED const char *classname)
+{
+}
+
+static inline void
+html_ostream_end_span (_GL_ATTRIBUTE_MAYBE_UNUSED html_ostream_t stream,
+                       _GL_ATTRIBUTE_MAYBE_UNUSED const char *classname)
+{
+}
+
+static inline const char *
+html_ostream_get_hyperlink_ref (_GL_ATTRIBUTE_MAYBE_UNUSED html_ostream_t stream)
+{
+  return NULL;
+}
+
+static inline void
+html_ostream_set_hyperlink_ref (_GL_ATTRIBUTE_MAYBE_UNUSED html_ostream_t stream,
+                                _GL_ATTRIBUTE_MAYBE_UNUSED const char *ref)
+{
+}
+
+static inline void
+html_ostream_flush_to_current_style (_GL_ATTRIBUTE_MAYBE_UNUSED html_ostream_t stream)
+{
+}
+
+static inline html_ostream_t
+html_ostream_create (ostream_t destination)
+{
+  /* Not supported without the real libtextstyle.  */
+  abort ();
+  return NULL;
+}
+
 /* ----------------------- From term-styled-ostream.h ----------------------- */
 
 typedef styled_ostream_t term_styled_ostream_t;
@@ -435,14 +513,48 @@ term_styled_ostream_create (int fd, const char *filename,
 
 typedef styled_ostream_t html_styled_ostream_t;
 
+#define html_styled_ostream_write_mem ostream_write_mem
+#define html_styled_ostream_flush ostream_flush
+#define html_styled_ostream_free ostream_free
+#define html_styled_ostream_begin_use_class styled_ostream_begin_use_class
+#define html_styled_ostream_end_use_class styled_ostream_end_use_class
+#define html_styled_ostream_get_hyperlink_ref styled_ostream_get_hyperlink_ref
+#define html_styled_ostream_get_hyperlink_id styled_ostream_get_hyperlink_id
+#define html_styled_ostream_set_hyperlink styled_ostream_set_hyperlink
+#define html_styled_ostream_flush_to_current_style styled_ostream_flush_to_current_style
+
 static inline html_styled_ostream_t
 html_styled_ostream_create (_GL_ATTRIBUTE_MAYBE_UNUSED ostream_t destination,
                             _GL_ATTRIBUTE_MAYBE_UNUSED const char *css_filename)
 {
+  /* Not supported without the real libtextstyle.  */
   abort ();
   return NULL;
 }
 
+/* ----------------------- From noop-styled-ostream.h ----------------------- */
+
+typedef styled_ostream_t noop_styled_ostream_t;
+
+#define noop_styled_ostream_write_mem ostream_write_mem
+#define noop_styled_ostream_flush ostream_flush
+#define noop_styled_ostream_free ostream_free
+#define noop_styled_ostream_begin_use_class styled_ostream_begin_use_class
+#define noop_styled_ostream_end_use_class styled_ostream_end_use_class
+#define noop_styled_ostream_get_hyperlink_ref styled_ostream_get_hyperlink_ref
+#define noop_styled_ostream_get_hyperlink_id styled_ostream_get_hyperlink_id
+#define noop_styled_ostream_set_hyperlink styled_ostream_set_hyperlink
+#define noop_styled_ostream_flush_to_current_style styled_ostream_flush_to_current_style
+
+static inline noop_styled_ostream_t
+noop_styled_ostream_create (ostream_t destination, bool pass_ownership)
+{
+  if (!pass_ownership)
+    /* Not supported without the real libtextstyle.  */
+    abort ();
+  return destination;
+}
+
 /* ------------------------------ From color.h ------------------------------ */
 
 #define color_test_mode false
@@ -466,6 +578,7 @@ handle_style_option (_GL_ATTRIBUTE_MAYBE_UNUSED const char *option)
 static inline void
 print_color_test (void)
 {
+  /* Not supported without the real libtextstyle.  */
   abort ();
 }
 
-- 
2.34.1

>From ddfbbf8ecc23777752b8c8972f35d228e807ee1c Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Thu, 29 Jun 2023 19:02:43 +0200
Subject: [PATCH 2/2] libtextstyle-optional: Update to gettext 0.22.

* lib/textstyle.in.h: Declare all functions that were added in
textstyle.h from gettext-0.22.
---
 ChangeLog          |   4 ++
 lib/textstyle.in.h | 161 +++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 151 insertions(+), 14 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a35fd0ee12..ecd0e03696 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2023-06-29  Bruno Haible  <[email protected]>
 
+	libtextstyle-optional: Update to gettext 0.22.
+	* lib/textstyle.in.h: Declare all functions that were added in
+	textstyle.h from gettext-0.22.
+
 	libtextstyle-optional: Update to gettext 0.21.
 	* lib/textstyle.in.h: Declare all functions that exist in textstyle.h
 	from gettext-0.21, independently of iconv.
diff --git a/lib/textstyle.in.h b/lib/textstyle.in.h
index b45f56287e..4c76a662e4 100644
--- a/lib/textstyle.in.h
+++ b/lib/textstyle.in.h
@@ -232,6 +232,12 @@ styled_ostream_flush_to_current_style (_GL_ATTRIBUTE_MAYBE_UNUSED styled_ostream
 {
 }
 
+static inline bool
+is_instance_of_styled_ostream (_GL_ATTRIBUTE_MAYBE_UNUSED ostream_t stream)
+{
+  return false;
+}
+
 /* -------------------------- From file-ostream.h -------------------------- */
 
 typedef ostream_t file_ostream_t;
@@ -240,12 +246,24 @@ typedef ostream_t file_ostream_t;
 #define file_ostream_flush ostream_flush
 #define file_ostream_free ostream_free
 
+static inline FILE *
+file_ostream_get_stdio_stream (file_ostream_t stream)
+{
+  return stream;
+}
+
 static inline file_ostream_t
 file_ostream_create (FILE *fp)
 {
   return fp;
 }
 
+static inline bool
+is_instance_of_file_ostream (_GL_ATTRIBUTE_MAYBE_UNUSED ostream_t stream)
+{
+  return true;
+}
+
 /* --------------------------- From fd-ostream.h --------------------------- */
 
 typedef ostream_t fd_ostream_t;
@@ -254,6 +272,24 @@ typedef ostream_t fd_ostream_t;
 #define fd_ostream_flush ostream_flush
 #define fd_ostream_free ostream_free
 
+static inline int
+fd_ostream_get_descriptor (fd_ostream_t stream)
+{
+  return fileno (stream);
+}
+
+static inline const char *
+fd_ostream_get_filename (_GL_ATTRIBUTE_MAYBE_UNUSED fd_ostream_t stream)
+{
+  return NULL;
+}
+
+static inline bool
+fd_ostream_is_buffered (_GL_ATTRIBUTE_MAYBE_UNUSED fd_ostream_t stream)
+{
+  return false;
+}
+
 static inline fd_ostream_t
 fd_ostream_create (int fd, _GL_ATTRIBUTE_MAYBE_UNUSED const char *filename,
                    _GL_ATTRIBUTE_MAYBE_UNUSED bool buffered)
@@ -266,6 +302,12 @@ fd_ostream_create (int fd, _GL_ATTRIBUTE_MAYBE_UNUSED const char *filename,
     return fdopen (fd, "w");
 }
 
+static inline bool
+is_instance_of_fd_ostream (ostream_t stream)
+{
+  return fileno (stream) >= 0;
+}
+
 /* -------------------------- From term-ostream.h -------------------------- */
 
 typedef int term_color_t;
@@ -295,6 +337,22 @@ typedef enum
   UNDERLINE_DEFAULT = UNDERLINE_OFF
 } term_underline_t;
 
+typedef enum
+{
+  TTYCTL_AUTO = 0,  /* Automatic best-possible choice.  */
+  TTYCTL_NONE,      /* No control.
+                       Result: Garbled output can occur, and the terminal can
+                       be left in any state when the program is interrupted.  */
+  TTYCTL_PARTIAL,   /* Signal handling.
+                       Result: Garbled output can occur, but the terminal will
+                       be left in the default state when the program is
+                       interrupted.  */
+  TTYCTL_FULL       /* Signal handling and disabling echo and flush-upon-signal.
+                       Result: No garbled output, and the terminal will
+                       be left in the default state when the program is
+                       interrupted.  */
+} ttyctl_t;
+
 typedef ostream_t term_ostream_t;
 
 #define term_ostream_write_mem ostream_write_mem
@@ -395,21 +453,20 @@ term_ostream_flush_to_current_style (term_ostream_t stream)
   fflush (stream);
 }
 
-typedef enum
+#define term_ostream_get_descriptor fd_ostream_get_descriptor
+#define term_ostream_get_filename fd_ostream_get_filename
+
+static inline ttyctl_t
+term_ostream_get_tty_control (_GL_ATTRIBUTE_MAYBE_UNUSED term_ostream_t stream)
 {
-  TTYCTL_AUTO = 0,  /* Automatic best-possible choice.  */
-  TTYCTL_NONE,      /* No control.
-                       Result: Garbled output can occur, and the terminal can
-                       be left in any state when the program is interrupted.  */
-  TTYCTL_PARTIAL,   /* Signal handling.
-                       Result: Garbled output can occur, but the terminal will
-                       be left in the default state when the program is
-                       interrupted.  */
-  TTYCTL_FULL       /* Signal handling and disabling echo and flush-upon-signal.
-                       Result: No garbled output, and the terminal will
-                       be left in the default state when the program is
-                       interrupted.  */
-} ttyctl_t;
+  return TTYCTL_NONE;
+}
+
+static inline ttyctl_t
+term_ostream_get_effective_tty_control (_GL_ATTRIBUTE_MAYBE_UNUSED term_ostream_t stream)
+{
+  return TTYCTL_NONE;
+}
 
 static inline term_ostream_t
 term_ostream_create (int fd, const char *filename,
@@ -418,6 +475,8 @@ term_ostream_create (int fd, const char *filename,
   return fd_ostream_create (fd, filename, true);
 }
 
+#define is_instance_of_term_ostream is_instance_of_fd_ostream
+
 /* ------------------------- From memory-ostream.h ------------------------- */
 
 typedef ostream_t memory_ostream_t;
@@ -442,6 +501,12 @@ memory_ostream_create (void)
   return NULL;
 }
 
+static inline bool
+is_instance_of_memory_ostream (_GL_ATTRIBUTE_MAYBE_UNUSED ostream_t stream)
+{
+  return false;
+}
+
 /* -------------------------- From html-ostream.h -------------------------- */
 
 typedef ostream_t html_ostream_t;
@@ -479,6 +544,12 @@ html_ostream_flush_to_current_style (_GL_ATTRIBUTE_MAYBE_UNUSED html_ostream_t s
 {
 }
 
+static inline ostream_t
+html_ostream_get_destination (_GL_ATTRIBUTE_MAYBE_UNUSED html_ostream_t stream)
+{
+  return NULL;
+}
+
 static inline html_ostream_t
 html_ostream_create (ostream_t destination)
 {
@@ -487,6 +558,12 @@ html_ostream_create (ostream_t destination)
   return NULL;
 }
 
+static inline bool
+is_instance_of_html_ostream (_GL_ATTRIBUTE_MAYBE_UNUSED ostream_t stream)
+{
+  return false;
+}
+
 /* ----------------------- From term-styled-ostream.h ----------------------- */
 
 typedef styled_ostream_t term_styled_ostream_t;
@@ -501,6 +578,18 @@ typedef styled_ostream_t term_styled_ostream_t;
 #define term_styled_ostream_set_hyperlink styled_ostream_set_hyperlink
 #define term_styled_ostream_flush_to_current_style styled_ostream_flush_to_current_style
 
+static inline term_ostream_t
+term_styled_ostream_get_destination (term_styled_ostream_t stream)
+{
+  return stream;
+}
+
+static inline const char *
+term_styled_ostream_get_css_filename (_GL_ATTRIBUTE_MAYBE_UNUSED term_styled_ostream_t stream)
+{
+  return NULL;
+}
+
 static inline term_styled_ostream_t
 term_styled_ostream_create (int fd, const char *filename,
                             _GL_ATTRIBUTE_MAYBE_UNUSED ttyctl_t tty_control,
@@ -509,6 +598,8 @@ term_styled_ostream_create (int fd, const char *filename,
   return fd_ostream_create (fd, filename, true);
 }
 
+#define is_instance_of_term_styled_ostream is_instance_of_term_ostream
+
 /* ----------------------- From html-styled-ostream.h ----------------------- */
 
 typedef styled_ostream_t html_styled_ostream_t;
@@ -523,6 +614,24 @@ typedef styled_ostream_t html_styled_ostream_t;
 #define html_styled_ostream_set_hyperlink styled_ostream_set_hyperlink
 #define html_styled_ostream_flush_to_current_style styled_ostream_flush_to_current_style
 
+static inline ostream_t
+html_styled_ostream_get_destination (_GL_ATTRIBUTE_MAYBE_UNUSED html_styled_ostream_t stream)
+{
+  return NULL;
+}
+
+static inline html_ostream_t
+html_styled_ostream_get_html_destination (_GL_ATTRIBUTE_MAYBE_UNUSED html_styled_ostream_t stream)
+{
+  return NULL;
+}
+
+static inline const char *
+html_styled_ostream_get_css_filename (_GL_ATTRIBUTE_MAYBE_UNUSED html_styled_ostream_t stream)
+{
+  return NULL;
+}
+
 static inline html_styled_ostream_t
 html_styled_ostream_create (_GL_ATTRIBUTE_MAYBE_UNUSED ostream_t destination,
                             _GL_ATTRIBUTE_MAYBE_UNUSED const char *css_filename)
@@ -532,6 +641,12 @@ html_styled_ostream_create (_GL_ATTRIBUTE_MAYBE_UNUSED ostream_t destination,
   return NULL;
 }
 
+static inline bool
+is_instance_of_html_styled_ostream (_GL_ATTRIBUTE_MAYBE_UNUSED ostream_t stream)
+{
+  return false;
+}
+
 /* ----------------------- From noop-styled-ostream.h ----------------------- */
 
 typedef styled_ostream_t noop_styled_ostream_t;
@@ -546,6 +661,18 @@ typedef styled_ostream_t noop_styled_ostream_t;
 #define noop_styled_ostream_set_hyperlink styled_ostream_set_hyperlink
 #define noop_styled_ostream_flush_to_current_style styled_ostream_flush_to_current_style
 
+static inline ostream_t
+noop_styled_ostream_get_destination (noop_styled_ostream_t stream)
+{
+  return stream;
+}
+
+static inline bool
+noop_styled_ostream_is_owning_destination (_GL_ATTRIBUTE_MAYBE_UNUSED noop_styled_ostream_t stream)
+{
+  return true;
+}
+
 static inline noop_styled_ostream_t
 noop_styled_ostream_create (ostream_t destination, bool pass_ownership)
 {
@@ -555,6 +682,12 @@ noop_styled_ostream_create (ostream_t destination, bool pass_ownership)
   return destination;
 }
 
+static inline bool
+is_instance_of_noop_styled_ostream (_GL_ATTRIBUTE_MAYBE_UNUSED ostream_t stream)
+{
+  return false;
+}
+
 /* ------------------------------ From color.h ------------------------------ */
 
 #define color_test_mode false
-- 
2.34.1

Reply via email to