From: Bruno Haible Date: Fri, 2 Aug 2024 20:57:06 +0000 (+0200) Subject: libgettextpo: Remove backward compatibility with versions < 0.15 (July 2006). X-Git-Tag: v0.23~192 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f8baed132fff135c90e5e901116ee480a1158a83;p=thirdparty%2Fgettext.git libgettextpo: Remove backward compatibility with versions < 0.15 (July 2006). * gettext-tools/libgettextpo/gettext-po.c (_GL_NO_INLINE_ERROR): Remove macro. Don't include , , , 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. --- diff --git a/gettext-tools/libgettextpo/gettext-po.c b/gettext-tools/libgettextpo/gettext-po.c index 2b58f6509..58771e1d5 100644 --- a/gettext-tools/libgettextpo/gettext-po.c +++ b/gettext-tools/libgettextpo/gettext-po.c @@ -18,30 +18,13 @@ #ifdef HAVE_CONFIG_H # include #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 -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 -#include #include #include -#include #include #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 = _(""); - 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 = _(""); - 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; -} diff --git a/gettext-tools/libgettextpo/gettext-po.in.h b/gettext-tools/libgettextpo/gettext-po.in.h index 69cf38cdb..b902b28f5 100644 --- a/gettext-tools/libgettextpo/gettext-po.in.h +++ b/gettext-tools/libgettextpo/gettext-po.in.h @@ -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 diff --git a/gettext-tools/src/po-xerror.c b/gettext-tools/src/po-xerror.c index a2a4f33e0..daa7740c3 100644 --- a/gettext-tools/src/po-xerror.c +++ b/gettext-tools/src/po-xerror.c @@ -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,