Index: engine/board.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/board.c,v retrieving revision 1.60 diff -u -r1.60 board.c --- engine/board.c 9 Dec 2002 10:41:22 -0000 1.60 +++ engine/board.c 31 Dec 2002 15:13:16 -0000 @@ -2290,10 +2290,10 @@ for (l = 0; l < s->liberties; l++) { lib = s->libs[l]; if (UNMARKED_LIBERTY(lib)) { - if(libs) + if (libs) libs[liberties] = lib; liberties++; - if(liberties >= maxlib) + if (liberties >= maxlib) return liberties; MARK_LIBERTY(lib); @@ -3060,11 +3060,13 @@ return 0; } + /* * Returns true if (pos) has a neighbor of color (color). */ -int has_neighbor(int pos, int color) +int +has_neighbor(int pos, int color) { ASSERT_ON_BOARD1(pos); ASSERT1(IS_STONE(color), pos); Index: engine/dragon.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/dragon.c,v retrieving revision 1.94 diff -u -r1.94 dragon.c --- engine/dragon.c 28 Dec 2002 00:33:04 -0000 1.94 +++ engine/dragon.c 31 Dec 2002 15:13:22 -0000 @@ -2205,12 +2205,14 @@ * At the moment first_worm(pos) will always be the origin of the dragon, * but you should not rely on that. */ -int first_worm_in_dragon(int w) +int +first_worm_in_dragon(int w) { return dragon[w].origin; } -int next_worm_in_dragon(int w) +int +next_worm_in_dragon(int w) { gg_assert(worm[w].origin == w); return next_worm_list[w]; Index: engine/genmove.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/genmove.c,v retrieving revision 1.60 diff -u -r1.60 genmove.c --- engine/genmove.c 22 Dec 2002 20:07:13 -0000 1.60 +++ engine/genmove.c 31 Dec 2002 15:13:24 -0000 @@ -817,7 +817,8 @@ if (search_mask[POS(m,n)]) col = GG_COLOR_RED; - else col = GG_COLOR_BLACK; + else + col = GG_COLOR_BLACK; if (board[POS(m, n)] == BLACK) c = 'X'; Index: engine/matchpat.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/matchpat.c,v retrieving revision 1.46 diff -u -r1.46 matchpat.c --- engine/matchpat.c 31 Dec 2002 12:41:09 -0000 1.46 +++ engine/matchpat.c 31 Dec 2002 15:13:30 -0000 @@ -62,7 +62,7 @@ /* Print profiling information for one pattern struct array. */ static void print_profile(struct pattern *pattern, int *total_hits, - int *total_nodes, int *total_dfa_hits) + int *total_nodes, int *total_dfa_hits) { for (; pattern->patn; ++pattern) if (pattern->hits > 0) { @@ -649,9 +649,9 @@ struct tree_node_list *tnl, struct rec_data *pdata) { - if (0 && !tnl) { + if (0 && !tnl) return; - } + tnl = tnl->next; while (tnl) { struct tree_node *node = &(tnl->node); @@ -914,11 +914,10 @@ /* collect patterns indexes */ int att = pdfa->states[state].att; while (att != 0) { - if (pdfa->pre_rotated) { + if (pdfa->pre_rotated) pat_list[id] = pdfa->indexes[att].val; - } else { + else pat_list[id] = l + 8 * (int)(pdfa->indexes[att].val); - } id++; att = pdfa->indexes[att].next; } Index: engine/oracle.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/oracle.c,v retrieving revision 1.8 diff -u -r1.8 oracle.c --- engine/oracle.c 6 Dec 2002 23:31:42 -0000 1.8 +++ engine/oracle.c 31 Dec 2002 15:13:31 -0000 @@ -111,7 +111,7 @@ error("can't open pipe a"); if (pipe(pfd_b) == -1) error("can't open pipe b"); - switch(fork()) { + switch (fork()) { case -1: error("fork failed (try chopsticks)"); case 0: @@ -238,7 +238,7 @@ int line_length = 0; char line[128]; - while(line_length != 1) { + while (line_length != 1) { if (!fgets(line, 128, from_gnugo_stream)) error("can't get response"); line_length = strlen(line); @@ -460,7 +460,8 @@ return 3; else if (stackp == 1) return 2; - else return 0; + else + return 0; } Index: engine/owl.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/owl.c,v retrieving revision 1.132 diff -u -r1.132 owl.c --- engine/owl.c 31 Dec 2002 12:41:09 -0000 1.132 +++ engine/owl.c 31 Dec 2002 15:13:41 -0000 @@ -3071,7 +3071,8 @@ * to the center of the board */ -static int bdist(int move) +static int +bdist(int move) { /* i = 0: idist = - (board_size - 1) i = board_size -1 : idist = board_size - 1 Index: engine/printutils.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/printutils.c,v retrieving revision 1.30 diff -u -r1.30 printutils.c --- engine/printutils.c 31 Dec 2002 12:41:09 -0000 1.30 +++ engine/printutils.c 31 Dec 2002 15:13:42 -0000 @@ -216,8 +216,6 @@ /* See gnugo.h for related TRACE family macro definitions */ -int trace_dummy; - /* Always returns 1 to allow use in short-circuit logical expressions. */ int DEBUG_func(int flag, const char *fmt, ...) Index: engine/surround.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/surround.c,v retrieving revision 1.4 diff -u -r1.4 surround.c --- engine/surround.c 25 Nov 2002 16:41:09 -0000 1.4 +++ engine/surround.c 31 Dec 2002 15:13:43 -0000 @@ -361,7 +361,8 @@ col = GG_COLOR_RED; else if (mn[POS(m,n)] == 2) col = GG_COLOR_YELLOW; - else col = GG_COLOR_GREEN; + else + col = GG_COLOR_GREEN; } else if (mn[POS(m,n)] == 1) col = GG_COLOR_BLUE; Index: patterns/dfa.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/patterns/dfa.c,v retrieving revision 1.25 diff -u -r1.25 dfa.c --- patterns/dfa.c 31 Dec 2002 12:41:09 -0000 1.25 +++ patterns/dfa.c 31 Dec 2002 15:13:58 -0000 @@ -37,32 +37,14 @@ #include #endif -#define gg_assert(x) assert(x); - /********************* * Public data * *********************/ -/* If > 0 more detailled infomation is given */ +/* If > 0 more detailed information is given */ int dfa_verbose = 0; -/* conversion array (stupid hack) */ -int dfa_asc2val[90] = { - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 0, 3, 3, 3, /* '.' == 46 */ - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, /* 'O' == 79 */ - 3, 3, 3, 3, 3, 3, 3, 3, 2, 3 /* 'X' == 88 */ -}; - -char dfa_val2asc[4] = { - '.', 'O', 'X', '#' }; - /********************* * Private data * @@ -86,13 +68,13 @@ {-1, -1, -1, -1}, /* not used */ {EMPTY, WHITE, BLACK, OUT_BOARD}, /* WHITE */ {EMPTY, BLACK, WHITE, OUT_BOARD} /* BLACK */ - }; /* convert ATT_* values to the corresponding expected values on the board */ -static const char att2val[8] = - { '.', 'X', 'O', 'x', 'o', ',', 'a', '!' }; +static const char att2val[8] = { + '.', 'X', 'O', 'x', 'o', ',', 'a', '!' +}; #define EXPECTED_VAL(att_val) att2val[att_val] @@ -101,7 +83,7 @@ * forward declaration of private functions * ************************************************/ static void clean_dfa(dfa_t *pdfa); -static void resize_dfa(dfa_t *pdfa, int maxStates, int maxIndexes); +static void resize_dfa(dfa_t *pdfa, int max_states, int max_indexes); static void create_dfa(dfa_t *pdfa, const char *str, int att_val); static void do_sync_product(int l, int r); static void sync_product(dfa_t *pout, dfa_t *pleft, dfa_t *pright); @@ -143,13 +125,14 @@ * */ -static const int generator[4] = - { 4 * DFA_MAX_BOARD, 1, -4 * DFA_MAX_BOARD, -1 }; +static const int generator[4] = { + 4 * DFA_MAX_BOARD, 1, -4 * DFA_MAX_BOARD, -1 +}; void buildSpiralOrder(int order[MAX_ORDER][8]) { - int Mark[DFA_MAX_BOARD * 4 * DFA_MAX_BOARD * 4]; + int mark[DFA_MAX_BOARD * 4 * DFA_MAX_BOARD * 4]; int fifo[8 * MAX_ORDER]; int top = 0, end = 0; int i, j, i0, j0; @@ -157,8 +140,6 @@ int ii; int delta; - - if (dfa_verbose > 1) fprintf(stderr, "Building spiral order\n"); @@ -167,16 +148,16 @@ /* initialization */ for (ii = 0; ii < DFA_MAX_BOARD * 4 * DFA_MAX_BOARD * 4; ii++) - Mark[ii] = 1; + mark[ii] = 1; for (i = DFA_MAX_BOARD; i < DFA_MAX_BOARD * 3; i++) for (j = DFA_MAX_BOARD; j < DFA_MAX_BOARD * 3; j++) - Mark[DFA_POS(i, j)] = 0; + mark[DFA_POS(i, j)] = 0; end = 0; top = 1; fifo[end] = 2 * DFA_OFFSET; - Mark[fifo[end]] = 1; + mark[fifo[end]] = 1; /* generation */ while (end < MAX_ORDER) { @@ -187,16 +168,15 @@ for (k = 0; k != 4; k++) { delta = generator[k]; - if (!Mark[ii + delta]) { + if (!mark[ii + delta]) { fifo[top] = ii + delta; - Mark[ii + delta] = 1; + mark[ii + delta] = 1; top++; } } } - /* Then we compute all the geometric transformations - on this order */ + /* Then we compute all the geometric transformations on this order */ for (k = 0; k < MAX_ORDER; k++) { j0 = order[k][0] % (4 * DFA_MAX_BOARD); if (j0 >= 2 * DFA_MAX_BOARD) @@ -211,11 +191,9 @@ } if (0) { - for (ll = 0; ll < 8; ll++) { - for (i = 0; i < 13; i++) { - fprintf(stderr, "i:%d; ll:%d; %d(%c)\n", i, ll, order[i][ll],'A'+i); - } - } + for (ll = 0; ll < 8; ll++) + for (i = 0; i < 13; i++) + fprintf(stderr, "i:%d; ll:%d; %d(%c)\n", i, ll, order[i][ll], 'A'+i); } } @@ -255,11 +233,10 @@ /* copy att1 in att */ att = 0; while (att1 != 0) { - pdfa->lastIndex++; - if (pdfa->lastIndex >= pdfa->maxIndexes) - resize_dfa(pdfa, pdfa->maxStates, - pdfa->maxIndexes + DFA_RESIZE_STEP); - att_aux = pdfa->lastIndex; + pdfa->last_index++; + if (pdfa->last_index >= pdfa->max_indexes) + resize_dfa(pdfa, pdfa->max_states, pdfa->max_indexes + DFA_RESIZE_STEP); + att_aux = pdfa->last_index; pdfa->indexes[att_aux].val = pdfa1->indexes[att1].val; pdfa->indexes[att_aux].next = att; @@ -270,10 +247,10 @@ /* add to att the new elements of att2 */ while (att2 != 0) { if (!member_att(pdfa, att, pdfa2->indexes[att2].val)) { - pdfa->lastIndex++; - if (pdfa->lastIndex >= pdfa->maxIndexes) - resize_dfa(pdfa, pdfa->maxStates, pdfa->maxIndexes + DFA_RESIZE_STEP); - att_aux = pdfa->lastIndex; + pdfa->last_index++; + if (pdfa->last_index >= pdfa->max_indexes) + resize_dfa(pdfa, pdfa->max_states, pdfa->max_indexes + DFA_RESIZE_STEP); + att_aux = pdfa->last_index; pdfa->indexes[att_aux].val = pdfa2->indexes[att2].val; pdfa->indexes[att_aux].next = att; @@ -293,7 +270,7 @@ { int k; int last = 0; - int save_last = pdfa->lastIndex; + int save_last = pdfa->last_index; int *map; int *search_first; int *search_next; @@ -335,11 +312,11 @@ free(search_next); if (last < save_last) { - pdfa->lastIndex = last; - for (k = 0; k <= pdfa->lastIndex; k++) + pdfa->last_index = last; + for (k = 0; k <= pdfa->last_index; k++) pdfa->indexes[k].next = map[pdfa->indexes[k].next]; - for (k = 0; k <= pdfa->lastState; k++) + for (k = 0; k <= pdfa->last_state; k++) pdfa->states[k].att = map[pdfa->states[k].att]; if (0) @@ -367,8 +344,8 @@ { int states_size, indexes_size; - states_size = (pdfa->lastState + 1) * sizeof(state_rt_t); - indexes_size = (pdfa->lastIndex + 1) * sizeof(attrib_rt_t); + states_size = (pdfa->last_state + 1) * sizeof(state_rt_t); + indexes_size = (pdfa->last_index + 1) * sizeof(attrib_rt_t); return (states_size + indexes_size + sizeof(dfa_rt_t)) / 1024; } @@ -379,7 +356,7 @@ */ static void -resize_dfa(dfa_t *pdfa, int maxStates, int maxIndexes) +resize_dfa(dfa_t *pdfa, int max_states, int max_indexes) { state_t *pBuf; attrib_t *pBuf2; @@ -388,25 +365,25 @@ if (dfa_verbose > 1) fprintf(stderr, "Resizing dfa %s\n", pdfa->name); - gg_assert(pdfa->lastState <= pdfa->maxStates); - gg_assert(pdfa->lastIndex <= pdfa->maxIndexes); + assert(pdfa->last_state <= pdfa->max_states); + assert(pdfa->last_index <= pdfa->max_indexes); - pBuf = realloc(pdfa->states, maxStates * sizeof(state_t)); - pBuf2 = realloc(pdfa->indexes, maxIndexes * sizeof(attrib_t)); + pBuf = realloc(pdfa->states, max_states * sizeof(state_t)); + pBuf2 = realloc(pdfa->indexes, max_indexes * sizeof(attrib_t)); if (pBuf == NULL || pBuf2 == NULL) { fprintf(stderr, "No memory left for dfa: %s", pdfa->name); exit(EXIT_FAILURE); } - for (i = pdfa->maxStates; i < maxStates; i++) + for (i = pdfa->max_states; i < max_states; i++) memset(pBuf + i, 0, sizeof(state_t)); - for (i = pdfa->maxIndexes; i < maxIndexes; i++) + for (i = pdfa->max_indexes; i < max_indexes; i++) memset(pBuf2 + i, 0, sizeof(attrib_t)); pdfa->states = pBuf; - pdfa->maxStates = maxStates; + pdfa->max_states = max_states; pdfa->indexes = pBuf2; - pdfa->maxIndexes = maxIndexes; + pdfa->max_indexes = max_indexes; } @@ -426,10 +403,10 @@ fprintf(f, line); fprintf(f, " name : %s\n", pdfa->name); - fprintf(f, " Nb states : %7d, max= %d\n", pdfa->lastState + 1, - pdfa->maxStates); - fprintf(f, " Nb Indexes : %7d, max= %d\n", pdfa->lastIndex, - pdfa->maxIndexes); + fprintf(f, " Nb states : %7d, max= %d\n", pdfa->last_state + 1, + pdfa->max_states); + fprintf(f, " Nb Indexes : %7d, max= %d\n", pdfa->last_index, + pdfa->max_indexes); fprintf(f, " memory needed : %d Mb\n", dfa_size(pdfa) / 1024); fprintf(f, line); @@ -437,7 +414,7 @@ return; fprintf(f, " state | . | O | X | # | att \n"); fprintf(f, line); - for (i = 1; i != pdfa->lastState + 1; i++) { + for (i = 1; i != pdfa->last_state + 1; i++) { int *pnext = pdfa->states[i].next; fprintf(f, " %6d |", i); fprintf(f, " %6d | %6d | %6d |", pnext[0], pnext[1], pnext[2]); @@ -466,10 +443,10 @@ static void clean_dfa(dfa_t *pdfa) { - memset(pdfa->states, 0, pdfa->maxStates * sizeof(state_t)); - memset(pdfa->indexes, 0, pdfa->maxIndexes * sizeof(attrib_t)); - pdfa->lastState = 1; /* initial state */ - pdfa->lastIndex = 0; + memset(pdfa->states, 0, pdfa->max_states * sizeof(state_t)); + memset(pdfa->indexes, 0, pdfa->max_indexes * sizeof(attrib_t)); + pdfa->last_state = 1; /* initial state */ + pdfa->last_index = 0; pdfa->indexes[0].val = -1; } @@ -511,30 +488,29 @@ /* - * Copy a dfa. - * and resize the destination dfa if necessary. + * Copy a dfa and resize the destination dfa if necessary. */ void copy_dfa(dfa_t *p_to, dfa_t *p_from) { - gg_assert(p_to != p_from); + assert(p_to != p_from); - if (p_to->maxStates < p_from->lastState) - resize_dfa(p_to, p_from->maxStates, p_to->maxIndexes); + if (p_to->max_states < p_from->last_state) + resize_dfa(p_to, p_from->max_states, p_to->max_indexes); - if (p_to->maxIndexes < p_from->lastIndex) - resize_dfa(p_to, p_to->maxStates, p_from->maxIndexes); + if (p_to->max_indexes < p_from->last_index) + resize_dfa(p_to, p_to->max_states, p_from->max_indexes); clean_dfa(p_to); memcpy(p_to->states, p_from->states, - sizeof(state_t) * (p_from->lastState + 1)); + sizeof(state_t) * (p_from->last_state + 1)); memcpy(p_to->indexes, p_from->indexes, - sizeof(attrib_t) * (p_from->lastIndex + 1)); + sizeof(attrib_t) * (p_from->last_index + 1)); - p_to->lastState = p_from->lastState; - p_to->lastIndex = p_from->lastIndex; + p_to->last_state = p_from->last_state; + p_to->last_index = p_from->last_index; } @@ -554,14 +530,14 @@ exit(EXIT_FAILURE); } - assert (dfa_minmax_delta(pdfa, -1, 1) > 0); + assert(dfa_minmax_delta(pdfa, -1, 1) > 0); if (dfa_minmax_delta(pdfa, -1, 0) > 65535) { fprintf(of, "#error too many states"); fprintf(stderr, "Error: The dfa states are too disperse. Can't fit delta into a short.\n"); exit(EXIT_FAILURE); } - if (pdfa->lastIndex + 1 > 65535) { + if (pdfa->last_index + 1 > 65535) { fprintf(of, "#error too many states"); fprintf(stderr, "Error: Too many index entries. Can't fit delta into a short.\n"); exit(EXIT_FAILURE); @@ -570,25 +546,27 @@ fprintf(of, "\n#include \"dfa.h\"\n"); - fprintf(of, "static const state_rt_t state_%s[%d] = {\n", name, pdfa->lastState + 1); - for (i = 0; i != pdfa->lastState + 1; i++) { + fprintf(of, "static const state_rt_t state_%s[%d] = {\n", + name, pdfa->last_state + 1); + for (i = 0; i != pdfa->last_state + 1; i++) { int j; fprintf(of, "{%d,", pdfa->states[i].att); fprintf(of, "{"); - for (j=0;j<4;j++) { + for (j = 0; j < 4; j++) { int n = pdfa->states[i].next[j]; - assert ((n == 0) || ( (n - i > 0) && (n - i < 65535) )); + assert((n == 0) || ((n - i > 0) && (n - i < 65535))); fprintf(of, "%d", n ? n - i : 0); if (j != 3) fprintf(of, ","); } - fprintf(of, "}},%s", ((i+1)%3 ? "\t" : "\n") ); + fprintf(of, "}},%s", ((i+1)%3 ? "\t" : "\n")); } fprintf(of, "};\n\n"); - fprintf(of, "static const attrib_rt_t idx_%s[%d] = {\n", name, pdfa->lastIndex + 1); - for (i = 0; i != pdfa->lastIndex + 1; i++) + fprintf(of, "static const attrib_rt_t idx_%s[%d] = {\n", + name, pdfa->last_index + 1); + for (i = 0; i != pdfa->last_index + 1; i++) fprintf(of, "{%d,%d},%s", pdfa->indexes[i].val, pdfa->indexes[i].next, ((i+1)%4 ? "\t" : "\n")); fprintf(of, "};\n\n"); @@ -637,9 +615,9 @@ if (dfa_verbose > 1) fprintf(stderr, "linear dfa in %s with string: %s\n", pdfa->name, str); - gg_assert(str != NULL); - gg_assert(pdfa->maxStates > 1); - gg_assert(pdfa->maxIndexes > 1); + assert(str != NULL); + assert(pdfa->max_states > 1); + assert(pdfa->max_indexes > 1); clean_dfa(pdfa); new_state = 1; @@ -654,23 +632,23 @@ if (strchr("$#+-|", *str)) pdfa->states[new_state].next[OUT_BOARD] = new_state + 1; new_state++; - if (new_state >= pdfa->maxStates) - resize_dfa(pdfa, pdfa->maxStates + DFA_RESIZE_STEP, - pdfa->maxIndexes); + if (new_state >= pdfa->max_states) + resize_dfa(pdfa, pdfa->max_states + DFA_RESIZE_STEP, + pdfa->max_indexes); } memset(pdfa->states[new_state].next, 0, 4 * sizeof(int)); - pdfa->lastIndex++; - if (pdfa->lastIndex >= pdfa->maxIndexes) - resize_dfa(pdfa, pdfa->maxStates, - pdfa->maxIndexes + DFA_RESIZE_STEP); + pdfa->last_index++; + if (pdfa->last_index >= pdfa->max_indexes) + resize_dfa(pdfa, pdfa->max_states, + pdfa->max_indexes + DFA_RESIZE_STEP); - memset(&(pdfa->indexes[pdfa->lastIndex]), 0, sizeof(attrib_t)); - pdfa->states[new_state].att = pdfa->lastIndex; + memset(&(pdfa->indexes[pdfa->last_index]), 0, sizeof(attrib_t)); + pdfa->states[new_state].att = pdfa->last_index; pdfa->indexes[pdfa->states[new_state].att].val = att_val; pdfa->indexes[pdfa->states[new_state].att].next = 0; - pdfa->lastState = new_state; + pdfa->last_state = new_state; } @@ -734,8 +712,8 @@ entry_t *new_entry; /* make sure val > 0: val = 0 is used in get_from_entry_list */ - gg_assert(val > 0); - gg_assert(!get_from_entry_list(*pplist, l, r)); + assert(val > 0); + assert(!get_from_entry_list(*pplist, l, r)); new_entry = malloc(sizeof(entry_t)); if (new_entry == NULL) { @@ -814,7 +792,7 @@ int nextl, nextr; int state; - state = gpout->lastState; + state = gpout->last_state; /* unify the attributes of states l and r */ gpout->states[state].att = union_att(gpout, gpleft, gpleft->states[l].att, @@ -824,23 +802,23 @@ for (c = 0; c != 4; c++) { nextl = gpleft->states[l].next[c]; nextr = gpright->states[r].next[c]; - gg_assert(nextl < gpleft->lastState + 1); - gg_assert(nextr < gpright->lastState + 1); + assert(nextl < gpleft->last_state + 1); + assert(nextr < gpright->last_state + 1); /* transition to (0,0) mean no transition at all */ if (nextl != 0 || nextr != 0) { /* if the out-state doesn't already exist */ if (get_from_test_array(>est, nextl, nextr) == 0) { /* create it! */ - gpout->lastState++; - if (gpout->lastState >= gpout->maxStates) - resize_dfa(gpout, gpout->maxStates + DFA_RESIZE_STEP, - gpout->maxIndexes); + gpout->last_state++; + if (gpout->last_state >= gpout->max_states) + resize_dfa(gpout, gpout->max_states + DFA_RESIZE_STEP, + gpout->max_indexes); - add_to_test_array(>est, nextl, nextr, gpout->lastState); + add_to_test_array(>est, nextl, nextr, gpout->last_state); /* link it */ - gpout->states[state].next[c] = gpout->lastState; + gpout->states[state].next[c] = gpout->last_state; /* create also its sub-automaton */ do_sync_product(nextl, nextr); @@ -861,11 +839,10 @@ static void sync_product(dfa_t *pout, dfa_t *pleft, dfa_t *pright) { - pout->lastIndex = 0; + pout->last_index = 0; if (dfa_verbose > 2) { - fprintf(stderr, "Product between %s and %s\n", pleft->name, - pright->name); + fprintf(stderr, "Product between %s and %s\n", pleft->name, pright->name); fprintf(stderr, "result in %s\n", pout->name); } @@ -875,7 +852,7 @@ gpright = pright; new_test_array(>est); add_to_test_array(>est, 1, 1, 1); - pout->lastState = 1; + pout->last_state = 1; do_sync_product(1, 1); @@ -931,34 +908,30 @@ int ret, i, j; assert(next_index <= 3); - if (isMin) { + if (isMin) ret = 99999; - } else { + else ret = -1; - } - for (i=0; i<=pdfa->lastState; i++) { - for (j=0; j<4; j++) { + for (i = 0; i <= pdfa->last_state; i++) { + for (j = 0; j < 4; j++) { if (j == next_index || next_index < 0) { int next = pdfa->states[i].next[j]; if (!next) continue; if (isMin) { - if (ret > next - i) { + if (ret > next - i) ret = next - i; - } - } else { - if (ret < next - i) { + } + else { + if (ret < next - i) ret = next - i; - } } } } } return ret; - - } @@ -970,37 +943,37 @@ void dfa_shuffle(dfa_t *pdfa) { - struct state *oldStates; - int *stateTo; - int *stateFrom; + struct state *old_states; + int *state_to; + int *state_from; int *queue1; int *queue2; int *tempq; - int nextNewState; + int next_new_state; int q1p; int q2p; int i, j; - stateTo = calloc(pdfa->lastState+1, sizeof(int)); - stateFrom = calloc(pdfa->lastState+1, sizeof(int)); + state_to = calloc(pdfa->last_state+1, sizeof(int)); + state_from = calloc(pdfa->last_state+1, sizeof(int)); - queue1 = malloc((pdfa->lastState+1) * sizeof(int)); - queue2 = malloc((pdfa->lastState+1) * sizeof(int)); + queue1 = malloc((pdfa->last_state+1) * sizeof(int)); + queue2 = malloc((pdfa->last_state+1) * sizeof(int)); q1p = 1; q2p = 0; queue1[0] = 1; /* i.e. start at state 1. */ - stateFrom[0] = stateTo[0] = 0; - stateFrom[1] = stateTo[1] = 1; - nextNewState = 2; + state_from[0] = state_to[0] = 0; + state_from[1] = state_to[1] = 1; + next_new_state = 2; while (q1p) { - for (i=0;istates[queue1[i]].next[j]; - if (n && !stateTo[n]) { - stateTo[n] = nextNewState; - stateFrom[nextNewState] = n; - nextNewState++; + if (n && !state_to[n]) { + state_to[n] = next_new_state; + state_from[next_new_state] = n; + next_new_state++; queue2[q2p++] = n; } } @@ -1012,21 +985,20 @@ q2p = 0; } - oldStates = malloc((pdfa->lastState+1) * sizeof(struct state)); - for (i=1; i<=pdfa->lastState; i++) { - for (j=0;j<4;j++) { - oldStates[i].next[j] = pdfa->states[i].next[j]; - oldStates[i].att = pdfa->states[i].att; + old_states = malloc((pdfa->last_state+1) * sizeof(struct state)); + for (i = 1; i <= pdfa->last_state; i++) { + for (j = 0; j < 4; j++) { + old_states[i].next[j] = pdfa->states[i].next[j]; + old_states[i].att = pdfa->states[i].att; } } - for (i=1; i<=pdfa->lastState; i++) { - for (j=0;j<4;j++) { - assert(stateTo[i]>0); - pdfa->states[i].next[j] = stateTo[oldStates[stateFrom[i]].next[j]]; + for (i = 1; i <= pdfa->last_state; i++) { + for (j = 0; j < 4; j++) { + assert(state_to[i] > 0); + pdfa->states[i].next[j] = state_to[old_states[state_from[i]].next[j]]; } - pdfa->states[i].att = oldStates[stateFrom[i]].att; + pdfa->states[i].att = old_states[state_from[i]].att; } - } @@ -1049,7 +1021,7 @@ &aux_dfa[(j+1) % DFA_BINS]); next_bin++; } - last_bin = next_bin-1; + last_bin = next_bin - 1; aux_count--; next_bin = aux_count; } @@ -1074,10 +1046,10 @@ float ratio; char strrot[MAX_ORDER+1]; - if (ll == 0) { + if (ll == 0) strcpy(strrot, str); - } else { - int i,j; + else { + int i, j; char strdollar[MAX_ORDER+1]; memset(strdollar, '$', sizeof(char) * (MAX_ORDER + 1)); strcpy(strdollar, str); @@ -1107,11 +1079,12 @@ if (dfa_verbose > 1) { fprintf(stderr, "Adding to dfa %s the string: %s\n", pdfa->name, strrot); - fprintf(stderr, " pat_ind: %d; rotation: %d at bin: %d\n", pattern_index, ll, aux_count); + fprintf(stderr, " pat_ind: %d; rotation: %d at bin: %d\n", + pattern_index, ll, aux_count); } - gg_assert(dfa_was_initialized > 0); - gg_assert(pdfa != NULL); + assert(dfa_was_initialized > 0); + assert(pdfa != NULL); if (pdfa->pre_rotated) pattern_index = pattern_index * 8 + ll; @@ -1147,7 +1120,7 @@ m = DFA_MAX_BOARD * 2 + ci; n = DFA_MAX_BOARD * 2 + cj; /* position of the anchor */ - gg_assert(dfa_was_initialized); + assert(dfa_was_initialized); memset(str, 0, MAX_ORDER); memset(work_space, '#', sizeof(work_space)); @@ -1219,8 +1192,7 @@ /* pattern representation on the work space */ for (k = 0; k != pat->patlen; k++) { c = EXPECTED_VAL(elements[k].att); - gg_assert(work_space[m + elements[k].x - ci] - [n + elements[k].y - cj] == '?'); + assert(work_space[m + elements[k].x - ci][n + elements[k].y - cj] == '?'); work_space[m + elements[k].x - ci][n + elements[k].y - cj] = c; } @@ -1273,9 +1245,9 @@ if (j == pat->minj) borders &= ~WEST_EDGE; - gg_assert(m + i < DFA_MAX_BOARD * 3 && m + i < DFA_MAX_BOARD * 3); + assert(m + i < DFA_MAX_BOARD * 3 && m + i < DFA_MAX_BOARD * 3); str[k] = work_space[m + i][n + j]; - gg_assert(strchr("XOxo.,a!?$#|-+", str[k])); + assert(strchr("XOxo.,a!?$#|-+", str[k])); if (strchr("XOxo.,a!", str[k])) to_test--; @@ -1291,7 +1263,7 @@ } } - gg_assert(k < MAX_ORDER); + assert(k < MAX_ORDER); str[k] = '\0'; /* end of string */ if (0 && dfa_verbose > 0) Index: patterns/dfa.h =================================================================== RCS file: /cvsroot/gnugo/gnugo/patterns/dfa.h,v retrieving revision 1.19 diff -u -r1.19 dfa.h --- patterns/dfa.h 9 Dec 2002 23:04:16 -0000 1.19 +++ patterns/dfa.h 31 Dec 2002 15:13:58 -0000 @@ -60,8 +60,7 @@ { int val; int next; -} -attrib_t; +} attrib_t; /* dfa state */ @@ -70,8 +69,7 @@ { int att; int next[4]; -} -state_t; +} state_t; /* dfa */ @@ -84,15 +82,14 @@ /* transition graph */ state_t *states; - int maxStates; - int lastState; + int max_states; + int last_state; /* attributes sets */ attrib_t *indexes; - int maxIndexes; - int lastIndex; -} -dfa_t; + int max_indexes; + int last_index; +} dfa_t; /* The run-time data structures are different from those used @@ -103,16 +100,14 @@ { short val; short next; -} -attrib_rt_t; +} attrib_rt_t; /* dfa state */ typedef struct state_rt { short att; unsigned short next[4]; -} -state_rt_t; +} state_rt_t; typedef struct dfa_rt { @@ -125,8 +120,7 @@ /* attributes sets */ const attrib_rt_t *indexes; -} -dfa_rt_t; +} dfa_rt_t; /* scan order */ @@ -136,8 +130,7 @@ { int i; int j; -} -order_t; +} order_t; #endif @@ -150,7 +143,7 @@ void buildSpiralOrder(int order[MAX_ORDER][8]); /* Needed by matchpat */ /* basic dfa manipulation */ -void print_c_dfa(FILE* of, const char *name, dfa_t *pdfa); +void print_c_dfa(FILE *of, const char *name, dfa_t *pdfa); void new_dfa(dfa_t *pdfa, const char *name); void copy_dfa(dfa_t *p_to, dfa_t *p_from); void kill_dfa(dfa_t *pdfa); @@ -175,11 +168,6 @@ /* conversion macros */ #define EXPECTED_COLOR(player_c, position_c) convert[player_c][position_c] - -extern int dfa_asc2val[90]; -extern char dfa_val2asc[4]; -#define ASC2VAL(c) (c < 90 ? dfa_asc2val[(int)c] : 3) -#define VAL2ASC(n) (n < 4 ? dfa_val2asc[n] : '!') /* incremental macro */ Index: patterns/joseki.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/patterns/joseki.c,v retrieving revision 1.13 diff -u -r1.13 joseki.c --- patterns/joseki.c 4 Sep 2002 07:23:46 -0000 1.13 +++ patterns/joseki.c 31 Dec 2002 15:13:59 -0000 @@ -29,10 +29,6 @@ #include "../sgf/sgftree.h" #include "liberty.h" -#ifndef VARIADIC_MACROS -int trace_dummy; -#endif - #define USAGE "\ Usage : joseki prefix filename\n\ " Index: patterns/mkpat.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/patterns/mkpat.c,v retrieving revision 1.103 diff -u -r1.103 mkpat.c --- patterns/mkpat.c 31 Dec 2002 12:41:09 -0000 1.103 +++ patterns/mkpat.c 31 Dec 2002 15:14:07 -0000 @@ -566,13 +566,14 @@ pattern_2_string(pattern+index, elements, str, 0, ci, cj); if (pre_rotate) { - if (pattern[index].trfno != 5) { + if (pattern[index].trfno != 5) rot_stop = pattern[index].trfno; - } else { + else { rot_start = 2; rot_stop = 6; } } + for (ll = 0; ll < rot_stop; ll++) { /* Then We add this string to the DFA */ ratio = (dfa_add_string(&dfa, str, index, ll) - 1)*100; @@ -2676,7 +2677,7 @@ fprintf(stderr, "dfa for %s\n", prefix); fprintf(stderr, "size: %d kB for ", dfa_size(&dfa)); fprintf(stderr, "%d patterns", patno); - fprintf(stderr, "(%d states)\n", dfa.lastState); + fprintf(stderr, "(%d states)\n", dfa.last_state); if (0 && dfa.pre_rotated) dump_dfa(stderr, &dfa); Index: patterns/transform.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/patterns/transform.c,v retrieving revision 1.8 diff -u -r1.8 transform.c --- patterns/transform.c 9 Dec 2002 23:04:17 -0000 1.8 +++ patterns/transform.c 31 Dec 2002 15:14:07 -0000 @@ -53,7 +53,8 @@ /* Initialize transformation[][] array. */ -void transformation_init(void) +void +transformation_init(void) { int k; int dx;