Remove deprecated "section charmap" feature

This commit is contained in:
ISSOtm
2019-12-04 01:56:06 +01:00
parent ef43ae0eea
commit b1d4be66e4
5 changed files with 5 additions and 54 deletions

View File

@@ -22,7 +22,6 @@ struct Section {
uint32_t nAlign; uint32_t nAlign;
struct Section *pNext; struct Section *pNext;
struct Patch *pPatches; struct Patch *pPatches;
struct Charmap *charmap;
uint8_t *tData; uint8_t *tData;
}; };

View File

@@ -33,17 +33,6 @@ static struct Charmap *currentCharmap;
struct CharmapStackEntry *charmapStack; struct CharmapStackEntry *charmapStack;
static void warnSectionCharmap(void)
{
static bool warned = false;
if (warned)
return;
warning(WARNING_OBSOLETE, "Using 'charmap' within a section when the current charmap is 'main' is deprecated");
warned = true;
}
static uint32_t charmap_CalcHash(const char *s) static uint32_t charmap_CalcHash(const char *s)
{ {
return calchash(s) % CHARMAP_HASH_SIZE; return calchash(s) % CHARMAP_HASH_SIZE;
@@ -163,30 +152,9 @@ int32_t charmap_Add(char *input, uint8_t output)
int32_t i; int32_t i;
uint8_t v; uint8_t v;
struct Charmap *charmap; struct Charmap *charmap = currentCharmap;
struct Charnode *curr_node, *temp_node; struct Charnode *curr_node, *temp_node;
/*
* If the user tries to define a character mapping inside a section
* and the current global charmap is the "main" one, then a local
* section charmap will be created or modified instead of the global
* one. In other words, the local section charmap can override the
* main global one, but not the others.
*/
if (pCurrentSection && currentCharmap == mainCharmap) {
warnSectionCharmap();
if (pCurrentSection->charmap) {
charmap = pCurrentSection->charmap;
} else {
charmap = calloc(1, sizeof(struct Charmap));
if (charmap == NULL)
fatalerror("Not enough memory for charmap");
pCurrentSection->charmap = charmap;
}
} else {
charmap = currentCharmap;
}
if (charmap->charCount >= MAXCHARMAPS || strlen(input) > CHARMAPLENGTH) if (charmap->charCount >= MAXCHARMAPS || strlen(input) > CHARMAPLENGTH)
return -1; return -1;
@@ -217,7 +185,7 @@ int32_t charmap_Add(char *input, uint8_t output)
int32_t charmap_Convert(char **input) int32_t charmap_Convert(char **input)
{ {
struct Charmap *charmap; struct Charmap *charmap = currentCharmap;
struct Charnode *charnode; struct Charnode *charnode;
char *output; char *output;
@@ -226,19 +194,6 @@ int32_t charmap_Convert(char **input)
int32_t i, match, length; int32_t i, match, length;
uint8_t v, foundCode; uint8_t v, foundCode;
/*
* If there is a local section charmap and the current global charmap
* is the "main" one, the local one is used. Otherwise, the global
* one is used. In other words, the local section charmap can override
* the main global one, but not the others.
*/
if (pCurrentSection &&
pCurrentSection->charmap &&
currentCharmap == mainCharmap)
charmap = pCurrentSection->charmap;
else
charmap = currentCharmap;
output = malloc(strlen(*input)); output = malloc(strlen(*input));
if (output == NULL) if (output == NULL)
fatalerror("Not enough memory for buffer"); fatalerror("Not enough memory for buffer");

View File

@@ -642,7 +642,6 @@ struct Section *out_FindSection(char *pzName, uint32_t secttype, int32_t org,
pSect->nAlign = alignment; pSect->nAlign = alignment;
pSect->pNext = NULL; pSect->pNext = NULL;
pSect->pPatches = NULL; pSect->pPatches = NULL;
pSect->charmap = NULL;
/* It is only needed to allocate memory for ROM sections. */ /* It is only needed to allocate memory for ROM sections. */
if (sect_HasData(secttype)) { if (sect_HasData(secttype)) {

View File

@@ -71,7 +71,7 @@ SECTION "sec0", ROM0
print "ab" print "ab"
printt "override main charmap\n" printt "modify main charmap\n"
charmap "ef", $3 charmap "ef", $3
print "ab" print "ab"

View File

@@ -1,5 +1,3 @@
warning: multiple-charmaps.asm(75): [-Wobsolete]
Using 'charmap' within a section when the current charmap is 'main' is deprecated
ERROR: multiple-charmaps.asm(100) -> multiple-charmaps.asm::new_(7): ERROR: multiple-charmaps.asm(100) -> multiple-charmaps.asm::new_(7):
Charmap 'map1' already exists Charmap 'map1' already exists
ERROR: multiple-charmaps.asm(102) -> multiple-charmaps.asm::set_(13): ERROR: multiple-charmaps.asm(102) -> multiple-charmaps.asm::set_(13):
@@ -24,8 +22,8 @@ $1
$6364 $6364
setcharmap main setcharmap main
$0 $0
override main charmap modify main charmap
$6162 $0
$3 $3
setcharmap map1 setcharmap map1
pushc pushc