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:
Lev Kujawski
2021-01-30 20:05:13 -07:00
committed by Jon Trulson
parent 3379999106
commit a6ea2a2d52
241 changed files with 3154 additions and 3498 deletions

View File

@@ -47,7 +47,7 @@
#define _OBJXM_P_H_
#include <X11/Intrinsic.h>
#include <nl_types.h>
#include <Dt/MsgCatP.h>
#include <ab_private/obj_notify.h>
#include <ab_private/objxm.h>

View File

@@ -546,7 +546,7 @@ objxm_comp_set_color_args(
if (status == ERR) /* Color couldn't be allocated! */
{
obj_get_safe_name(rootObj, name, 256);
util_printf_err(catgets(OBJXM_MESSAGE_CATD,
util_printf_err(CATGETS(OBJXM_MESSAGE_CATD,
OBJXM_MESSAGE_SET, 21,
"WARNING: Object '%s'\nCould not allocate Background color \"%s\".\n\
Object's Background will default to white."),
@@ -572,7 +572,7 @@ Object's Background will default to white."),
if (status == ERR) /* Color couldn't be allocated! */
{
obj_get_safe_name(rootObj, name, 256);
util_printf_err(catgets(OBJXM_MESSAGE_CATD,
util_printf_err(CATGETS(OBJXM_MESSAGE_CATD,
OBJXM_MESSAGE_SET, 22,
"WARNING: Object '%s'\nCould not allocate Foreground color \"%s\".\n\
Object's Foreground will default to black."),
@@ -1667,7 +1667,7 @@ objxmP_set_attachment_arg(
{
char name[256];
obj_get_safe_name(obj, name, 256);
util_printf_err(catgets(OBJXM_MESSAGE_CATD, OBJXM_MESSAGE_SET, 3,
util_printf_err(CATGETS(OBJXM_MESSAGE_CATD, OBJXM_MESSAGE_SET, 3,
"ERROR: %s: NULL Object attachment\n"), name);
}
break;

View File

@@ -309,7 +309,7 @@ xm_configure_tree(
if (configCount!= numSalientObjs)
{
fprintf(stderr, "%s",
catgets(OBJXM_MESSAGE_CATD, OBJXM_MESSAGE_SET, 8,
CATGETS(OBJXM_MESSAGE_CATD, OBJXM_MESSAGE_SET, 8,
"INTERNAL ERROR: salient counts don't match.\n") );
iRetVal= -1;
goto epilogue;
@@ -471,7 +471,7 @@ objxm_comp_get_subobj(
char name[256];
obj_get_safe_name(obj, name, 256);
fprintf(stderr,
catgets(OBJXM_MESSAGE_CATD, OBJXM_MESSAGE_SET, 9,
CATGETS(OBJXM_MESSAGE_CATD, OBJXM_MESSAGE_SET, 9,
"ERROR: objxm_comp_get_subobj - object not xmconfigured: %s\n"),
name);

View File

@@ -219,25 +219,25 @@ objxm_pixmap_conversion_error_msg(
char file_buf[BUF_SIZE];
if (obj != NULL)
sprintf(buf, catgets(OBJXM_MESSAGE_CATD, 203, 14,
sprintf(buf, CATGETS(OBJXM_MESSAGE_CATD, 203, 14,
"Warning: %s :\n"), util_strsafe(obj_get_name(obj)));
else
strcpy(buf, "");
sprintf(buf2, catgets(OBJXM_MESSAGE_CATD, 203, 15,
sprintf(buf2, CATGETS(OBJXM_MESSAGE_CATD, 203, 15,
"Graphic File base '%s'\ncould not be converted to a Pixmap because\n"), filebase);
strcat(buf, buf2);
if (status == ERR_BAD_PARAM2)
strcat(buf, catgets(OBJXM_MESSAGE_CATD, 203, 16,
strcat(buf, CATGETS(OBJXM_MESSAGE_CATD, 203, 16,
"File base is an empty string."));
else
{
strcat(buf, catgets(OBJXM_MESSAGE_CATD, 203, 17,
strcat(buf, CATGETS(OBJXM_MESSAGE_CATD, 203, 17,
"None of the following files could be converted to a Pixmap:\n"));
if ((int)(strlen(buf) + (4 * (strlen(filebase) + 4))) > LG_BUF_SIZE)
strcat(buf, catgets(OBJXM_MESSAGE_CATD, 203, 18,
strcat(buf, CATGETS(OBJXM_MESSAGE_CATD, 203, 18,
"filenames too long to display\n"));
else
{
@@ -248,7 +248,7 @@ objxm_pixmap_conversion_error_msg(
}
}
util_set_help_data(catgets(OBJXM_MESSAGE_CATD, 203, 20,
util_set_help_data(CATGETS(OBJXM_MESSAGE_CATD, 203, 20,
"The graphic file name specified could not be converted\ninto a pixmap. App Builder searches for a file of the\nform Filename.pm, Filename.xpm, Filename.bm, and\nFilename.xbm.\n\nEither none of those files exists in the directory specified\n(via the Graphic Filename field or if no path was specified,\nthen the current working directory), or a file exists but may\nbe corrupt."), NULL, NULL);
return(buf);