chiark / gitweb /
New upstream version 1.19 upstream
authorSimon Tatham <anakin@pobox.com>
Tue, 26 Oct 2021 16:37:35 +0000 (17:37 +0100)
committerSimon Tatham <anakin@pobox.com>
Tue, 26 Oct 2021 16:37:35 +0000 (17:37 +0100)
CHANGELOG
README
colours.c
cursesdisplay.c
cursesmenudisplay.c
editor.c
graphics.c
main.c
sdldisplay.c
sdlfont.c

index 7a1b3ab269b60152d86e306288cccd886a29b456..af7499826ac53f66493e1ce31d17c56db7d360e6 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,7 @@
+1.19  (26th October 2021)
+=========================
+  * squash various compilation warnings
+
 1.18  (10th January 2021)
 =========================
   * fixed problems to allow building on Ubuntu 20.04
diff --git a/README b/README
index f8d80381ad779bdcfb2f643a2fa67cff50727df1..7d19f76f83e0b146f664daf4cfa90b9eda53a1be 100644 (file)
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-Chroma  1.18 (10th January 2021)
+Chroma  1.19 (26th October 2021)
 ================================
 Chroma is an abstract puzzle game. A variety of colourful shapes are arranged
 in a series of increasingly complex patterns, forming fiendish traps that must
index 12d6be0669884279161abe8da4d495dae44be5c1..cc5fe9ce564d14cdd19dce60b8f8e574c6a4df24 100644 (file)
--- a/colours.c
+++ b/colours.c
@@ -58,7 +58,7 @@ void colours_init()
     {   
         /* Revert to default */
         getfilename("colours", directory, 0, LOCATION_SYSTEM);
-        sprintf(filename, "%s%s%s", directory, "/", COLOURS_DEFAULT);
+        snprintf(filename, sizeof(filename), "%s%s%s", directory, "/", COLOURS_DEFAULT);
         pdisplaycolours = colours_load(filename, 0);
 
         /* If we can't even load the default, use an emergency scheme */
@@ -373,7 +373,7 @@ struct menu* colours_menu()
             if(strcmp(dentry->d_name, "..") == 0)
                 continue;
 
-            sprintf(filename, "%s%s%s", directory, "/", dentry->d_name);
+            snprintf(filename, sizeof(filename), "%s%s%s", directory, "/", dentry->d_name);
 
         if(isfile(filename) && strlen(filename) > 7 && strcmp(filename + strlen(filename) - 7, ".chroma") == 0)
         {
index 1c694ada6a793f1222afeaeda2d24cc775efe4fa..4765a73ca8972fcfda8d826bdfb9964ed21bb3f8 100644 (file)
@@ -494,7 +494,7 @@ void display_play(struct level* plevel, struct level* plevelreplay)
                             c = font_logo_colours[x] - '0';
                         else
                         {
-                            printw(buffer + x);
+                            printw("%s", buffer + x);
                             x = strlen(buffer);
                             break;
                         }
@@ -1631,7 +1631,7 @@ void display_options_load()
     options_debug = 0;
 
     getfilename("colours", filename, 0, 1);
-    sprintf(options_colours, "%s/%s", filename, COLOURS_DEFAULT);
+    snprintf(options_colours, sizeof(options_colours), "%s/%s", filename, COLOURS_DEFAULT);
 
     getfilename("curses.chroma", filename, 0, 0);
 
index fdb36eb55499e9abe5293eef704f43865334ab61..23bd27a64243bc3db79d99b917a9d1837631cea1 100644 (file)
@@ -132,7 +132,7 @@ void menu_displayentry(struct menu *pmenu, struct menuentry *pentry, int y, int
         {   
             utf8strncpy(buffer, pentry->text2, menu_width - 2);
             x = menu_offset + menu_width - 1 - utf8strlen(buffer);
-            mvprintw(y, x, buffer);
+            mvprintw(y, x, "%s", buffer);
         }
 
         /* Plot main text */
@@ -148,7 +148,7 @@ void menu_displayentry(struct menu *pmenu, struct menuentry *pentry, int y, int
 
             if(pentry->flags & MENU_BOLD)
                 attron(A_BOLD);
-            mvprintw(y, x, buffer);
+            mvprintw(y, x, "%s", buffer);
             if(pentry->flags & MENU_BOLD)
                 attroff(A_BOLD);
         }
@@ -197,7 +197,7 @@ void menu_displayentry(struct menu *pmenu, struct menuentry *pentry, int y, int
             x = menu_offset + menu_width - 1 - utf8strlen(buffer);
             if(pentry->flags & MENU_EDITING)
                 attron(COLOR_PAIR(colourpair_white));
-            mvprintw(y, x, buffer);
+            mvprintw(y, x, "%s", buffer);
             if(pentry->flags & MENU_EDITING)
                 attroff(COLOR_PAIR(colourpair_white));
         }
@@ -208,7 +208,7 @@ void menu_displayentry(struct menu *pmenu, struct menuentry *pentry, int y, int
             utf8strncpy(buffer, pentry->text3, menu_width - 2);
 
             x = menu_offset + 1;
-            mvprintw(y, x, buffer);
+            mvprintw(y, x, "%s", buffer);
         }
 
         if(selected)
@@ -357,7 +357,7 @@ void menu_display(struct menu *pmenu, int redraw)
                 if(i == 5) attron(COLOR_PAIR(colourpair_magenta));
 
                 sprintf(buffer, "%c", title[i]);
-                mvprintw(2, x, buffer);
+                mvprintw(2, x, "%s", buffer);
                 x +=2;
             }
             attroff(COLOR_PAIR(colourpair_red));
@@ -373,7 +373,7 @@ void menu_display(struct menu *pmenu, int redraw)
             if(x < 0)
             {
                 x = (display_size_x - utf8strlen(pmenu->title)) / 2;
-                mvprintw(y, x, pmenu->title);
+                mvprintw(y, x, "%s", pmenu->title);
             }
             else
             {
@@ -387,7 +387,7 @@ void menu_display(struct menu *pmenu, int redraw)
             buffer[j] = pmenu->title[i + j]; j ++;
             }
             buffer[j] = 0;
-                    mvprintw(y, x, buffer);
+                    mvprintw(y, x, "%s", buffer);
             x += 2;  i += j - 1;
                 }
             }
