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
@@ -101,10 +101,10 @@
|
||||
|
||||
/* include file for message texts */
|
||||
#include <limits.h>
|
||||
#include <nl_types.h>
|
||||
#include <Dt/MsgCatP.h>
|
||||
#define MF_DTSCREEN "dtscreen"
|
||||
|
||||
#include <nl_types.h>
|
||||
#include <Dt/MsgCatP.h>
|
||||
#include <locale.h>
|
||||
nl_catd scmc_catd; /* Cat descriptor for scmc conversion */
|
||||
|
||||
@@ -198,7 +198,7 @@ allocpixel(Colormap cmap, char *name, char *def)
|
||||
name, def);
|
||||
|
||||
#else
|
||||
fprintf(stderr, catgets(scmc_catd, 2, 35,
|
||||
fprintf(stderr, CATGETS(scmc_catd, 2, 35,
|
||||
"couldn't allocate: %s, using %s instead\n"),
|
||||
name, def);
|
||||
#endif
|
||||
@@ -225,7 +225,7 @@ main(int argc, char *argv[])
|
||||
|
||||
/* set locale to what is defined by local environment */
|
||||
setlocale(LC_ALL,"");
|
||||
scmc_catd = catopen(MF_DTSCREEN, NL_CAT_LOCALE);
|
||||
scmc_catd = CATOPEN(MF_DTSCREEN, NL_CAT_LOCALE);
|
||||
|
||||
ProgramName = strrchr(argv[0], '/');
|
||||
if (ProgramName)
|
||||
@@ -264,7 +264,7 @@ main(int argc, char *argv[])
|
||||
*/
|
||||
if (!DtSaverGetWindows(dsp, &winprop, &nitems))
|
||||
{
|
||||
fprintf(stderr, catgets(scmc_catd, 2, 40,
|
||||
fprintf(stderr, CATGETS(scmc_catd, 2, 40,
|
||||
"%s: Cannot locate window in which to draw. Using the -create\n"
|
||||
"option will cause %s to create its own window.\n"),
|
||||
ProgramName, ProgramName);
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
|
||||
/* include file for message texts */
|
||||
#include <limits.h>
|
||||
#include <nl_types.h>
|
||||
#include <Dt/MsgCatP.h>
|
||||
#define MF_DTSCREEN "dtscreen.cat"
|
||||
|
||||
#include <locale.h>
|
||||
@@ -247,7 +247,7 @@ Syntax(char *badOption)
|
||||
fprintf(stderr, "%s: bad command line option: %s.\n\n",
|
||||
ProgramName, badOption);
|
||||
#else
|
||||
fprintf(stderr, catgets(scmc_catd, 2, 1,
|
||||
fprintf(stderr, CATGETS(scmc_catd, 2, 1,
|
||||
"%s: Bad command line option: %s.\n\n"),
|
||||
ProgramName, badOption);
|
||||
#endif
|
||||
@@ -286,7 +286,7 @@ Syntax(char *badOption)
|
||||
fprintf(stderr, "\nType %s -help for a full description.\n\n",
|
||||
ProgramName);
|
||||
#else
|
||||
fprintf(stderr, catgets(scmc_catd, 2, 2,
|
||||
fprintf(stderr, CATGETS(scmc_catd, 2, 2,
|
||||
"\nType %s -help for a full description.\n\n"),
|
||||
ProgramName);
|
||||
#endif
|
||||
@@ -303,7 +303,7 @@ Help(void)
|
||||
fprintf(stderr, "where options include:\n");
|
||||
|
||||
#else
|
||||
fprintf(stderr, catgets(scmc_catd, 2, 3,
|
||||
fprintf(stderr, CATGETS(scmc_catd, 2, 3,
|
||||
"Usage:\n %s [-options ...]\n\n\
|
||||
where options include:\n"), ProgramName);
|
||||
#endif
|
||||
@@ -316,7 +316,7 @@ Help(void)
|
||||
fprintf(stderr, " %-28s %s\n", "-mode mode", "animation mode");
|
||||
fprintf(stderr, " where mode is one of:\n");
|
||||
#else
|
||||
fprintf(stderr, catgets(scmc_catd, 2, 5,
|
||||
fprintf(stderr, CATGETS(scmc_catd, 2, 5,
|
||||
" %-28s %s\n\t where mode is one of:\n"),
|
||||
"-mode mode", "animation mode");
|
||||
#endif
|
||||
@@ -398,7 +398,7 @@ GetResource(XrmDatabase database, char *parentname, char *parentclass,
|
||||
error("%s: GetResource - couldn't allocate memory");
|
||||
#else
|
||||
{
|
||||
fprintf(stderr, catgets(scmc_catd, 2, 18,
|
||||
fprintf(stderr, CATGETS(scmc_catd, 2, 18,
|
||||
"%s: GetResource - couldn't allocate memory.\n"),ProgramName);
|
||||
exit(1);
|
||||
}
|
||||
@@ -502,7 +502,7 @@ open_display(void)
|
||||
error("%s: Malformed -display argument, \"%s\"\n", display);
|
||||
#else
|
||||
{
|
||||
fprintf(stderr, catgets(scmc_catd, 2, 19,
|
||||
fprintf(stderr, CATGETS(scmc_catd, 2, 19,
|
||||
"%s: Malformed -display argument: %s.\n"), ProgramName,display);
|
||||
exit(1);
|
||||
}
|
||||
@@ -515,7 +515,7 @@ open_display(void)
|
||||
error("%s: unable to open display %s.\n", display);
|
||||
#else
|
||||
{
|
||||
fprintf(stderr, catgets(scmc_catd, 2, 17,
|
||||
fprintf(stderr, CATGETS(scmc_catd, 2, 17,
|
||||
"%s: Unable to open display %s.\n"),ProgramName, display);
|
||||
exit(1);
|
||||
}
|
||||
@@ -716,7 +716,7 @@ void CheckResources(void)
|
||||
#ifdef MIT_R5
|
||||
fprintf(stderr, "Unknown mode: ");
|
||||
#else
|
||||
fprintf(stderr, "%s", catgets(scmc_catd, 2, 7,
|
||||
fprintf(stderr, "%s", CATGETS(scmc_catd, 2, 7,
|
||||
"Unknown mode: "));
|
||||
#endif
|
||||
Syntax(mode);
|
||||
|
||||
Reference in New Issue
Block a user