]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
libgettextpo: Remove backward compatibility with versions < 0.15 (July 2006).
authorBruno Haible <bruno@clisp.org>
Fri, 2 Aug 2024 20:57:06 +0000 (22:57 +0200)
committerBruno Haible <bruno@clisp.org>
Fri, 2 Aug 2024 22:31:17 +0000 (00:31 +0200)
* gettext-tools/libgettextpo/gettext-po.c (_GL_NO_INLINE_ERROR): Remove macro.
Don't include <error.h>, <stdbool.h>, <stdarg.h>, xerror.h, po-error.h,
format.h.
(orig_error, orig_error_at_line): Remove variables.
(void_multiline_warning, void_multiline_error): Remove functions.
(po_file_read_v2, po_file_read, po_file_write, po_error_logger,
po_message_check_format): Remove functions.
* gettext-tools/libgettextpo/gettext-po.in.h (struct po_error_handler): Update
comment.
* gettext-tools/src/po-xerror.c: Update comment.

gettext-tools/libgettextpo/gettext-po.c
gettext-tools/libgettextpo/gettext-po.in.h
gettext-tools/src/po-xerror.c

index 2b58f6509860ae5c4dc7e02f3bab4a9e45426afe..58771e1d5a9fd7989761f1cff3e07060eafd09ec 100644 (file)
 #ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
-/* Avoid side effect of gnulib's error.h on 'struct po_error_handler'.  */
-#define _GL_NO_INLINE_ERROR
-
-/* Avoid side effect of config.h on 'struct po_error_handler'.  */
-#include <error.h>
-static void (*orig_error) (int status, int errnum,
-                           const char *format, ...)
-  = error;
-
-static void (*orig_error_at_line) (int status, int errnum,
-                                   const char *filename, unsigned int lineno,
-                                   const char *format, ...)
-  = error_at_line;
-#undef error
-#undef error_at_line
 
 /* Specification.  */
 #include "gettext-po.h"
 
 #include <limits.h>
-#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <stdarg.h>
 #include <string.h>
 
 #include "message.h"
@@ -51,10 +34,7 @@ static void (*orig_error_at_line) (int status, int errnum,
 #include "read-po-lex.h"
 #include "write-catalog.h"
 #include "write-po.h"
-#include "xerror.h"
-#include "po-error.h"
 #include "po-xerror.h"
-#include "format.h"
 #include "xvasprintf.h"
 #include "msgl-check.h"
 #include "gettext.h"
@@ -87,19 +67,6 @@ struct po_message_iterator
 int libgettextpo_version = LIBGETTEXTPO_VERSION;
 
 
-static void
-void_multiline_warning (char *prefix, char *message)
-{
-  multiline_warning (prefix, message);
-}
-
-static void
-void_multiline_error (char *prefix, char *message)
-{
-  multiline_error (prefix, message);
-}
-
-
 /* Create an empty PO file representation in memory.  */
 
 po_file_t
@@ -162,88 +129,6 @@ po_file_read (const char *filename, po_xerror_handler_t handler)
     fclose (fp);
   return file;
 }