index 0aa81074ef868ed2c56de0fe596103c3215eb512..03c0b7c753784d608733a4e210ed61dd852d1084 100644 (file)
--- a/editor.c
+++ b/editor.c
@@ -215,7 +215,7 @@ void editor()
                     if(strcmp(filename, "") == 0)
                     {
                         /* Create new file */
-                        sprintf(filename, "%s/%x.chroma", directory, (int)time(NULL));
+                        snprintf(filename, sizeof(filename), "%s/%x.chroma", directory, (int)time(NULL));
                         level_save(plevelcurrent, filename, 1);
                     }
                     else
index be2090d4ee3c8237dfdd51f8b81d17f21e7cbc2f..ecae2a822b706fdb64d97423ee69e8d98ef3c5e4 100644 (file)
@@ -81,7 +81,7 @@ void graphics_init()
     {
         /* Revert to default */
         getfilename("graphics", directory, 0, LOCATION_SYSTEM);
-        sprintf(filename, "%s%s%s", directory, "/", GRAPHICS_DEFAULT);
+        snprintf(filename, sizeof(filename), "%s%s%s", directory, "/", GRAPHICS_DEFAULT);
         pdisplaygraphics = graphics_load(filename, 0);
 
         /* If we can't even load the default, use a curses based scheme */
@@ -383,7 +383,7 @@ struct menu* graphics_menu()
             if(strcmp(dentry->d_name, "..") == 0)
                 continue;
 
-            sprintf(filename, "%s%s%s", directory, "/", dentry->d_name);
+            snprintf(filename, sizeof(filename), "%s%s%s", directory, "/", dentry->d_name);
 
             if(isfile(filename) && strlen(filename) > 7 && strcmp(filename + strlen(filename) - 7, ".chroma") == 0)
             {
@@ -424,7 +424,8 @@ SDL_Surface *graphics_loadimage(char *filename)
     char directory[FILENAME_MAX];
 
     getfilename("graphics", directory, 0, LOCATION_SYSTEM);
-    sprintf(fullfilename, "%s%s%s", directory, "/", filename);
+    snprintf(fullfilename, sizeof(fullfilename), "%s%s%s",
+             directory, "/", filename);
 
     return IMG_Load(fullfilename);
 }
@@ -1327,9 +1328,9 @@ struct graphics* graphics_load(char *filename, int partial)
                         {
                             /* Construct pathname */
                             if(strcmp(path, "") == 0)
-                                sprintf(file, "%s/", basepath);
+                                snprintf(file, sizeof(file), "%s/", basepath);
                             else
-                                sprintf(file, "%s/%s/", basepath, path);
+                                snprintf(file, sizeof(file), "%s/%s/", basepath, path);
 
                             /* Substitute %s as necessary */
                             j = strlen(file);
diff --git a/main.c b/main.c
index c5577da16ebccfc3fe8c400722d7a74dadfdf580..2c7e058ec88f55b1ee969ec4329801d98cf643f1 100644 (file)
--- a/main.c
+++ b/main.c
@@ -269,7 +269,7 @@ void level_play(struct level* plevelgame)
                         if(menu_levelselector(directory, filename, menutitle, LEVELMENU_RETURN | LEVELMENU_NEW | LEVELMENU_DELETE | LEVELMENU_MOVES | LEVELMENU_FILTER) == MENU_SELECT)
                         {
                             if(strcmp(filename, "") == 0)
-                                sprintf(filename, "%s/%x.chroma", directory, (int)time(NULL));
+                                snprintf(filename, sizeof(filename), "%s/%x.chroma", directory, (int)time(NULL));
                             level_save(plevelgame, filename, 0);
 
                             level_delete(plevelrevert);
@@ -387,7 +387,7 @@ void help()
             buffer[i] = locale[i]; i ++;
         }
         buffer[i] = 0;
-        sprintf(filename, "%s.%s", directory, buffer);
+        snprintf(filename, sizeof(filename), "%s.%s", directory, buffer);
 
         if(menu_addfile(pmenu, filename))
             ok = 1;
@@ -402,7 +402,7 @@ void help()
             buffer[i] = locale[i]; i ++;
         }
         buffer[i] = 0;
-        sprintf(filename, "%s.%s", directory, buffer);
+        snprintf(filename, sizeof(filename), "%s.%s", directory, buffer);
 
         if(menu_addfile(pmenu, filename))
             ok = 1;
@@ -415,7 +415,7 @@ void help()
             buffer[i] = locale[i]; i ++;
         }
         buffer[i] = 0;
