Centralize catgets() calls through MsgCat
CDE has relied upon catgets() implementations following a relaxed interpretation of the XPG internationalization standard that ignored -1, the standard error value returned by catopen, as the catalog argument. However, this same behavior causes segmentation faults with the musl C library. This patch: - Centralizes (with the exception of ToolTalk) all calls to catopen(), catgets(), and catclose() through MsgCat within the DtSvc library. - Prevents calls to catgets() and catclose() that rely upon undefined behavior. - Eliminates a number of bespoke catgets() wrappers, including multiple redundant caching implementations designed to work around a design peculiarity in HP/UX. - Eases building CDE without XPG internationalization support by providing the appropriate macros.
This commit is contained in:
committed by
Jon Trulson
parent
3379999106
commit
a6ea2a2d52
@@ -43,7 +43,6 @@
|
||||
#include <errno.h>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
#include <nl_types.h>
|
||||
|
||||
#include "Tt/tt_c.h"
|
||||
#include "util/tt_file_system.h"
|
||||
|
||||
@@ -103,7 +103,7 @@ _tt_gettext(
|
||||
#endif // OPT_DGETTEXT
|
||||
|
||||
#if defined(OPT_CATGETS)
|
||||
static char *
|
||||
static const char *
|
||||
_tt__catgets(
|
||||
int set_num,
|
||||
int msg_num,
|
||||
@@ -111,13 +111,16 @@ _tt__catgets(
|
||||
)
|
||||
{
|
||||
static nl_catd catalog = 0;
|
||||
if (catalog == 0) {
|
||||
if (catalog == (nl_catd) 0) {
|
||||
catalog = catopen(
|
||||
#if defined(OPT_BUG_AIX)
|
||||
(char *)
|
||||
#endif
|
||||
tt_err_domain, NL_CAT_LOCALE );
|
||||
}
|
||||
if (catalog == (nl_catd) -1) {
|
||||
return default_string;
|
||||
}
|
||||
return catgets( catalog, set_num, msg_num,
|
||||
#if defined(OPT_BUG_SUNOS_5) || defined(OPT_BUG_AIX)
|
||||
(char *)
|
||||
@@ -126,7 +129,7 @@ _tt__catgets(
|
||||
}
|
||||
#endif // OPT_CATGETS
|
||||
|
||||
char *
|
||||
const char *
|
||||
_tt_catgets(
|
||||
int set_num,
|
||||
int msg_num,
|
||||
|
||||
@@ -56,7 +56,6 @@
|
||||
#include <sys/resource.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <nl_types.h>
|
||||
#include <util/tt_gettext.h>
|
||||
#include <tt_const.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
Reference in New Issue
Block a user