aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--FICS/formula.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/FICS/formula.c b/FICS/formula.c
index 4315239..980f7d8 100644
--- a/FICS/formula.c
+++ b/FICS/formula.c
@@ -96,20 +96,27 @@ int GetRating(player *p, int gametype)
else return 0;
} /* end of function GetRating. */
-int GetNumberInsideParens (game *g, int clause, int *i, int *token,
- int eval)
+int
+GetNumberInsideParens(game *g, int clause, int *i, int *token, int eval)
{
- char *string = GetPlayersFormula(&parray[g->black], clause);
- int ret;
+ char *string = GetPlayersFormula(&parray[g->black], clause);
+ int ret;
+
+ while (string[*i] != '\0' && isspace(string[*i]))
+ (*i)++;
- while (string[*i] != '\0' && isspace(string[*i])) (*i)++;
- if (!MoveIndexPastString(string, i, "(")) return (ERR_BADCHAR);
+ if (!MoveIndexPastString(string, i, "("))
+ return ERR_BADCHAR;
- ret = CheckFormula(g, clause, i, OPTYPE_PAREN, token, eval);
- if (ret != ERR_NONE)
- return (ret);
- if (MoveIndexPastString(string, i, ")")) return (ERR_NONE);
- else return (ERR_PAREN);
+ ret = CheckFormula(g, clause, i, OPTYPE_PAREN, token, eval);
+
+ if (ret != ERR_NONE)
+ return ret;
+
+ if (MoveIndexPastString(string, i, ")"))
+ return ERR_NONE;
+ else
+ return ERR_PAREN;
}
int