[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnugo-devel] 3.1.32: -Wshadow fixes in reading.c
From: |
Teun Burgers |
Subject: |
[gnugo-devel] 3.1.32: -Wshadow fixes in reading.c |
Date: |
Sun, 14 Apr 2002 23:16:40 +0200 |
This patch fixes shadowing warnings in reading.c.
The {ADD,REMOVE}_CANDIDATE_MOVE macros used k and l
that are commonly used in the invoking functions as well.
These are not errors of cause, but I think readability
of the code improves when a variable name has a unique
meaning in a function.
Also I think usage of "l" is error prone because of
the similarity between "l"(el) and "1" (one).
- fix shadowing warnings in reading.c
Teun
Index: reading.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/reading.c,v
retrieving revision 1.57
diff -u -r1.57 reading.c
--- reading.c 4 Apr 2002 20:36:26 -0000 1.57
+++ reading.c 14 Apr 2002 21:09:33 -0000
@@ -41,14 +41,14 @@
#define ADD_CANDIDATE_MOVE(move, score, moves, scores, num_moves)\
do {\
- int l;\
- for (l = 0; l < num_moves; l++)\
- if (moves[l] == (move)) {\
- if (scores[l] < score)\
- scores[l] = score;\
+ int l_acm;\
+ for (l_acm = 0; l_acm < num_moves; l_acm++)\
+ if (moves[l_acm] == (move)) {\
+ if (scores[l_acm] < score)\
+ scores[l_acm] = score;\
break;\
}\
- if ((l == num_moves) && (num_moves < MAX_MOVES)) {\
+ if ((l_acm == num_moves) && (num_moves < MAX_MOVES)) {\
moves[num_moves] = move;\
scores[num_moves] = score;\
(num_moves)++;\
@@ -57,12 +57,12 @@
#define REMOVE_CANDIDATE_MOVE(move, moves, scores, num_moves)\
do {\
- int k, l;\
- for (k = 0; k < num_moves; k++) {\
- if (moves[k] == (move)) {\
- for (l = k; l < num_moves-1; l++) {\
- moves[l] = moves[l+1];\
- scores[l] = scores[l+1];\
+ int k_rcm, l_rcm;\
+ for (k_rcm = 0; k_rcm < num_moves; k_rcm++) {\
+ if (moves[k_rcm] == (move)) {\
+ for (l_rcm = k_rcm; l_rcm < num_moves-1; l_rcm++) {\
+ moves[l_rcm] = moves[l_rcm+1];\
+ scores[l_rcm] = scores[l_rcm+1];\
}\
(num_moves)--;\
break;\
@@ -1389,12 +1389,12 @@
* super_string.
*/
if (level >= 10 && stackp <= superstring_depth) {
- int liberties;
- int libs[MAX_LIBERTIES + 4];
+ int liberties_ss;
+ int libs_ss[MAX_LIBERTIES + 4];
- find_superstring_liberties(str, &liberties, libs, 3);
- for (k = 0; k < liberties; k++) {
- int apos = libs[k];
+ find_superstring_liberties(str, &liberties_ss, libs_ss, 3);
+ for (k = 0; k < liberties_ss; k++) {
+ int apos = libs_ss[k];
/* Skip if already tried */
for (s = 0; s < num_moves; s++)
@@ -1733,12 +1733,12 @@
* super_string.
*/
if (level >= 10 && stackp <= backfill2_depth) {
- int liberties;
- int libs[MAX_LIBERTIES + 4];
+ int liberties_ss;
+ int libs_ss[MAX_LIBERTIES + 4];
- find_superstring_liberties(str, &liberties, libs, 3);
- for (k = 0; k < liberties; k++) {
- int apos = libs[k];
+ find_superstring_liberties(str, &liberties_ss, libs_ss, 3);
+ for (k = 0; k < liberties_ss; k++) {
+ int apos = libs_ss[k];
if (liberty_of_string(apos, str))
continue;
@@ -3335,7 +3335,7 @@
{
int color = board[str];
int other = OTHER_COLOR(color);
- int apos;
+ /* int apos; */
int hpos;
int xpos;
int liberties, r;
@@ -3415,7 +3415,7 @@
adjacent_liberties = 1;
for (k = 0; k < 2; k++) {
- apos = libs[k];
+ int apos = libs[k];
if (!is_self_atari(apos, other))
atari_possible = 1;
/* we only want to consider the move at (apos) if:
@@ -3463,7 +3463,7 @@
adj = chainlinks2(str, adjs, 2);
for (r = 0; r < adj; r++) {
- apos = adjs[r];
+ int apos = adjs[r];
if (liberty_of_string(libs[0], apos)
&& liberty_of_string(libs[1], apos))
break_chain_moves(apos, moves, scores, &num_moves);
@@ -3477,7 +3477,7 @@
int new_kom_pos;
int ko_move;
- apos = moves[k];
+ int apos = moves[k];
if (komaster_trymove(apos, other, "attack2-A", str,
komaster, kom_pos, &new_komaster, &new_kom_pos,
&ko_move, stackp <= ko_depth && savecode == 0)) {
@@ -3545,17 +3545,17 @@
if (level >= 10
&& stackp <= backfill_depth
&& (stackp <= superstring_depth || !atari_possible)) {
- int liberties;
- int libs[MAX_LIBERTIES + 4];
+ int liberties_ss;
+ int libs_ss[MAX_LIBERTIES + 4];
int liberty_cap = 2;
if (stackp <= backfill2_depth)
liberty_cap = 3;
- find_superstring_liberties(str, &liberties, libs, liberty_cap);
- if (liberties <= 5) {
- for (k = 0; k < liberties; k++) {
- int apos = libs[k];
+ find_superstring_liberties(str, &liberties_ss, libs_ss, liberty_cap);
+ if (liberties_ss <= 5) {
+ for (k = 0; k < liberties_ss; k++) {
+ int apos = libs_ss[k];
if (liberty_of_string(apos, str))
continue;
@@ -3834,13 +3834,13 @@
* super_string.
*/
if (level >= 10 && stackp <= backfill2_depth) {
- int liberties;
- int libs[MAX_LIBERTIES + 4];
+ int liberties_ss;
+ int libs_ss[MAX_LIBERTIES + 4];
- find_superstring_liberties(str, &liberties, libs, 3);
- if (liberties <= 5) {
- for (k = 0; k < liberties; k++) {
- int apos = libs[k];
+ find_superstring_liberties(str, &liberties_ss, libs_ss, 3);
+ if (liberties_ss <= 5) {
+ for (k = 0; k < liberties_ss; k++) {
+ int apos = libs_ss[k];
if (liberty_of_string(apos, str))
continue;
- [gnugo-devel] 3.1.32: -Wshadow fixes in reading.c,
Teun Burgers <=