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
8278e0eae3
commit
7010b2c11b
@@ -166,7 +166,8 @@ INCLUDES = -I$(XPROJECTROOT)/include/freetype2
|
||||
dpylist.o error.o file.o mitauth.o protodpy.o policy.o \
|
||||
reset.o resource.o server.o session.o socket.o util.o \
|
||||
verify.o sysauth.o fontpath.o $(DESOBJS) qualify.o choose.o \
|
||||
netaddr.o xdmcp.o $(PAM_OBJS) $(SOLARIS_OBJS)
|
||||
netaddr.o xdmcp.o $(PAM_OBJS) $(SOLARIS_OBJS) \
|
||||
$(CDELIBSRC)/DtSvc/DtUtil2/MsgCat.o
|
||||
|
||||
PROG2 = dtgreet
|
||||
#ifdef AlphaArchitecture
|
||||
|
||||
@@ -100,10 +100,6 @@ in this Software without prior written authorization from the X Consortium.
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <locale.h>
|
||||
#include <nl_types.h>
|
||||
#ifndef NL_CAT_LOCALE
|
||||
#define NL_CAT_LOCALE 0
|
||||
#endif
|
||||
|
||||
#ifdef SVR4
|
||||
#include <sys/sockio.h>
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
#include <setjmp.h>
|
||||
#include <string.h>
|
||||
#include <dirent.h>
|
||||
#include <nl_types.h>
|
||||
#include <Dt/MsgCatP.h>
|
||||
|
||||
# include <sys/signal.h>
|
||||
|
||||
@@ -112,7 +112,6 @@ unsigned char *
|
||||
ReadCatalog( int set_num, int msg_num, char *def_str )
|
||||
{
|
||||
static Bool alreadyopen = False;
|
||||
char *s;
|
||||
|
||||
if (alreadyopen == False)
|
||||
{
|
||||
@@ -174,12 +173,10 @@ ReadCatalog( int set_num, int msg_num, char *def_str )
|
||||
* msg catalog could not be opened), subsequent call to catgets() using
|
||||
* that descriptor will return 'def_str'.
|
||||
*/
|
||||
nl_fd = catopen("dtlogin", NL_CAT_LOCALE);
|
||||
nl_fd = CATOPEN("dtlogin", NL_CAT_LOCALE);
|
||||
}
|
||||
|
||||
s = catgets(nl_fd,set_num,msg_num,def_str);
|
||||
|
||||
return((unsigned char *)s);
|
||||
return ((unsigned char *) CATGETS(nl_fd, set_num, msg_num, def_str));
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#ifndef _H_XDM_MSG
|
||||
#define _H_XDM_MSG
|
||||
#include <limits.h>
|
||||
#include <nl_types.h>
|
||||
#define MF_XDM "xdm.cat"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user