10
10
// SGFの座標を数値に変換
11
11
static int ParsePosition ( const char c );
12
12
// 盤の大きさの抽出
13
- static int GetSize ( SGF_record_t *kifu, char *sgf_text, int cursor );
13
+ static int GetSize ( SGF_record_t *kifu, const char *sgf_text, const int cursor );
14
14
// 結果の抽出
15
- static int GetResult ( SGF_record_t *kifu, char *sgf_text, int cursor );
15
+ static int GetResult ( SGF_record_t *kifu, const char *sgf_text, const int cursor );
16
16
// 着手の抽出
17
- static int GetMove ( SGF_record_t *kifu, char *sgf_text, int cursor );
17
+ static int GetMove ( SGF_record_t *kifu, const char *sgf_text, const int cursor );
18
18
// 置き石の数の抽出
19
- static int GetHandicaps ( SGF_record_t *kifu, char *sgf_text, int cursor );
19
+ static int GetHandicaps ( SGF_record_t *kifu, const char *sgf_text, const int cursor );
20
20
// 置き石の座標の抽出
21
- static int GetHandicapPosition ( SGF_record_t *kifu, char *sgf_text, int cursor, int color );
21
+ static int GetHandicapPosition ( SGF_record_t *kifu, const char *sgf_text, const int cursor, const int color );
22
22
// コミの抽出
23
- static int GetKomi ( SGF_record_t *kifu, char *sgf_text, int cursor );
23
+ static int GetKomi ( SGF_record_t *kifu, const char *sgf_text, const int cursor );
24
24
// 対局者の名前を抽出
25
- static int GetPlayerName ( SGF_record_t *kifu, char *sgf_text, int cursor, int color );
25
+ static int GetPlayerName ( SGF_record_t *kifu, const char *sgf_text, const int cursor, const int color );
26
26
// 無視する情報を飛ばす処理
27
- static int SkipData ( SGF_record_t *kifu, char *sgf_text, int cursor );
27
+ static int SkipData ( SGF_record_t *kifu, const char *sgf_text, const int cursor );
28
28
29
29
30
30
// ////////////////
@@ -44,7 +44,8 @@ GetKifuMove( const SGF_record_t *kifu, const int n )
44
44
// //////////////////
45
45
// 置き石の抽出 //
46
46
// //////////////////
47
- int GetHandicapStone ( const SGF_record_t *kifu, const int n )
47
+ int
48
+ GetHandicapStone ( const SGF_record_t *kifu, const int n )
48
49
{
49
50
if (kifu->handicap_x [n] == 0 ) {
50
51
return PASS;
@@ -101,7 +102,6 @@ ExtractKifu( const char *file_name, SGF_record_t *kifu )
101
102
memset (kifu->handicap_x , 0 , sizeof (kifu->handicap_x ));
102
103
memset (kifu->handicap_y , 0 , sizeof (kifu->handicap_y ));
103
104
memset (kifu->handicap_color , 0 , sizeof (kifu->handicap_color ));
104
-
105
105
106
106
while ((cursor < 100000 ) && (sgf_text[cursor] != ' \0 ' )) {
107
107
if (sgf_text[cursor] == ' \n ' ||
@@ -132,6 +132,8 @@ ExtractKifu( const char *file_name, SGF_record_t *kifu )
132
132
// GetHandicaps : 置き石の個数の抽出
133
133
// GetHandicapPosition : 置き石の座標
134
134
// GetMove : 着手の抽出
135
+ // GetKomi : コミの抽出
136
+ // GetPlayerName : 対局者の名前の抽出
135
137
if (strncmp (&sgf_text[cursor], " SZ[" , 3 ) == 0 ) cursor = GetSize (kifu, sgf_text, cursor);
136
138
if (strncmp (&sgf_text[cursor], " RE[" , 3 ) == 0 ) cursor = GetResult (kifu, sgf_text, cursor);
137
139
if (strncmp (&sgf_text[cursor], " HA[" , 3 ) == 0 ) cursor = GetHandicaps (kifu, sgf_text, cursor);
@@ -169,21 +171,22 @@ ExtractKifu( const char *file_name, SGF_record_t *kifu )
169
171
// 盤の大きさの抽出 //
170
172
// /////////////////////
171
173
static int
172
- GetSize ( SGF_record_t *kifu, char *sgf_text, int cursor )
174
+ GetSize ( SGF_record_t *kifu, const char *sgf_text, const int cursor )
173
175
{
174
176
int tmp_cursor = 3 ;
175
177
char size[10 ];
176
- memset (size, 0 , sizeof (char )*10 );
178
+
179
+ memset (size, 0 , sizeof (char ) * 10 );
177
180
178
- while ((cursor+ tmp_cursor < 100000 ) && (sgf_text[cursor + tmp_cursor] != ' ]' )) tmp_cursor++;
181
+ while ((cursor + tmp_cursor < 100000 ) && (sgf_text[cursor + tmp_cursor] != ' ]' )) tmp_cursor++;
179
182
180
183
for (int i = 0 ; i < tmp_cursor - 3 ; i++) {
181
184
if (cursor + i + 3 < 100000 ){
182
185
size[i] = sgf_text[cursor + i + 3 ];
183
186
}
184
187
}
185
188
kifu->board_size = atoi (size);
186
- while ((cursor+ tmp_cursor < 100000 ) && (sgf_text[cursor + tmp_cursor] != ' ]' )) tmp_cursor++;
189
+ while ((cursor + tmp_cursor < 100000 ) && (sgf_text[cursor + tmp_cursor] != ' ]' )) tmp_cursor++;
187
190
return cursor + tmp_cursor;
188
191
}
189
192
@@ -192,10 +195,12 @@ GetSize( SGF_record_t *kifu, char *sgf_text, int cursor )
192
195
// 結果の抽出 //
193
196
// ///////////////
194
197
static int
195
- GetResult ( SGF_record_t *kifu, char *sgf_text, int cursor )
198
+ GetResult ( SGF_record_t *kifu, const char *sgf_text, const int cursor )
196
199
{
197
200
int tmp_cursor = 3 ;
198
- while ((cursor+tmp_cursor < 100000 ) && (sgf_text[cursor + tmp_cursor] != ' ]' )) tmp_cursor++;
201
+
202
+ while ((cursor + tmp_cursor < 100000 ) && (sgf_text[cursor + tmp_cursor] != ' ]' )) tmp_cursor++;
203
+
199
204
if (cursor + 3 < 100000 ){
200
205
switch (sgf_text[cursor + 3 ]) {
201
206
case ' B' :
@@ -212,7 +217,7 @@ GetResult( SGF_record_t *kifu, char *sgf_text, int cursor )
212
217
break ;
213
218
}
214
219
}
215
- while ((cursor+ tmp_cursor < 100000 ) && (sgf_text[cursor + tmp_cursor] != ' ]' )) tmp_cursor++;
220
+ while ((cursor + tmp_cursor < 100000 ) && (sgf_text[cursor + tmp_cursor] != ' ]' )) tmp_cursor++;
216
221
return cursor + tmp_cursor;
217
222
}
218
223
@@ -221,9 +226,10 @@ GetResult( SGF_record_t *kifu, char *sgf_text, int cursor )
221
226
// 着手の抽出 //
222
227
// ///////////////
223
228
static int
224
- GetMove ( SGF_record_t *kifu, char *sgf_text, int cursor )
229
+ GetMove ( SGF_record_t *kifu, const char *sgf_text, const int cursor )
225
230
{
226
231
int tmp_cursor = 0 ;
232
+
227
233
if (cursor + 3 < 100000 ){
228
234
if (kifu->moves == 0 ) {
229
235
if (sgf_text[cursor] == ' B' ) {
@@ -255,11 +261,12 @@ GetMove( SGF_record_t *kifu, char *sgf_text, int cursor )
255
261
// 置き石の数の抽出 //
256
262
// /////////////////////
257
263
static int
258
- GetHandicaps ( SGF_record_t *kifu, char *sgf_text, int cursor )
264
+ GetHandicaps ( SGF_record_t *kifu, const char *sgf_text, const int cursor )
259
265
{
260
266
int tmp_cursor = 3 ;
261
267
char handicaps[10 ] = {0 };
262
- while ((cursor+tmp_cursor < 100000 ) && (sgf_text[cursor + tmp_cursor] != ' ]' )) tmp_cursor++;
268
+
269
+ while ((cursor + tmp_cursor < 100000 ) && (sgf_text[cursor + tmp_cursor] != ' ]' )) tmp_cursor++;
263
270
264
271
for (int i = 0 ; i < tmp_cursor - 3 ; i++) {
265
272
if (cursor + i + 3 < 100000 ){
@@ -277,7 +284,7 @@ GetHandicaps( SGF_record_t *kifu, char *sgf_text, int cursor )
277
284
// 置き石の座標の抽出 //
278
285
// ///////////////////////
279
286
static int
280
- GetHandicapPosition ( SGF_record_t *kifu, char *sgf_text, int cursor, int color )
287
+ GetHandicapPosition ( SGF_record_t *kifu, const char *sgf_text, const int cursor, const int color )
281
288
{
282
289
int tmp_cursor = 3 ;
283
290
int handicaps = 0 ;
@@ -311,7 +318,7 @@ GetHandicapPosition( SGF_record_t *kifu, char *sgf_text, int cursor, int color )
311
318
// コミの抽出 //
312
319
// ////////////////
313
320
static int
314
- GetKomi ( SGF_record_t *kifu, char *sgf_text, int cursor )
321
+ GetKomi ( SGF_record_t *kifu, const char *sgf_text, const int cursor )
315
322
{
316
323
int tmp_cursor = 3 ;
317
324
char komi[10 ] = {0 };
@@ -335,7 +342,7 @@ GetKomi( SGF_record_t *kifu, char *sgf_text, int cursor )
335
342
// 対局名の抽出 //
336
343
// //////////////////
337
344
static int
338
- GetPlayerName ( SGF_record_t *kifu, char *sgf_text, int cursor, int color )
345
+ GetPlayerName ( SGF_record_t *kifu, const char *sgf_text, const int cursor, const int color )
339
346
{
340
347
int tmp_cursor = 0 ;
341
348
@@ -363,7 +370,7 @@ GetPlayerName( SGF_record_t *kifu, char *sgf_text, int cursor, int color )
363
370
// 無視する情報を飛ばす処理 //
364
371
// /////////////////////////////
365
372
static int
366
- SkipData ( SGF_record_t *kifu, char *sgf_text, int cursor )
373
+ SkipData ( SGF_record_t *kifu, const char *sgf_text, const int cursor )
367
374
{
368
375
int tmp_cursor = 3 ;
369
376
0 commit comments