clean code
authorLaurent Mazet <mazet@softndesign.org>
Sat, 1 Mar 2025 22:51:24 +0000 (23:51 +0100)
committerLaurent Mazet <mazet@softndesign.org>
Sat, 1 Mar 2025 22:51:24 +0000 (23:51 +0100)
function.c

index c8f73eaf888cc4e5dcf0da6ec16eddb70ea86f08..4d8769a4d04e9bcf84cd9c2e60175d454221605a 100644 (file)
@@ -133,7 +133,9 @@ board_t *initplay (board_t *board)
             }
 
             /* random position */
-            pos = (pos > 0) ? rand () % pos : 0;
+            if (pos > 0) {
+                pos = rand () % pos;
+            }
             for (j = 0; (j < board->length) && (pos >= 0); j++) {
                 if (getvalue (box, j % n, j / n) == ' ') {
                     if (pos == 0) {
@@ -144,12 +146,12 @@ board_t *initplay (board_t *board)
                 }
             }
 
-                char *buffer = (char *) calloc (board->length * (8 + board->length) + 1, 1);
-                _makecomments (buffer, box);
-                printf ("box:\n%s", buffer);
-                _makecomments (buffer, board);
-                printf ("board:\n%s", buffer);
-                free (buffer);
+            char *buffer = (char *) calloc (board->length * (8 + board->length) + 1, 1);
+            _makecomments (buffer, box);
+            printf ("box:\n%s", buffer);
+            _makecomments (buffer, board);
+            printf ("board:\n%s", buffer);
+            free (buffer);
 
             freeboard (box);
         }