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
@@ -46,8 +46,8 @@
|
||||
#define _ABIL_BIL_P_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <nl_types.h>
|
||||
#include "bil_parse.h"
|
||||
#include <Dt/MsgCatP.h>
|
||||
#include <ab_private/bil_parse.h>
|
||||
#include <ab/util_types.h>
|
||||
#include <ab_private/obj.h>
|
||||
#include "loadP.h"
|
||||
|
||||
@@ -260,7 +260,7 @@ get_keyword(FILE *file, int lastChar)
|
||||
*/
|
||||
char msg[256];
|
||||
sprintf(msg,
|
||||
catgets(ABIL_MESSAGE_CATD, ABIL_MESSAGE_SET, 35,
|
||||
CATGETS(ABIL_MESSAGE_CATD, ABIL_MESSAGE_SET, 35,
|
||||
"unknown keyword - %s"),
|
||||
tokenText);
|
||||
abil_print_custom_load_err(msg);
|
||||
@@ -378,7 +378,7 @@ yyerror(const char *message)
|
||||
if (strlen(tokenText) > 0)
|
||||
{
|
||||
sprintf(tokenMsg,
|
||||
catgets(ABIL_MESSAGE_CATD, ABIL_MESSAGE_SET, 37, ", near '%s'"),
|
||||
CATGETS(ABIL_MESSAGE_CATD, ABIL_MESSAGE_SET, 37, ", near '%s'"),
|
||||
tokenText);
|
||||
}
|
||||
sprintf(errMsg, "%s%s\n", message, tokenMsg);
|
||||
|
||||
@@ -1352,7 +1352,7 @@ bilP_load_att_name(BIL_TOKEN valueToken)
|
||||
|
||||
obj_name = obj_get_name(load_obj);
|
||||
sprintf(msg,
|
||||
catgets(ABIL_MESSAGE_CATD, ABIL_MESSAGE_SET, 36,
|
||||
CATGETS(ABIL_MESSAGE_CATD, ABIL_MESSAGE_SET, 36,
|
||||
"Duplicate name. Changed to %s.\n\t(This may be a conflict with the interface or project name)\n"), obj_name);
|
||||
abil_print_custom_load_err(msg);
|
||||
}
|
||||
@@ -1986,7 +1986,7 @@ bilP_load_att_type(BIL_TOKEN valueToken)
|
||||
|
||||
/* REMIND: make cat entry!
|
||||
sprintf(msg,
|
||||
catgets(ABIL_MESSAGE_CATD, ABIL_MESSAGE_SET, 36,
|
||||
CATGETS(ABIL_MESSAGE_CATD, ABIL_MESSAGE_SET, 36,
|
||||
"Duplicate name. Changed to %s.\n\t(This may be a conflict with the interface or project name)\n"),
|
||||
obj_name);
|
||||
*/
|
||||
@@ -2139,7 +2139,7 @@ bilP_load_list_value(BIL_TOKEN token)
|
||||
obj_set_drag_types(loadObj, dndTypeFlag);
|
||||
else
|
||||
util_dprintf(1, "%s",
|
||||
abil_loadmsg(catgets(ABIL_MESSAGE_CATD, ABIL_MESSAGE_SET, 48,
|
||||
abil_loadmsg(CATGETS(ABIL_MESSAGE_CATD, ABIL_MESSAGE_SET, 48,
|
||||
"only 1 drag-type allowed - discarding additional drag-type")));
|
||||
break;
|
||||
|
||||
|
||||
@@ -209,7 +209,7 @@ bil_load_file(
|
||||
if (bilP_load.project == NULL)
|
||||
{
|
||||
LoadErr = TRUE;
|
||||
sprintf(Buf, "%s", catgets(ABIL_MESSAGE_CATD, ABIL_MESSAGE_SET, 39,
|
||||
sprintf(Buf, "%s", CATGETS(ABIL_MESSAGE_CATD, ABIL_MESSAGE_SET, 39,
|
||||
"Unable to load project."));
|
||||
errmsg = Buf;
|
||||
goto epilogue;
|
||||
|
||||
@@ -265,7 +265,7 @@ attr_is_undef(
|
||||
if ( obj_get_packing(obj) == AB_PACK_UNDEF )
|
||||
{
|
||||
util_error(
|
||||
catgets(ABIL_MESSAGE_CATD, ABIL_MESSAGE_SET, 41,
|
||||
CATGETS(ABIL_MESSAGE_CATD, ABIL_MESSAGE_SET, 41,
|
||||
"packing is undefined\n"));
|
||||
return (True);
|
||||
}
|
||||
@@ -285,7 +285,7 @@ attr_is_undef(
|
||||
if ( obj_get_menu_type(obj) == AB_MENU_UNDEF )
|
||||
{
|
||||
util_error(
|
||||
catgets(ABIL_MESSAGE_CATD, ABIL_MESSAGE_SET, 42,
|
||||
CATGETS(ABIL_MESSAGE_CATD, ABIL_MESSAGE_SET, 42,
|
||||
"menu type is undefined\n"));
|
||||
return (True);
|
||||
}
|
||||
@@ -299,7 +299,7 @@ attr_is_undef(
|
||||
if (obj_get_ref_point(obj) == AB_CP_UNDEF)
|
||||
{
|
||||
util_error(
|
||||
catgets(ABIL_MESSAGE_CATD, ABIL_MESSAGE_SET, 42,
|
||||
CATGETS(ABIL_MESSAGE_CATD, ABIL_MESSAGE_SET, 42,
|
||||
"reference point is undefined\n"));
|
||||
return (True);
|
||||
}
|
||||
@@ -3195,7 +3195,7 @@ store_project_tree(
|
||||
else
|
||||
{
|
||||
util_printf_err(
|
||||
catgets(ABIL_MESSAGE_CATD, ABIL_MESSAGE_SET, 45,
|
||||
CATGETS(ABIL_MESSAGE_CATD, ABIL_MESSAGE_SET, 45,
|
||||
"Cannot save project; Either nothing to store or NULL filename."));
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <nl_types.h>
|
||||
#include <Dt/MsgCatP.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <ab_private/util.h>
|
||||
|
||||
@@ -82,28 +82,28 @@ abil_loadmsg(STRING userMessage)
|
||||
if (*File != 0)
|
||||
{
|
||||
sprintf(tmpMsg,
|
||||
catgets(ABIL_MESSAGE_CATD, ABIL_MESSAGE_SET, 27, "file: %s"),
|
||||
CATGETS(ABIL_MESSAGE_CATD, ABIL_MESSAGE_SET, 27, "file: %s"),
|
||||
File);
|
||||
strcat(msg, tmpMsg);
|
||||
}
|
||||
if (lineNumber > 0)
|
||||
{
|
||||
sprintf(tmpMsg,
|
||||
catgets(ABIL_MESSAGE_CATD, ABIL_MESSAGE_SET, 28, ", line: %d"),
|
||||
CATGETS(ABIL_MESSAGE_CATD, ABIL_MESSAGE_SET, 28, ", line: %d"),
|
||||
lineNumber);
|
||||
strcat(msg, tmpMsg);
|
||||
}
|
||||
if (*Current_Object != 0)
|
||||
{
|
||||
sprintf(tmpMsg,
|
||||
catgets(ABIL_MESSAGE_CATD, ABIL_MESSAGE_SET,29, ", object: %s"),
|
||||
CATGETS(ABIL_MESSAGE_CATD, ABIL_MESSAGE_SET,29, ", object: %s"),
|
||||
Current_Object);
|
||||
strcat(msg, tmpMsg);
|
||||
}
|
||||
if (*Attribute != 0)
|
||||
{
|
||||
sprintf(tmpMsg,
|
||||
catgets(ABIL_MESSAGE_CATD, ABIL_MESSAGE_SET, 30,
|
||||
CATGETS(ABIL_MESSAGE_CATD, ABIL_MESSAGE_SET, 30,
|
||||
", attribute: %s"),
|
||||
Attribute);
|
||||
strcat(msg, tmpMsg);
|
||||
@@ -111,23 +111,23 @@ abil_loadmsg(STRING userMessage)
|
||||
if (*Action_Attr != 0)
|
||||
{
|
||||
sprintf(tmpMsg,
|
||||
catgets(ABIL_MESSAGE_CATD, ABIL_MESSAGE_SET, 31,
|
||||
CATGETS(ABIL_MESSAGE_CATD, ABIL_MESSAGE_SET, 31,
|
||||
", action-attribute: %s"),
|
||||
Action_Attr);
|
||||
strcat(msg, tmpMsg);
|
||||
}
|
||||
|
||||
strcat(msg, catgets(ABIL_MESSAGE_CATD, ABIL_MESSAGE_SET, 32, ", "));
|
||||
strcat(msg, CATGETS(ABIL_MESSAGE_CATD, ABIL_MESSAGE_SET, 32, ", "));
|
||||
if ( (userMessage == 0) || (*userMessage == 0) )
|
||||
{
|
||||
strcat(msg, catgets(ABIL_MESSAGE_CATD, ABIL_MESSAGE_SET, 33,
|
||||
strcat(msg, CATGETS(ABIL_MESSAGE_CATD, ABIL_MESSAGE_SET, 33,
|
||||
"syntax error"));
|
||||
}
|
||||
else
|
||||
{
|
||||
strcat(msg, userMessage);
|
||||
}
|
||||
strcat(msg, catgets(ABIL_MESSAGE_CATD, ABIL_MESSAGE_SET, 34, "\n"));
|
||||
strcat(msg, CATGETS(ABIL_MESSAGE_CATD, ABIL_MESSAGE_SET, 34, "\n"));
|
||||
|
||||
return msg;
|
||||
}
|
||||
@@ -238,12 +238,12 @@ abil_print_load_err(int errmsg)
|
||||
if (!abil_loadmsg_err_printed())
|
||||
{
|
||||
if(Errormsg[errmsg].msg_id < 0) {
|
||||
snprintf(msg, sizeof(msg), "%s", catgets(ABIL_MESSAGE_CATD, ABIL_MESSAGE_SET, 33,
|
||||
snprintf(msg, sizeof(msg), "%s", CATGETS(ABIL_MESSAGE_CATD, ABIL_MESSAGE_SET, 33,
|
||||
"syntax error"));
|
||||
}
|
||||
else {
|
||||
snprintf(msg, sizeof(msg), "%s",
|
||||
catgets(ABIL_MESSAGE_CATD, ABIL_MESSAGE_SET,
|
||||
CATGETS(ABIL_MESSAGE_CATD, ABIL_MESSAGE_SET,
|
||||
Errormsg[errmsg].msg_id,
|
||||
Errormsg[errmsg].def_str));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user