Debug output clean-up

Wrapped some debug output in "#ifdef DEBUG" tests,
and made sure some warnings and errors were going to
STDERR, rather than STDOUT.

Motivation: Less noise while launching/using Tux Paint,
unless it matters.
This commit is contained in:
Bill Kendrick 2020-04-02 22:15:13 -07:00
parent b9c929a0a1
commit 91505fae8e
6 changed files with 131 additions and 68 deletions

View file

@ -31,6 +31,10 @@ $Id$
* macOS build documentation updates. * macOS build documentation updates.
Mark K. Kim <markuskimius@gmail.com> Mark K. Kim <markuskimius@gmail.com>
* Wrapped some debug output in "#ifdef DEBUG" tests,
and made sure some warnings and errors were going to
STDERR, rather than STDOUT.
* Other Improvements * Other Improvements
------------------ ------------------
* Added ability to move color palette options to the end of * Added ability to move color palette options to the end of

View file

@ -1,7 +1,7 @@
/* /*
fonts.c fonts.c
Copyright (c) 2009-2017 Copyright (c) 2009-2020
http://www.tuxpaint.org/ http://www.tuxpaint.org/
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
@ -901,7 +901,7 @@ static void groupfonts(void)
//printf("groupfonts() qsort(user_font_families 2...)\n"); //printf("groupfonts() qsort(user_font_families 2...)\n");
//fflush(stdout); //fflush(stdout);
if (num_font_families > 0 && user_font_families[0]->score < 0) if (num_font_families > 0 && user_font_families[0]->score < 0)
printf("sorted the wrong way, or all fonts were unusable\n"); fprintf(stderr, "sorted the wrong way, or all fonts were unusable\n");
#if 0 #if 0
// THREADED_FONTS // THREADED_FONTS
printf("Trim starting with %d families\n", num_font_families); printf("Trim starting with %d families\n", num_font_families);
@ -1219,7 +1219,7 @@ void receive_some_font_info(SDL_Surface * screen)
waitpid(font_scanner_pid, &status, 0); waitpid(font_scanner_pid, &status, 0);
if (WIFSIGNALED(status) || font_thread_aborted) if (WIFSIGNALED(status) || font_thread_aborted)
{ {
printf("child killed by signal %u\n", WTERMSIG(status)); fprintf(stderr, "child killed by signal %u\n", WTERMSIG(status));
user_font_families = NULL; user_font_families = NULL;
num_font_families = 0; num_font_families = 0;
font_thread_done = 1; font_thread_done = 1;
@ -1451,7 +1451,7 @@ static int do_surfcmp(const SDL_Surface * const *const v1, const SDL_Surface * c
if (s1 == s2) if (s1 == s2)
{ {
printf("s1==s2?\n"); fprintf(stderr, "s1==s2?\n");
return 0; return 0;
} }
if (!s1 || !s2 || !s1->w || !s2->w || !s1->h || !s2->h || !s1->format || !s2->format) if (!s1 || !s2 || !s1->w || !s2->w || !s1->h || !s2->h || !s1->format || !s2->format)
@ -1557,7 +1557,7 @@ out:
while (count--) while (count--)
{ {
if (surfs[count] == NULL) if (surfs[count] == NULL)
printf("TRYING TO RE-FREE!"); fprintf(stderr, "TRYING TO RE-FREE!");
else else
{ {
SDL_FreeSurface(surfs[count]); SDL_FreeSurface(surfs[count]);

View file

@ -4,7 +4,7 @@
For Tux Paint For Tux Paint
Language-related functions Language-related functions
Copyright (c) 2002-2019 by Bill Kendrick and others Copyright (c) 2002-2020 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 - August 29, 2019 June 14, 2002 - April 2, 2020
*/ */
#include <stdio.h> #include <stdio.h>

View file

