From d510ce075bc2a192c82bbc2e7ad8d2d15fb52d82 Mon Sep 17 00:00:00 2001 From: Richard Date: Sun, 18 Feb 2024 16:30:50 -0700 Subject: [PATCH] Rename variabls to avoid shadowing --- common/miscovl.cpp | 30 ++++++++-------- common/mpmath_c.cpp | 18 +++++----- common/parser.cpp | 86 ++++++++++++++++++++++----------------------- 3 files changed, 67 insertions(+), 67 deletions(-) diff --git a/common/miscovl.cpp b/common/miscovl.cpp index d3a453b6f..a052ff018 100644 --- a/common/miscovl.cpp +++ b/common/miscovl.cpp @@ -473,9 +473,9 @@ void make_batch_file() } PCommandName[w] = 0; { - char buf[20]; - std::snprintf(buf, NUM_OF(buf), "_%c%c", PAR_KEY(i), PAR_KEY(j)); - std::strcat(PCommandName, buf); + char tmpbuff[20]; + std::snprintf(tmpbuff, NUM_OF(tmpbuff), "_%c%c", PAR_KEY(i), PAR_KEY(j)); + std::strcat(PCommandName, tmpbuff); } std::fprintf(parmfile, "%-19s{", PCommandName); g_x_min = pxxmin + pdelx*(i*pxdots) + pdelx2*(j*pydots); @@ -503,18 +503,18 @@ void make_batch_file() /* guarantee that there are no blank comments above the last non-blank par_comment */ int last = -1; - for (int i = 0; i < 4; i++) + for (int k = 0; k < 4; k++) { - if (*par_comment[i]) + if (*par_comment[k]) { - last = i; + last = k; } } - for (int i = 0; i < last; i++) + for (int k = 0; k < last; k++) { - if (g_command_comment[i].empty()) + if (g_command_comment[k].empty()) { - g_command_comment[i] = ";"; + g_command_comment[k] = ";"; } } } @@ -524,20 +524,20 @@ void make_batch_file() } fputc('\n', parmfile); { - char buf[25]; - std::memset(buf, ' ', 23); - buf[23] = 0; - buf[21] = ';'; + char tmpbuff[25]; + std::memset(tmpbuff, ' ', 23); + tmpbuff[23] = 0; + tmpbuff[21] = ';'; for (int k = 1; k < 4; k++) { if (!g_command_comment[k].empty()) { - std::fprintf(parmfile, "%s%s\n", buf, g_command_comment[k].c_str()); + std::fprintf(parmfile, "%s%s\n", tmpbuff, g_command_comment[k].c_str()); } } if (g_patch_level != 0 && !colorsonly) { - std::fprintf(parmfile, "%s %s Version %d Patchlevel %d\n", buf, + std::fprintf(parmfile, "%s %s Version %d Patchlevel %d\n", tmpbuff, Fractint, g_release, g_patch_level); } } diff --git a/common/mpmath_c.cpp b/common/mpmath_c.cpp index 8c47bcd0e..b346ca235 100644 --- a/common/mpmath_c.cpp +++ b/common/mpmath_c.cpp @@ -696,7 +696,7 @@ long ExpFloat14(long xx) } static double TwoPi; -static DComplex temp; +static DComplex s_temp; static DComplex BaseLog; static DComplex cdegree = { 3.0, 0.0 }; static DComplex croot = { 1.0, 0.0 }; @@ -731,8 +731,8 @@ int ComplexNewton() cd1.x = cdegree.x - 1.0; cd1.y = cdegree.y; - temp = ComplexPower(g_old_z, cd1); - FPUcplxmul(&temp, &g_old_z, &g_new_z); + s_temp = ComplexPower(g_old_z, cd1); + FPUcplxmul(&s_temp, &g_old_z, &g_new_z); g_tmp_z.x = g_new_z.x - croot.x; g_tmp_z.y = g_new_z.y - croot.y; @@ -745,7 +745,7 @@ int ComplexNewton() g_tmp_z.x += croot.x; g_tmp_z.y += croot.y; - FPUcplxmul(&temp, &cdegree, &cd1); + FPUcplxmul(&s_temp, &cdegree, &cd1); FPUcplxdiv(&g_tmp_z, &cd1, &g_old_z); if (g_overflow) { @@ -766,8 +766,8 @@ int ComplexBasin() cd1.x = cdegree.x - 1.0; cd1.y = cdegree.y; - temp = ComplexPower(g_old_z, cd1); - FPUcplxmul(&temp, &g_old_z, &g_new_z); + s_temp = ComplexPower(g_old_z, cd1); + FPUcplxmul(&s_temp, &g_old_z, &g_new_z); g_tmp_z.x = g_new_z.x - croot.x; g_tmp_z.y = g_new_z.y - croot.y; @@ -777,8 +777,8 @@ int ComplexBasin() { g_old_z.y = 0.0; } - FPUcplxlog(&g_old_z, &temp); - FPUcplxmul(&temp, &cdegree, &g_tmp_z); + FPUcplxlog(&g_old_z, &s_temp); + FPUcplxmul(&s_temp, &cdegree, &g_tmp_z); double mod = g_tmp_z.y/TwoPi; g_color_iter = (long)mod; if (std::fabs(mod - g_color_iter) > 0.5) @@ -804,7 +804,7 @@ int ComplexBasin() g_tmp_z.x += croot.x; g_tmp_z.y += croot.y; - FPUcplxmul(&temp, &cdegree, &cd1); + FPUcplxmul(&s_temp, &cdegree, &cd1); FPUcplxdiv(&g_tmp_z, &cd1, &g_old_z); if (g_overflow) { diff --git a/common/parser.cpp b/common/parser.cpp index bc180fcae..c8d13ca36 100644 --- a/common/parser.cpp +++ b/common/parser.cpp @@ -188,11 +188,11 @@ bool g_is_mandelbrot = true; unsigned int g_operation_index; unsigned int g_variable_index; unsigned int g_last_op; -static unsigned int n; +static unsigned int s_n; static unsigned int NextOp; static unsigned int InitN; static int paren; -static bool ExpectingArg = false; +static bool s_expecting_arg{}; int InitLodPtr; int InitStoPtr; int InitOpPtr; @@ -2681,15 +2681,15 @@ static bool ParseStr(char const *Str, int pass) OpPtr = g_load_index; paren = OpPtr; g_last_init_op = paren; - ExpectingArg = true; - for (n = 0; Str[n]; n++) + s_expecting_arg = true; + for (s_n = 0; Str[s_n]; s_n++) { - if (!Str[n]) + if (!Str[s_n]) { break; } - InitN = n; - switch (Str[n]) + InitN = s_n; + switch (Str[s_n]) { case ' ': case '\t': @@ -2703,10 +2703,10 @@ static bool ParseStr(char const *Str, int pass) paren--; break; case '|': - if (Str[n+1] == '|') + if (Str[s_n+1] == '|') { - ExpectingArg = true; - n++; + s_expecting_arg = true; + s_n++; o[g_operation_index].f = StkOR; o[g_operation_index++].p = 7 - (paren + Equals)*15; } @@ -2725,9 +2725,9 @@ static bool ParseStr(char const *Str, int pass) break; case ',': case ';': - if (!ExpectingArg) + if (!s_expecting_arg) { - ExpectingArg = true; + s_expecting_arg = true; o[g_operation_index].f = (void(*)())nullptr; o[g_operation_index++].p = 15; o[g_operation_index].f = StkClr; @@ -2737,7 +2737,7 @@ static bool ParseStr(char const *Str, int pass) } break; case ':': - ExpectingArg = true; + s_expecting_arg = true; o[g_operation_index].f = (void(*)())nullptr; o[g_operation_index++].p = 15; o[g_operation_index].f = EndInit; @@ -2747,12 +2747,12 @@ static bool ParseStr(char const *Str, int pass) g_last_init_op = 10000; break; case '+': - ExpectingArg = true; + s_expecting_arg = true; o[g_operation_index].f = StkAdd; o[g_operation_index++].p = 4 - (paren + Equals)*15; break; case '-': - if (ExpectingArg) + if (s_expecting_arg) { o[g_operation_index].f = StkNeg; o[g_operation_index++].p = 2 - (paren + Equals)*15; @@ -2761,26 +2761,26 @@ static bool ParseStr(char const *Str, int pass) { o[g_operation_index].f = StkSub; o[g_operation_index++].p = 4 - (paren + Equals)*15; - ExpectingArg = true; + s_expecting_arg = true; } break; case '&': - ExpectingArg = true; - n++; + s_expecting_arg = true; + s_n++; o[g_operation_index].f = StkAND; o[g_operation_index++].p = 7 - (paren + Equals)*15; break; case '!': - ExpectingArg = true; - n++; + s_expecting_arg = true; + s_n++; o[g_operation_index].f = StkNE; o[g_operation_index++].p = 6 - (paren + Equals)*15; break; case '<': - ExpectingArg = true; - if (Str[n+1] == '=') + s_expecting_arg = true; + if (Str[s_n+1] == '=') { - n++; + s_n++; o[g_operation_index].f = StkLTE; } else @@ -2790,10 +2790,10 @@ static bool ParseStr(char const *Str, int pass) o[g_operation_index++].p = 6 - (paren + Equals)*15; break; case '>': - ExpectingArg = true; - if (Str[n+1] == '=') + s_expecting_arg = true; + if (Str[s_n+1] == '=') { - n++; + s_n++; o[g_operation_index].f = StkGTE; } else @@ -2803,25 +2803,25 @@ static bool ParseStr(char const *Str, int pass) o[g_operation_index++].p = 6 - (paren + Equals)*15; break; case '*': - ExpectingArg = true; + s_expecting_arg = true; o[g_operation_index].f = StkMul; o[g_operation_index++].p = 3 - (paren + Equals)*15; break; case '/': - ExpectingArg = true; + s_expecting_arg = true; o[g_operation_index].f = StkDiv; o[g_operation_index++].p = 3 - (paren + Equals)*15; break; case '^': - ExpectingArg = true; + s_expecting_arg = true; o[g_operation_index].f = StkPwr; o[g_operation_index++].p = 2 - (paren + Equals)*15; break; case '=': - ExpectingArg = true; - if (Str[n+1] == '=') + s_expecting_arg = true; + if (Str[s_n+1] == '=') { - n++; + s_n++; o[g_operation_index].f = StkEQ; o[g_operation_index++].p = 6 - (paren + Equals)*15; } @@ -2834,12 +2834,12 @@ static bool ParseStr(char const *Str, int pass) } break; default: - while (std::isalnum(Str[n+1]) || Str[n+1] == '.' || Str[n+1] == '_') + while (std::isalnum(Str[s_n+1]) || Str[s_n+1] == '.' || Str[s_n+1] == '_') { - n++; + s_n++; } - Len = (n+1)-InitN; - ExpectingArg = false; + Len = (s_n+1)-InitN; + s_expecting_arg = false; jumptype = isjump(&Str[InitN], Len); if (jumptype != 0) { @@ -2847,13 +2847,13 @@ static bool ParseStr(char const *Str, int pass) switch (jumptype) { case 1: // if - ExpectingArg = true; + s_expecting_arg = true; jump_control[jump_index++].type = 1; o[g_operation_index].f = StkJumpOnFalse; o[g_operation_index++].p = 1; break; case 2: // elseif - ExpectingArg = true; + s_expecting_arg = true; jump_control[jump_index++].type = 2; jump_control[jump_index++].type = 2; o[g_operation_index].f = StkJump; @@ -2885,7 +2885,7 @@ static bool ParseStr(char const *Str, int pass) if (o[g_operation_index].f != NotAFnct) { o[g_operation_index++].p = 1 - (paren + Equals)*15; - ExpectingArg = true; + s_expecting_arg = true; } else { @@ -2893,7 +2893,7 @@ static bool ParseStr(char const *Str, int pass) Load[g_load_index++] = &(c->a); o[g_operation_index].f = StkLod; o[g_operation_index++].p = 1 - (paren + Equals)*15; - n = InitN + c->len - 1; + s_n = InitN + c->len - 1; } } break; @@ -3821,11 +3821,11 @@ static bool frmgettoken(std::FILE * openfile, token_st * this_token) this_token->token_str[i] = (char) 0; if (this_token->token_type == OPERATOR) { - for (int i = 0; i < sizeof(OPList)/sizeof(OPList[0]); i++) + for (int j = 0; j < sizeof(OPList)/sizeof(OPList[0]); j++) { - if (!std::strcmp(OPList[i], this_token->token_str)) + if (!std::strcmp(OPList[j], this_token->token_str)) { - this_token->token_id = i; + this_token->token_id = j; } } }