src/main.c

changeset 69
c8f2c280cff7
parent 55
54ea19938d57
     1.1 --- a/src/main.c	Wed Aug 29 17:31:36 2018 +0200
     1.2 +++ b/src/main.c	Tue Sep 18 15:02:08 2018 +0200
     1.3 @@ -34,6 +34,7 @@
     1.4  #include <string.h>
     1.5  #include <time.h>
     1.6  #include <getopt.h>
     1.7 +#include <locale.h>
     1.8  
     1.9  int get_settings(int argc, char **argv, Settings *settings) {
    1.10      char *valid;
    1.11 @@ -41,7 +42,7 @@
    1.12      uint8_t timeunit = 60;
    1.13      size_t len;
    1.14      
    1.15 -    for (int opt ; (opt = getopt(argc, argv, "a:bc:hp:rsS:t:v")) != -1 ;) {
    1.16 +    for (int opt ; (opt = getopt(argc, argv, "a:bc:hp:rsS:t:Uv")) != -1 ;) {
    1.17          switch (opt) {
    1.18          case 'c':
    1.19              settings->continuepgn = optarg;
    1.20 @@ -58,6 +59,9 @@
    1.21          case 'S':
    1.22              settings->analyzepgn = optarg;
    1.23              break;
    1.24 +        case 'U':
    1.25 +            settings->unicode = 0;
    1.26 +            break;
    1.27          case 't':
    1.28          case 'a':
    1.29              len = strlen(optarg);
    1.30 @@ -114,6 +118,7 @@
    1.31  "  -r            Distribute color randomly\n"
    1.32  "  -s            Single machine mode\n"
    1.33  "  -t <time>     Specifies time limit (default: no limit)\n"
    1.34 +"  -U            Disables unicode pieces\n"
    1.35  "\nNotes\n"
    1.36  "The time unit for -a is seconds and for -t minutes by default. To "
    1.37  "specify\nseconds for the -t option, use the s suffix.\n"
    1.38 @@ -151,6 +156,7 @@
    1.39      memset(&settings, 0, sizeof(Settings));
    1.40      settings.gameinfo.servercolor = WHITE;
    1.41      settings.port = "27015";
    1.42 +    settings.unicode = !!setlocale(LC_CTYPE, "C.UTF-8");
    1.43      return settings;
    1.44  }
    1.45  

mercurial