-#undef po_file_read
-
-#ifdef __cplusplus
-extern "C" po_file_t po_file_read_v2 (const char *filename, po_error_handler_t handler);
-#endif
-po_file_t
-po_file_read_v2 (const char *filename, po_error_handler_t handler)
-{
-  FILE *fp;
-  po_file_t file;
-
-  if (strcmp (filename, "-") == 0 || strcmp (filename, "/dev/stdin") == 0)
-    {
-      filename = _("<stdin>");
-      fp = stdin;
-    }
-  else
-    {
-      fp = fopen (filename, "r");
-      if (fp == NULL)
-        return NULL;
-    }
-
-  /* Establish error handler around read_catalog_stream().  */
-  po_error             = handler->error;
-  po_error_at_line     = handler->error_at_line;
-  po_multiline_warning = handler->multiline_warning;
-  po_multiline_error   = handler->multiline_error;
-  gram_max_allowed_errors = UINT_MAX;
-
-  file = XMALLOC (struct po_file);
-  file->real_filename = filename;
-  file->logical_filename = filename;
-  file->mdlp = read_catalog_stream (fp, file->real_filename,
-                                    file->logical_filename, &input_format_po);
-  file->domains = NULL;
-
-  /* Restore error handler.  */
-  po_error             = orig_error;
-  po_error_at_line     = orig_error_at_line;
-  po_multiline_warning = void_multiline_warning;
-  po_multiline_error   = void_multiline_error;
-  gram_max_allowed_errors = 20;
-
-  if (fp != stdin)
-    fclose (fp);
-  return file;
-}
-
-/* Older version for binary backward compatibility.  */
-#ifdef __cplusplus
-extern "C" po_file_t po_file_read (const char *filename);
-#endif
-po_file_t
-po_file_read (const char *filename)
-{
-  FILE *fp;
-  po_file_t file;
-
-  if (strcmp (filename, "-") == 0 || strcmp (filename, "/dev/stdin") == 0)
-    {
-      filename = _("<stdin>");
-      fp = stdin;
-    }
-  else
-    {
-      fp = fopen (filename, "r");
-      if (fp == NULL)
-        return NULL;
-    }
-
-  file = XMALLOC (struct po_file);
-  file->real_filename = filename;
-  file->logical_filename = filename;
-  file->mdlp = read_catalog_stream (fp, file->real_filename,
-                                    file->logical_filename, &input_format_po);
-  file->domains = NULL;
-
-  if (fp != stdin)
-    fclose (fp);
-  return file;
-}
 
 
 /* Write an in-memory PO file to a file.
@@ -268,31 +153,6 @@ po_file_write (po_file_t file, const char *filename, po_xerror_handler_t handler
 
   return file;
 }
-#undef po_file_write
-
-/* Older version for binary backward compatibility.  */
-#ifdef __cplusplus
-extern "C" po_file_t po_file_write (po_file_t file, const char *filename, po_error_handler_t handler);
-#endif
-po_file_t
-po_file_write (po_file_t file, const char *filename, po_error_handler_t handler)
-{
-  /* Establish error handler around msgdomain_list_print().  */
-  po_error             = handler->error;
-  po_error_at_line     = handler->error_at_line;
-  po_multiline_warning = handler->multiline_warning;
-  po_multiline_error   = handler->multiline_error;
-
-  msgdomain_list_print (file->mdlp, filename, &output_format_po, true, false);
-
-  /* Restore error handler.  */
-  po_error             = orig_error;
-  po_error_at_line     = orig_error_at_line;
-  po_multiline_warning = void_multiline_warning;
-  po_multiline_error   = void_multiline_error;
-
-  return file;
-}
 
 
 /* Free a PO file from memory.  */
@@ -1335,47 +1195,3 @@ po_message_check_format (po_message_t message, po_xerror_handler_t handler)
   po_xerror  = textmode_xerror;
   po_xerror2 = textmode_xerror2;
 }
-#undef po_message_check_format
-
-/* Older version for binary backward compatibility.  */
-
-/* An error logger based on the po_error function pointer.  */
-static void
-po_error_logger (void *data, const char *format, ...)
-     __attribute__ ((__format__ (__printf__, 2, 3)));
-static void
-po_error_logger (void *data, const char *format, ...)
-{
-  va_list args;
-  char *error_message;
-
-  va_start (args, format);
-  if (vasprintf (&error_message, format, args) < 0)
-    orig_error (EXIT_FAILURE, 0, _("memory exhausted"));
-  va_end (args);
-  po_error (0, 0, "%s", error_message);
-  free (error_message);
-}
-
-/* Test whether the message translation is a valid format string if the message
-   is marked as being a format string.  If it is invalid, pass the reasons to
-   the handler.  */
-#ifdef __cplusplus
-extern "C" void po_message_check_format (po_message_t message, po_error_handler_t handler);
-#endif
-void
-po_message_check_format (po_message_t message, po_error_handler_t handler)
-{
-  message_ty *mp = (message_ty *) message;
-
-  /* Establish error handler for po_error_logger().  */
-  po_error = handler->error;
-
-  check_msgid_msgstr_format (mp->msgid, mp->msgid_plural,
-                             mp->msgstr, mp->msgstr_len,
-                             mp->is_format, mp->range, NULL,
-                             po_error_logger, NULL);
-
-  /* Restore error handler.  */
-  po_error = orig_error;
-}
index 69cf38cdb315ca3d14648e734d82815096d18a0d..b902b28f57f50ccf910bc8cf745581620297c478 100644 (file)
@@ -46,7 +46,7 @@ typedef struct po_message *po_message_t;
 /* A po_filepos_t represents a string's position within a source file.  */
 typedef struct po_filepos *po_filepos_t;
 
-/* A po_error_handler handles error situations.  */
+/* A po_error_handler handles error situations.  No longer used.  */
 struct po_error_handler
 {
   /* Signal an error.  The error message is built from FORMAT and the following
index a2a4f33e03cf782b8b63209d503be10df173d2d3..daa7740c307bd16f64c75b087e0d0efd63a9fdb1 100644 (file)
@@ -113,8 +113,7 @@ xerror (int severity, const char *prefix_tail,
 }
 
 /* The default error handler is based on the lower-level error handler
-   in po-error.h, so that gettext-po.h can offer to override one or the
-   other.  */
+   in po-error.h.  */
 void
 textmode_xerror (int severity,
                  const struct message_ty *message,