[Tux4kids-commits] r822 - in tuxtype/trunk: . src
dbruce-guest at alioth.debian.org
dbruce-guest at alioth.debian.org
Tue Jan 6 08:24:17 UTC 2009
Author: dbruce-guest
Date: 2009-01-06 08:24:17 +0000 (Tue, 06 Jan 2009)
New Revision: 822
Modified:
tuxtype/trunk/ChangeLog
tuxtype/trunk/ChangeLog~
tuxtype/trunk/src/SDL_extras.c
tuxtype/trunk/src/alphabet.c
tuxtype/trunk/src/loaders.c
tuxtype/trunk/src/practice.c
tuxtype/trunk/src/scripting.c
tuxtype/trunk/src/setup.c
tuxtype/trunk/src/theme.c
tuxtype/trunk/src/titlescreen.c
Log:
- Bugfix to prevent BlackOutline() from segfault if passed empty string
- incorporation of several small patches from OpenSuse (thanks Lars Vogdt)
Modified: tuxtype/trunk/ChangeLog
===================================================================
--- tuxtype/trunk/ChangeLog 2009-01-06 02:51:55 UTC (rev 821)
+++ tuxtype/trunk/ChangeLog 2009-01-06 08:24:17 UTC (rev 822)
@@ -1,3 +1,8 @@
+06 Jan 2009 - svn revision 822
+[ David Bruce <davidstuartbruce at gmail.com> ]
+ - Bugfix to prevent BlackOutline() from segfault if passed empty string
+ - incorporation of several small patches from OpenSuse (thanks Lars Vogdt)
+
05 Jan 2009 - svn revision 821
[ David Bruce <davidstuartbruce at gmail.com> ]
- Bugfix for path for bundled fonts - caused error when run on non-Debian
Modified: tuxtype/trunk/ChangeLog~
===================================================================
--- tuxtype/trunk/ChangeLog~ 2009-01-06 02:51:55 UTC (rev 821)
+++ tuxtype/trunk/ChangeLog~ 2009-01-06 08:24:17 UTC (rev 822)
@@ -1,3 +1,12 @@
+06 Jan 2009 - svn revision 822
+[ David Bruce <davidstuartbruce at gmail.com> ]
+ - Bugfix to prevent BlackOutline() from segfault if passed empty string
+
+05 Jan 2009 - svn revision 821
+[ David Bruce <davidstuartbruce at gmail.com> ]
+ - Bugfix for path for bundled fonts - caused error when run on non-Debian
+ systems.
+
2008-11-22 gettextize <bug-gnu-gettext at gnu.org>
* m4/gettext.m4: Upgrade to gettext-0.17.
Modified: tuxtype/trunk/src/SDL_extras.c
===================================================================
--- tuxtype/trunk/src/SDL_extras.c 2009-01-06 02:51:55 UTC (rev 821)
+++ tuxtype/trunk/src/SDL_extras.c 2009-01-06 08:24:17 UTC (rev 822)
@@ -381,11 +381,20 @@
SDL_Rect dstrect;
Uint32 color_key;
+ LOG("Entering BlackOutline()\n");
+
if (!t || !font || !c)
{
fprintf(stderr, "BlackOutline(): invalid ptr parameter, returning.");
return NULL;
}
+
+ if (t[0] == '\0')
+ {
+ fprintf(stderr, "BlackOutline(): empty string, returning");
+ return NULL;
+ }
+
#ifndef HAVE_LIBSDL_PANGO
black_letters = TTF_RenderUTF8_Blended(font, t, black);
@@ -460,6 +469,8 @@
out = SDL_DisplayFormatAlpha(bg);
SDL_FreeSurface(bg);
+ LOG("Leaving BlackOutline()\n");
+
return out;
}
@@ -529,14 +540,14 @@
SDL_Surface* BlackOutline_w(wchar_t* t, const TTF_Font* font, const SDL_Color* c, int size)
{
- wchar_t wchar_tmp[1024];
- char tmp[1024];
- int i;
- wcsncpy( wchar_tmp, t, size);
- wchar_tmp[size]=0;
- i=ConvertToUTF8( wchar_tmp, tmp);
- tmp[i]=0;
- return BlackOutline(tmp, font, c);
+ wchar_t wchar_tmp[1024];
+ char tmp[1024];
+ int i;
+ wcsncpy( wchar_tmp, t, size);
+ wchar_tmp[size] = 0;
+ i = ConvertToUTF8( wchar_tmp, tmp);
+ tmp[i] = 0;
+ return BlackOutline(tmp, font, c);
}
Modified: tuxtype/trunk/src/alphabet.c
===================================================================
--- tuxtype/trunk/src/alphabet.c 2009-01-06 02:51:55 UTC (rev 821)
+++ tuxtype/trunk/src/alphabet.c 2009-01-06 08:24:17 UTC (rev 822)
@@ -26,6 +26,7 @@
#include "globals.h"
#include "funcs.h"
+#include "SDL_extras.h"
@@ -237,14 +238,14 @@
{
if (i == -1)
{
- fprintf(stderr, "GetFinger() - Unicode char '%C' not found in list.\n");
+ fprintf(stderr, "GetFinger() - Unicode char '%C' not found in list.\n",i);
return -2;
}
if ((keyboard_list[i].finger < 0)
|| (keyboard_list[i].finger > 9))
{
- fprintf(stderr, "GetFinger() - Unicode char '%C' has no valid finger.\n");
+ fprintf(stderr, "GetFinger() - Unicode char '%C' has no valid finger.\n",i);
return -1;
}
@@ -1248,6 +1249,7 @@
keyboard_entry->finger=-1;
break;
}
+ return 0;
}
void GenerateKeyboard(SDL_Surface* keyboard)
@@ -1490,6 +1492,8 @@
LOG ("Unable to add unicode - list at max capacity");
return -1;
}
+ // We never want to get here...
+ return -1;
}
Modified: tuxtype/trunk/src/loaders.c
===================================================================
--- tuxtype/trunk/src/loaders.c 2009-01-06 02:51:55 UTC (rev 821)
+++ tuxtype/trunk/src/loaders.c 2009-01-06 08:24:17 UTC (rev 822)
@@ -37,7 +37,7 @@
if (!file)
{
fprintf(stderr, "CheckFile(): invalid char* argument!");
- return;
+ return -1;
}
DEBUGCODE {fprintf(stderr, "CheckFile() - checking: %s\n", file);}
@@ -481,6 +481,8 @@
tempChunk = Mix_LoadWAV(fn);
return tempChunk;
}
+ // We never want to get here...
+ return tempChunk;
}
@@ -509,4 +511,6 @@
temp_music = Mix_LoadMUS(fn);
return temp_music;
}
+ // We never want to get here...
+ return temp_music;
}
Modified: tuxtype/trunk/src/practice.c
===================================================================
--- tuxtype/trunk/src/practice.c 2009-01-06 02:51:55 UTC (rev 821)
+++ tuxtype/trunk/src/practice.c 2009-01-06 08:24:17 UTC (rev 822)
@@ -24,6 +24,7 @@
#include "globals.h"
#include "funcs.h"
#include "SDL_extras.h"
+#include "ConvertUTF.h"
#define MAX_PHRASES 256
#define MAX_PHRASE_LENGTH 256
@@ -98,7 +99,6 @@
/*local function prototypes: */
static int load_phrases(const char* phrase_file);
static int find_next_wrap(const wchar_t* wstr, const TTF_Font* font, int width);
-static int get_phrase(const wchar_t* phr);
static void recalc_positions(void);
static void calc_font_sizes(void);
static int practice_load_media(void);
@@ -229,16 +229,19 @@
smallfont, phrase_draw_width);
tmpsurf = BlackOutline_w(&phrases[cur_phrase][prev_wrap],
smallfont, &white, wrap_pt + 1);
+
if (tmpsurf)
{
SDL_BlitSurface(tmpsurf, NULL, screen, &phr_text_rect);
SDL_FreeSurface(tmpsurf);
tmpsurf = NULL;
}
+
/* Draw the text the player has typed so far: */
tmpsurf = BlackOutline_w(&phrases[cur_phrase][prev_wrap],
smallfont, &white,
cursor - prev_wrap);
+
if (tmpsurf)
{
SDL_BlitSurface(tmpsurf, NULL, screen, &user_text_rect);
@@ -575,6 +578,8 @@
case SDLK_x: tmp='x'; break;
case SDLK_y: tmp='y'; break;
case SDLK_z: tmp='z'; break;
+ /* ignore other keys: */
+ default: break;
}
/* If state has changed as direct result of keypress (e.g. F10), leave */
@@ -1244,7 +1249,6 @@
int phr_length = 0;
int test_w = 0; /* The width in pixels of the SDL-rendered string */
- settings.debug_on = 1;
LOG("Entering find__next_wrap\n");
/* Make sure args OK: */
@@ -1316,8 +1320,8 @@
{
fprintf(stderr, "width exceeded, returning end of previous word as wrap point\n");
fprintf(stderr, "prev_word_end is %d\n", prev_word_end);
+ fprintf(stderr, "leaving find_next_wrap()\n");
}
- settings.debug_on = 0;
return prev_word_end;
}
else
@@ -1331,7 +1335,6 @@
}
/* We reached the end of the phrase without exceeding the width, */
/* so just return our current position: */
- settings.debug_on = 0;
return word_end;
}
else
@@ -1344,107 +1347,6 @@
}
-static int get_phrase(const wchar_t* phr)
-{
- int pc = 0; // 'phrase count' (?)
- int phr_widths[MAX_PHRASES] = { 0 };
- int wrap_pt = 0, i = 0, c = 0, z = 0;
- char fn[FNLEN];
- int old_debug_on = settings.debug_on;
- settings.debug_on = 1;
-
- LOG("Entering get_phrase()\n");
-
- /* If we didn't receive a phrase get the first one from the file...*/
- if (wcsncmp((wchar_t*)"", phr, 40) == 0)
- {
- FILE* phrase_file;
- /* set the phrases directory/file */
- /* FIXME I think the phrases should be under data or the theme */
-#ifdef WIN32
- snprintf(fn, FNLEN - 1, "userdata/phrases.txt");
-#else
- snprintf(fn, FNLEN - 1, (const char*)"%s/.tuxtype/phrases.txt", getenv("HOME"));
-#endif
-
- DEBUGCODE { printf("get_phrases(): phrases file is '%s'\n", fn ); }
- LOG("get_phrases(): trying to open phrases file\n");
- phrase_file = fopen( fn, "r" );
- if (phrase_file == NULL)
- return(wrap_pt); /* why not just 'return 0;' ??? */
-
- /* So now copy each line into phrases array: */
- while (!feof(phrase_file) && pc < 256)
- {
- fscanf( phrase_file, "%[^\n]\n", phrases[pc] );
- pc++;
- DEBUGCODE {printf("%s", phrases[pc]);}
- }
- if (pc == MAX_PHRASES)
- LOG("File contains more than MAX_PHRASES - stopping\n");
-
- fclose(phrase_file);
- pc--;
- }
- else
- {
- LOG("get_phrase() in else clause\n");
- pc = 1;
- wcsncpy(phrases[0], phr, MAX_PHRASE_LENGTH);
- }
-
- /* FIXME this seems to be broken - phr_widths[] has not yet been calculated! */
- //Find wrapping point
- for (c = 0; c <= pc; c++)
- {
- if (phr_widths[c] < 50) // If the phrase is less than 598 pixels wide
- {
- if (c == 0)
- {
- wrap_pt = wcslen(phrases[c]);
- print_at(phrases[0], wrap_pt, 40, 10);
- }
- }
- else
- {
- z = 0;
- wrap_pt = 0;
-
- for (i = 0; i < wcslen(phrases[c]); i++)
- {
- /* Should be safe (if no glyph, will have returned above) */
- z ++;
- if (wrap_pt == 0 && z > 50)
- {
- wrap_pt = i - 1;
- break;
- }
- }
-
- for (i = wrap_pt; i >= 0; i--)
- {
- if (wcsncmp((wchar_t*)" ", &phrases[c][i], 1) == 0)
- {
- wrap_pt = i-1;
- break;
- }
- }
-
- if (c == 0)
- {
- LOG("about to call print_at() near bottom\n");
- print_at(phrases[0], wrap_pt, 40, 10);
- }
- }
- }
-
- LOG("Leaving get_phrase()\n");
-
- settings.debug_on = old_debug_on;
-
- return(wrap_pt);
-}
-
static void print_at(const wchar_t *pphrase, int wrap, int x, int y)
{
int z = 0;
@@ -1497,6 +1399,7 @@
DEBUGCODE { printf("Leaving print_at \n\n\n"); }
}
+
static void next_letter(wchar_t *t, int c)
{
int i;
Modified: tuxtype/trunk/src/scripting.c
===================================================================
--- tuxtype/trunk/src/scripting.c 2009-01-06 02:51:55 UTC (rev 821)
+++ tuxtype/trunk/src/scripting.c 2009-01-06 08:24:17 UTC (rev 822)
@@ -380,7 +380,7 @@
/* Getting to here means "stop == 1", try to run chosen script: */
if (load_script(fn) != 0)
{
- fprintf(stderr, "load_script() failed to load '%s'\n");
+ fprintf(stderr, "load_script() failed to load '%s'\n",fn);
return 0; // bail if any errors occur
}
Modified: tuxtype/trunk/src/setup.c
===================================================================
--- tuxtype/trunk/src/setup.c 2009-01-06 02:51:55 UTC (rev 821)
+++ tuxtype/trunk/src/setup.c 2009-01-06 08:24:17 UTC (rev 822)
@@ -230,7 +230,7 @@
if (!fp)
{
fprintf(stderr, "load_settings_filename(): no theme-specific settings found%s\n",fn);
- return;
+ return -1;
}
if (!load_settings_fp(fp))
Modified: tuxtype/trunk/src/theme.c
===================================================================
--- tuxtype/trunk/src/theme.c 2009-01-06 02:51:55 UTC (rev 821)
+++ tuxtype/trunk/src/theme.c 2009-01-06 08:24:17 UTC (rev 822)
@@ -18,6 +18,7 @@
#include "globals.h"
#include "funcs.h"
+#include "SDL_extras.h"
SDL_Surface* letters[255] = {NULL}; //get rid of this
Modified: tuxtype/trunk/src/titlescreen.c
===================================================================
--- tuxtype/trunk/src/titlescreen.c 2009-01-06 02:51:55 UTC (rev 821)
+++ tuxtype/trunk/src/titlescreen.c 2009-01-06 08:24:17 UTC (rev 822)
@@ -1811,7 +1811,7 @@
FILE *fp;
- int start,themes = 0;
+ int start,themes,themest = 0;
int i,len;
unsigned char fn[FNLEN];
unsigned char str[FNLEN];
@@ -1843,7 +1843,8 @@
{
/* HACK: we should get the strings from file :) */
fscanf(fp, "%[^\n]\n", editWordW[themes]);
- strcpy(editWordY[themes++],editWordW[themes]);
+ themest=themes;
+ strcpy(editWordY[themes++],editWordW[themest]);
}
fclose(fp);
More information about the Tux4kids-commits
mailing list