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
@@ -52,7 +52,7 @@ extern "C" { extern int seteuid(uid_t); }
|
||||
#ifdef hpux
|
||||
static char **msg_strings = NULL;
|
||||
|
||||
// Cannot use multiple catgets paramemter calls in functions because the
|
||||
// Cannot use multiple catgets parameter calls in functions because the
|
||||
// previous catgets returned value is overwritten by later catgets calls
|
||||
// Example: this would fail on HP systems
|
||||
// sprintf(buf, "%s %s" catgets(...), catgets(...))
|
||||
@@ -63,7 +63,7 @@ char *Catgets(nl_catd catd, int set_num, int msg_num, char *s)
|
||||
return s;
|
||||
|
||||
if (!msg_strings[msg_num])
|
||||
msg_strings[msg_num] = strdup(catgets(catd, set_num, msg_num, s));
|
||||
msg_strings[msg_num] = strdup(CATGETS(catd, set_num, msg_num, s));
|
||||
return msg_strings[msg_num];
|
||||
}
|
||||
#endif
|
||||
@@ -89,9 +89,9 @@ int main(int argc, char **argv)
|
||||
errno = 0;
|
||||
|
||||
#ifdef NL_CAT_LOCALE
|
||||
dtprintinfo_cat = catopen("dtprintinfo", NL_CAT_LOCALE);
|
||||
dtprintinfo_cat = CATOPEN("dtprintinfo", NL_CAT_LOCALE);
|
||||
#else
|
||||
dtprintinfo_cat = catopen("dtprintinfo", 0);
|
||||
dtprintinfo_cat = CATOPEN("dtprintinfo", 0);
|
||||
#endif
|
||||
|
||||
if ((nl_catd) errno)
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <nl_types.h>
|
||||
#include <Dt/MsgCatP.h>
|
||||
#include <locale.h>
|
||||
|
||||
#include "dtprintinfo_msg.h"
|
||||
@@ -41,14 +41,8 @@ extern "C" {
|
||||
|
||||
extern nl_catd dtprintinfo_cat;
|
||||
|
||||
#ifdef hpux
|
||||
extern char *Catgets(nl_catd catd, int set_num, int msg_num, char *s);
|
||||
#define MESSAGE(msg) \
|
||||
Catgets(dtprintinfo_cat,DTPRINTER_SET,msg,TXT_DTPRINTER_SET_ ## msg)
|
||||
#else
|
||||
#define MESSAGE(msg) \
|
||||
catgets(dtprintinfo_cat,DTPRINTER_SET,msg,TXT_DTPRINTER_SET_ ## msg)
|
||||
#endif
|
||||
CATGETS(dtprintinfo_cat,DTPRINTER_SET,msg,TXT_DTPRINTER_SET_ ## msg)
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* Close scope of 'extern "C"' declaration which encloses file. */
|
||||
|
||||
Reference in New Issue
Block a user