@ -1,3 +1,25 @@
/*
onscreen_keyboard.c
Copyright (c) 2020
http://www.tuxpaint.org/
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
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt)
*/
#include "onscreen_keyboard.h" #include "onscreen_keyboard.h"
//#define DEBUG_OSK_COMPOSEMAP //#define DEBUG_OSK_COMPOSEMAP
@ -79,14 +101,14 @@ struct osk_keyboard *osk_create(char *layout_name, SDL_Surface * canvas, SDL_Sur
layout = load_layout(keyboard, layout_name); layout = load_layout(keyboard, layout_name);
if (!layout) if (!layout)
{ {
printf("Error trying to load the required layout %s\n", layout_name); fprintf(stderr, "Error trying to load the required layout %s\n", layout_name);
layout = load_layout(keyboard, strdup("default.layout")); layout = load_layout(keyboard, strdup("default.layout"));
if (!layout) if (!layout)
{ {
printf("Error trying to load the default layout\n"); fprintf(stderr, "Error trying to load the default layout\n");
return NULL; return NULL;
} }
printf("Loaded the default layout instead.\n"); fprintf(stderr, "Loaded the default layout instead.\n");
} }
#ifdef DEBUG #ifdef DEBUG
@ -100,7 +122,7 @@ struct osk_keyboard *osk_create(char *layout_name, SDL_Surface * canvas, SDL_Sur
canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask, 0); canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask, 0);
if (!surface) if (!surface)
{ {
printf("Error creating the onscreen keyboard surface\n"); fprintf(stderr, "Error creating the onscreen keyboard surface\n");
return NULL; return NULL;
} }
// keyboard->name = layout_name; // keyboard->name = layout_name;
@ -177,7 +199,7 @@ static struct osk_layout *load_layout(on_screen_keyboard * keyboard, char *layou
fi = fopen(filename, "r"); fi = fopen(filename, "r");
if (fi == NULL) if (fi == NULL)
{ {
printf("Can't open either %s nor %s\n", layout_name, filename); fprintf(stderr, "Can't open either %s nor %s\n", layout_name, filename);
/* Fallback to default */ /* Fallback to default */
snprintf(filename, 255, "%sosk/default.layout", DATA_PREFIX); snprintf(filename, 255, "%sosk/default.layout", DATA_PREFIX);
fi = fopen(filename, "r"); fi = fopen(filename, "r");
@ -195,7 +217,7 @@ static struct osk_layout *load_layout(on_screen_keyboard * keyboard, char *layou
free(filename); free(filename);
if (fi == NULL) if (fi == NULL)
{ {
printf("Can't load the on screen keyboard layout\n"); fprintf(stderr, "Can't load the on screen keyboard layout\n");
return NULL; return NULL;
} }
@ -297,7 +319,7 @@ void load_hlayout(osk_layout * layout, char *hlayout_name)
fi = fopen(filename, "r"); fi = fopen(filename, "r");
if (fi == NULL) if (fi == NULL)
{ {
printf("Can't open either %s nor %s\n", hlayout_name, filename); fprintf(stderr, "Can't open either %s nor %s\n", hlayout_name, filename);
layout->keys = NULL; layout->keys = NULL;
free(filename); free(filename);
return; return;
@ -482,7 +504,7 @@ void load_keymap(osk_layout * layout, char *keymap_name)
fi = fopen(filename, "r"); fi = fopen(filename, "r");
if (fi == NULL) if (fi == NULL)
{ {
printf("Can't open either %s nor %s\n", keymap_name, filename); fprintf(stderr, "Can't open either %s nor %s\n", keymap_name, filename);
layout->keys = NULL; layout->keys = NULL;
free(filename); free(filename);
return; return;
@ -670,7 +692,7 @@ static void load_composemap(osk_layout * layout, char *composemap_name)
fi = fopen(filename, "r"); fi = fopen(filename, "r");
if (fi == NULL) if (fi == NULL)
{ {
printf("Can't open either %s nor %s\n", composemap_name, filename); fprintf(stderr, "Can't open either %s nor %s\n", composemap_name, filename);
layout->keys = NULL; layout->keys = NULL;
free(filename); free(filename);
return; return;
@ -778,7 +800,7 @@ static void load_keysymdefs(osk_layout * layout, char *keysymdefs_name)
fi = fopen(filename, "r"); fi = fopen(filename, "r");
if (fi == NULL) if (fi == NULL)
{ {
printf("Can't open either %s nor %s\n", keysymdefs_name, filename); fprintf(stderr, "Can't open either %s nor %s\n", keysymdefs_name, filename);
layout->keysymdefs = NULL; layout->keysymdefs = NULL;
free(filename); free(filename);
return; return;

View file

@ -221,9 +221,9 @@ void parse_one_option(struct cfginfo *restrict tmpcfg, const char *str, const ch
opt = "yes"; opt = "yes";
} else if (strcmp(opt, "yes")) { } else if (strcmp(opt, "yes")) {
if(src) if(src)
printf("Option '%s' in config file '%s' is yes/ask/new only, but got '%s'\n",str,src,opt); fprintf(stderr, "Option '%s' in config file '%s' is yes/ask/new only, but got '%s'\n",str,src,opt);
else else
printf("Command line option '--%s' is yes/ask/new only, but got '%s'\n",str,opt); fprintf(stderr, "Command line option '--%s' is yes/ask/new only, but got '%s'\n",str,opt);
exit(51); exit(51);
} }
} }
@ -237,9 +237,9 @@ void parse_one_option(struct cfginfo *restrict tmpcfg, const char *str, const ch
if(!cfg || (!(flags & BOOLMASK) && noflag) ) if(!cfg || (!(flags & BOOLMASK) && noflag) )
{ {
if(src) if(src)
printf("Unknown option '%s' in config file '%s'\n",str,src); fprintf(stderr, "Unknown option '%s' in config file '%s'\n",str,src);
else else
printf("Unknown command line option '--%s'\n",str); fprintf(stderr, "Unknown command line option '--%s'\n",str);
exit(47); exit(47);
} }
@ -248,12 +248,12 @@ void parse_one_option(struct cfginfo *restrict tmpcfg, const char *str, const ch
if(src) if(src)
{ {
// immediate options are only for the command line // immediate options are only for the command line
printf("Unknown option '%s' in config file '%s'\n",str,src); fprintf(stderr, "Unknown option '%s' in config file '%s'\n",str,src);
exit(49); exit(49);
} }
if(opt) if(opt)
{ {
printf("Command line option '--%s' doesn't take a value.\n",str); fprintf(stderr, "Command line option '--%s' doesn't take a value.\n",str);
exit(50); exit(50);
} }
cfg->val(); cfg->val();
@ -272,18 +272,18 @@ void parse_one_option(struct cfginfo *restrict tmpcfg, const char *str, const ch
else else
{ {
if(src) if(src)
printf("Option '%s' in config file '%s' is yes/no only, but got '%s'\n",str,src,opt); fprintf(stderr, "Option '%s' in config file '%s' is yes/no only, but got '%s'\n",str,src,opt);
else else
printf("Command line option '--%s' is yes/no only, but got '%s'\n",str,opt); fprintf(stderr, "Command line option '--%s' is yes/no only, but got '%s'\n",str,opt);
exit(51); exit(51);
} }
} }
else if(!opt || !*opt) else if(!opt || !*opt)
{ {
if(src) if(src)
printf("Option '%s' in config file '%s' needs a value\n",str,src); fprintf(stderr, "Option '%s' in config file '%s' needs a value\n",str,src);
else else
printf("Command line option '--%s' needs a value\n",str); fprintf(stderr, "Command line option '--%s' needs a value\n",str);
exit(52); exit(52);
} }
@ -293,9 +293,9 @@ void parse_one_option(struct cfginfo *restrict tmpcfg, const char *str, const ch
if(dupecheck) if(dupecheck)
{ {
if(src) if(src)
printf("Option '%s' in config file '%s' sets '%s' again.\n",str,src,cfg->name); fprintf(stderr, "Option '%s' in config file '%s' sets '%s' again.\n",str,src,cfg->name);
else else
printf("Command line option '--%s' sets '%s' again.\n",str,cfg->name); fprintf(stderr, "Command line option '--%s' sets '%s' again.\n",str,cfg->name);
exit(53); exit(53);
} }

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 1, 2020 June 14, 2002 - April 2, 2020
*/ */
@ -1477,7 +1477,7 @@ static SDL_Surface *render_text(TuxPaint_Font * restrict font, const char *restr
if (font == NULL) if (font == NULL)
{ {
printf("render_text() received a NULL font!\n"); fprintf(stderr, "render_text() received a NULL font!\n");
fflush(stdout); fflush(stdout);
return NULL; return NULL;
} }
@ -2360,7 +2360,9 @@ static void mainloop(void)
#ifndef NOSOUND #ifndef NOSOUND
if (use_sound) if (use_sound)
{ {
#ifdef DEBUG
printf("modstate at mainloop %d, mod %d\n", SDL_GetModState(), mod); printf("modstate at mainloop %d, mod %d\n", SDL_GetModState(), mod);
#endif
mute = !mute; mute = !mute;
Mix_HaltChannel(-1); Mix_HaltChannel(-1);
@ -3103,7 +3105,9 @@ static void mainloop(void)
onscreen_keyboard_disable_change); onscreen_keyboard_disable_change);
} }
if (kbd == NULL) if (kbd == NULL)
printf("kbd = NULL\n"); {
fprintf(stderr, "kbd = NULL\n");
}
else else
{ {
kbd_rect.x = button_w * 2 + (canvas->w - kbd->surface->w) / 2; kbd_rect.x = button_w * 2 + (canvas->w - kbd->surface->w) / 2;
@ -7702,7 +7706,7 @@ int generate_fontconfig_cache_spinner(SDL_Surface * screen)
{ {
if (event.type == SDL_QUIT || (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_ESCAPE)) if (event.type == SDL_QUIT || (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_ESCAPE))
{ {
printf("Aborting!\n"); fprintf(stderr, "Aborting!\n");
fflush(stdout); fflush(stdout);
return (1); return (1);
} }
@ -8579,7 +8583,7 @@ static void draw_fonts(void)
if (tmp_surf_1 == NULL) if (tmp_surf_1 == NULL)
{ {
printf("render_text() returned NULL!\n"); fprintf(stderr, "render_text() returned NULL!\n");
return; return;
} }
@ -11372,8 +11376,9 @@ static void load_starter_id(char *saved_id, FILE * fil)
tmp_ptr = 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? */ #ifdef DEBUG
printf("template = %s\n (Personal=%d)", template_id, template_personal); printf("template = %s\n (Personal=%d)", template_id, template_personal);
#endif
} }
if (!feof(fi) && color_tag == 'M') if (!feof(fi) && color_tag == 'M')
{ {
@ -13440,13 +13445,17 @@ static void do_png_embed_data(png_structp png_ptr)
if (SDL_MUSTLOCK(img_starter_bkgd)) if (SDL_MUSTLOCK(img_starter_bkgd))
SDL_UnlockSurface(img_starter_bkgd); SDL_UnlockSurface(img_starter_bkgd);
#ifdef DEBUG
printf("%d \n", (int)compressedLen); printf("%d \n", (int)compressedLen);
#endif
compress(compressed_data, &compressedLen, sbk_pixs, img_starter_bkgd->h * img_starter_bkgd->w * 3); compress(compressed_data, &compressedLen, sbk_pixs, img_starter_bkgd->h * img_starter_bkgd->w * 3);
set_chunk_data(&chunk_data, &chunk_data_len, img_starter_bkgd->w * img_starter_bkgd->h * 3, compressed_data, set_chunk_data(&chunk_data, &chunk_data_len, img_starter_bkgd->w * img_starter_bkgd->h * 3, compressed_data,
compressedLen); compressedLen);
#ifdef DEBUG
printf("%d \n", (int)compressedLen); printf("%d \n", (int)compressedLen);
#endif
tuxpaint_chunks[2].data = (png_byte *) chunk_data; tuxpaint_chunks[2].data = (png_byte *) chunk_data;
@ -13627,7 +13636,9 @@ static void do_png_embed_data(png_structp png_ptr)
fprintf(lfi, "\n\n"); fprintf(lfi, "\n\n");
} }
current_node = current_node->next_to_up_label_node; current_node = current_node->next_to_up_label_node;
#ifdef DEBUG
printf("cur %p, red %p\n", current_node, first_label_node_in_redo_stack); printf("cur %p, red %p\n", current_node, first_label_node_in_redo_stack);
#endif
} }
#ifdef fmemopen_alternative #ifdef fmemopen_alternative
@ -21365,7 +21376,9 @@ static void load_info_about_label_surface(FILE * lfi)
new_node->save_y = tmp_pos; new_node->save_y = tmp_pos;
} }
#ifdef DEBUG
printf("Original label size %dx%d\n", new_node->save_width, new_node->save_height); printf("Original label size %dx%d\n", new_node->save_width, new_node->save_height);
#endif
tmp_fscanf_return = fscanf(lfi, "%d\n", &new_node->save_cur_font); tmp_fscanf_return = fscanf(lfi, "%d\n", &new_node->save_cur_font);
new_node->save_cur_font = 0; new_node->save_cur_font = 0;
@ -21824,7 +21837,7 @@ Bytef *get_chunk_data(FILE * fp, char *fname, png_structp png_ptr,
if (f > 3) if (f > 3)
{ {
comp_buff[i - count] = unknown.data[i]; comp_buff[i - count] = unknown.data[i];
// printf("%d, %d, %d ",i-count, comp_buff[i - count], unknown.data[i]); // printf("%d, %d, %d ",i-count, comp_buff[i - count], unknown.data[i]);
} }
if (unknown.data[i] == '\n' && f < 4) if (unknown.data[i] == '\n' && f < 4)
@ -21870,13 +21883,13 @@ Bytef *get_chunk_data(FILE * fp, char *fname, png_structp png_ptr,
if (unc_err != Z_STREAM_END) if (unc_err != Z_STREAM_END)
{ {
printf("\n error %d, unc %d, comp %d\n", unc_err, *unc_size, comp); fprintf(stderr, "\n error %d, unc %d, comp %d\n", unc_err, *unc_size, comp);
fclose(fp); fclose(fp);
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) NULL); png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) NULL);
free(comp_buff); free(comp_buff);
free(unc_buff); free(unc_buff);
printf("Can't recover the embedded data in %s, error in uncompressing data from %s\n\n", fname, chunk_name); fprintf(stderr, "Can't recover the embedded data in %s, error in uncompressing data from %s\n\n", fname, chunk_name);
draw_tux_text(TUX_OOPS, strerror(errno), 0); draw_tux_text(TUX_OOPS, strerror(errno), 0);
return (NULL); return (NULL);
} }
@ -21910,8 +21923,10 @@ void load_embedded_data(char *fname, SDL_Surface * org_surf)
png_uint_32 ww, hh; png_uint_32 ww, hh;
png_uint_32 i, j; png_uint_32 i, j;
#ifdef DEBUG
printf("Loading embedded data...\n"); printf("Loading embedded data...\n");
printf("%s\n", fname); printf("%s\n", fname);
#endif
fp = fopen(fname, "rb"); fp = fopen(fname, "rb");
if (!fp) if (!fp)
@ -21933,7 +21948,9 @@ void load_embedded_data(char *fname, SDL_Surface * org_surf)
} }
else else
{ {
#ifdef DEBUG
printf("%s\n", fname); printf("%s\n", fname);
#endif
info_ptr = png_create_info_struct(png_ptr); info_ptr = png_create_info_struct(png_ptr);
if (info_ptr == NULL) if (info_ptr == NULL)
@ -21958,7 +21975,9 @@ void load_embedded_data(char *fname, SDL_Surface * org_surf)
num_unknowns = (int)png_get_unknown_chunks(png_ptr, info_ptr, &unknowns); num_unknowns = (int)png_get_unknown_chunks(png_ptr, info_ptr, &unknowns);
#ifdef DEBUG
printf("num_unknowns %i\n", num_unknowns); printf("num_unknowns %i\n", num_unknowns);
#endif
if (num_unknowns) if (num_unknowns)
{ {
have_label_delta = have_label_data = have_background = have_foreground = FALSE; have_label_delta = have_label_data = have_background = have_foreground = FALSE;
@ -21972,11 +21991,15 @@ void load_embedded_data(char *fname, SDL_Surface * org_surf)
blured when scaled one) */ blured when scaled one) */
for (u = 0; u < num_unknowns; u++) for (u = 0; u < num_unknowns; u++)
{ {
#ifdef DEBUG
printf("%s, %d\n", unknowns[u].name, (int)unknowns[u].size); printf("%s, %d\n", unknowns[u].name, (int)unknowns[u].size);
#endif
if (chunk_is_valid("tpDT", unknowns[u])) if (chunk_is_valid("tpDT", unknowns[u]))
{ {
#ifdef DEBUG
printf("Valid tpDT\n"); printf("Valid tpDT\n");
#endif
fi = fmemopen(unknowns[u].data, unknowns[u].size, "r"); fi = fmemopen(unknowns[u].data, unknowns[u].size, "r");
if (fi == NULL) if (fi == NULL)
{ {
@ -22037,7 +22060,9 @@ void load_embedded_data(char *fname, SDL_Surface * org_surf)
{ {
if (chunk_is_valid("tpLD", unknowns[u])) if (chunk_is_valid("tpLD", unknowns[u]))
{ {
#ifdef DEBUG
printf("Valid tpLD\n"); printf("Valid tpLD\n");
#endif
unc_buff = get_chunk_data(fp, fname, png_ptr, info_ptr, "tpLD", unknowns[u], &unc_size); unc_buff = get_chunk_data(fp, fname, png_ptr, info_ptr, "tpLD", unknowns[u], &unc_size);
if (unc_buff == NULL) if (unc_buff == NULL)
@ -22076,7 +22101,9 @@ void load_embedded_data(char *fname, SDL_Surface * org_surf)
/* Label Data */ /* Label Data */
if (!disable_label && chunk_is_valid("tpLL", unknowns[u])) if (!disable_label && chunk_is_valid("tpLL", unknowns[u]))
{ {
#ifdef DEBUG
printf("Valid tpLL\n"); printf("Valid tpLL\n");
#endif
unc_buff = get_chunk_data(fp, fname, png_ptr, info_ptr, "tpLL", unknowns[u], &unc_size); unc_buff = get_chunk_data(fp, fname, png_ptr, info_ptr, "tpLL", unknowns[u], &unc_size);
if (unc_buff == NULL) if (unc_buff == NULL)
@ -22089,7 +22116,7 @@ void load_embedded_data(char *fname, SDL_Surface * org_surf)
fi = fmemopen(unc_buff, unc_size, "rb"); fi = fmemopen(unc_buff, unc_size, "rb");
if (fi == NULL) if (fi == NULL)
{ {
printf("Can't recover the label data embedded in %s, error in create file stream\n\n", fprintf(stderr, "Can't recover the label data embedded in %s, error in create file stream\n\n",
fname); fname);
fclose(fp); fclose(fp);
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) NULL); png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) NULL);
@ -22105,7 +22132,9 @@ void load_embedded_data(char *fname, SDL_Surface * org_surf)
free(unc_buff); free(unc_buff);
ldata = TRUE; ldata = TRUE;
#ifdef DEBUG
printf("Out of label data\n"); printf("Out of label data\n");
#endif
} }
} }
} }
@ -22130,8 +22159,10 @@ void load_embedded_data(char *fname, SDL_Surface * org_surf)
canvas->format->Rmask, canvas->format->Gmask, canvas->format->Gmask, 0); canvas->format->Rmask, canvas->format->Gmask, canvas->format->Gmask, 0);
if (aux_surf == NULL) if (aux_surf == NULL)
{ {
printf("Can't recover the background data embedded in %s, error in create aux image\n\n", #ifdef DEBUG
fprintf(stderr, "Can't recover the background data embedded in %s, error in create aux image\n\n",
fname); fname);
#endif
fclose(fp); fclose(fp);
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) NULL); png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) NULL);
free(unc_buff); free(unc_buff);
@ -22143,7 +22174,9 @@ void load_embedded_data(char *fname, SDL_Surface * org_surf)
} }
SDL_LockSurface(aux_surf); SDL_LockSurface(aux_surf);
#ifdef DEBUG
printf("Bkgd!!!\n"); printf("Bkgd!!!\n");
#endif
for (j = 0; j < hh; j++) for (j = 0; j < hh; j++)
for (i = 0; i < ww; i++) for (i = 0; i < ww; i++)
putpixels[aux_surf->format->BytesPerPixel] (aux_surf, i, j, putpixels[aux_surf->format->BytesPerPixel] (aux_surf, i, j,
@ -22173,7 +22206,9 @@ void load_embedded_data(char *fname, SDL_Surface * org_surf)
if ((starter_modified || !img_starter) && chunk_is_valid("tpFG", unknowns[u])) if ((starter_modified || !img_starter) && chunk_is_valid("tpFG", unknowns[u]))
{ {
#ifdef DEBUG
printf("Frgd!!!\n"); printf("Frgd!!!\n");
#endif
unc_buff = get_chunk_data(fp, fname, png_ptr, info_ptr, "tpFG", unknowns[u], &unc_size); unc_buff = get_chunk_data(fp, fname, png_ptr, info_ptr, "tpFG", unknowns[u], &unc_size);
if (unc_buff == NULL) if (unc_buff == NULL)
@ -22185,7 +22220,7 @@ void load_embedded_data(char *fname, SDL_Surface * org_surf)
canvas->format->Gmask, canvas->format->Gmask, TPAINT_AMASK); canvas->format->Gmask, canvas->format->Gmask, TPAINT_AMASK);
if (aux_surf == NULL) if (aux_surf == NULL)
{ {
printf("Can't recover the foreground data embedded in %s, error in create aux image\n\n", fprintf(stderr, "Can't recover the foreground data embedded in %s, error in create aux image\n\n",
fname); fname);
fclose(fp); fclose(fp);
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) NULL); png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) NULL);
@ -22691,7 +22726,7 @@ static void setup_config(char *argv[])
{ {
if (strtof(tmpcfg.joystick_dev, NULL) < 0 || strtof(tmpcfg.joystick_dev, NULL) > 100) if (strtof(tmpcfg.joystick_dev, NULL) < 0 || strtof(tmpcfg.joystick_dev, NULL) > 100)
{ {
printf("Joystick dev (now %s) must be between 0 and 100.\n", tmpcfg.joystick_dev); fprintf(stderr, "Joystick dev (now %s) must be between 0 and 100.\n", tmpcfg.joystick_dev);
exit(1); exit(1);
} }
joystick_dev = strtof(tmpcfg.joystick_dev, NULL); joystick_dev = strtof(tmpcfg.joystick_dev, NULL);
@ -22701,7 +22736,7 @@ static void setup_config(char *argv[])
{ {
if (strtof(tmpcfg.joystick_slowness, NULL) < 0 || strtof(tmpcfg.joystick_slowness, NULL) > 500) if (strtof(tmpcfg.joystick_slowness, NULL) < 0 || strtof(tmpcfg.joystick_slowness, NULL) > 500)
{ {
printf("Joystick slowness (now %s) must be between 0 and 500.\n", tmpcfg.joystick_slowness); fprintf(stderr, "Joystick slowness (now %s) must be between 0 and 500.\n", tmpcfg.joystick_slowness);
exit(1); exit(1);
} }
joystick_slowness = strtof(tmpcfg.joystick_slowness, NULL); joystick_slowness = strtof(tmpcfg.joystick_slowness, NULL);
@ -22711,7 +22746,7 @@ static void setup_config(char *argv[])
if (strtof(tmpcfg.joystick_lowthreshold, NULL) < 0 || strtof(tmpcfg.joystick_lowthreshold, NULL) > 32766) if (strtof(tmpcfg.joystick_lowthreshold, NULL) < 0 || strtof(tmpcfg.joystick_lowthreshold, NULL) > 32766)
{ {
/* FIXME: Find better exit code */ /* FIXME: Find better exit code */
printf("Joystick lower threshold (now %s) must be between 0 and 32766", tmpcfg.joystick_lowthreshold); fprintf(stderr, "Joystick lower threshold (now %s) must be between 0 and 32766", tmpcfg.joystick_lowthreshold);
exit(1); exit(1);
} }
joystick_low_threshold = strtof(tmpcfg.joystick_lowthreshold, NULL); joystick_low_threshold = strtof(tmpcfg.joystick_lowthreshold, NULL);
@ -22721,7 +22756,7 @@ static void setup_config(char *argv[])
if (strtof(tmpcfg.joystick_maxsteps, NULL) < 1 || strtof(tmpcfg.joystick_maxsteps, NULL) > 7) if (strtof(tmpcfg.joystick_maxsteps, NULL) < 1 || strtof(tmpcfg.joystick_maxsteps, NULL) > 7)
{ {
/* FIXME: Find better exit code */ /* FIXME: Find better exit code */
printf("Joystick max steps (now %s) must be between 1 and 7", tmpcfg.joystick_maxsteps); fprintf(stderr, "Joystick max steps (now %s) must be between 1 and 7", tmpcfg.joystick_maxsteps);
exit(1); exit(1);
} }
joystick_maxsteps = strtof(tmpcfg.joystick_maxsteps, NULL); joystick_maxsteps = strtof(tmpcfg.joystick_maxsteps, NULL);
@ -22730,7 +22765,7 @@ static void setup_config(char *argv[])
{ {
if (strtof(tmpcfg.joystick_hat_slowness, NULL) < 0 || strtof(tmpcfg.joystick_hat_slowness, NULL) > 500) if (strtof(tmpcfg.joystick_hat_slowness, NULL) < 0 || strtof(tmpcfg.joystick_hat_slowness, NULL) > 500)
{ {
printf("Joystick hat slowness (now %s) must be between 0 and 500.\n", tmpcfg.joystick_hat_slowness); fprintf(stderr, "Joystick hat slowness (now %s) must be between 0 and 500.\n", tmpcfg.joystick_hat_slowness);
exit(1); exit(1);
} }
joystick_hat_slowness = strtof(tmpcfg.joystick_hat_slowness, NULL); joystick_hat_slowness = strtof(tmpcfg.joystick_hat_slowness, NULL);
@ -22740,7 +22775,7 @@ static void setup_config(char *argv[])
if (strtof(tmpcfg.joystick_hat_timeout, NULL) < 0 || strtof(tmpcfg.joystick_hat_timeout, NULL) > 3000) if (strtof(tmpcfg.joystick_hat_timeout, NULL) < 0 || strtof(tmpcfg.joystick_hat_timeout, NULL) > 3000)
{ {
/* FIXME: Find better exit code */ /* FIXME: Find better exit code */
printf("Joystick hat timeout (now %s) must be between 0 and 3000", tmpcfg.joystick_hat_timeout); fprintf(stderr, "Joystick hat timeout (now %s) must be between 0 and 3000", tmpcfg.joystick_hat_timeout);
exit(1); exit(1);
} }
joystick_hat_timeout = strtof(tmpcfg.joystick_hat_timeout, NULL); joystick_hat_timeout = strtof(tmpcfg.joystick_hat_timeout, NULL);
@ -22750,7 +22785,7 @@ static void setup_config(char *argv[])
if (strtof(tmpcfg.joystick_button_escape, NULL) < 0 || strtof(tmpcfg.joystick_button_escape, NULL) > 254) if (strtof(tmpcfg.joystick_button_escape, NULL) < 0 || strtof(tmpcfg.joystick_button_escape, NULL) > 254)
{ {
/* FIXME: Find better exit code */ /* FIXME: Find better exit code */
printf("Joystick button escape shortcurt (now %s) must be between 0 and 254", tmpcfg.joystick_button_escape); fprintf(stderr, "Joystick button escape shortcurt (now %s) must be between 0 and 254", tmpcfg.joystick_button_escape);
exit(1); exit(1);
} }
joystick_button_escape = strtof(tmpcfg.joystick_button_escape, NULL); joystick_button_escape = strtof(tmpcfg.joystick_button_escape, NULL);
@ -22761,7 +22796,7 @@ static void setup_config(char *argv[])
|| strtof(tmpcfg.joystick_button_selectbrushtool, NULL) > 254) || strtof(tmpcfg.joystick_button_selectbrushtool, NULL) > 254)
{ {
/* FIXME: Find better exit code */ /* FIXME: Find better exit code */
printf("Joystick button brush tool shortcurt (now %s) must be between 0 and 254", fprintf(stderr, "Joystick button brush tool shortcurt (now %s) must be between 0 and 254",
tmpcfg.joystick_button_selectbrushtool); tmpcfg.joystick_button_selectbrushtool);
exit(1); exit(1);
} }
@ -22773,7 +22808,7 @@ static void setup_config(char *argv[])
|| strtof(tmpcfg.joystick_button_selectstamptool, NULL) > 254) || strtof(tmpcfg.joystick_button_selectstamptool, NULL) > 254)
{ {
/* FIXME: Find better exit code */ /* FIXME: Find better exit code */
printf("Joystick button stamp tool shortcurt (now %s) must be between 0 and 254", fprintf(stderr, "Joystick button stamp tool shortcurt (now %s) must be between 0 and 254",
tmpcfg.joystick_button_selectstamptool); tmpcfg.joystick_button_selectstamptool);
exit(1); exit(1);
} }
@ -22785,7 +22820,7 @@ static void setup_config(char *argv[])
|| strtof(tmpcfg.joystick_button_selectlinestool, NULL) > 254) || strtof(tmpcfg.joystick_button_selectlinestool, NULL) > 254)
{ {
/* FIXME: Find better exit code */ /* FIXME: Find better exit code */
printf("Joystick button lines tool shortcurt (now %s) must be between 0 and 254", fprintf(stderr, "Joystick button lines tool shortcurt (now %s) must be between 0 and 254",
tmpcfg.joystick_button_selectlinestool); tmpcfg.joystick_button_selectlinestool);
exit(1); exit(1);
} }
@ -22797,7 +22832,7 @@ static void setup_config(char *argv[])
|| strtof(tmpcfg.joystick_button_selectshapestool, NULL) > 254) || strtof(tmpcfg.joystick_button_selectshapestool, NULL) > 254)
{ {
/* FIXME: Find better exit code */ /* FIXME: Find better exit code */
printf("Joystick button shapes tool shortcurt (now %s) must be between 0 and 254", fprintf(stderr, "Joystick button shapes tool shortcurt (now %s) must be between 0 and 254",
tmpcfg.joystick_button_selectshapestool); tmpcfg.joystick_button_selectshapestool);
exit(1); exit(1);
} }
@ -22809,7 +22844,7 @@ static void setup_config(char *argv[])
|| strtof(tmpcfg.joystick_button_selecttexttool, NULL) > 254) || strtof(tmpcfg.joystick_button_selecttexttool, NULL) > 254)
{ {
/* FIXME: Find better exit code */ /* FIXME: Find better exit code */
printf("Joystick button text tool shortcurt (now %s) must be between 0 and 254", fprintf(stderr, "Joystick button text tool shortcurt (now %s) must be between 0 and 254",
tmpcfg.joystick_button_selecttexttool); tmpcfg.joystick_button_selecttexttool);
exit(1); exit(1);
} }
@ -22821,7 +22856,7 @@ static void setup_config(char *argv[])
|| strtof(tmpcfg.joystick_button_selectlabeltool, NULL) > 254) || strtof(tmpcfg.joystick_button_selectlabeltool, NULL) > 254)
{ {
/* FIXME: Find better exit code */ /* FIXME: Find better exit code */
printf("Joystick button label tool shortcurt (now %s) must be between 0 and 254", fprintf(stderr, "Joystick button label tool shortcurt (now %s) must be between 0 and 254",
tmpcfg.joystick_button_selectlabeltool); tmpcfg.joystick_button_selectlabeltool);
exit(1); exit(1);
} }
@ -22833,7 +22868,7 @@ static void setup_config(char *argv[])
|| strtof(tmpcfg.joystick_button_selectmagictool, NULL) > 254) || strtof(tmpcfg.joystick_button_selectmagictool, NULL) > 254)
{ {
/* FIXME: Find better exit code */ /* FIXME: Find better exit code */
printf("Joystick button magic tool shortcurt (now %s) must be between 0 and 254", fprintf(stderr, "Joystick button magic tool shortcurt (now %s) must be between 0 and 254",
tmpcfg.joystick_button_selectmagictool); tmpcfg.joystick_button_selectmagictool);
exit(1); exit(1);
} }
@ -22844,7 +22879,7 @@ static void setup_config(char *argv[])
if (strtof(tmpcfg.joystick_button_undo, NULL) < 0 || strtof(tmpcfg.joystick_button_undo, NULL) > 254) if (strtof(tmpcfg.joystick_button_undo, NULL) < 0 || strtof(tmpcfg.joystick_button_undo, NULL) > 254)
{ {
/* FIXME: Find better exit code */ /* FIXME: Find better exit code */
printf("Joystick button undo shortcurt (now %s) must be between 0 and 254", tmpcfg.joystick_button_undo); fprintf(stderr, "Joystick button undo shortcurt (now %s) must be between 0 and 254", tmpcfg.joystick_button_undo);
exit(1); exit(1);
} }
joystick_button_undo = strtof(tmpcfg.joystick_button_undo, NULL); joystick_button_undo = strtof(tmpcfg.joystick_button_undo, NULL);
@ -22854,7 +22889,7 @@ static void setup_config(char *argv[])
if (strtof(tmpcfg.joystick_button_redo, NULL) < 0 || strtof(tmpcfg.joystick_button_redo, NULL) > 254) if (strtof(tmpcfg.joystick_button_redo, NULL) < 0 || strtof(tmpcfg.joystick_button_redo, NULL) > 254)
{ {
/* FIXME: Find better exit code */ /* FIXME: Find better exit code */
printf("Joystick button redo shortcurt (now %s) must be between 0 and 254", tmpcfg.joystick_button_redo); fprintf(stderr, "Joystick button redo shortcurt (now %s) must be between 0 and 254", tmpcfg.joystick_button_redo);
exit(1); exit(1);
} }
joystick_button_redo = strtof(tmpcfg.joystick_button_redo, NULL); joystick_button_redo = strtof(tmpcfg.joystick_button_redo, NULL);
@ -22865,7 +22900,7 @@ static void setup_config(char *argv[])
|| strtof(tmpcfg.joystick_button_selecterasertool, NULL) > 254) || strtof(tmpcfg.joystick_button_selecterasertool, NULL) > 254)
{ {
/* FIXME: Find better exit code */ /* FIXME: Find better exit code */
printf("Joystick button eraser tool shortcurt (now %s) must be between 0 and 254", fprintf(stderr, "Joystick button eraser tool shortcurt (now %s) must be between 0 and 254",
tmpcfg.joystick_button_selecterasertool); tmpcfg.joystick_button_selecterasertool);
exit(1); exit(1);
} }
@ -22876,7 +22911,7 @@ static void setup_config(char *argv[])
if (strtof(tmpcfg.joystick_button_new, NULL) < 0 || strtof(tmpcfg.joystick_button_new, NULL) > 254) if (strtof(tmpcfg.joystick_button_new, NULL) < 0 || strtof(tmpcfg.joystick_button_new, NULL) > 254)
{ {
/* FIXME: Find better exit code */ /* FIXME: Find better exit code */
printf("Joystick button new shortcurt (now %s) must be between 0 and 254", tmpcfg.joystick_button_new); fprintf(stderr, "Joystick button new shortcurt (now %s) must be between 0 and 254", tmpcfg.joystick_button_new);
exit(1); exit(1);
} }
joystick_button_new = strtof(tmpcfg.joystick_button_new, NULL); joystick_button_new = strtof(tmpcfg.joystick_button_new, NULL);
@ -22886,7 +22921,7 @@ static void setup_config(char *argv[])
if (strtof(tmpcfg.joystick_button_open, NULL) < 0 || strtof(tmpcfg.joystick_button_open, NULL) > 254) if (strtof(tmpcfg.joystick_button_open, NULL) < 0 || strtof(tmpcfg.joystick_button_open, NULL) > 254)
{ {
/* FIXME: Find better exit code */ /* FIXME: Find better exit code */
printf("Joystick button open shortcurt (now %s) must be between 0 and 254", tmpcfg.joystick_button_open); fprintf(stderr, "Joystick button open shortcurt (now %s) must be between 0 and 254", tmpcfg.joystick_button_open);
exit(1); exit(1);
} }
joystick_button_open = strtof(tmpcfg.joystick_button_open, NULL); joystick_button_open = strtof(tmpcfg.joystick_button_open, NULL);
@ -22896,7 +22931,7 @@ static void setup_config(char *argv[])
if (strtof(tmpcfg.joystick_button_save, NULL) < 0 || strtof(tmpcfg.joystick_button_save, NULL) > 254) if (strtof(tmpcfg.joystick_button_save, NULL) < 0 || strtof(tmpcfg.joystick_button_save, NULL) > 254)
{ {
/* FIXME: Find better exit code */ /* FIXME: Find better exit code */
printf("Joystick button save shortcurt (now %s) must be between 0 and 254", tmpcfg.joystick_button_save); fprintf(stderr, "Joystick button save shortcurt (now %s) must be between 0 and 254", tmpcfg.joystick_button_save);
exit(1); exit(1);
} }
joystick_button_save = strtof(tmpcfg.joystick_button_save, NULL); joystick_button_save = strtof(tmpcfg.joystick_button_save, NULL);
@ -22906,7 +22941,7 @@ static void setup_config(char *argv[])
if (strtof(tmpcfg.joystick_button_pagesetup, NULL) < 0 || strtof(tmpcfg.joystick_button_pagesetup, NULL) > 254) if (strtof(tmpcfg.joystick_button_pagesetup, NULL) < 0 || strtof(tmpcfg.joystick_button_pagesetup, NULL) > 254)
{ {
/* FIXME: Find better exit code */ /* FIXME: Find better exit code */
printf("Joystick button page setup shortcurt (now %s) must be between 0 and 254", fprintf(stderr, "Joystick button page setup shortcurt (now %s) must be between 0 and 254",
tmpcfg.joystick_button_pagesetup); tmpcfg.joystick_button_pagesetup);
exit(1); exit(1);
} }
@ -22917,7 +22952,7 @@ static void setup_config(char *argv[])
if (strtof(tmpcfg.joystick_button_print, NULL) < 0 || strtof(tmpcfg.joystick_button_print, NULL) > 254) if (strtof(tmpcfg.joystick_button_print, NULL) < 0 || strtof(tmpcfg.joystick_button_print, NULL) > 254)
{ {
/* FIXME: Find better exit code */ /* FIXME: Find better exit code */
printf("Joystick button print shortcurt (now %s) must be between 0 and 254", tmpcfg.joystick_button_print); fprintf(stderr, "Joystick button print shortcurt (now %s) must be between 0 and 254", tmpcfg.joystick_button_print);
exit(1); exit(1);
} }
joystick_button_print = strtof(tmpcfg.joystick_button_print, NULL); joystick_button_print = strtof(tmpcfg.joystick_button_print, NULL);
@ -22932,7 +22967,7 @@ static void setup_config(char *argv[])
if (strtof(token, NULL) < 0 || strtof(token, NULL) > 254) if (strtof(token, NULL) < 0 || strtof(token, NULL) > 254)
{ {
/* FIXME: Find better exit code */ /* FIXME: Find better exit code */
printf("Joystick buttons must be between 0 and 254 (don't like %s)", tmpcfg.joystick_buttons_ignore); fprintf(stderr, "Joystick buttons must be between 0 and 254 (don't like %s)", tmpcfg.joystick_buttons_ignore);
exit(1); exit(1);
} }
joystick_buttons_ignore[joystick_buttons_ignore_len++] = strtof(token, NULL); joystick_buttons_ignore[joystick_buttons_ignore_len++] = strtof(token, NULL);
@ -23418,11 +23453,11 @@ static void setup(void)
if (joystick_dev == -1) if (joystick_dev == -1)
{ {
printf("%i joystick(s) were found:\n", SDL_NumJoysticks()); fprintf(stderr, "%i joystick(s) were found:\n", SDL_NumJoysticks());
for (i = 0; i < SDL_NumJoysticks(); i++) for (i = 0; i < SDL_NumJoysticks(); i++)
{ {
printf(" %d: %s\n", i, SDL_JoystickName(i)); fprintf(stderr, " %d: %s\n", i, SDL_JoystickName(i));
} }
SDL_Quit(); SDL_Quit();
@ -23718,8 +23753,8 @@ static void setup(void)
#endif #endif
if (generate_fontconfig_cache_spinner(screen)) /* returns 1 if aborted */ if (generate_fontconfig_cache_spinner(screen)) /* returns 1 if aborted */
{ {
printf("Pango thread aborted!\n"); fprintf(stderr, "Pango thread aborted!\n");
fflush(stdout); fflush(stderr);
SDL_KillThread(fontconfig_thread); SDL_KillThread(fontconfig_thread);
SDL_Quit(); SDL_Quit();
exit(0); exit(0);
@ -24525,7 +24560,9 @@ static int trash(char *path)
return (unlink(path)); return (unlink(path));
} }
#ifdef DEBUG
printf("trash: basename=%s", basename(path)); /* EP */ printf("trash: basename=%s", basename(path)); /* EP */
#endif
strcpy(fname, basename(path)); strcpy(fname, basename(path));
if (!file_exists(path)) if (!file_exists(path))