From b239c00ae80f1327393c466603cfeb500c0d16c3 Mon Sep 17 00:00:00 2001 From: Liang Chang Date: Wed, 19 Jan 2022 07:17:46 +0800 Subject: [PATCH] dthelp: use system locales. --- cde/programs/dthelp/dthelpprint/PrintTopics.c | 25 +- .../dthelp/parser/canon1/helptag/Makefile.am | 23 +- .../dthelp/parser/canon1/helptag/help.c | 225 +----------------- .../dthelp/parser/pass1/helptag/Makefile.am | 23 +- .../dthelp/parser/pass1/helptag/help.c | 223 +---------------- .../dthelp/parser/pass2/htag2/Makefile.am | 23 +- cde/programs/dthelp/parser/pass2/htag2/sdl.c | 85 +------ 7 files changed, 39 insertions(+), 588 deletions(-) diff --git a/cde/programs/dthelp/dthelpprint/PrintTopics.c b/cde/programs/dthelp/dthelpprint/PrintTopics.c index bfcbaf372..5ca32e852 100644 --- a/cde/programs/dthelp/dthelpprint/PrintTopics.c +++ b/cde/programs/dthelp/dthelpprint/PrintTopics.c @@ -72,7 +72,6 @@ $COPYRIGHT$: #include "DtI/HelpTermP.h" /* from libDtHelp */ #include "Dt/CanvasP.h" /* from libDtHelp */ #include "StringFuncsI.h" /* from libDtHelp */ -#include "Dt/LocaleXlate.h" /* from libDtHelp */ #include "DtI/bufioI.h" /* from libDtHelp; required for AccessI.h */ #include "DtI/FileUtilsI.h" /* from libDtHelp */ #include "DtI/Access.h" /* from libDtHelp */ @@ -468,9 +467,7 @@ int IconvFile( for (i=0; i\n"; @@ -6536,27 +6533,16 @@ while (name = CycleEnt(FALSE, &type, &content, &wheredef)); } -/* A function that takes a language/charset pair and: - * if they are standard, leave them unchanged but get local - * versions and setlocale(3) using those - * if they are local, setlocale(3) with them and replace them with - * standard versions. +/* A function that takes a language/charset pair and setlocale(3) using those. */ void SetLocale(M_WCHAR *pLang, M_WCHAR *pCharset) { const char cString[] = "C"; -_DtXlateDb myDb = NULL; -char myPlatform[_DtPLATFORM_MAX_LEN+1]; char myLocale[256]; /* arbitrarily large */ char *mb_lang; char *mb_charset; -char *locale; -char *lang; char *charset; -int execVer; -int compVer; -int isStd; if (!pLang && !pCharset) return; @@ -6576,76 +6562,15 @@ if (mb_charset && *mb_charset) strcat(myLocale, mb_charset); } -if ((_DtLcxOpenAllDbs(&myDb) != 0) || - (_DtXlateGetXlateEnv(myDb,myPlatform,&execVer,&compVer) != 0)) - { - fprintf(stderr, - "Warning: could not open locale translation database.\n"); - if (m_errfile != stderr) - fprintf(m_errfile, - "Warning: could not open locale translation database.\n"); - if (mb_lang != cString) - mb_free(&mb_lang); - if (mb_charset) - mb_free(&mb_charset); - if (myDb != 0) - _DtLcxCloseDb(&myDb); - return; - } - -isStd = !_DtLcxXlateOpToStd(myDb, - "CDE", - 0, - DtLCX_OPER_STD, - myLocale, - NULL, - NULL, - NULL, - NULL); - -if (isStd) - { /* already standard - get local versions and set locale */ - if (_DtLcxXlateStdToOp(myDb, - myPlatform, - compVer, - DtLCX_OPER_SETLOCALE, - myLocale, - NULL, - NULL, - NULL, - &locale)) - { - fprintf(stderr, - "Warning: could not translate CDE locale to local\n"); - if (m_errfile != stderr) - fprintf(m_errfile, - "Warning: could not translate CDE locale to local\n"); - _DtLcxCloseDb(&myDb); - if (mb_lang != cString) - mb_free(&mb_lang); - if (mb_charset) - mb_free(&mb_charset); - return; - } - else - { - setlocale(LC_CTYPE, locale); - operantLocale = mb_malloc(strlen(locale)+1); - strcpy(operantLocale, locale); - } - } -else - { /* already local - just set locale */ - setlocale(LC_CTYPE, myLocale); - operantLocale = mb_malloc(strlen(myLocale)+1); - strcpy(operantLocale, myLocale); - } +setlocale(LC_CTYPE, myLocale); +mb_free(&operantLocale); +operantLocale = mb_malloc(strlen(myLocale)+1); +strcpy(operantLocale, myLocale); if (mb_lang != cString) mb_free(&mb_lang); if (mb_charset) mb_free(&mb_charset); -_DtLcxCloseDb(&myDb); }