Clean up GCC warnings (2019-08-29 edition)

Updated most parts of the code that were throwing warnings in GCC.
This commit is contained in:
Bill Kendrick 2019-08-30 00:00:18 -07:00
parent 1f2c6c3c4e
commit 7938480174
16 changed files with 110 additions and 141 deletions

View file

@ -42,6 +42,8 @@ $Id$
(Thanks to Flavio Airundo for the idea; closes (Thanks to Flavio Airundo for the idea; closes
https://sourceforge.net/p/tuxpaint/feature-requests/188/) https://sourceforge.net/p/tuxpaint/feature-requests/188/)
* Updated most parts of the code that were throwing warnings in GCC.
* Documentation updates * Documentation updates
--------------------- ---------------------
* Mended link to MinGW/MSYS instructions at John Popplewell's website. * Mended link to MinGW/MSYS instructions at John Popplewell's website.

View file

@ -1,12 +1,12 @@
/* /*
alien.c alien.c
//
alien, Modifies the colours of the image. alien, Modifies the colours of the image.
Tux Paint - A simple drawing program for children. Tux Paint - A simple drawing program for children.
Credits: Andrew Corcoran <akanewbie@gmail.com> inspired by the Alien Map GIMP plugin Credits: Andrew Corcoran <akanewbie@gmail.com> inspired by the Alien Map GIMP plugin
Copyright (c) 2002-2007 by Bill Kendrick and others; see AUTHORS.txt Copyright (c) 2002-2019 by Bill Kendrick and others; see AUTHORS.txt
bill@newbreedsoftware.com bill@newbreedsoftware.com
http://www.tuxpaint.org/ http://www.tuxpaint.org/
@ -25,7 +25,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt) (See COPYING.txt)
Last updated: June 6, 2008 Last updated: August 29, 2019
$Id$ $Id$
*/ */
@ -168,9 +168,6 @@ static void do_alien_pixel(void *ptr, int which ATTRIBUTE_UNUSED,
// Do the effect for the full image // Do the effect for the full image
static void do_alien_full(void *ptr, SDL_Surface * canvas, SDL_Surface * last, int which) static void do_alien_full(void *ptr, SDL_Surface * canvas, SDL_Surface * last, int which)
{ {
magic_api *api = (magic_api *) ptr;
int x, y; int x, y;
for (y = 0; y < last->h; y++) for (y = 0; y < last->h; y++)

View file

@ -4,7 +4,7 @@
Calligraphy Magic Tool Plugin Calligraphy Magic Tool Plugin
Tux Paint - A simple drawing program for children. Tux Paint - A simple drawing program for children.
Copyright (c) 2002-2008 by Bill Kendrick and others; see AUTHORS.txt Copyright (c) 2002-2019 by Bill Kendrick and others; see AUTHORS.txt
bill@newbreedsoftware.com bill@newbreedsoftware.com
http://www.tuxpaint.org/ http://www.tuxpaint.org/
@ -23,7 +23,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt) (See COPYING.txt)
Last updated: July 8, 2008 Last updated: August 29, 2019
$Id$ $Id$
*/ */
@ -137,7 +137,6 @@ void calligraphy_drag(magic_api * api, int which ATTRIBUTE_UNUSED, SDL_Surface *
{ {
Point2D *curve; Point2D *curve;
int i, n_points, thick, new_thick; int i, n_points, thick, new_thick;
Uint32 colr;
SDL_Rect src, dest; SDL_Rect src, dest;
// if (SDL_GetTicks() < calligraphy_last_time + 5) // if (SDL_GetTicks() < calligraphy_last_time + 5)
@ -184,8 +183,6 @@ void calligraphy_drag(magic_api * api, int which ATTRIBUTE_UNUSED, SDL_Surface *
calligraphy_ComputeBezier(calligraphy_control_points, n_points, curve); calligraphy_ComputeBezier(calligraphy_control_points, n_points, curve);
colr = SDL_MapRGB(canvas->format, calligraphy_r, calligraphy_g, calligraphy_b);
new_thick = 40 - min((n_points /* / 2 */ ), 32); new_thick = 40 - min((n_points /* / 2 */ ), 32);
for (i = 0; i < n_points - 1; i++) for (i = 0; i < n_points - 1; i++)
@ -218,23 +215,6 @@ void calligraphy_drag(magic_api * api, int which ATTRIBUTE_UNUSED, SDL_Surface *
dest.y = y; dest.y = y;
SDL_BlitSurface(calligraphy_colored_brush, &src, canvas, &dest); SDL_BlitSurface(calligraphy_colored_brush, &src, canvas, &dest);
/* Old way; using putpixel:
SDL_LockSurface(canvas);
for (j = -(thick / 2); j < (thick / 2) + 1; j++)
{
x = curve[i].x + j;
y = curve[i].y - (j / 2); // 30 degrees
api->putpixel(canvas, x, y, colr);
api->putpixel(canvas, x + 1, y, colr);
api->putpixel(canvas, x, y + 1, colr);
api->putpixel(canvas, x + 1, y + 1, colr);
}
SDL_UnlockSurface(canvas);
*/
} }
calligraphy_old_thick = (calligraphy_old_thick + new_thick) / 2; calligraphy_old_thick = (calligraphy_old_thick + new_thick) / 2;

View file

@ -4,7 +4,7 @@
Emboss Magic Tool Plugin Emboss Magic Tool Plugin
Tux Paint - A simple drawing program for children. Tux Paint - A simple drawing program for children.
Copyright (c) 2002-2008 by Bill Kendrick and others; see AUTHORS.txt Copyright (c) 2002-2019 by Bill Kendrick and others; see AUTHORS.txt
bill@newbreedsoftware.com bill@newbreedsoftware.com
http://www.tuxpaint.org/ http://www.tuxpaint.org/
@ -23,7 +23,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt) (See COPYING.txt)
Last updated: July 8, 2008 Last updated: August 29, 2019
$Id$ $Id$
*/ */
@ -114,7 +114,7 @@ static void do_emboss(void *ptr, int which ATTRIBUTE_UNUSED, SDL_Surface * canva
magic_api *api = (magic_api *) ptr; magic_api *api = (magic_api *) ptr;
int xx, yy; int xx, yy;
Uint8 r1, g1, b1, r2, g2, b2; Uint8 r1, g1, b1, r2, g2, b2;
int r, g, b; int r;
float h, s, v; float h, s, v;
int avg1, avg2; int avg1, avg2;
@ -139,7 +139,6 @@ static void do_emboss(void *ptr, int which ATTRIBUTE_UNUSED, SDL_Surface * canva
r = 0; r = 0;
if (r > 255) if (r > 255)
r = 255; r = 255;
g = b = r;
v = (r / 255.0); v = (r / 255.0);

View file

@ -1,3 +1,9 @@
/*
* Folds the picture down from the corners.
*
* Last updated: 2019-08-29
*/
//optimized version soon :) //optimized version soon :)
//when "folding" same corner many times it gives strange results. Now it's allowed. Let me know //when "folding" same corner many times it gives strange results. Now it's allowed. Let me know
//if you think it shouldn't be. //if you think it shouldn't be.
@ -138,25 +144,29 @@ void fold_draw(magic_api * api, int which,
right_step_y = (float)(y - left_arm_y) / (float)(left_arm_x - fold_ox); right_step_y = (float)(y - left_arm_y) / (float)(left_arm_x - fold_ox);
left_step_x = (float)(x - right_arm_x) / (float)(right_arm_y - fold_oy); left_step_x = (float)(x - right_arm_x) / (float)(right_arm_y - fold_oy);
left_step_y = (float)(y - right_arm_y) / (float)(right_arm_y - fold_oy); left_step_y = (float)(y - right_arm_y) / (float)(right_arm_y - fold_oy);
left_y = (float)right_arm_y / left_arm_x * (left_arm_x - canvas->w);
right_x = (float)left_arm_x / right_arm_y * (right_arm_y - canvas->h);
for (w = 0; w < canvas->w; w += 0.5) for (w = 0; w < canvas->w; w += 0.5)
for (h = 0; h < canvas->h; h += 0.5) {
{ for (h = 0; h < canvas->h; h += 0.5)
dist_x = right_step_x * w + left_step_x * h; {
dist_y = right_step_y * w + left_step_y * h; dist_x = right_step_x * w + left_step_x * h;
api->putpixel(canvas, x - dist_x, y - dist_y, api->getpixel(temp, w, h)); dist_y = right_step_y * w + left_step_y * h;
} api->putpixel(canvas, x - dist_x, y - dist_y, api->getpixel(temp, w, h));
}
}
// Erasing the triangle. // Erasing the triangle.
// The 1 pixel in plus is a workaround for api-line not getting the end in some lines. // The 1 pixel in plus is a workaround for api-line not getting the end in some lines.
if (left_arm_x > canvas->w) if (left_arm_x > canvas->w)
{ {
left_y = (float)right_arm_y / left_arm_x * (left_arm_x - canvas->w);
for (h = 0; h <= right_arm_y; h++) for (h = 0; h <= right_arm_y; h++)
api->line((void *)api, which, canvas, snapshot, canvas->w, left_y - h, -1, right_arm_y - h, 1, fold_erase); api->line((void *)api, which, canvas, snapshot, canvas->w, left_y - h, -1, right_arm_y - h, 1, fold_erase);
} }
else if (right_arm_y > canvas->h) else if (right_arm_y > canvas->h)
{ {
right_x = (float)left_arm_x / right_arm_y * (right_arm_y - canvas->h);
for (w = 0; w <= left_arm_x; w++) for (w = 0; w <= left_arm_x; w++)
api->line((void *)api, which, canvas, snapshot, left_arm_x - w, 0, right_x - w, canvas->h + 1, 1, fold_erase); api->line((void *)api, which, canvas, snapshot, left_arm_x - w, 0, right_x - w, canvas->h + 1, 1, fold_erase);
} }

View file

@ -1,3 +1,9 @@
/*
* Draws fretwork
*
* Last updated: 2019-08-29
*/
#include "tp_magic_api.h" #include "tp_magic_api.h"
#include "SDL_image.h" #include "SDL_image.h"
#include "SDL_mixer.h" #include "SDL_mixer.h"
@ -25,7 +31,7 @@
Mix_Chunk *fretwork_snd; Mix_Chunk *fretwork_snd;
unsigned int img_w, img_h; unsigned int img_w, img_h;
unsigned int fretwork_segments_x, fretwork_segments_y; //how many segments do we have? unsigned int fretwork_segments_x, fretwork_segments_y; //how many segments do we have?
static int fretwork_math_ceil(int x, int y); //ceil() in cstdlib returns float and is relative slow, so we'll use our one inline int fretwork_math_ceil(int x, int y); //ceil() in cstdlib returns float and is relative slow, so we'll use our one
static Uint8 *fretwork_status_of_segments; //a place to store an info about bitmap used for selected segment static Uint8 *fretwork_status_of_segments; //a place to store an info about bitmap used for selected segment
static char **fretwork_images; //the pathes to all the images needed static char **fretwork_images; //the pathes to all the images needed
static unsigned int fretwork_segment_modified; //which segment was modified this time? static unsigned int fretwork_segment_modified; //which segment was modified this time?
@ -239,7 +245,7 @@ void fretwork_switchout(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UN
// Interactivity functions // Interactivity functions
static int fretwork_math_ceil(int x, int y) inline int fretwork_math_ceil(int x, int y)
{ {
int temp; int temp;

View file

@ -8,7 +8,7 @@
Credits: Andrew Corcoran <akanewbie@gmail.com> Credits: Andrew Corcoran <akanewbie@gmail.com>
Copyright (c) 2002-2009 by Bill Kendrick and others; see AUTHORS.txt Copyright (c) 2002-2019 by Bill Kendrick and others; see AUTHORS.txt
bill@newbreedsoftware.com bill@newbreedsoftware.com
http://www.tuxpaint.org/ http://www.tuxpaint.org/
@ -27,7 +27,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt) (See COPYING.txt)
Last updated: May 6, 2009 Last updated: August 29, 2019
$Id$ $Id$
*/ */
@ -86,9 +86,11 @@ void perspective_line(void *ptr_to_api, int which, SDL_Surface * canvas, SDL_Sur
/* Unused?
static const int perspective_AMOUNT = 300; static const int perspective_AMOUNT = 300;
static const int perspective_RADIUS = 16; static const int perspective_RADIUS = 16;
static const double perspective_SHARPEN = 1.0; static const double perspective_SHARPEN = 1.0;
*/
Uint8 perspective_r, perspective_g, perspective_b; Uint8 perspective_r, perspective_g, perspective_b;
int corner; int corner;
int dash; int dash;
@ -396,12 +398,10 @@ void perspective_release(magic_api * api, int which,
} }
else else
{ {
int aux_x, aux_y, aux_h, aux_w; int aux_h, aux_w;
aux_h = canvas->h * canvas->h / new_h; aux_h = canvas->h * canvas->h / new_h;
aux_w = canvas->w * aux_h / canvas->h; aux_w = canvas->w * aux_h / canvas->h;
aux_x = canvas->w / 2 - aux_w / 2;
aux_y = canvas->h / 2 - aux_h / 2;
update_rect->x = canvas->w / 2 - aux_w / 2; update_rect->x = canvas->w / 2 - aux_w / 2;
update_rect->y = canvas->h / 2 - aux_h / 2; update_rect->y = canvas->h / 2 - aux_h / 2;

View file

@ -24,7 +24,7 @@
Mix_Chunk *rails_snd; Mix_Chunk *rails_snd;
unsigned int img_w, img_h; unsigned int img_w, img_h;
unsigned int rails_segments_x, rails_segments_y; //how many segments do we have? unsigned int rails_segments_x, rails_segments_y; //how many segments do we have?
static int rails_math_ceil(int x, int y); //ceil() in cstdlib returns float and is relative slow, so we'll use our one inline int rails_math_ceil(int x, int y); //ceil() in cstdlib returns float and is relative slow, so we'll use our one
static Uint8 *rails_status_of_segments; //a place to store an info about bitmap used for selected segment static Uint8 *rails_status_of_segments; //a place to store an info about bitmap used for selected segment
static char **rails_images; //the pathes to all the images needed static char **rails_images; //the pathes to all the images needed
static unsigned int rails_segment_modified; //which segment was modified this time? static unsigned int rails_segment_modified; //which segment was modified this time?
@ -51,7 +51,6 @@ void rails_release(magic_api * api, int which,
void rails_shutdown(magic_api * api); void rails_shutdown(magic_api * api);
void rails_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); void rails_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
void rails_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); void rails_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
static int rails_math_ceil(int x, int y);
inline unsigned int rails_get_segment(int x, int y); inline unsigned int rails_get_segment(int x, int y);
inline void rails_extract_coords_from_segment(unsigned int segment, Sint16 * x, Sint16 * y); inline void rails_extract_coords_from_segment(unsigned int segment, Sint16 * x, Sint16 * y);
static void rails_flip(void *ptr, SDL_Surface * dest, SDL_Surface * src); static void rails_flip(void *ptr, SDL_Surface * dest, SDL_Surface * src);
@ -193,7 +192,7 @@ void rails_switchout(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSE
// Interactivity functions // Interactivity functions
static int rails_math_ceil(int x, int y) inline int rails_math_ceil(int x, int y)
{ {
int temp; int temp;

View file

@ -1,3 +1,8 @@
/*
* Strings -- draws string art.
*
* Last modified: 2019-08-29
*/
#include "tp_magic_api.h" #include "tp_magic_api.h"
#include "SDL_image.h" #include "SDL_image.h"
#include "SDL_mixer.h" #include "SDL_mixer.h"
@ -353,20 +358,9 @@ void string_draw_triangle_preview(magic_api * api, int which,
SDL_Rect * update_rect) SDL_Rect * update_rect)
{ {
int middle_x, middle_y; int middle_x, middle_y;
int w, h;
scale_coords(&ox, &oy, &x, &y); scale_coords(&ox, &oy, &x, &y);
w = max(string_ox, x) - min(string_ox, x);
h = max(string_oy, y) - min(string_oy, y);
/*
This is enouth if you move the mouse slowly, but if you move the mouse fast,
there are rests of old previews left around.
update_rect->w=max(max(string_ox,x),max(ox,x))-min(min(string_ox,x),min(ox,x)) +80;
update_rect->h=max(max(string_oy,y),max(oy,y))-min(min(string_oy,y),min(oy,y)) +80;
update_rect->x=min(string_ox,x) -40;
update_rect->y=min(string_oy,y) -40;
*/
update_rect->x = 0; update_rect->x = 0;
update_rect->y = 0; update_rect->y = 0;
update_rect->w = canvas->w; update_rect->w = canvas->w;
@ -387,13 +381,9 @@ void string_draw_angle_preview(magic_api * api, int which,
int ox, __attribute__ ((unused)) int ox, __attribute__ ((unused))
int oy, int x, int y, SDL_Rect * update_rect) int oy, int x, int y, SDL_Rect * update_rect)
{ {
int w, h;
int middle_x, middle_y; int middle_x, middle_y;
int dx, dy; int dx, dy;
w = max(string_ox, x) - min(string_ox, x);
h = max(string_oy, y) - min(string_oy, y);
update_rect->x = 0; update_rect->x = 0;
update_rect->y = 0; update_rect->y = 0;
update_rect->w = canvas->w; update_rect->w = canvas->w;

View file

@ -4,7 +4,7 @@
For Tux Paint For Tux Paint
Language-related functions Language-related functions
Copyright (c) 2002-2014 by Bill Kendrick and others Copyright (c) 2002-2019 by Bill Kendrick and others
bill@newbreedsoftware.com bill@newbreedsoftware.com
http://www.tuxpaint.org/ http://www.tuxpaint.org/
@ -25,7 +25,7 @@
$Id$ $Id$
June 14, 2002 - December 11, 2016 June 14, 2002 - August 29, 2019
*/ */
#include <stdio.h> #include <stdio.h>
@ -986,7 +986,6 @@ static int set_current_language(const char *restrict locale_choice) MUST_CHECK;
static int set_current_language(const char *restrict loc) static int set_current_language(const char *restrict loc)
{ {
int i; int i;
int y_nudge = 0;
char *oldloc; char *oldloc;
char *env_language; char *env_language;
@ -1104,7 +1103,6 @@ static int set_current_language(const char *restrict loc)
if (lang_y_nudge[i][0] == langint) if (lang_y_nudge[i][0] == langint)
{ {
wished_langs[j].lang_y_nudge = lang_y_nudge[i][1]; wished_langs[j].lang_y_nudge = lang_y_nudge[i][1];
//printf("y_nudge = %d\n", y_nudge);
break; break;
} }
} }
@ -1130,18 +1128,6 @@ static int set_current_language(const char *restrict loc)
need_right_to_left = wished_langs[0].need_right_to_left; need_right_to_left = wished_langs[0].need_right_to_left;
need_right_to_left_word = wished_langs[0].need_right_to_left_word; need_right_to_left_word = wished_langs[0].need_right_to_left_word;
#if 0
for (i = 0; lang_y_nudge[i][0] != -1; i++)
{
// printf("lang_y_nudge[%d][0] = %d\n", i, lang_y_nudge[i][0]);
if (lang_y_nudge[i][0] == langint)
{
y_nudge = lang_y_nudge[i][1];
//printf("y_nudge = %d\n", y_nudge);
break;
}
}
#endif
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "DEBUG: Language is %s (%d) %s/%s\n", fprintf(stderr, "DEBUG: Language is %s (%d) %s/%s\n",
lang_prefix, langint, need_right_to_left ? "(RTL)" : "", need_right_to_left_word ? "(RTL words)" : ""); lang_prefix, langint, need_right_to_left ? "(RTL)" : "", need_right_to_left_word ? "(RTL words)" : "");

View file

@ -2,7 +2,7 @@
im.c im.c
Input method handling Input method handling
Copyright (c)2007 by Mark K. Kim and others Copyright (c) 2007-2019 by Mark K. Kim and others
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -905,12 +905,12 @@ static int im_event_zh_tw(IM_DATA * im, SDL_keysym ks)
case IM_REQ_FREE: /* Free allocated resources */ case IM_REQ_FREE: /* Free allocated resources */
charmap_free(&cm); charmap_free(&cm);
/* go onto full reset */ __attribute__ ((fallthrough)); /* go onto full reset */
case IM_REQ_RESET_FULL: /* Full reset */ case IM_REQ_RESET_FULL: /* Full reset */
cm.section = SEC_ENGLISH; cm.section = SEC_ENGLISH;
im->tip_text = im_tip_text[IM_TIP_ENGLISH]; im->tip_text = im_tip_text[IM_TIP_ENGLISH];
/* go onto soft reset */ __attribute__ ((fallthrough)); /* go onto soft reset */
case IM_REQ_RESET_SOFT: /* Soft reset */ case IM_REQ_RESET_SOFT: /* Soft reset */
im->s[0] = L'\0'; im->s[0] = L'\0';
@ -1124,12 +1124,12 @@ static int im_event_th(IM_DATA * im, SDL_keysym ks)
case IM_REQ_FREE: /* Free allocated resources */ case IM_REQ_FREE: /* Free allocated resources */
charmap_free(&cm); charmap_free(&cm);
/* go onto full reset */ __attribute__ ((fallthrough)); /* go onto full reset */
case IM_REQ_RESET_FULL: /* Full reset */ case IM_REQ_RESET_FULL: /* Full reset */
cm.section = SEC_ENGLISH; cm.section = SEC_ENGLISH;
im->tip_text = im_tip_text[IM_TIP_ENGLISH]; im->tip_text = im_tip_text[IM_TIP_ENGLISH];
/* go onto soft reset */ __attribute__ ((fallthrough)); /* go onto soft reset */
case IM_REQ_RESET_SOFT: /* Soft reset */ case IM_REQ_RESET_SOFT: /* Soft reset */
im->s[0] = L'\0'; im->s[0] = L'\0';
@ -1343,12 +1343,12 @@ static int im_event_ja(IM_DATA * im, SDL_keysym ks)
case IM_REQ_FREE: /* Free allocated resources */ case IM_REQ_FREE: /* Free allocated resources */
charmap_free(&cm); charmap_free(&cm);
/* go onto full reset */ __attribute__ ((fallthrough)); /* go onto full reset */
case IM_REQ_RESET_FULL: /* Full reset */ case IM_REQ_RESET_FULL: /* Full reset */
cm.section = SEC_ENGLISH; cm.section = SEC_ENGLISH;
im->tip_text = im_tip_text[IM_TIP_ENGLISH]; im->tip_text = im_tip_text[IM_TIP_ENGLISH];
/* go onto soft reset */ __attribute__ ((fallthrough)); /* go onto soft reset */
case IM_REQ_RESET_SOFT: /* Soft reset */ case IM_REQ_RESET_SOFT: /* Soft reset */
im->s[0] = L'\0'; im->s[0] = L'\0';
@ -1590,12 +1590,12 @@ static int im_event_ko(IM_DATA * im, SDL_keysym ks)
case IM_REQ_FREE: /* Free allocated resources */ case IM_REQ_FREE: /* Free allocated resources */
charmap_free(&cm); charmap_free(&cm);
/* go onto full reset */ __attribute__ ((fallthrough)); /* go onto full reset */
case IM_REQ_RESET_FULL: /* Full reset */ case IM_REQ_RESET_FULL: /* Full reset */
cm.section = SEC_ENGLISH; cm.section = SEC_ENGLISH;
im->tip_text = im_tip_text[IM_TIP_ENGLISH]; im->tip_text = im_tip_text[IM_TIP_ENGLISH];
/* go onto soft reset */ __attribute__ ((fallthrough)); /* go onto soft reset */
case IM_REQ_RESET_SOFT: /* Soft reset */ case IM_REQ_RESET_SOFT: /* Soft reset */
im->s[0] = L'\0'; im->s[0] = L'\0';
@ -1681,7 +1681,7 @@ static int im_event_ko(IM_DATA * im, SDL_keysym ks)
im->redraw--; im->redraw--;
ks.unicode = L'\0'; ks.unicode = L'\0';
} }
/* continue processing: */ __attribute__ ((fallthrough)); /* continue processing: */
/* Actual character processing */ /* Actual character processing */
default: default:

View file

@ -1,7 +1,9 @@
/* /*
* FIXME * FIXME
*/ */
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include "macos.h" #include "macos.h"
#define MACOS_FONTS_PATH "%s/Library/Fonts" #define MACOS_FONTS_PATH "%s/Library/Fonts"
@ -12,7 +14,7 @@
/** /**
* FIXME * FIXME
*/ */
const char *macos_fontsPath() const char *macos_fontsPath(void)
{ {
static char *p = NULL; static char *p = NULL;
@ -35,7 +37,7 @@ const char *macos_fontsPath()
/** /**
* FIXME * FIXME
*/ */
const char *macos_preferencesPath() const char *macos_preferencesPath(void)
{ {
static char *p = NULL; static char *p = NULL;
@ -58,7 +60,7 @@ const char *macos_preferencesPath()
/** /**
* FIXME * FIXME
*/ */
const char *macos_globalPreferencesPath() const char *macos_globalPreferencesPath(void)
{ {
return MACOS_GLOBAL_PREFERENCES_PATH; return MACOS_GLOBAL_PREFERENCES_PATH;
} }

View file

@ -1,9 +1,9 @@
#ifndef __MACOS_H__ #ifndef __MACOS_H__
#define __MACOS_H__ #define __MACOS_H__
const char *macos_fontsPath(); const char *macos_fontsPath(void);
const char *macos_preferencesPath(); const char *macos_preferencesPath(void);
const char *macos_globalPreferencesPath(); const char *macos_globalPreferencesPath(void);
#endif /* __MACOS_H__ */ #endif /* __MACOS_H__ */

View file

@ -155,6 +155,7 @@ static struct osk_layout *load_layout(on_screen_keyboard * keyboard, char *layou
char *filename; char *filename;
char *key, *value; char *key, *value;
osk_layout *layout; osk_layout *layout;
char * __attribute__((unused)) tmp_ptr;
layout = malloc(sizeof(osk_layout)); layout = malloc(sizeof(osk_layout));
layout->name = NULL; layout->name = NULL;
@ -205,7 +206,7 @@ static struct osk_layout *load_layout(on_screen_keyboard * keyboard, char *layou
while (!feof(fi)) while (!feof(fi))
{ {
fgets(line, 1023, fi); tmp_ptr = fgets(line, 1023, fi);
if (is_blank_or_comment(line)) if (is_blank_or_comment(line))
continue; continue;
@ -277,6 +278,7 @@ void load_hlayout(osk_layout * layout, char *hlayout_name)
char *key, *fontpath; char *key, *fontpath;
char *plain_label, *top_label, *altgr_label, *shift_altgr_label; char *plain_label, *top_label, *altgr_label, *shift_altgr_label;
FILE *fi; FILE *fi;
char * __attribute__((unused)) tmp_ptr;
key_number = line_number = 0; key_number = line_number = 0;
width = height = 0; width = height = 0;
@ -342,7 +344,7 @@ void load_hlayout(osk_layout * layout, char *hlayout_name)
allocated = 1; allocated = 1;
} }
fgets(line, 1023, fi); tmp_ptr = fgets(line, 1023, fi);
if (is_blank_or_comment(line)) if (is_blank_or_comment(line))
continue; continue;
@ -466,6 +468,7 @@ void load_keymap(osk_layout * layout, char *keymap_name)
char *ksname1, *ksname2, *ksname3, *ksname4; char *ksname1, *ksname2, *ksname3, *ksname4;
char *line; char *line;
FILE *fi; FILE *fi;
char * __attribute__((unused)) tmp_ptr;
filename = malloc(sizeof(char) * 255); filename = malloc(sizeof(char) * 255);
@ -502,7 +505,7 @@ void load_keymap(osk_layout * layout, char *keymap_name)
while (!feof(fi)) while (!feof(fi))
{ {
fgets(line, 1023, fi); tmp_ptr = fgets(line, 1023, fi);
if (is_blank_or_comment(line)) if (is_blank_or_comment(line))
continue; continue;
@ -652,6 +655,7 @@ static void load_composemap(osk_layout * layout, char *composemap_name)
char **pointer; char **pointer;
char *line; char *line;
FILE *fi; FILE *fi;
char * __attribute__((unused)) tmp_ptr;
pointer = malloc(sizeof(wchar_t *)); pointer = malloc(sizeof(wchar_t *));
filename = malloc(sizeof(char) * 255); filename = malloc(sizeof(char) * 255);
@ -684,7 +688,7 @@ static void load_composemap(osk_layout * layout, char *composemap_name)
while (!feof(fi)) while (!feof(fi))
{ {
fgets(line, 1023, fi); tmp_ptr = fgets(line, 1023, fi);
if (is_blank_or_comment(line)) if (is_blank_or_comment(line))
continue; continue;
@ -760,6 +764,7 @@ static void load_keysymdefs(osk_layout * layout, char *keysymdefs_name)
char *filename; char *filename;
char *line; char *line;
FILE *fi; FILE *fi;
char * __attribute__((unused)) tmp_ptr;
filename = malloc(sizeof(char) * 255); filename = malloc(sizeof(char) * 255);
@ -789,7 +794,7 @@ static void load_keysymdefs(osk_layout * layout, char *keysymdefs_name)
while (!feof(fi)) while (!feof(fi))
{ {
fgets(line, 1023, fi); tmp_ptr = fgets(line, 1023, fi);
if (strncmp("#define XK_", line, 11) != 0) if (strncmp("#define XK_", line, 11) != 0)
continue; continue;

View file

@ -37,6 +37,10 @@ struct cfg
#define NEGBOOL(x) (void*)(offsetof(struct cfginfo,x)|NEG) #define NEGBOOL(x) (void*)(offsetof(struct cfginfo,x)|NEG)
#define IMM(x) imm_##x #define IMM(x) imm_##x
/* Prototypes of what's in tuxpaint.c: */
void show_version(int details);
void show_usage(int exitcode);
static void imm_version(void) static void imm_version(void)
{ {
show_version(0); show_version(0);

View file

@ -22,7 +22,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt) (See COPYING.txt)
June 14, 2002 - April 3, 2019 June 14, 2002 - August 29, 2019
*/ */
@ -457,9 +457,7 @@ static void mtw(wchar_t * wtok, char *tok)
#else #else
#include <librsvg/rsvg.h> #include <librsvg/rsvg.h>
#include <librsvg/rsvg-cairo.h>
/* #include "rsvg.h" */
/* #include "rsvg-cairo.h" */
#if !defined(RSVG_H) || !defined(RSVG_CAIRO_H) #if !defined(RSVG_H) || !defined(RSVG_CAIRO_H)
#error "---------------------------------------------------" #error "---------------------------------------------------"
#error "If you installed libRSVG from packages, be sure" #error "If you installed libRSVG from packages, be sure"
@ -2040,17 +2038,19 @@ static char *debug_gettext(const char *str);
static int charsize(Uint16 c); static int charsize(Uint16 c);
#endif #endif
static SDL_Surface *load_kpx(char *file); static SDL_Surface *load_kpx(const char *file);
#ifndef NOSVG #ifndef NOSVG
static SDL_Surface *load_svg(char *file); static SDL_Surface *load_svg(const char *file);
static float pick_best_scape(unsigned int orig_w, unsigned int orig_h, unsigned int max_w, unsigned int max_h); static float pick_best_scape(unsigned int orig_w, unsigned int orig_h, unsigned int max_w, unsigned int max_h);
#endif #endif
static SDL_Surface *myIMG_Load_RWops(char *file); static SDL_Surface *myIMG_Load_RWops(const char *file);
static SDL_Surface *myIMG_Load(char *file); static SDL_Surface *myIMG_Load(const char *file);
static int trash(char *path); static int trash(char *path);
int file_exists(char *path); int file_exists(char *path);
int generate_fontconfig_cache_spinner(SDL_Surface * screen);
#define MAX_UTF8_CHAR_LENGTH 6 #define MAX_UTF8_CHAR_LENGTH 6
@ -7731,7 +7731,7 @@ static int generate_fontconfig_cache_real(void)
/** /**
* FIXME * FIXME
*/ */
static int generate_fontconfig_cache(void *vp) static int generate_fontconfig_cache(__attribute__((unused)) void *vp)
{ {
return generate_fontconfig_cache_real(); return generate_fontconfig_cache_real();
} }
@ -9344,13 +9344,6 @@ static SDL_Surface *thumbnail2(SDL_Surface * src, int max_x, int max_y, int keep
for (x = 0; x < max_x; x++) for (x = 0; x < max_x; x++)
{ {
#ifndef LOW_QUALITY_THUMBNAILS #ifndef LOW_QUALITY_THUMBNAILS
#ifdef GAMMA_CORRECTED_THUMBNAILS
/* per: http://www.4p8.com/eric.brasseur/gamma.html */
float gamma = 2.2;
float gamma_invert = 1.0 / gamma;
#endif
tr = 0; tr = 0;
tg = 0; tg = 0;
tb = 0; tb = 0;
@ -9365,9 +9358,8 @@ static SDL_Surface *thumbnail2(SDL_Surface * src, int max_x, int max_y, int keep
SDL_GetRGBA(getpixel(src, src_x, src_y), src->format, &r, &g, &b, &a); SDL_GetRGBA(getpixel(src, src_x, src_y), src->format, &r, &g, &b, &a);
#ifdef GAMMA_CORRECTED_THUMBNAILS #ifdef GAMMA_CORRECTED_THUMBNAILS
// tr = tr + pow((float)r, gamma); /* per: http://www.4p8.com/eric.brasseur/gamma.html */
// tb = tb + pow((float)b, gamma);
// tg = tg + pow((float)g, gamma);
tr = tr + sRGB_to_linear_table[r]; tr = tr + sRGB_to_linear_table[r];
tg = tg + sRGB_to_linear_table[g]; tg = tg + sRGB_to_linear_table[g];
tb = tb + sRGB_to_linear_table[b]; tb = tb + sRGB_to_linear_table[b];
@ -9390,9 +9382,6 @@ static SDL_Surface *thumbnail2(SDL_Surface * src, int max_x, int max_y, int keep
ta = ta / tmp; ta = ta / tmp;
#ifdef GAMMA_CORRECTED_THUMBNAILS #ifdef GAMMA_CORRECTED_THUMBNAILS
// tr = ceil(pow(tr, gamma_invert));
// tg = ceil(pow(tg, gamma_invert));
// tb = ceil(pow(tb, gamma_invert));
tr = linear_to_sRGB(tr); tr = linear_to_sRGB(tr);
tg = linear_to_sRGB(tg); tg = linear_to_sRGB(tg);
tb = linear_to_sRGB(tb); tb = linear_to_sRGB(tb);
@ -11285,7 +11274,8 @@ static void load_starter_id(char *saved_id, FILE * fil)
char fname[FILENAME_MAX]; char fname[FILENAME_MAX];
FILE *fi; FILE *fi;
char color_tag; char color_tag;
int r, g, b, tmp; int r, g, b, __attribute__((unused))tmp;
char * __attribute__((unused)) tmp_ptr;
rname = NULL; rname = NULL;
@ -11343,7 +11333,7 @@ static void load_starter_id(char *saved_id, FILE * fil)
if (!feof(fi) && color_tag == 'T') if (!feof(fi) && color_tag == 'T')
{ {
tmp = fgets(template_id, sizeof(template_id), fi); tmp_ptr = fgets(template_id, sizeof(template_id), fi);
template_id[strlen(template_id) - 1] = '\0'; template_id[strlen(template_id) - 1] = '\0';
tmp = fscanf(fi, "%d", &template_personal); tmp = fscanf(fi, "%d", &template_personal);
/* FIXME: Debug only? */ /* FIXME: Debug only? */
@ -11371,12 +11361,12 @@ static void load_starter_id(char *saved_id, FILE * fil)
/** /**
* FIXME * FIXME
*/ */
static SDL_Surface *load_starter_helper(char *path_and_basename, char *extension, SDL_Surface * (*load_func) (char *)) static SDL_Surface *load_starter_helper(char *path_and_basename, const char *extension, SDL_Surface * (*load_func) (const char *))
{ {
char *ext; char *ext;
char fname[256]; char fname[256];
SDL_Surface *surf; SDL_Surface *surf;
int i; unsigned int i;
ext = strdup(extension); ext = strdup(extension);
snprintf(fname, sizeof(fname), "%s.%s", path_and_basename, ext); snprintf(fname, sizeof(fname), "%s.%s", path_and_basename, ext);
@ -11890,7 +11880,7 @@ static int do_prompt_image_flash_snd(const char *const text,
int i; int i;
SDL_Surface *alpha_surf; SDL_Surface *alpha_surf;
#endif #endif
int img1_w, img2_w, img3_w, max_img_w, img_x, img_y, offset; int img1_w, img2_w, img3_w, max_img_w, img_y, offset;
SDL_Surface *img1b; SDL_Surface *img1b;
int free_img1b; int free_img1b;
int txt_left, txt_right, img_left, btn_left, txt_btn_left, txt_btn_right; int txt_left, txt_right, img_left, btn_left, txt_btn_left, txt_btn_right;
@ -12071,7 +12061,6 @@ static int do_prompt_image_flash_snd(const char *const text,
/* Draw the images (if any, and if not animated): */ /* Draw the images (if any, and if not animated): */
img_x = img_left;
img_y = 100 + PROMPTOFFSETY + 4; img_y = 100 + PROMPTOFFSETY + 4;
if (img1b != NULL) if (img1b != NULL)
@ -13236,9 +13225,9 @@ static void set_chunk_data(unsigned char **chunk_data, size_t * chunk_data_len,
strcat(headers, "Tuxpaint\n"); strcat(headers, "Tuxpaint\n");
strcat(headers, "Tuxpaint_" VER_VERSION "\n"); strcat(headers, "Tuxpaint_" VER_VERSION "\n");
sprintf(line, "%d%s", uncompressed_size, "\n"); sprintf(line, "%lu%s", uncompressed_size, "\n");
strcat(headers, line); strcat(headers, line);
sprintf(line, "%d%s", dataLen, "\n"); sprintf(line, "%lu%s", dataLen, "\n");
strcat(headers, line); strcat(headers, line);
headersLen = strlen(headers); headersLen = strlen(headers);
@ -17210,7 +17199,7 @@ static void handle_active(SDL_Event * event)
SDL_Flip(screen); SDL_Flip(screen);
} }
} }
if (event->active.state & SDL_APPINPUTFOCUS | SDL_APPACTIVE) if (event->active.state & (SDL_APPINPUTFOCUS | SDL_APPACTIVE))
{ {
if (event->active.gain == 1) if (event->active.gain == 1)
{ {
@ -17477,7 +17466,7 @@ static int paintsound(int size)
/* Old libcairo1, svg and svg-cairo based code /* Old libcairo1, svg and svg-cairo based code
Based on cairo-demo/sdl/main.c from Cairo (GPL'd, (c) 2004 Eric Windisch): Based on cairo-demo/sdl/main.c from Cairo (GPL'd, (c) 2004 Eric Windisch):
*/ */
static SDL_Surface *load_svg(char *file) static SDL_Surface *load_svg(const char *file)
{ {
svg_cairo_t *scr; svg_cairo_t *scr;
int bpp, btpp, stride; int bpp, btpp, stride;
@ -17636,7 +17625,7 @@ static SDL_Surface *load_svg(char *file)
* FIXME * FIXME
*/ */
/* New libcairo2, rsvg and rsvg-cairo based code */ /* New libcairo2, rsvg and rsvg-cairo based code */
static SDL_Surface *load_svg(char *file) static SDL_Surface *load_svg(const char *file)
{ {
cairo_surface_t *cairo_surf; cairo_surface_t *cairo_surf;
cairo_t *cr; cairo_t *cr;
@ -17887,7 +17876,7 @@ static float pick_best_scape(unsigned int orig_w, unsigned int orig_h, unsigned
*/ */
/* FIXME: we can remove this after SDL folks fix their bug at http://bugzilla.libsdl.org/show_bug.cgi?id=1485 */ /* FIXME: we can remove this after SDL folks fix their bug at http://bugzilla.libsdl.org/show_bug.cgi?id=1485 */
/* Try to load an image with IMG_Load(), if it fails, then try with RWops() */ /* Try to load an image with IMG_Load(), if it fails, then try with RWops() */
static SDL_Surface *myIMG_Load_RWops(char *file) static SDL_Surface *myIMG_Load_RWops(const char *file)
{ {
SDL_Surface *surf; SDL_Surface *surf;
FILE *fi; FILE *fi;
@ -17921,7 +17910,7 @@ static SDL_Surface *myIMG_Load_RWops(char *file)
if we notice it's an SVG file (if available!); if we notice it's an SVG file (if available!);
call load_kpx() if we notice it's a KPX file (JPEG with wrapper); call load_kpx() if we notice it's a KPX file (JPEG with wrapper);
otherwise call SDL_Image lib's IMG_Load() (for PNGs, JPEGs, BMPs, etc.) */ otherwise call SDL_Image lib's IMG_Load() (for PNGs, JPEGs, BMPs, etc.) */
static SDL_Surface *myIMG_Load(char *file) static SDL_Surface *myIMG_Load(const char *file)
{ {
if (strlen(file) > 4 && strcasecmp(file + strlen(file) - 4, ".kpx") == 0) if (strlen(file) > 4 && strcasecmp(file + strlen(file) - 4, ".kpx") == 0)
{ {
@ -17942,7 +17931,7 @@ static SDL_Surface *myIMG_Load(char *file)
/** /**
* FIXME * FIXME
*/ */
static SDL_Surface *load_kpx(char *file) static SDL_Surface *load_kpx(const char *file)
{ {
SDL_RWops *data; SDL_RWops *data;
FILE *fi; FILE *fi;
@ -19819,7 +19808,7 @@ static int do_color_sel(void)
int i, dx, dy; int i, dx, dy;
int done, chose; int done, chose;
int back_left, back_top; int back_left, back_top;
int color_sel_x, color_sel_y; int color_sel_x = 0, color_sel_y = 0;
SDL_Surface *tmp_btn_up, *tmp_btn_down; SDL_Surface *tmp_btn_up, *tmp_btn_down;
Uint32(*getpixel_tmp_btn_up) (SDL_Surface *, int, int); Uint32(*getpixel_tmp_btn_up) (SDL_Surface *, int, int);
@ -21130,7 +21119,7 @@ static void render_all_nodes_starting_at(struct label_node **node)
* FIXME * FIXME
*/ */
/* FIXME: This should search for the top-down of the overlaping labels and only re-render from it */ /* FIXME: This should search for the top-down of the overlaping labels and only re-render from it */
static void derender_node(struct label_node **ref_head) static void derender_node(__attribute__((unused)) struct label_node **ref_head)
{ {
SDL_Rect r_tmp_derender; SDL_Rect r_tmp_derender;
@ -22890,7 +22879,7 @@ static void setup_config(char *argv[])
{ {
char *token; char *token;
token = strtok(tmpcfg.joystick_buttons_ignore, ","); token = strtok((char *) tmpcfg.joystick_buttons_ignore, ",");
while (token != NULL) while (token != NULL)
{ {
if (strtof(token, NULL) < 0 || strtof(token, NULL) > 254) if (strtof(token, NULL) < 0 || strtof(token, NULL) > 254)