Fixed compilation error in VS2010

* In C89, variables must be declared at the beginning of a block.
This commit is contained in:
NovaRain
2023-06-10 22:02:08 +08:00
parent 7b019d2634
commit 742b6d2497
2 changed files with 11 additions and 9 deletions
+9 -8
View File
@@ -1135,10 +1135,11 @@ static void FreeNamelistData(int* refs, int* offsets, int* transforms) {
}
static void RemoveFromNamelist(char* namelist, int i, int entries, int* offsets, int* transforms, char** endptr, char* logFormat) {
int j;
char* namestart;
int j, len;
parseMessageAtNode(0, logFormat, namelist + offsets[i]);
char* namestart = namelist + offsets[i] - 2;
int len = *(unsigned short*)namestart + 2;
namestart = namelist + offsets[i] - 2;
len = *(unsigned short*)namestart + 2;
memmove(namestart, len + namestart, *endptr - (len + namestart));
(*(unsigned int*)namelist) -= len;
*endptr -= len;
@@ -1170,7 +1171,7 @@ static void ShiftName(int* name, int entries, int* transforms, int* offsets) {
static void CompressNamelist(Program *prog) {
char* endptr, *namestart;
int entries = 0, *refs, *offsets, *transforms, i, j;
int entries = 0, *refs, *offsets, *transforms, i, j, len;
GetNamelistData(prog->namelist, &entries, &endptr, &refs, &offsets, &transforms);
@@ -1188,9 +1189,9 @@ static void CompressNamelist(Program *prog) {
for (i = entries - 1; i >= 0; i--) {
if (!refs[i]) {
RemoveFromNamelist(prog->namelist, i, entries, offsets, transforms, &endptr, "Removing unused string '%s' from program namespace");
} else if (refs[i] == 2 && optimize>=3) {
} else if (refs[i] == 2 && optimize >= 3) {
namestart = prog->namelist + offsets[i] - 2;
int len = *(unsigned short*)namestart + 2;
len = *(unsigned short*)namestart + 2;
if (len > 4) {
parseMessageAtNode(0, "Shortening non-visible string '%s' in program namespace", prog->namelist + offsets[i]);
*(unsigned short*)(namestart) = 2;
@@ -1239,13 +1240,13 @@ static void ShiftVariableDefaultValue(Variable* var, int entries, int* transform
}
static void CompressStringspace(Program *prog) {
if (!prog->stringspace) return;
char* endptr;
int entries = 0, *refs, *offsets, *transforms, i, k, *stringData;
Procedure* proc;
Node* node;
if (!prog->stringspace) return;
GetNamelistData(prog->stringspace, &entries, &endptr, &refs, &offsets, &transforms);
//Then check all procedures nodes and variable default values to see where in the stringspace they point
+2 -1
View File
@@ -973,11 +973,12 @@ void emitNode(Procedure *p, NodeList *n, LexData *data) {
else referenceVariable(&currentProgram->variables, v);
}
else {
Procedure *proc;
type |= P_PROCEDURE;
referenceProcedure(&currentProgram->procedures, v);
if (data->type == T_STRING) {
type |= P_STRINGIFY;
Procedure *proc = &currentProgram->procedures.procedures[v];
proc = &currentProgram->procedures.procedures[v];
// Add stringified procedure name (because program has separate namelist of string constants)
if (!proc->stringifiedName) {
proc->stringifiedName = addString(&currentProgram->stringspace, data->stringData);