chiark / gitweb /
Since the lack of this has caused portability issues in the past:
authorSimon Tatham <anakin@pobox.com>
Sat, 13 Sep 2008 18:25:19 +0000 (18:25 +0000)
committerSimon Tatham <anakin@pobox.com>
Sat, 13 Sep 2008 18:25:19 +0000 (18:25 +0000)
add "-ansi -pedantic" to the main Unix makefile, and clean up a few
minor problems pointed out thereby.

[originally from svn r8175]

grid.c
loopy.c
mkfiles.pl
slant.c
tents.c
unfinished/slide.c

diff --git a/grid.c b/grid.c
index 75887eb7fa7235d059863f96ebf42674c9247f2f..dcc384a97513c4fe004eb3329b6a4b8c8d45a725 100644 (file)
--- a/grid.c
+++ b/grid.c
@@ -643,8 +643,14 @@ static grid_dot *grid_dot_add_new(grid *g, int x, int y)
  * Assumes g->dots has enough capacity allocated */
 static grid_dot *grid_get_dot(grid *g, tree234 *dot_list, int x, int y)
 {
-    grid_dot test = {0, NULL, NULL, x, y};
-    grid_dot *ret = find234(dot_list, &test, NULL);
+    grid_dot test, *ret;
+
+    test.order = 0;
+    test.edges = NULL;
+    test.faces = NULL;
+    test.x = x;
+    test.y = y;
+    ret = find234(dot_list, &test, NULL);
     if (ret)
         return ret;
 
diff --git a/loopy.c b/loopy.c
index b54922a6cd16df315b2a402b09484a0e96d7b534..f5a237b986ee2e7b491d4deb5ed392c162534766 100644 (file)
--- a/loopy.c
+++ b/loopy.c
@@ -179,7 +179,7 @@ enum { DIFFLIST(ENUM) DIFF_MAX };
 static char const *const diffnames[] = { DIFFLIST(TITLE) };
 static char const diffchars[] = DIFFLIST(ENCODE);
 #define DIFFCONFIG DIFFLIST(CONFIG)
-DIFFLIST(SOLVER_FN_DECL);
+DIFFLIST(SOLVER_FN_DECL)
 static int (*(solver_fns[]))(solver_state *) = { DIFFLIST(SOLVER_FN) };
 
 struct game_params {
@@ -3070,7 +3070,7 @@ static void game_redraw(drawing *dr, game_drawstate *ds, game_state *oldstate,
      * bounding-box around the line, then flag all nearby objects for redraw.
      */
     if (ds->started) {
-        const char redraw_flag = 1<<7;
+        const char redraw_flag = (char)(1<<7);
         for (i = 0; i < g->num_edges; i++) {
             /* If we're changing state, AND
              * the previous state was a coloured line */
@@ -3199,12 +3199,15 @@ static void game_redraw(drawing *dr, game_drawstate *ds, game_state *oldstate,
              * direction to create a thin rectangle. */
             int dx = (x1 > x2) ? -1 : ((x1 < x2) ? 1 : 0);
             int dy = (y1 > y2) ? -1 : ((y1 < y2) ? 1 : 0);
-            int points[] = {
-                x1 + dy, y1 - dx,
-                x1 - dy, y1 + dx,
-                x2 - dy, y2 + dx,
-                x2 + dy, y2 - dx
-            };
+            int points[8];
+           points[0] = x1 + dy;
+           points[1] = y1 - dx;
+           points[2] = x1 - dy;
+           points[3] = y1 + dx;
+           points[4] = x2 - dy;
+           points[5] = y2 + dx;
+           points[6] = x2 + dy;
+           points[7] = y2 - dx;
             draw_polygon(dr, points, 4, line_colour, line_colour);
         }
         if (ds->started) {
index 8119f6c88c001514c8016dcca2270353ef34f9c4..01f60e1810d22d4697cd58b60b7614816f05cd00 100755 (executable)
@@ -1108,7 +1108,7 @@ if (defined $makefiles{'gtk'}) {
     "# to 1.2 if it isn't found.\n".
     "GTK_CONFIG = sh -c 'pkg-config gtk+-2.0 \$\$0 2>/dev/null || gtk-config \$\$0'\n".
     "\n".
-    &splitline("CFLAGS = -O2 -Wall -Werror -g " .
+    &splitline("CFLAGS = -O2 -Wall -Werror -ansi -pedantic -g " .
               (join " ", map {"-I$dirpfx$_"} @srcdirs) .
               " `\$(GTK_CONFIG) --cflags`")."\n".
     "XLDFLAGS = `\$(GTK_CONFIG) --libs`\n".
diff --git a/slant.c b/slant.c
index 000d880dc3ae587d2bde20b6d14e66ec7fd50468..c3b9f17a9d509a34c568a028df695bd76282a4a8 100644 (file)
--- a/slant.c
+++ b/slant.c
@@ -1835,7 +1835,8 @@ static void game_compute_size(game_params *params, int tilesize,
                              int *x, int *y)
 {
     /* fool the macros */
-    struct dummy { int tilesize; } dummy = { tilesize }, *ds = &dummy;
+    struct dummy { int tilesize; } dummy, *ds = &dummy;
+    dummy.tilesize = tilesize;
 
     *x = 2 * BORDER + params->w * TILESIZE + 1;
     *y = 2 * BORDER + params->h * TILESIZE + 1;
diff --git a/tents.c b/tents.c
index bc07b4bfebfcc3e3f9408d70c177502171cb375f..bab0de7013f366087ce9cd4df9c8734092ba4cf2 100644 (file)
--- a/tents.c
+++ b/tents.c
@@ -1803,7 +1803,8 @@ static void game_compute_size(game_params *params, int tilesize,
                              int *x, int *y)
 {
     /* fool the macros */
-    struct dummy { int tilesize; } dummy = { tilesize }, *ds = &dummy;
+    struct dummy { int tilesize; } dummy, *ds = &dummy;
+    dummy.tilesize = tilesize;
 
     *x = TLBORDER + BRBORDER + TILESIZE * params->w;
     *y = TLBORDER + BRBORDER + TILESIZE * params->h;
index af8f21055005e4821f306544e8e4d1b55bcba7db..cc341b8c337e742dad598c81a63a85b0810cb8ca 100644 (file)
@@ -1597,7 +1597,8 @@ static void game_compute_size(game_params *params, int tilesize,
                              int *x, int *y)
 {
     /* fool the macros */
-    struct dummy { int tilesize; } dummy = { tilesize }, *ds = &dummy;
+    struct dummy { int tilesize; } dummy, *ds = &dummy;
+    dummy.tilesize = tilesize;
 
     *x = params->w * TILESIZE + 2*BORDER;
     *y = params->h * TILESIZE + 2*BORDER;