Subversion Repositories Games.Chess Giants

Rev

Rev 105 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 105 Rev 154
Line 62... Line 62...
62
  int i;
62
  int i;
63
  FD fd;
63
  FD fd;
64
  char file[256];
64
  char file[256];
65
 
65
 
66
  for (i = 0; i < num_paths; i++) {
66
  for (i = 0; i < num_paths; i++) {
67
    strcpy_s(file, sizeof(file), paths[i]); // Pierre-Marie Baty -- strcpy_s() instead of strcpy
-
 
68
    strcat_s(file, sizeof(file), "/"); // Pierre-Marie Baty -- strcat_s() instead of strat
-
 
69
    strcat_s(file, sizeof(file), str); // Pierre-Marie Baty -- strcat_s() instead of strcat
-
 
70
    strcat_s(file, sizeof(file), suffix); // Pierre-Marie Baty -- strcat_s() instead of strcat
67
    sprintf_s (file, sizeof (file), "%s/%s%s", paths[i], str, suffix); // Pierre-Marie Baty -- why make it simple when you can make it complicated
71
#ifndef _WIN32
68
#ifndef _WIN32
72
    fd = open(file, O_RDONLY);
69
    fd = open(file, O_RDONLY);
73
#else
70
#else
74
    fd = CreateFile(file, GENERIC_READ, FILE_SHARE_READ, NULL,
71
    fd = CreateFile(file, GENERIC_READ, FILE_SHARE_READ, NULL,
75
                          OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
72
                          OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
Line 277... Line 274...
277
    init_indices();
274
    init_indices();
278
    initialized = true;
275
    initialized = true;
279
  }
276
  }
280
 
277
 
281
  const char *p = path.c_str();
278
  const char *p = path.c_str();
282
  l = strlen(p); // Pierre-Marie Baty -- strcpy_s() instead of strcpy
279
  if (strlen(p) == 0 || !strcmp(p, "<empty>")) return;
283
  if (l == 0 || !strcmp(p, "<empty>")) return; // Pierre-Marie Baty -- strcpy_s() instead of strcpy
280
  size_t pathstring_size = strlen (p) + 1;
284
  path_string = (char *)malloc(l + 1); // Pierre-Marie Baty -- strcpy_s() instead of strcpy
281
  path_string = (char *)malloc(pathstring_size);
285
  strcpy_s(path_string, l + 1, p); // Pierre-Marie Baty -- strcpy_s() instead of strcpy
282
  strcpy_s(path_string, pathstring_size, p); // Pierre-Marie Baty -- cleanliness
286
  num_paths = 0;
283
  num_paths = 0;
287
  for (i = 0;; i++) {
284
  for (i = 0;; i++) {
288
    if (path_string[i] != SEP_CHAR)
285
    if (path_string[i] != SEP_CHAR)
289
      num_paths++;
286
      num_paths++;
290
    while (path_string[i] && path_string[i] != SEP_CHAR)
287
    while (path_string[i] && path_string[i] != SEP_CHAR)
Line 312... Line 309...
312
 
309
 
313
  for (i = 0; i < DTZ_ENTRIES; i++)
310
  for (i = 0; i < DTZ_ENTRIES; i++)
314
    DTZ_table[i].entry = NULL;
311
    DTZ_table[i].entry = NULL;
315
 
312
 
316
  for (i = 1; i < 6; i++) {
313
  for (i = 1; i < 6; i++) {
317
    sprintf_s(str, sizeof(str), "K%cvK", pchr[i]); // Pierre-Marie Baty -- sprintf_s() instead of sprintf
314
    sprintf_s(str, sizeof (str), "K%cvK", pchr[i]); // Pierre-Marie Baty -- cleanliness
318
    init_tb(str);
315
    init_tb(str);
319
  }
316
  }
320
 
317
 
321
  for (i = 1; i < 6; i++)
318
  for (i = 1; i < 6; i++)
322
    for (j = i; j < 6; j++) {
319
    for (j = i; j < 6; j++) {
323
      sprintf_s(str, sizeof (str), "K%cvK%c", pchr[i], pchr[j]); // Pierre-Marie Baty -- sprintf_s() instead of sprintf
320
      sprintf_s(str, sizeof (str), "K%cvK%c", pchr[i], pchr[j]); // Pierre-Marie Baty -- cleanliness
324
      init_tb(str);
321
      init_tb(str);
325
    }
322
    }
326
 
323
 
327
  for (i = 1; i < 6; i++)
324
  for (i = 1; i < 6; i++)
328
    for (j = i; j < 6; j++) {
325
    for (j = i; j < 6; j++) {
329
      sprintf_s(str, sizeof (str), "K%c%cvK", pchr[i], pchr[j]); // Pierre-Marie Baty -- sprintf_s() instead of sprintf
326
      sprintf_s(str, sizeof (str), "K%c%cvK", pchr[i], pchr[j]); // Pierre-Marie Baty -- cleanliness
330
      init_tb(str);
327
      init_tb(str);
331
    }
328
    }
332
 
329
 
333
  for (i = 1; i < 6; i++)
330
  for (i = 1; i < 6; i++)
334
    for (j = i; j < 6; j++)
331
    for (j = i; j < 6; j++)
335
      for (k = 1; k < 6; k++) {
332
      for (k = 1; k < 6; k++) {
336
        sprintf_s(str, sizeof (str), "K%c%cvK%c", pchr[i], pchr[j], pchr[k]); // Pierre-Marie Baty -- sprintf_s() instead of sprintf
333
        sprintf_s(str, sizeof (str), "K%c%cvK%c", pchr[i], pchr[j], pchr[k]); // Pierre-Marie Baty -- cleanliness
337
        init_tb(str);
334
        init_tb(str);
338
      }
335
      }
339
 
336
 
340
  for (i = 1; i < 6; i++)
337
  for (i = 1; i < 6; i++)
341
    for (j = i; j < 6; j++)
338
    for (j = i; j < 6; j++)
342
      for (k = j; k < 6; k++) {
339
      for (k = j; k < 6; k++) {
343
        sprintf_s(str, sizeof (str), "K%c%c%cvK", pchr[i], pchr[j], pchr[k]); // Pierre-Marie Baty -- sprintf_s() instead of sprintf
340
        sprintf_s(str, sizeof (str), "K%c%c%cvK", pchr[i], pchr[j], pchr[k]); // Pierre-Marie Baty -- cleanliness
344
        init_tb(str);
341
        init_tb(str);
345
      }
342
      }
346
 
343
 
347
  for (i = 1; i < 6; i++)
344
  for (i = 1; i < 6; i++)
348
    for (j = i; j < 6; j++)
345
    for (j = i; j < 6; j++)
349
      for (k = i; k < 6; k++)
346
      for (k = i; k < 6; k++)
350
        for (l = (i == k) ? j : k; l < 6; l++) {
347
        for (l = (i == k) ? j : k; l < 6; l++) {
351
          sprintf_s(str, sizeof (str), "K%c%cvK%c%c", pchr[i], pchr[j], pchr[k], pchr[l]); // Pierre-Marie Baty -- sprintf_s() instead of sprintf
348
          sprintf_s(str, sizeof (str), "K%c%cvK%c%c", pchr[i], pchr[j], pchr[k], pchr[l]); // Pierre-Marie Baty -- cleanliness
352
          init_tb(str);
349
          init_tb(str);
353
        }
350
        }
354
 
351
 
355
  for (i = 1; i < 6; i++)
352
  for (i = 1; i < 6; i++)
356
    for (j = i; j < 6; j++)
353
    for (j = i; j < 6; j++)
357
      for (k = j; k < 6; k++)
354
      for (k = j; k < 6; k++)
358
        for (l = 1; l < 6; l++) {
355
        for (l = 1; l < 6; l++) {
359
          sprintf_s(str, sizeof (str), "K%c%c%cvK%c", pchr[i], pchr[j], pchr[k], pchr[l]); // Pierre-Marie Baty -- sprintf_s() instead of sprintf
356
          sprintf_s(str, sizeof (str), "K%c%c%cvK%c", pchr[i], pchr[j], pchr[k], pchr[l]); // Pierre-Marie Baty -- cleanliness
360
          init_tb(str);
357
          init_tb(str);
361
        }
358
        }
362
 
359
 
363
  for (i = 1; i < 6; i++)
360
  for (i = 1; i < 6; i++)
364
    for (j = i; j < 6; j++)
361
    for (j = i; j < 6; j++)
365
      for (k = j; k < 6; k++)
362
      for (k = j; k < 6; k++)
366
        for (l = k; l < 6; l++) {
363
        for (l = k; l < 6; l++) {
367
          sprintf_s(str, sizeof (str), "K%c%c%c%cvK", pchr[i], pchr[j], pchr[k], pchr[l]); // Pierre-Marie Baty -- sprintf_s() instead of sprintf
364
          sprintf_s(str, sizeof (str), "K%c%c%c%cvK", pchr[i], pchr[j], pchr[k], pchr[l]); // Pierre-Marie Baty -- cleanliness
368
          init_tb(str);
365
          init_tb(str);
369
        }
366
        }
370
 
367
 
371
  printf("info string Found %d tablebases.\n", TBnum_piece + TBnum_pawn);
368
  printf("info string Found %d tablebases.\n", TBnum_piece + TBnum_pawn);
372
}
369
}