tuxpaint.c code & warning clean-up (WIP)

- Replace any C++ style comments (// ...) with C style (/* ... */).
 - Improve calls to fgets() to avoid "ignoring return value
   of ‘fscanf’, declared with attribute warn_unused_result
   [-Wunused-result]" errors (WIP).
 - Removed some unused, commented-out code.
This commit is contained in:
Bill Kendrick 2017-10-15 12:57:43 -07:00
parent a8a0276f89
commit 284a64a08f

View file

@ -3,7 +3,7 @@
Tux Paint - A simple drawing program for children.
Copyright (c) 2002-2014 by Bill Kendrick and others; see AUTHORS.txt
Copyright (c) 2002-2017 by Bill Kendrick and others; see AUTHORS.txt
bill@newbreedsoftware.com
http://www.tuxpaint.org/
@ -22,7 +22,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt)
June 14, 2002 - April 16, 2014
June 14, 2002 - October 15, 2017
*/
@ -181,7 +181,7 @@ static scaleparams scaletable[] = {
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <libgen.h> //EP added this include for basename()
#include <libgen.h> /* EP added this include for basename() */
/* On Linux, we can use 'wordexp()' to expand env. vars. in settings
pulled from config. files */
@ -256,7 +256,7 @@ char *strcasestr(const char *haystack, const char *needle)
#endif
#ifdef DEBUG
#undef gettext //EP to avoid warning on following line
#undef gettext /* EP to avoid warning on following line */
#define gettext(String) debug_gettext(String)
#endif
@ -276,7 +276,7 @@ char *strcasestr(const char *haystack, const char *needle)
#include <dirent.h>
#include <signal.h>
#if defined __BEOS__ //|| defined __HAIKU__
#if defined __BEOS__
/* BeOS */
@ -467,7 +467,7 @@ static void mtw(wchar_t * wtok, char *tok)
#endif
#include <zlib.h> //EP added for PNG upgrade from 1.2 to 1.5
#include <zlib.h> /* EP added for PNG upgrade from 1.2 to 1.5 */
#define PNG_INTERNAL
#include <png.h>
#define FNAME_EXTENSION ".png"
@ -512,7 +512,7 @@ static void mtw(wchar_t * wtok, char *tok)
#include "compiler.h"
//EP added #ifndef __APPLE__ because macros are buggy (shifted by 1 byte), plus the function exists in SDL
/* EP added #ifndef __APPLE__ because macros are buggy (shifted by 1 byte), plus the function exists in SDL */
#ifndef __APPLE__
#if VIDEO_BPP==32
#ifdef __GNUC__
@ -549,9 +549,9 @@ static void mtw(wchar_t * wtok, char *tok)
#endif
#endif
//#define fmemopen_alternative */ /* Uncomment this to test the fmemopen alternative in systems were fmemopen exists */
/* #define fmemopen_alternative */ /* Uncomment this to test the fmemopen alternative in systems were fmemopen exists */
#if defined (WIN32) || defined (__APPLE__) || defined(__NetBSD__) || defined(__sun) // MINGW/MSYS, NetBSD, and MacOSX need it, at least for now
#if defined (WIN32) || defined (__APPLE__) || defined(__NetBSD__) || defined(__sun) /* MINGW/MSYS, NetBSD, and MacOSX need it, at least for now */
#define fmemopen_alternative
#endif
@ -623,8 +623,8 @@ enum
{
LABEL_OFF,
LABEL_LABEL,
LABEL_SELECT //,
// LABEL_ROTATE
LABEL_SELECT
/* , LABEL_ROTATE */
};
@ -715,7 +715,7 @@ static grid_dims gd_colors; /* was 17x1 */
static int WINDOW_WIDTH = 800;
static int WINDOW_HEIGHT = 480;
#elif defined(OLPC_XO)
// ideally we'd support rotation and 2x scaling
/* ideally we'd support rotation and 2x scaling */
static int WINDOW_WIDTH = 1200;
static int WINDOW_HEIGHT = 900;
#else
@ -996,12 +996,7 @@ static void update_canvas_ex_r(int x1, int y1, int x2, int y2, int screen_too)
SDL_BlitSurface(img_starter, &dest, canvas, &dest);
}
// printf("%d\n", canvas );
//printf("%d, %d, %d, %d\n", dest.x, dest.y, dest.w, dest.h);
//printf("%d\n", screen);
//printf("%d, %d, %d, %d\n\n\n", r_canvas.x, r_canvas.y, r_canvas.w, r_canvas.w);
// src.x = x1 + 96;
dest.x = x1 + 96;
SDL_BlitSurface(canvas, &src, screen, &dest);
@ -1443,7 +1438,7 @@ static Uint16 *wcstou16(const wchar_t * str)
will cause a change from one utf16 character into two....
(though at least UTF-8 suffers from this problem) */
// FIXME: mangles non-BMP characters rather than using UTF-16 surrogates!
/* FIXME: mangles non-BMP characters rather than using UTF-16 surrogates! */
res[i] = (Uint16) str[i];
}
@ -2239,7 +2234,7 @@ static void mainloop(void)
mod = event.key.keysym.mod;
#ifdef DEBUG
// FIXME: debug junk
/* FIXME: debug junk */
fprintf(stderr,
"key 0x%04x mod 0x%04x character 0x%04x %d <%c> is %sprintable, key_down 0x%x\n",
(unsigned)key,
@ -2662,7 +2657,7 @@ static void mainloop(void)
add_label_node(0, 0, 0, 0, NULL);
derender_node(&label_node_to_edit);
label_node_to_edit = NULL;
// playsound(screen, 0, SND_DELETE_LABEL, 0, SNDPOS_CENTER); // FIXME lack of specific sound
/* playsound(screen, 0, SND_DELETE_LABEL, 0, SNDPOS_CENTER); */ /* FIXME lack of specific sound */
if (been_saved)
{
@ -2704,7 +2699,6 @@ static void mainloop(void)
cur_font = select_cur_font;
text_state = select_text_state;
text_size = select_text_size;
// int j;
for (j = 0; j < num_font_families; j++)
{
if (user_font_families[j] && user_font_families[j]->handle)
@ -2777,7 +2771,7 @@ static void mainloop(void)
add_label_node(0, 0, 0, 0, NULL);
derender_node(&label_node_to_edit);
label_node_to_edit = NULL;
// playsound(screen, 0, SND_DELETE_LABEL, 0, SNDPOS_CENTER); // FIXME lack of specific sound
/* playsound(screen, 0, SND_DELETE_LABEL, 0, SNDPOS_CENTER); */ /* FIXME lack of specific sound */
if (been_saved)
{
@ -3331,8 +3325,6 @@ static void mainloop(void)
WARNING: this must be kept in sync with the mouse-move
code (for cursor changes) and mouse-scroll code. */
// magic_switchout(canvas);
if (cur_tool == TOOL_BRUSH || cur_tool == TOOL_STAMP ||
cur_tool == TOOL_SHAPES || cur_tool == TOOL_LINES ||
cur_tool == TOOL_MAGIC || cur_tool == TOOL_TEXT ||
@ -3911,17 +3903,18 @@ static void mainloop(void)
}
else if (cur_tool == TOOL_TEXT || cur_tool == TOOL_LABEL)
{
/* FIXME *//* char font_tux_text[512]; */
/* FIXME */
/* char font_tux_text[512]; */
cur_font = cur_thing;
/* FIXME */
/*
/* FIXME */
/*
snprintf(font_tux_text, sizeof font_tux_text, "%s (%s).",
TTF_FontFaceFamilyName(getfonthandle(cur_font)),
TTF_FontFaceStyleName(getfonthandle(cur_font)));
draw_tux_text(TUX_GREAT, font_tux_text, 1);
*/
*/
if (do_draw)
draw_fonts();
@ -6434,8 +6427,8 @@ static void loadbrush_callback(SDL_Surface * screen,
{
do
{
fgets(buf, sizeof(buf), fi);
if (fgets(buf, sizeof(buf), fi))
{
if (strstr(buf, "frames=") != NULL)
{
brushes_frames[num_brushes] = atoi(strstr(buf, "frames=") + 7);
@ -6453,6 +6446,7 @@ static void loadbrush_callback(SDL_Surface * screen,
want_rand = 1;
}
}
}
while (!feof(fi));
fclose(fi);
@ -7365,7 +7359,7 @@ static void loadstamp_callback(SDL_Surface * screen,
show_progress_bar(screen);
if (dotext > files[i].str && !strcasecmp(dotext, ext)
&& (dotext - files[i].str + 1 + dirlen < sizeof fname)
&& (dotext - files[i].str + 1 + dirlen < (int) (sizeof fname))
&& !strcasestr(files[i].str, mirror_ext)
&& !strcasestr(files[i].str, flip_ext) && !strcasestr(files[i].str, mirrorflip_ext))
{
@ -10628,8 +10622,8 @@ static char *loaddesc(const char *const fname, Uint8 * locale_text)
do
{
fgets(buf, sizeof(buf), fi);
if (fgets(buf, sizeof(buf), fi))
{
if (!feof(fi))
{
strip_trailing_whitespace(buf);
@ -10666,8 +10660,6 @@ static char *loaddesc(const char *const fname, Uint8 * locale_text)
need_right_to_left = wished_langs[i].need_right_to_left;
need_right_to_left_word = wished_langs[i].need_right_to_left_word;
found = 1;
debug("...FOUND!");
@ -10675,6 +10667,7 @@ static char *loaddesc(const char *const fname, Uint8 * locale_text)
}
}
}
}
while (!feof(fi) && !found);
fclose(fi);
@ -10723,8 +10716,8 @@ static double loadinfo(const char *const fname, stamp_type * inf)
do
{
fgets(buf, sizeof buf, fi);
if (fgets(buf, sizeof buf, fi))
{
if (!feof(fi))
{
strip_trailing_whitespace(buf);
@ -10808,6 +10801,7 @@ static double loadinfo(const char *const fname, stamp_type * inf)
inf->flipable = 0;
}
}
}
while (!feof(fi));
fclose(fi);
@ -10961,7 +10955,7 @@ static void load_starter_id(char *saved_id, FILE * fil)
char fname[FILENAME_MAX];
FILE *fi;
char color_tag;
int r, g, b;
int r, g, b, tmp;
rname = NULL;
@ -10980,12 +10974,13 @@ static void load_starter_id(char *saved_id, FILE * fil)
if (fi != NULL)
{
fgets(starter_id, sizeof(starter_id), fi);
if (fgets(starter_id, sizeof(starter_id), fi))
{
starter_id[strlen(starter_id) - 1] = '\0';
fscanf(fi, "%d", &starter_mirrored);
fscanf(fi, "%d", &starter_flipped);
fscanf(fi, "%d", &starter_personal);
tmp = fscanf(fi, "%d", &starter_mirrored);
tmp = fscanf(fi, "%d", &starter_flipped);
tmp = fscanf(fi, "%d", &starter_personal);
do
{
@ -10995,9 +10990,9 @@ static void load_starter_id(char *saved_id, FILE * fil)
if (!feof(fi) && color_tag == 'c')
{
fscanf(fi, "%d", &r);
fscanf(fi, "%d", &g);
fscanf(fi, "%d", &b);
tmp = fscanf(fi, "%d", &r);
tmp = fscanf(fi, "%d", &g);
tmp = fscanf(fi, "%d", &b);
canvas_color_r = (Uint8) r;
canvas_color_g = (Uint8) g;
@ -11015,12 +11010,13 @@ static void load_starter_id(char *saved_id, FILE * fil)
color_tag = fgetc(fi);
}
while ((color_tag == '\n' || color_tag == '\r') && !feof(fi));
{
if (!feof(fi) && color_tag == 'T')
{
fgets(template_id, sizeof(template_id), fi);
tmp = fgets(template_id, sizeof(template_id), fi);
template_id[strlen(template_id) - 1] = '\0';
fscanf(fi, "%d", &template_personal);
tmp = fscanf(fi, "%d", &template_personal);
/* FIXME: Debug only? */
printf("template = %s\n (Personal=%d)", template_id, template_personal);
}
if (!feof(fi) && color_tag == 'M')
@ -11028,7 +11024,6 @@ static void load_starter_id(char *saved_id, FILE * fil)
starter_modified = fgetc(fi);
}
}
fclose(fi);
}
else
@ -12284,37 +12279,6 @@ static void free_surface_array(SDL_Surface * surface_array[], int count)
}
/* Update screen where shape is/was: */
/* FIXME: unused */
/*
static void update_shape(int cx, int ox1, int ox2, int cy, int oy1, int oy2, int fix)
{
int rx, ry;
rx = abs(ox1 - cx);
if (abs(ox2 - cx) > rx)
rx = abs(ox2 - cx);
ry = abs(oy1 - cy);
if (abs(oy2 - cy) > ry)
ry = abs(oy2 - cy);
if (fix)
{
if (ry > rx)
rx = ry;
else
ry = rx;
}
SDL_UpdateRect(screen, max((cx - rx), 0) + 96, max(cy - ry, 0),
min((cx + rx) + 96, screen->w),
min(cy + ry, screen->h));
}
*/
/* Draw a shape! */
static void do_shape(int cx, int cy, int ox, int oy, int rotn, int use_brush)
@ -21275,6 +21239,7 @@ void load_embedded_data(char *fname, SDL_Surface * org_surf)
{
FILE *fi, *fp;
char *control;
char *CHAR_PTR_TMP;
Bytef *unc_buff;
int unc_size;
@ -21345,9 +21310,12 @@ void load_embedded_data(char *fname, SDL_Surface * org_surf)
have_label_delta = have_label_data = have_background = have_foreground = FALSE;
ldelta = ldata = fgnd = bgnd = FALSE;
/* Need to get things in order, as we can't enforce any order in custom chunks, we need to go around them 3 times */
/* Need to get things in order, as we can't enforce any order in custom chunks,
we need to go around them 3 times */
/* First we search for the things that usually were in the .dat file, so if a starter or a template is found and if it is not modified, we can load it clean (i.e. not rebluring a blured when scaled one)*/
/* First we search for the things that usually were in the .dat file, so if a starter or a
template is found and if it is not modified, we can load it clean (i.e. not rebluring a
blured when scaled one)*/
for (u = 0; u < num_unknowns; u++)
{
printf("%s, %d\n", unknowns[u].name, unknowns[u].size);
@ -21367,15 +21335,16 @@ void load_embedded_data(char *fname, SDL_Surface * org_surf)
return; /* Refusing to go further with the other chunks */
}
/* Put fi position at the right place after the chunk headers */
/* Put fi position at the right place after the chunk headers */
control = malloc(50);
fgets(control, 49, fi);
fgets(control, 49, fi);
fgets(control, 49, fi);
fgets(control, 49, fi);
CHAR_PTR_TMP = fgets(control, 49, fi);
CHAR_PTR_TMP = fgets(control, 49, fi);
CHAR_PTR_TMP = fgets(control, 49, fi);
CHAR_PTR_TMP = fgets(control, 49, fi);
free(control);
load_starter_id(NULL, fi); // fi will be closed in load_starter_id()
/* fi will be closed in load_starter_id() */
load_starter_id(NULL, fi);
if (!starter_modified)
{
/* Code adapted from load_current() */
@ -21615,7 +21584,7 @@ void load_embedded_data(char *fname, SDL_Surface * org_surf)
}
/////////////////////////////////////////////////////////////////////////////
/* ================================================================================== */
#if !defined(WIN32) && !defined(__APPLE__) && !defined(__BEOS__) && !defined(__HAIKU__)
static void show_available_papersizes(int exitcode)
@ -21650,7 +21619,7 @@ static void show_available_papersizes(int exitcode)
}
#endif
/////////////////////////////////////////////////////////////////////////////
/* ================================================================================== */
static void parse_file_options(struct cfginfo *restrict tmpcfg, const char *filename)
{
@ -21679,10 +21648,10 @@ static void parse_file_options(struct cfginfo *restrict tmpcfg, const char *file
wordfree(&result);
#endif
// FIXME: leaking mem here, but the trouble is that these
// strings get mixed in with ones from .data and .rodata
// and free() isn't smart about the situation -- also some
// of the strings end up being kept around
/* FIXME: leaking mem here, but the trouble is that these
strings get mixed in with ones from .data and .rodata
and free() isn't smart about the situation -- also some
of the strings end up being kept around */
parse_one_option(tmpcfg, str, strdup(arg), filename);
#ifdef __linux__
free(arg);
@ -21690,7 +21659,7 @@ static void parse_file_options(struct cfginfo *restrict tmpcfg, const char *file
}
fclose(fi);
// These interact in horrid ways.
/* These interact in horrid ways. */
if (tmpcfg->parsertmp_lang && tmpcfg->parsertmp_locale)
fprintf(stderr,
"Warning: option 'lang=%s' overrides option 'locale=%s' in '%s'\n",
@ -21761,7 +21730,7 @@ static void parse_argv_options(struct cfginfo *restrict tmpcfg, char *argv[])
exit(1);
}
// These interact in horrid ways.
/* These interact in horrid ways. */
if (tmpcfg->parsertmp_lang && tmpcfg->parsertmp_locale)
{
fprintf(stderr,
@ -21775,7 +21744,7 @@ static void parse_argv_options(struct cfginfo *restrict tmpcfg, char *argv[])
tmpcfg->parsertmp_lang = PARSE_CLOBBER;
}
// merge two configs, with the winner taking priority
/* merge two configs, with the winner taking priority */
static void tmpcfg_merge(struct cfginfo *loser, const struct cfginfo *winner)
{
int i = CFGINFO_MAXOFFSET / sizeof(char *);
@ -21809,7 +21778,9 @@ static void setup_config(char *argv[])
parse_argv_options(&tmpcfg_cmd, argv);
#if defined(__APPLE__) //EP added this conditional section for Mac to allow for a config in the current directory, that supersedes sys and user configs
#if defined(__APPLE__)
/* EP added this conditional section for Mac to allow for a config in
the current directory, that supersedes sys and user configs */
/* Mac OS X: Use a "tuxpaint.cfg" file in the current folder */
struct cfginfo tmpcfg_curdir;
@ -21866,14 +21837,15 @@ static void setup_config(char *argv[])
#else
/* Linux and other Unixes: Use 'rc' style (~/.tuxpaintrc) */
// it should it be "~/.tuxpaint/tuxpaintrc" instead, but too late now
/* it should it be "~/.tuxpaint/tuxpaintrc" instead, but too late now */
snprintf(str, sizeof(str), "%s/.tuxpaintrc", home);
#endif
parse_file_options(&tmpcfg_usr, str);
#if defined(__APPLE__) //EP added this conditional section for Mac
#if defined(__APPLE__)
/* EP added this conditional section for Mac */
tmpcfg_merge(&tmpcfg_usr, &tmpcfg_curdir);
#else
tmpcfg_merge(&tmpcfg_usr, &tmpcfg_cmd);
@ -21885,14 +21857,17 @@ static void setup_config(char *argv[])
memset(&tmpcfg_sys, '\0', sizeof tmpcfg_sys);
#ifdef _WIN32
// global config file in the application directory
/* global config file in the application directory */
parse_file_options(&tmpcfg_sys, "tuxpaint.cfg");
#elif defined(__APPLE__) //EP added this conditional section for Mac to fix folder&extension inconsistency with Tux Paint Config application)
/* Mac OS X: Use a "tuxpaint.cfg" file in the *global* Tux Paint application support folder */
#elif defined(__APPLE__)
/* EP added this conditional section for Mac to fix
folder & extension inconsistency with Tux Paint Config application) */
/* Mac OS X: Use a "tuxpaint.cfg" file in the *global* Tux Paint
application support folder */
snprintf(str, sizeof(str), "%s/tuxpaint.cfg", macosx.globalPreferencesPath);
parse_file_options(&tmpcfg_sys, str);
#else
// normally /etc/tuxpaint/tuxpaint.conf
/* normally /etc/tuxpaint/tuxpaint.conf */
parse_file_options(&tmpcfg_sys, CONFDIR "tuxpaint.conf");
#endif
tmpcfg_merge(&tmpcfg, &tmpcfg_sys);
@ -21914,7 +21889,7 @@ static void setup_config(char *argv[])
button_label_y_nudge = setup_i18n(tmpcfg.parsertmp_lang, tmpcfg.parsertmp_locale);
// FIXME: most of this is not required before starting the font scanner
/* FIXME: most of this is not required before starting the font scanner */
#ifdef PAPER_H
if (tmpcfg_cmd.papersize && !strcmp(tmpcfg_cmd.papersize, "help"))
@ -21980,7 +21955,7 @@ static void setup_config(char *argv[])
}
if (tmpcfg.parsertmp_fullscreen_native)
{
// should conflict with other fullscreen/native_screensize setting?
/* should conflict with other fullscreen/native_screensize setting? */
if (!strcmp(tmpcfg.parsertmp_fullscreen_native, "native"))
native_screensize = 1;
fullscreen = strcmp(tmpcfg.parsertmp_fullscreen_native, "no");
@ -21991,17 +21966,17 @@ static void setup_config(char *argv[])
stamp_size_override = -1;
else
{
// FIXME: needs to be a scaling factor
/* FIXME: needs to be a scaling factor */
stamp_size_override = atoi(tmpcfg.stamp_size_override);
if (stamp_size_override > 10)
stamp_size_override = 10;
}
}
// FIXME: make this dynamic (accelerometer or OLPC XO-1 rotation button)
/* FIXME: make this dynamic (accelerometer or OLPC XO-1 rotation button) */
if (tmpcfg.rotate_orientation)
rotate_orientation = !strcmp(tmpcfg.rotate_orientation, "portrait"); // alternative is "landscape"
rotate_orientation = !strcmp(tmpcfg.rotate_orientation, "portrait"); /* alternative is "landscape" */
if (tmpcfg.colorfile)
strcpy(colorfile, tmpcfg.colorfile); // FIXME can overflow
strcpy(colorfile, tmpcfg.colorfile); /* FIXME can overflow */
if (tmpcfg.print_delay)
{
print_delay = atoi(tmpcfg.print_delay);
@ -22015,13 +21990,13 @@ static void setup_config(char *argv[])
#endif
if (tmpcfg.alt_print_command_default)
{
// FIXME: probably need extra variables
/* FIXME: probably need extra variables */
if (!strcmp(tmpcfg.alt_print_command_default, "always"))
alt_print_command_default = ALTPRINT_ALWAYS;
else if (!strcmp(tmpcfg.alt_print_command_default, "never"))
alt_print_command_default = ALTPRINT_NEVER;
else
alt_print_command_default = ALTPRINT_MOD; // default ("mod")
alt_print_command_default = ALTPRINT_MOD; /* default ("mod") */
}
#ifdef PAPER_H
if (tmpcfg.papersize)
@ -22324,14 +22299,15 @@ static void setup_config(char *argv[])
static void chdir_to_binary(char *argv0)
{
char curdir[256]; //EP added this block to print out of current directory
char curdir[256];
/* EP added this block to print out of current directory */
getcwd(curdir, sizeof(curdir));
#ifdef DEBUG
printf("Binary Path: %s\nCurrent directory at launchtime: %s\n", argv0, curdir);
#endif
#if defined(__BEOS__) || defined(WIN32) || defined(__APPLE__) //EP added __APPLE__
#if defined(__BEOS__) || defined(WIN32) || defined(__APPLE__)
/* if run from gui, like OpenTracker in BeOS or Explorer in Windows,
find path from which binary was run and change dir to it
so all files will be local :) */
@ -22346,14 +22322,16 @@ static void chdir_to_binary(char *argv0)
char *app_path = strdup(argv0);
char *slash = strrchr(app_path, '/');
#if defined(__APPLE__) //EP added to fix 10.9 issue of current directory set by Finder to something else than folder where app bundle resides
// typical path of app's binary on Mac OS : /Applications/Tux Paint.app/Contents/MacOS/Tux Paint
int levels = 3; // we need to back up 3 levels
#if defined(__APPLE__)
/* EP added to fix 10.9 issue of current directory set by Finder
to something else than folder where app bundle resides */
/* typical path of app's binary on Mac OS : /Applications/Tux Paint.app/Contents/MacOS/Tux Paint */
int levels = 3; /* we need to back up 3 levels */
while ((levels-- > 0) && (slash))
{
*slash = '\0'; // this overwrites the \0 at end of string
slash = strrchr(app_path, '/'); // so we can carry on our back-pedaling...
*slash = '\0'; /* this overwrites the \0 at end of string */
slash = strrchr(app_path, '/'); /* so we can carry on our back-pedaling... */
}
#endif
@ -22375,7 +22353,7 @@ static void chdir_to_binary(char *argv0)
#endif
}
/////////////////////////////////////////////////////////////////////
/* ================================================================================== */
static void setup_colors(void)
{
@ -22403,8 +22381,8 @@ static void setup_colors(void)
do
{
fgets(str, sizeof(str), fi);
if (fgets(str, sizeof(str), fi))
{
if (!feof(fi))
{
if (NUM_COLORS + 1 > max)
@ -22465,6 +22443,7 @@ static void setup_colors(void)
}
}
}
}
while (!feof(fi));
if (NUM_COLORS < 2)
@ -22534,7 +22513,7 @@ static void setup_colors(void)
}
//////////////////////////////////////////////////////////////////
/* ================================================================================== */
static void do_lock_file(void)
{
@ -22634,7 +22613,8 @@ int TP_EventFilter(const SDL_Event * event)
return 0;
}
/////////////////////////////////////////////////////////////////////////////
/* ================================================================================== */
static void setup(void)
{
int i;
@ -23587,22 +23567,9 @@ static void setup(void)
signal(SIGPIPE, signal_handler);
#endif
/* Call this once */
//EP now deprecated
/*
#if !defined(NOSVG) && !defined(OLD_SVG)
#ifdef DEBUG
printf("rsvg_init()\n"); fflush(stdout);
#endif
rsvg_init();
#endif
*/
}
/////////////////////////////////////////////////////////////////////////////
/* ================================================================================== */
static void claim_to_be_ready(void)
{
@ -23704,7 +23671,7 @@ static void claim_to_be_ready(void)
draw_tux_text(tool_tux[cur_tool], tool_tips[cur_tool], 1);
}
////////////////////////////////////////////////////////////////////////////
/* ================================================================================== */
int main(int argc, char *argv[])
{
@ -23717,14 +23684,15 @@ int main(int argc, char *argv[])
CLOCK_ASM(time1);
// do not add code (slowness) here unless required for scanning fonts
/* do not add code (slowness) here unless required for scanning fonts */
progname = argv[0];
#if defined(DEBUG) && defined(__APPLE__) //EP added block to log messages
freopen("/tmp/tuxpaint.log", "w", stdout); // redirect stdout to a file
dup2(fileno(stdout), fileno(stderr)); // redirect stderr to stdout
setvbuf(stdout, NULL, _IONBF, 0); // we don't want buffering to avoid de-sync'ing stdout and stderr
setvbuf(stderr, NULL, _IONBF, 0); // we don't want buffering to avoid de-sync'ing stdout and stderr
#if defined(DEBUG) && defined(__APPLE__)
/* EP added block to log messages */
freopen("/tmp/tuxpaint.log", "w", stdout); /* redirect stdout to a file */
dup2(fileno(stdout), fileno(stderr)); /* redirect stderr to stdout */
setvbuf(stdout, NULL, _IONBF, 0); /* we don't want buffering to avoid de-sync'ing stdout and stderr */
setvbuf(stderr, NULL, _IONBF, 0); /* we don't want buffering to avoid de-sync'ing stdout and stderr */
char logTime[100];
time_t t = time(NULL);
@ -23737,7 +23705,7 @@ int main(int argc, char *argv[])
CLOCK_ASM(time2);
#ifdef FORKED_FONTS
// must start ASAP, but depends on locale which in turn needs the config
/* must start ASAP, but depends on locale which in turn needs the config */
#ifdef NO_SDLPANGO
/* Only fork it now if we're not planning on creating a thread to handle fontconfig stuff -bjk 2010.04.27 */
#ifdef DEBUG
@ -23805,7 +23773,7 @@ static int trash(char *path)
char deldate[32];
struct tm tim;
time_t now;
int cnt;
int cnt, tmp;
FILE *fi, *fo;
unsigned char buf[1024];
size_t len;
@ -23821,7 +23789,7 @@ static int trash(char *path)
return (unlink(path));
}
printf("trash: basename=%s", basename(path)); //EP
printf("trash: basename=%s", basename(path)); /* EP */
strcpy(fname, basename(path));
if (!file_exists(path))
@ -23945,7 +23913,7 @@ static int trash(char *path)
-bjk 2011.04.18 */
/* FIXME: Is this sufficient to find 'dbus-send' (rely on system to use $PATH?) -bjk 2011.04.18 */
system("dbus-send / org.kde.KDirNotify.FilesAdded string:trash:/");
tmp = system("dbus-send / org.kde.KDirNotify.FilesAdded string:trash:/");
/* Note: GNOME figures out when things change because it asks the Kernel
@ -24008,7 +23976,6 @@ static void handle_joyaxismotion(SDL_Event event, int *motioner, int *val_x, int
else
*val_y = 0;
// printf("i %d valx %d j %d val_y %d\n", i, val_x, j, val_y);
if (*val_x || *val_y)
{
*motioner = TRUE;