Commit 0190a8dd authored by Vivien Kraus's avatar Vivien Kraus
Browse files

Indent the installed C programs

parent b6fac6c1
......@@ -45,18 +45,18 @@ msgid "Print version information and exit"
msgstr "Affiche l'information de version et quitte"
#: src/tarot-app/main.vala:100 src/tarot-app/main.vala:110
#: src/tarot-app/tarot_deal.c:66 src/tarot-app/tarot_mcts.c:89
#: src/tarot-app/tarot_stacking.c:81 src/tarot-app/tarot_features.c:61
#: src/tarot-app/tarot_deal.c:70 src/tarot-app/tarot_mcts.c:88
#: src/tarot-app/tarot_stacking.c:80 src/tarot-app/tarot_features.c:62
#: src/tarot-app/tarot_cnn_features.c:58
#: src/tarot-app/tarot_perceptron_bootstrap.c:60
msgid "version"
msgstr "version"
#: src/tarot-app/main.vala:117 src/tarot-app/tarot_status.c:57
#: src/tarot-app/tarot_deal.c:106 src/tarot-app/tarot_mcts.c:135
#: src/tarot-app/tarot_stacking.c:111 src/tarot-app/tarot_features.c:90
#: src/tarot-app/tarot_cnn_features.c:86
#: src/tarot-app/tarot_perceptron_bootstrap.c:94
#: src/tarot-app/tarot_deal.c:112 src/tarot-app/tarot_mcts.c:136
#: src/tarot-app/tarot_stacking.c:112 src/tarot-app/tarot_features.c:93
#: src/tarot-app/tarot_cnn_features.c:89
#: src/tarot-app/tarot_perceptron_bootstrap.c:97
#, c-format
msgid ""
"%s (libtarot %s)\n"
......@@ -1155,16 +1155,16 @@ msgstr ""
msgid "--version"
msgstr "--version"
#: src/tarot-app/tarot_status.c:65
#: src/tarot-app/tarot_status.c:63
msgid "next"
msgstr "suivant"
#: src/tarot-app/tarot_status.c:76
#: src/tarot-app/tarot_status.c:75
#, c-format
msgid "Error: all players have played in this game.\n"
msgstr "Erreur : tous les joueurs ont joué dans cette partie.\n"
#: src/tarot-app/tarot_status.c:81
#: src/tarot-app/tarot_status.c:80
msgid "at-end"
msgstr "fini"
......@@ -1172,28 +1172,28 @@ msgstr "fini"
msgid "score"
msgstr "score"
#: src/tarot-app/tarot_status.c:99 src/tarot-app/tarot_features.c:42
#: src/tarot-app/tarot_status.c:100 src/tarot-app/tarot_features.c:44
#, c-format
msgid "Error: this game is not finished yet.\n"
msgstr "ERREUR : cette partie n'est pas terminée.\n"
#: src/tarot-app/tarot_status.c:110
#: src/tarot-app/tarot_status.c:111
msgid "errors"
msgstr "erreurs"
#: src/tarot-app/tarot_status.c:117
#: src/tarot-app/tarot_status.c:118
#, c-format
msgid "Error: unknown command '%s'.\n"
msgstr "Erreur : commande inconnue « %s ».\n"
#: src/tarot-app/tarot_deal.c:41
#: src/tarot-app/tarot_deal.c:44
#, c-format
msgid "Error: could not set the game up for %lu players (call: %d)\n"
msgstr ""
"Erreur : impossible de mettre en place la partie pour %lu joueurs (appel : "
"%d)\n"
#: src/tarot-app/tarot_deal.c:47
#: src/tarot-app/tarot_deal.c:52
#, c-format
msgid ""
"Error: could not use this random seed, '%s', to deal. Please retry with a "
......@@ -1202,31 +1202,31 @@ msgstr ""
"Erreur : impossible d'utiliser cette graine aléatoire, « %s », pour la\n"
"distribution. Veuillez réessayer avec une graine différente.\n"
#: src/tarot-app/tarot_deal.c:65 src/tarot-app/tarot_mcts.c:88
#: src/tarot-app/tarot_stacking.c:80 src/tarot-app/tarot_features.c:60
#: src/tarot-app/tarot_deal.c:69 src/tarot-app/tarot_mcts.c:87
#: src/tarot-app/tarot_stacking.c:79 src/tarot-app/tarot_features.c:61
#: src/tarot-app/tarot_cnn_features.c:57
#: src/tarot-app/tarot_perceptron_bootstrap.c:59
msgid "help"
msgstr "aide"
#: src/tarot-app/tarot_deal.c:67
#: src/tarot-app/tarot_deal.c:71
msgid "n-players"
msgstr "n-joueurs"
#: src/tarot-app/tarot_deal.c:68
#: src/tarot-app/tarot_deal.c:72
msgid "call-allowed"
msgstr "appel-autorisé"
#: src/tarot-app/tarot_deal.c:69
#: src/tarot-app/tarot_deal.c:73
msgid "no-call-allowed"
msgstr "appel-interdit"
#: src/tarot-app/tarot_deal.c:70 src/tarot-app/tarot_mcts.c:91
#: src/tarot-app/tarot_deal.c:74 src/tarot-app/tarot_mcts.c:90
#: src/tarot-app/tarot_perceptron_bootstrap.c:63
msgid "seed"
msgstr "graine"
#: src/tarot-app/tarot_deal.c:88
#: src/tarot-app/tarot_deal.c:94
#, c-format
msgid ""
"Usage: tarot-deal [OPTIONS]...\n"
......@@ -1260,12 +1260,12 @@ msgstr ""
"Donc en cas d'échec vous voudrez probablement réessayer avec quelques\n"
"autres graines.\n"
#: src/tarot-app/tarot_deal.c:118
#: src/tarot-app/tarot_deal.c:124
#, c-format
msgid "Error: the number of players should be a number, not '%s'.\n"
msgstr "Erreur : le nombre de joueurs doit être un nombre, et pas « %s ».\n"
#: src/tarot-app/tarot_deal.c:124
#: src/tarot-app/tarot_deal.c:132
#, c-format
msgid ""
"Error: the number of players (%lu) has an unexpected suffix, '%s': '%s'.\n"
......@@ -1273,7 +1273,7 @@ msgstr ""
"Erreur : le nombre de joueurs (%lu) a un suffixe inattendu, « %s » : "
"« %s ».\n"
#: src/tarot-app/tarot_deal.c:138 src/tarot-app/tarot_mcts.c:163
#: src/tarot-app/tarot_deal.c:148 src/tarot-app/tarot_mcts.c:168
#, c-format
msgid ""
"Error: the seed must not be empty. The default is usually \"default\".\n"
......@@ -1281,16 +1281,16 @@ msgstr ""
"Erreur : la graine ne doit pas être vide. La valeur par défaut est\n"
"habituellement « default ».\n"
#: src/tarot-app/tarot_deal.c:154 src/tarot-app/tarot_mcts.c:199
#: src/tarot-app/tarot_stacking.c:134 src/tarot-app/tarot_features.c:113
#: src/tarot-app/tarot_cnn_features.c:105
#: src/tarot-app/tarot_deal.c:164 src/tarot-app/tarot_mcts.c:208
#: src/tarot-app/tarot_stacking.c:133 src/tarot-app/tarot_features.c:114
#: src/tarot-app/tarot_cnn_features.c:106
#, c-format
msgid "Error: extra arguments:\n"
msgstr "Erreur : arguments supplémentaires :\n"
#: src/tarot-app/tarot_deal.c:156 src/tarot-app/tarot_mcts.c:201
#: src/tarot-app/tarot_stacking.c:136 src/tarot-app/tarot_features.c:115
#: src/tarot-app/tarot_cnn_features.c:107
#: src/tarot-app/tarot_deal.c:166 src/tarot-app/tarot_mcts.c:210
#: src/tarot-app/tarot_stacking.c:135 src/tarot-app/tarot_features.c:116
#: src/tarot-app/tarot_cnn_features.c:108
#, c-format
msgid "- %s\n"
msgstr "- %s\n"
......@@ -1300,47 +1300,47 @@ msgstr "- %s\n"
msgid "Error: invalid game.\n"
msgstr "Erreur : partie invalide.\n"
#: src/tarot-app/program_commons.c:281
#: src/tarot-app/program_commons.c:292
msgid "GiB"
msgstr "GiB"
#: src/tarot-app/program_commons.c:287
#: src/tarot-app/program_commons.c:298
msgid "MiB"
msgstr "MiB"
#: src/tarot-app/program_commons.c:293
#: src/tarot-app/program_commons.c:304
msgid "KiB"
msgstr "KiB"
#: src/tarot-app/program_commons.c:299
#: src/tarot-app/program_commons.c:310
msgid "B"
msgstr "B"
#: src/tarot-app/tarot_mcts.c:90
#: src/tarot-app/tarot_mcts.c:89
msgid "max-memory"
msgstr "mémoire-max"
#: src/tarot-app/tarot_mcts.c:92
#: src/tarot-app/tarot_mcts.c:91
msgid "n-iterations"
msgstr "n-itérations"
#: src/tarot-app/tarot_mcts.c:93
#: src/tarot-app/tarot_mcts.c:92
msgid "mcts-parameter"
msgstr "mcts-paramètre"
#: src/tarot-app/tarot_mcts.c:94
#: src/tarot-app/tarot_mcts.c:93
msgid "parameter-random"
msgstr "paramètre-aléatoire"
#: src/tarot-app/tarot_mcts.c:95
#: src/tarot-app/tarot_mcts.c:94
msgid "parameter-agreed"
msgstr "paramètre-accord"
#: src/tarot-app/tarot_mcts.c:96 src/tarot-app/tarot_stacking.c:82
#: src/tarot-app/tarot_mcts.c:95 src/tarot-app/tarot_stacking.c:81
msgid "generate"
msgstr "générer"
#: src/tarot-app/tarot_mcts.c:114
#: src/tarot-app/tarot_mcts.c:115
#, c-format
msgid ""
"Usage: tarot-mcts [OPTIONS]... < GAME\n"
......@@ -1378,14 +1378,14 @@ msgstr ""
"Si le nombre d'itérations est trop bas, ou si l'algorithme a\n"
"extrêmement peu de chance, alors l'opération peut échouer.\n"
#: src/tarot-app/tarot_mcts.c:147
#: src/tarot-app/tarot_mcts.c:148
#, c-format
msgid "Error: the memory limit should be a size in bytes, not '%s'.\n"
msgstr ""
"Erreur : la limite de mémoire doit être une taille en octets, et pas "
"« %s ».\n"
#: src/tarot-app/tarot_mcts.c:153
#: src/tarot-app/tarot_mcts.c:156
#, c-format
msgid ""
"Error: the memory limit (%lu bytes) has an unexpected suffix, '%s': '%s'.\n"
......@@ -1393,12 +1393,12 @@ msgstr ""
"Erreur : la limite de mémoire (%lu) a un suffixe inattendu, « %s » : "
"« %s ».\n"
#: src/tarot-app/tarot_mcts.c:172
#: src/tarot-app/tarot_mcts.c:179
#, c-format
msgid "Error: the number of iterations should be a number, not '%s'.\n"
msgstr "Erreur : le nombre d'itérations doit être un nombre, et pas « %s ».\n"
#: src/tarot-app/tarot_mcts.c:178
#: src/tarot-app/tarot_mcts.c:187
#, c-format
msgid ""
"Error: the number of iterations (%lu) has an unexpected suffix, '%s': '%s'.\n"
......@@ -1406,30 +1406,30 @@ msgstr ""
"Erreur : le nombre d'itérations (%lu) a un suffixe inattendu, « %s » : "
"« %s ».\n"
#: src/tarot-app/tarot_mcts.c:212
#: src/tarot-app/tarot_mcts.c:221
#, c-format
msgid "Error: no player needs to play in this game.\n"
msgstr "Erreur : aucun joueur ne peut jouer dans cette partie.\n"
#: src/tarot-app/tarot_mcts.c:215
#: src/tarot-app/tarot_mcts.c:225
#, c-format
msgid "Error: we don't know the cards of the next player.\n"
msgstr "Erreur : on ne connaît pas les cartes du prochain joueur.\n"
#: src/tarot-app/tarot_mcts.c:218
#: src/tarot-app/tarot_mcts.c:230
#, c-format
msgid "Error: too few experiments. Please use more iterations.\n"
msgstr ""
"Erreur : pas assez d'expériences. Veuillez utiliser plus d'itérations.\n"
#: src/tarot-app/tarot_mcts.c:221
#: src/tarot-app/tarot_mcts.c:235
#, c-format
msgid "Error: memory exceeded. Please pass --max-memory=SIZE.\n"
msgstr ""
"Erreur : la capacité de mémoire est épuisée. Veuillez passer --mémoire-"
"max=TAILLE.\n"
#: src/tarot-app/tarot_stacking.c:100
#: src/tarot-app/tarot_stacking.c:101
#, c-format
msgid ""
"Usage: tarot-stacking [OPTIONS]... < GAME\n"
......@@ -1446,11 +1446,11 @@ msgstr ""
"- -g, --générer : joue avec les mêmes paramètres jusqu'à la fin de la\n"
" partie.\n"
#: src/tarot-app/tarot_features.c:62
#: src/tarot-app/tarot_features.c:63
msgid "encoded"
msgstr "encodées"
#: src/tarot-app/tarot_features.c:80
#: src/tarot-app/tarot_features.c:83
#, c-format
msgid ""
"Usage: tarot-features [OPTIONS]... < GAME > FEATURES\n"
......@@ -1466,7 +1466,7 @@ msgstr ""
"- -e, --encodées : utilise un encodage one-hot pour les\n"
" caractéristiques catégorielles.\n"
#: src/tarot-app/tarot_cnn_features.c:76
#: src/tarot-app/tarot_cnn_features.c:79
#, c-format
msgid ""
"Usage: tarot-cnn-features [OPTIONS]... < GAME > FEATURES\n"
......@@ -1581,7 +1581,7 @@ msgstr "taux-d-apprentissage"
msgid "exploration"
msgstr "exploration"
#: src/tarot-app/tarot_perceptron_bootstrap.c:81
#: src/tarot-app/tarot_perceptron_bootstrap.c:84
#, c-format
msgid ""
"Usage: tarot-perceptron-bootstrap [OPTIONS]... [HIDDEN_SIZE]...\n"
......@@ -1602,14 +1602,14 @@ msgstr ""
"- -s GRAINE, --seed=GRAINE : définit la graine aléatoire. GRAINE ne\n"
" peut pas être une chaîne vide.\n"
#: src/tarot-app/tarot_perceptron_bootstrap.c:108
#: src/tarot-app/tarot_perceptron_bootstrap.c:109
#, c-format
msgid "Error: the learning rate should be a positive number, not '%s'.\n"
msgstr ""
"Erreur : le taux d'apprentissage doit être un nombre positif, et pas "
"« %s ».\n"
#: src/tarot-app/tarot_perceptron_bootstrap.c:120
#: src/tarot-app/tarot_perceptron_bootstrap.c:121
#, c-format
msgid ""
"Error: the exploration probability should be a probability (between 0 and "
......@@ -1618,12 +1618,12 @@ msgstr ""
"Erreur : la probabilité d'exploration doit être une probabilité (entre\n"
"0 et 1), et pas « %s ».\n"
#: src/tarot-app/tarot_perceptron_bootstrap.c:131
#: src/tarot-app/tarot_perceptron_bootstrap.c:132
#, c-format
msgid "Error: the seed must not be empty.\n"
msgstr "Erreur : la graine ne doit pas être vide.\n"
#: src/tarot-app/tarot_perceptron_bootstrap.c:158
#: src/tarot-app/tarot_perceptron_bootstrap.c:161
#, c-format
msgid ""
"Error: the %d-th dimension should be a strictly positive integer, not '%s'.\n"
......
......@@ -28,7 +28,7 @@ tarot_program_read_game (void)
free (input);
return ret;
}
fprintf (stderr, _ ("Error: invalid game.\n"));
fprintf (stderr, _("Error: invalid game.\n"));
tarot_game_free (ret);
exit (1);
}
......@@ -42,7 +42,7 @@ tarot_program_setup (void)
tarot_set_datadir (DATADIR);
if (tarot_init (LOCALEDIR) != 0)
{
fprintf (stderr, _ ("ERROR: could not initialize libtarot.\n"));
fprintf (stderr, _("ERROR: could not initialize libtarot.\n"));
}
}
......@@ -71,8 +71,9 @@ tarot_strtosz (const char *str, char **end)
}
void
tarot_program_iterate (const TarotGame *game,
void (*event_handler) (const TarotGame *, TarotPlayer, const TarotGameEvent *))
tarot_program_iterate (const TarotGame * game,
void (*event_handler) (const TarotGame *, TarotPlayer,
const TarotGameEvent *))
{
TarotGame *rebuilt[5] = { NULL, NULL, NULL, NULL, NULL };
size_t n_players = tarot_game_n_players (game);
......@@ -89,105 +90,115 @@ tarot_program_iterate (const TarotGame *game,
TarotPlayer next;
int has_next = 0;
for (player = 0; player < n_players; player++)
{
if (rebuilt[player] != NULL)
{
has_next = (tarot_game_get_next (rebuilt[player], &next) == TAROT_GAME_OK);
}
}
{
if (rebuilt[player] != NULL)
{
has_next =
(tarot_game_get_next (rebuilt[player], &next) ==
TAROT_GAME_OK);
}
}
switch (tarot_game_event_type (event))
{
case TAROT_DEAL_EVENT:
case TAROT_DEAL_ALL_EVENT:
for (player = 0; player < n_players; player++)
{
TarotCard hand[78];
size_t n_hand;
TarotGameEvent *deal_local;
if (tarot_game_get_deal_of (game, player, &n_hand, 0, 78, hand) != TAROT_GAME_OK)
{
/* We will not call event_handler on this player's
* decisions */
tarot_game_free (rebuilt[player]);
rebuilt[player] = NULL;
}
else
{
assert (n_hand < sizeof (hand) / sizeof (hand[0]));
deal_local = tarot_game_event_alloc_deal (player, n_hand, hand);
if (tarot_game_add_event (rebuilt[player], deal_local) != TAROT_GAME_OK)
{
assert (0);
}
tarot_game_event_free (deal_local);
}
}
break;
case TAROT_DISCARD_EVENT:
if (1)
{
size_t n_full;
size_t n_part;
TarotCard full[78];
TarotCard part[78];
static const size_t max_full = sizeof (full) / sizeof (full[0]);
static const size_t max_part = sizeof (part) / sizeof (part[0]);
TarotPlayer taker;
TarotGameEvent *e_full;
TarotGameEvent *e_part;
tarot_game_get_taker (game, &taker);
if ((tarot_game_get_full_discard (game, &n_full, 0, max_full, full)
!= TAROT_GAME_OK)
|| (tarot_game_get_public_discard (game, &n_part, 0, max_part, part)
!= TAROT_GAME_OK))
{
/* We're iterating over the events of game, and the
* current event is a discard. So game has a
* discard. */
assert (0);
}
assert (n_full <= max_full);
assert (n_part <= max_part);
e_full = tarot_game_event_alloc_discard (n_full, full);
e_part = tarot_game_event_alloc_discard (n_part, part);
assert (has_next);
assert (next == taker);
event_handler (rebuilt[taker], taker, e_full);
for (player = 0; player < n_players; player++)
{
if (rebuilt[player] != NULL && player == taker)
{
if (tarot_game_add_event (rebuilt[player], e_full) != TAROT_GAME_OK)
{
assert (0);
}
}
else if (rebuilt[player] != NULL)
{
if (tarot_game_add_event (rebuilt[player], e_part) != TAROT_GAME_OK)
{
assert (0);
}
}
}
tarot_game_event_free (e_full);
tarot_game_event_free (e_part);
}
break;
default:
if (has_next && rebuilt[next] != NULL)
{
event_handler (rebuilt[next], next, event);
}
for (player = 0; player < n_players; player++)
{
if (rebuilt[player] != NULL && tarot_game_add_event (rebuilt[player], event) != TAROT_GAME_OK)
{
assert (0);
}
}
break;
}
{
case TAROT_DEAL_EVENT:
case TAROT_DEAL_ALL_EVENT:
for (player = 0; player < n_players; player++)
{
TarotCard hand[78];
size_t n_hand;
TarotGameEvent *deal_local;
if (tarot_game_get_deal_of (game, player, &n_hand, 0, 78, hand)
!= TAROT_GAME_OK)
{
/* We will not call event_handler on this player's
* decisions */
tarot_game_free (rebuilt[player]);
rebuilt[player] = NULL;
}
else
{
assert (n_hand < sizeof (hand) / sizeof (hand[0]));
deal_local =
tarot_game_event_alloc_deal (player, n_hand, hand);
if (tarot_game_add_event (rebuilt[player], deal_local) !=
TAROT_GAME_OK)
{
assert (0);
}
tarot_game_event_free (deal_local);
}
}
break;
case TAROT_DISCARD_EVENT:
if (1)
{
size_t n_full;
size_t n_part;
TarotCard full[78];
TarotCard part[78];
static const size_t max_full = sizeof (full) / sizeof (full[0]);
static const size_t max_part = sizeof (part) / sizeof (part[0]);
TarotPlayer taker;
TarotGameEvent *e_full;
TarotGameEvent *e_part;
tarot_game_get_taker (game, &taker);
if ((tarot_game_get_full_discard
(game, &n_full, 0, max_full, full) != TAROT_GAME_OK)
||
(tarot_game_get_public_discard
(game, &n_part, 0, max_part, part) != TAROT_GAME_OK))
{
/* We're iterating over the events of game, and the
* current event is a discard. So game has a
* discard. */
assert (0);
}
assert (n_full <= max_full);
assert (n_part <= max_part);
e_full = tarot_game_event_alloc_discard (n_full, full);
e_part = tarot_game_event_alloc_discard (n_part, part);
assert (has_next);
assert (next == taker);
event_handler (rebuilt[taker], taker, e_full);
for (player = 0; player < n_players; player++)
{
if (rebuilt[player] != NULL && player == taker)
{
if (tarot_game_add_event (rebuilt[player], e_full) !=
TAROT_GAME_OK)
{
assert (0);
}
}
else if (rebuilt[player] != NULL)
{
if (tarot_game_add_event (rebuilt[player], e_part) !=
TAROT_GAME_OK)
{
assert (0);
}
}
}
tarot_game_event_free (e_full);
tarot_game_event_free (e_part);
}
break;
default:
if (has_next && rebuilt[next] != NULL)
{
event_handler (rebuilt[next], next, event);
}
for (player = 0; player < n_players; player++)
{
if (rebuilt[player] != NULL
&& tarot_game_add_event (rebuilt[player],
event) != TAROT_GAME_OK)
{
assert (0);
}
}
break;
}
}
tarot_game_iterator_free (it);
for (player = 0; player < n_players; player++)
......@@ -199,9 +210,9 @@ tarot_program_iterate (const TarotGame *game,
struct buffer;
typedef struct buffer buffer;
static buffer *buffer_alloc (void);
static void buffer_free (buffer *buffer);
static void buffer_push_back (buffer *b, char c);
static char *buffer_data (buffer *b); /* NOT nul-terminated */
static void buffer_free (buffer * buffer);
static void buffer_push_back (buffer * b, char c);
static char *buffer_data (buffer * b); /* NOT nul-terminated */
static char *
read_stdin (void)
......@@ -238,14 +249,14 @@ buffer_alloc (void)
}
static void
buffer_free (buffer *buffer)
buffer_free (buffer * buffer)
{
free (buffer->data);
free (buffer);
}
static void
buffer_push_back (buffer *b, char c)
buffer_push_back (buffer * b, char c)
{
if (b->used >= b->allocated)
{
......@@ -257,7 +268,7 @@ buffer_push_back (buffer *b, char c)
}
static char *
buffer_data (buffer *b)
buffer_data (buffer * b)
{
return b->data;
}
......@@ -278,25 +289,25 @@ parse_unit (const char *str, char **end)
{
return parse_unit (my_end, end);
}
test = _ ("GiB");
test = _("GiB");
if (strncmp (my_end, test, strlen (test)) == 0)
{
*end = my_end + strlen (test);
return UNIT_GiB;
}
test = _ ("MiB");