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 8278e0eae3
commit 7010b2c11b
241 changed files with 3153 additions and 3493 deletions

View File

@@ -54,7 +54,6 @@
*
***************************************************************************/
#include <nl_types.h>
#include <stdio.h>
#include <setjmp.h>
#include <time.h>
@@ -64,6 +63,7 @@
#include <X11/Xlibint.h>
#include <Xm/Xm.h>
#include <Dt/MsgCatP.h>
#include "vg.h"
#include "vgmsg.h"
@@ -734,7 +734,7 @@ LogError( unsigned char *fmt, ...)
void
CloseCatalog(void)
{
catclose(nl_fd);
CATCLOSE(nl_fd);
}
/***************************************************************************
@@ -773,7 +773,7 @@ OpenCatalog(void)
*/
if (NULL != langenv)
{
nl_fd = catopen(NLS_CATALOG, NL_CAT_LOCALE);
nl_fd = CATOPEN(NLS_CATALOG, NL_CAT_LOCALE);
if (0 > (long) nl_fd)
LogError((unsigned char*) MC_DEF_LOG_NO_MSGCAT, langenv);
}
@@ -794,7 +794,7 @@ ReadCatalog(int setn, int msgn, char *dflt)
if ((0 > (long) nl_fd) || (NULL == langenv))
return (unsigned char*) dflt;
else
return (unsigned char*) catgets(nl_fd, setn, msgn, dflt);
return (unsigned char*) CATGETS(nl_fd, setn, msgn, dflt);
}
/***************************************************************************
@@ -1127,48 +1127,3 @@ ToPixel( Widget w, int orientation, int pixel )
XmPIXELS));
}
}
#if 0
/***************************************************************************
*
* _DtMessage Catalog Stubs
*
* These stub routines can be used for porting to systems that do not yet
* support message catalogs. Replace the above "0" with an appropriate
* define for your target system. Do the same for the external defines
* in "vg.h".
***************************************************************************/
nl_catd
catopen(name, oflag)
char *name;
int oflag;
{
return (555);
}
int
catclose(catd)
nl_catd catd;
{
return;
}
char *
catgets(catd, set_num, msg_num, def_str)
nl_catd catd;
int set_num;
int msg_num;
char *def_str;
{
return (def_str);
}
#endif