Skip to content

Commit 720ec32

Browse files
committed
load YesNo characters in CONFIG.SYS via COUNTRY statement so can use without having to load NLSFUNC
1 parent f38076d commit 720ec32

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

kernel/config.c

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,27 +1542,28 @@ STATIC BOOL LoadCountryInfo(char *filenam, UWORD ctryCode, UWORD codePage)
15421542
ULONG offset; /* offset within file of subfunction data entry */
15431543
};
15441544
static struct { /* subfunction data */
1545-
char signature[8]; /* \377CTYINFO|UCASE|LCASE|FUCASE|FCHAR|COLLATE|DBCS */
1545+
char signature[8]; /* \377CTYINFO|UCASE|LCASE|FUCASE|FCHAR|COLLATE|DBCS|YESNO */
15461546
int length; /* length of following table in bytes */
15471547
UBYTE buffer[256];
15481548
} subf_data;
15491549
struct subf_tbl {
15501550
char sig[8]; /* signature for each subfunction data */
15511551
int idx; /* index of pointer in nls_hc.asm to be copied to */
15521552
};
1553-
static struct subf_tbl table[8] = {
1553+
static struct subf_tbl table[9] = {
15541554
{"\377 ", -1}, /* 0, unused */
15551555
{"\377CTYINFO", 5}, /* 1 */
15561556
{"\377UCASE ", 0}, /* 2 */
15571557
{"\377LCASE ", -1}, /* 3, not supported [yet] */
15581558
{"\377FUCASE ", 1}, /* 4 */
15591559
{"\377FCHAR ", 2}, /* 5 */
15601560
{"\377COLLATE", 3}, /* 6 */
1561-
{"\377DBCS ", 4} /* 7, not supported [yet] */
1561+
{"\377DBCS ", 4}, /* 7, not supported [yet] */
1562+
{"\377YESNO ", -1} /* 35 */
15621563
};
1563-
static struct subf_hdr hdr[8];
1564+
static struct subf_hdr hdr[9];
15641565
static int entries, count;
1565-
int fd, i;
1566+
int fd, i, subf_tbl_ndx;
15661567
char *filename = filenam == NULL ? "\\COUNTRY.SYS" : filenam;
15671568
BOOL rc = FALSE;
15681569
BYTE FAR *ptable;
@@ -1599,15 +1600,20 @@ err:printf("%s has invalid format\n", filename);
15991600
|| read(fd, hdr, sizeof(struct subf_hdr) * count)
16001601
!= sizeof(struct subf_hdr) * count)
16011602
goto err;
1603+
1604+
/* Note: we reuse i here as we only process 1 entry, goto after inner for ends outer for */
16021605
for (i = 0; i < count; i++)
16031606
{
16041607
if (hdr[i].length != 6)
16051608
goto err;
1606-
if (hdr[i].id < 1 || hdr[i].id > 7 || hdr[i].id == 3)
1609+
subf_tbl_ndx = hdr[i].id;
1610+
if (subf_tbl_ndx == 3 || ((subf_tbl_ndx < 1 || subf_tbl_ndx > 7) && subf_tbl_ndx != 35))
16071611
continue;
1612+
if (subf_tbl_ndx == 35)
1613+
subf_tbl_ndx = 8; /* 0 through 7 match, but subfunction 35 is 9th entry in table[] */
16081614
if (lseek(fd, hdr[i].offset) == 0xffffffffL
16091615
|| read(fd, &subf_data, 10) != 10
1610-
|| memcmp(subf_data.signature, table[hdr[i].id].sig, 8) && (hdr[i].id !=4
1616+
|| memcmp(subf_data.signature, table[subf_tbl_ndx].sig, 8) && (hdr[i].id !=4
16111617
|| memcmp(subf_data.signature, table[2].sig, 8)) /* UCASE for FUCASE ^*/
16121618
|| read(fd, subf_data.buffer, subf_data.length) != subf_data.length)
16131619
goto err;
@@ -1627,7 +1633,7 @@ err:printf("%s has invalid format\n", filename);
16271633
if (hdr[i].id == 1)
16281634
ptable = (BYTE FAR *)&nlsPackageHardcoded.nlsExt.size;
16291635
else
1630-
ptable = nlsPackageHardcoded.nlsPointers[table[hdr[i].id].idx].pointer;
1636+
ptable = nlsPackageHardcoded.nlsPointers[table[subf_tbl_ndx].idx].pointer;
16311637
if (hdr[i].id == 7)
16321638
{
16331639
if (subf_data.length == 0)
@@ -1646,8 +1652,15 @@ err:printf("%s has invalid format\n", filename);
16461652
continue;
16471653
}
16481654

1649-
fmemcpy(ptable + 2, subf_data.buffer,
1650-
/* skip length ^*/ subf_data.length);
1655+
/* for 0-7 we store COUNTRY.SYS data directly in buffer, but yes/no characters we store in nls package directly */
1656+
if (hdr[i].id == 35)
1657+
{
1658+
fmemcpy(&nlsPackageHardcoded.yeschar, subf_data.buffer, 2);
1659+
fmemcpy(&nlsPackageHardcoded.nochar, subf_data.buffer + 2, 2);
1660+
} else {
1661+
fmemcpy(ptable + 2, subf_data.buffer,
1662+
/* skip length ^*/ subf_data.length);
1663+
}
16511664
}
16521665
rc = TRUE;
16531666
goto ret;

0 commit comments

Comments
 (0)