-        sprintf(filename, "%s.%s", directory, buffer);
+        snprintf(filename, sizeof(filename), "%s.%s", directory, buffer);
 
         if(menu_addfile(pmenu, filename))
             ok = 1;
index f95cc54d4819d9c77cf6cede84594dedb20ba322..33312b8bbcb3750a0c417ea24cc96786b2eb8394 100644 (file)
@@ -3557,9 +3557,9 @@ void display_options_load()
     options_debug = 0;
 
     getfilename("colours", filename, 0, LOCATION_SYSTEM);
-    sprintf(options_colours, "%s/%s", filename, COLOURS_DEFAULT);
+    snprintf(options_colours, sizeof(options_colours), "%s/%s", filename, COLOURS_DEFAULT);
     getfilename("graphics", filename, 0, LOCATION_SYSTEM);
-    sprintf(options_graphics, "%s/%s", filename, GRAPHICS_DEFAULT);
+    snprintf(options_graphics, sizeof(options_graphics), "%s/%s", filename, GRAPHICS_DEFAULT);
 
     getfilename("sdl.chroma", filename, 0, LOCATION_LOCAL);
 
index 5d6c0ffc60fbd15c4b44f9217359111de290f8a1..c19bc8419c657ed2e3f3fb4195e7d4c292960d6d 100644 (file)
--- a/sdlfont.c
+++ b/sdlfont.c
@@ -168,7 +168,7 @@ int font_calculate_width(char *text, int cache)
 {
     int n, x;
     FT_Glyph glyph;
-    Uint16 c;
+    Uint32 c;
     FT_UInt glyph_index;
 
     /* Determine width of text */
@@ -226,7 +226,7 @@ SDL_Surface* font_render(char *text, int foreground)
     int pass;
     Uint32 *dst;
     Uint32 colour;
-    Uint16 c;
+    Uint32 c;
     FT_UInt glyph_index;
     FT_Bitmap*  bitmap;