diff options
author | scw <scw@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-09-02 21:16:44 +0800 |
---|---|---|
committer | scw <scw@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-09-02 21:16:44 +0800 |
commit | d4da0ab5ad5337030f4d1923e6e6368fc571f70b (patch) | |
tree | 9bacaa45f474251b3f52ff171c88a8294e4827d6 /mbbsd | |
parent | cbaa24d062e1ecebc90fd8b671a1c68daa70664b (diff) | |
download | pttbbs-d4da0ab5ad5337030f4d1923e6e6368fc571f70b.tar pttbbs-d4da0ab5ad5337030f4d1923e6e6368fc571f70b.tar.gz pttbbs-d4da0ab5ad5337030f4d1923e6e6368fc571f70b.tar.bz2 pttbbs-d4da0ab5ad5337030f4d1923e6e6368fc571f70b.tar.lz pttbbs-d4da0ab5ad5337030f4d1923e6e6368fc571f70b.tar.xz pttbbs-d4da0ab5ad5337030f4d1923e6e6368fc571f70b.tar.zst pttbbs-d4da0ab5ad5337030f4d1923e6e6368fc571f70b.zip |
Gomoku log read error
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3125 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r-- | mbbsd/chc.c | 8 | ||||
-rw-r--r-- | mbbsd/gomo.c | 34 |
2 files changed, 32 insertions, 10 deletions
diff --git a/mbbsd/chc.c b/mbbsd/chc.c index 76725a97..52598375 100644 --- a/mbbsd/chc.c +++ b/mbbsd/chc.c @@ -954,7 +954,7 @@ chc_replay(FILE* fp) if (p == NULL) continue; ++p; /* skip '.' */ - while(*p && isspace(*p)) ++p; + while (*p && isspace(*p)) ++p; if (!*p) continue; /* p -> "Ch2-e2 ...." */ @@ -971,7 +971,7 @@ chc_replay(FILE* fp) ChessHistoryAppend(info, &step); p += 6; - while(*p && isspace(*p)) ++p; + while (*p && isspace(*p)) ++p; if (!*p) continue; /* p -> "Nb9-c7\n" */ @@ -983,6 +983,10 @@ chc_replay(FILE* fp) if (INVALID_LOC(step.from) || INVALID_LOC(step.to)) continue; ChessHistoryAppend(info, &step); + +#undef INVALID_ROW +#undef INVALID_COL +#undef INVALID_LOC } } diff --git a/mbbsd/gomo.c b/mbbsd/gomo.c index 5603a4ec..3e242517 100644 --- a/mbbsd/gomo.c +++ b/mbbsd/gomo.c @@ -525,11 +525,20 @@ gomoku_replay(FILE* fp) if (getuser(buf + 6, &rec)) gomo_init_user_userec(&rec, user); } else if (buf[0] == '[') { - /* "[ 1]¡´ ==> H8 [ 2]¡³ ==> H9" * - * 012345678901234567890123456789 */ + /* "[ 1]¡´ ==> H8 [ 2]¡³ ==> H9" */ gomo_step_t step = { CHESS_STEP_NORMAL, BLK }; - int c = buf[11] - 'A'; - int r = BRDSIZ - atoi(&buf[12]); + int c, r; + const char *p = strchr(buf, '>'); + + if (p == NULL) continue; + + ++p; /* skip '>' */ + while (*p && isspace(*p)) ++p; + if (!*p) continue; + + /* p -> "H8 ..." */ + c = p[0] - 'A'; + r = BRDSIZ - atoi(p + 1); #define INVALID_ROW(R) ((R) < 0 || (R) >= BRDSIZ) #define INVALID_COL(C) ((C) < 0 || (C) >= BRDSIZ) @@ -540,11 +549,17 @@ gomoku_replay(FILE* fp) step.loc.c = c; ChessHistoryAppend(info, &step); - if (strlen(buf) < 28) - continue; + p = strchr(p, '>'); - c = buf[28] - 'A'; - r = BRDSIZ - atoi(&buf[29]); + if (p == NULL) continue; + + ++p; /* skip '>' */ + while (*p && isspace(*p)) ++p; + if (!*p) continue; + + /* p -> "H9\n" */ + c = p[0] - 'A'; + r = BRDSIZ - atoi(p + 1); if (INVALID_COL(c) || INVALID_ROW(r)) continue; @@ -553,6 +568,9 @@ gomoku_replay(FILE* fp) step.loc.r = r; step.loc.c = c; ChessHistoryAppend(info, &step); + +#undef INVALID_ROW +#undef INVALID_COL } } |