NLS: clean up to use the struct more and fewer relocations.

This commit is contained in:
Bart Oldeman 2017-12-18 13:06:21 -05:00 committed by Kenneth J Davis
parent fdac78cc67
commit 0b26c3f18f
5 changed files with 31 additions and 24 deletions

View File

@ -430,7 +430,8 @@ struct nlsPackage { /* the contents of one chain item of the
UWORD yeschar; /* yes / no character DOS-65-23 */ UWORD yeschar; /* yes / no character DOS-65-23 */
UWORD nochar; UWORD nochar;
unsigned numSubfct; /* number of supported sub-functions */ unsigned numSubfct; /* number of supported sub-functions */
struct nlsPointer nlsPointers[1]; /* grows dynamically */ struct nlsPointer nlsPointers[5]; /* may grow dynamically */
struct nlsExtCntryInfo nlsExt;
}; };
struct nlsDBCS { /* The internal structure is unknown to me */ struct nlsDBCS { /* The internal structure is unknown to me */
@ -479,14 +480,7 @@ struct nlsInfoBlock { /* This block contains all information
}; };
extern struct nlsInfoBlock ASM nlsInfo; extern struct nlsInfoBlock ASM nlsInfo;
extern struct nlsPackage FAR ASM nlsPackageHardcoded; extern struct nlsPackage DOSFAR ASM nlsPackageHardcoded;
/* These are the "must have" tables within the hard coded NLS pkg */
extern struct nlsFnamTerm FAR ASM nlsFnameTermHardcoded;
extern struct nlsDBCS FAR ASM nlsDBCSHardcoded;
extern struct nlsCharTbl FAR ASM nlsUpcaseHardcoded;
extern struct nlsCharTbl FAR ASM nlsFUpcaseHardcoded;
extern struct nlsCharTbl FAR ASM nlsCollHardcoded;
extern struct nlsExtCntryInfo FAR ASM nlsCntryInfoHardcoded;
extern BYTE FAR hcTablesStart[], hcTablesEnd[]; extern BYTE FAR hcTablesStart[], hcTablesEnd[];
/*********************************************************************** /***********************************************************************

View File

@ -198,6 +198,11 @@ typedef unsigned size_t;
#define ASMCFUNC CDECL #define ASMCFUNC CDECL
#define ASMPASCAL PASCAL #define ASMPASCAL PASCAL
#define ASM ASMCFUNC #define ASM ASMCFUNC
/* variables that can be near or far: redefined in init-dat.h */
#define DOSFAR
#define DOSTEXTFAR
/* */ /* */
/* Boolean type & definitions of TRUE and FALSE boolean values */ /* Boolean type & definitions of TRUE and FALSE boolean values */
/* */ /* */

View File

@ -1511,23 +1511,24 @@ STATIC BOOL LoadCountryInfo(char *filenam, UWORD ctryCode, UWORD codePage)
} subf_data; } subf_data;
struct subf_tbl { struct subf_tbl {
char sig[8]; /* signature for each subfunction data */ char sig[8]; /* signature for each subfunction data */
void FAR *p; /* pointer to data in nls_hc.asm to be copied to */ int idx; /* index of pointer in nls_hc.asm to be copied to */
}; };
static struct subf_tbl table[8] = { static struct subf_tbl table[8] = {
{"\377 ", NULL}, /* 0, unused */ {"\377 ", -1}, /* 0, unused */
{"\377CTYINFO", &nlsCntryInfoHardcoded},/* 1 */ {"\377CTYINFO", 5}, /* 1 */
{"\377UCASE ", &nlsUpcaseHardcoded}, /* 2 */ {"\377UCASE ", 0}, /* 2 */
{"\377LCASE ", NULL}, /* 3, not supported [yet] */ {"\377LCASE ", -1}, /* 3, not supported [yet] */
{"\377FUCASE ", &nlsFUpcaseHardcoded}, /* 4 */ {"\377FUCASE ", 1}, /* 4 */
{"\377FCHAR ", &nlsFnameTermHardcoded},/* 5 */ {"\377FCHAR ", 2}, /* 5 */
{"\377COLLATE", &nlsCollHardcoded}, /* 6 */ {"\377COLLATE", 3}, /* 6 */
{"\377DBCS ", &nlsDBCSHardcoded} /* 7, not supported [yet] */ {"\377DBCS ", 4} /* 7, not supported [yet] */
}; };
static struct subf_hdr hdr[8]; static struct subf_hdr hdr[8];
static int entries, count; static int entries, count;
int fd, i; int fd, i;
char *filename = filenam == NULL ? "\\COUNTRY.SYS" : filenam; char *filename = filenam == NULL ? "\\COUNTRY.SYS" : filenam;
BOOL rc = FALSE; BOOL rc = FALSE;
BYTE FAR *ptable;
if ((fd = open(filename, 0)) < 0) if ((fd = open(filename, 0)) < 0)
{ {
@ -1586,25 +1587,29 @@ err:printf("%s has invalid format\n", filename);
subf_data.length = /* MS-DOS "CTYINFO" is up to 38 bytes */ subf_data.length = /* MS-DOS "CTYINFO" is up to 38 bytes */
min(subf_data.length, sizeof(struct CountrySpecificInfo)); min(subf_data.length, sizeof(struct CountrySpecificInfo));
} }
if (hdr[i].id == 1)
ptable = (BYTE FAR *)&nlsPackageHardcoded.nlsExt.size;
else
ptable = nlsPackageHardcoded.nlsPointers[table[hdr[i].id].idx].pointer;
if (hdr[i].id == 7) if (hdr[i].id == 7)
{ {
if (subf_data.length == 0) if (subf_data.length == 0)
{ {
/* if DBCS table (in country.sys) is empty, clear internal table */ /* if DBCS table (in country.sys) is empty, clear internal table */
*(DWORD *)(subf_data.buffer) = 0L; *(DWORD *)(subf_data.buffer) = 0L;
fmemcpy((BYTE FAR *)(table[hdr[i].id].p), subf_data.buffer, 4); fmemcpy(ptable, subf_data.buffer, 4);
} }
else else
{ {
fmemcpy((BYTE FAR *)(table[hdr[i].id].p) + 2, subf_data.buffer, subf_data.length); fmemcpy(ptable + 2, subf_data.buffer, subf_data.length);
/* write length */ /* write length */
*(UWORD *)(subf_data.buffer) = subf_data.length; *(UWORD *)(subf_data.buffer) = subf_data.length;
fmemcpy((BYTE FAR *)(table[hdr[i].id].p), subf_data.buffer, 2); fmemcpy(ptable, subf_data.buffer, 2);
} }
continue; continue;
} }
fmemcpy((BYTE FAR *)(table[hdr[i].id].p) + 2, subf_data.buffer, fmemcpy(ptable + 2, subf_data.buffer,
/* skip length ^*/ subf_data.length); /* skip length ^*/ subf_data.length);
} }
rc = TRUE; rc = TRUE;

View File

@ -1,3 +1,6 @@
#undef DOSFAR
#undef DOSTEXTFAR
/* Included by initialisation functions */ /* Included by initialisation functions */
#if _MSC_VER != 0 #if _MSC_VER != 0

View File

@ -16,12 +16,12 @@
#include "tail.h" #include "tail.h"
#include "process.h" #include "process.h"
#include "pcb.h" #include "pcb.h"
#include "nls.h"
#include "buffer.h" #include "buffer.h"
#include "dcb.h" #include "dcb.h"
#include "lol.h" #include "lol.h"
#include "init-dat.h" #include "init-dat.h"
#include "nls.h"
#include "kconfig.h" #include "kconfig.h"
@ -275,7 +275,7 @@ extern struct {
struct CountrySpecificInfo C; struct CountrySpecificInfo C;
} FAR ASM nlsCountryInfoHardcoded; } DOSFAR ASM nlsCountryInfoHardcoded;
/* /*
data shared between DSK.C and INITDISK.C data shared between DSK.C and INITDISK.C