From e88bbf66cf5c96e4c35b26e7621d2d09b8ea198c Mon Sep 17 00:00:00 2001 From: Ionen Wolkens Date: Mon, 4 Jan 2021 21:26:31 -0500 Subject: [PATCH] dev-games/t4k-common: fix crash for tuxmath[svg] + build fix Closes: https://bugs.gentoo.org/759574 Closes: https://bugs.gentoo.org/763591 Package-Manager: Portage-3.0.12, Repoman-3.0.2 Signed-off-by: Ionen Wolkens --- .../t4k-common-0.1.1-fix-declaration.patch | 11 +++ .../files/t4k-common-0.1.1-svg-libxml2.patch | 71 +++++++++++++++++++ ....1.1.ebuild => t4k-common-0.1.1-r1.ebuild} | 4 +- 3 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 dev-games/t4k-common/files/t4k-common-0.1.1-fix-declaration.patch create mode 100644 dev-games/t4k-common/files/t4k-common-0.1.1-svg-libxml2.patch rename dev-games/t4k-common/{t4k-common-0.1.1.ebuild => t4k-common-0.1.1-r1.ebuild} (90%) diff --git a/dev-games/t4k-common/files/t4k-common-0.1.1-fix-declaration.patch b/dev-games/t4k-common/files/t4k-common-0.1.1-fix-declaration.patch new file mode 100644 index 00000000000..6b564a7c238 --- /dev/null +++ b/dev-games/t4k-common/files/t4k-common-0.1.1-fix-declaration.patch @@ -0,0 +1,11 @@ +https://bugs.gentoo.org/759574 + +--- a/src/t4k_menu.c 2013-12-02 10:50:23.000000000 -0500 ++++ b/src/t4k_menu.c 2021-01-04 19:49:20.561524579 -0500 +@@ -152,5 +152,5 @@ + char* find_longest_text(MenuNode* menu, int* length); + int find_longest_menu_page(MenuNode* menu); +-void set_font_size(); ++void set_font_size(bool uniform); + void prerender_menu(MenuNode* menu); + int min(int a, int b); diff --git a/dev-games/t4k-common/files/t4k-common-0.1.1-svg-libxml2.patch b/dev-games/t4k-common/files/t4k-common-0.1.1-svg-libxml2.patch new file mode 100644 index 00000000000..838d0cc1e24 --- /dev/null +++ b/dev-games/t4k-common/files/t4k-common-0.1.1-svg-libxml2.patch @@ -0,0 +1,71 @@ +https://bugs.gentoo.org/763591 + +Backported from upstream commit: +https://github.com/tux4kids/t4kcommon/commit/99e9d3895b480d5998513592f6af25096c6d1c50 + +--- a/src/t4k_loaders.c 2013-12-02 10:50:23.000000000 -0500 ++++ b/src/t4k_loaders.c 2021-01-04 20:11:37.468033734 -0500 +@@ -41,4 +41,6 @@ + #include + #include ++#include ++#include + #endif + +@@ -49,4 +51,5 @@ + + #ifdef HAVE_RSVG ++int get_number_of_frames_from_svg(const char *file_name); + SDL_Surface* load_svg(const char* file_name, int width, int height, const char* layer_name); + sprite* load_svg_sprite(const char* file_name, int width, int height); +@@ -161,4 +164,43 @@ + #ifdef HAVE_RSVG + ++int get_number_of_frames_from_svg(const char* file_name) { ++ xmlDocPtr svgFile; ++ xmlNodePtr svgNode = NULL, nodeIterator = NULL; ++ int number_of_frames = 0, found = 0; ++ ++ svgFile = xmlReadFile(file_name, NULL, XML_PARSE_RECOVER | XML_PARSE_NOERROR | XML_PARSE_NOWARNING); ++ ++ /* If it's null something's really wrong because we're trying to load a sprite that doesn't exist */ ++ if(svgFile == NULL) { ++ DEBUGMSG(debug_loaders, "get_number_of_frames_from_svg: couldn't load svgFile: %s\n", file_name); ++ return 0; ++ } ++ ++ svgNode = xmlDocGetRootElement(svgFile); ++ ++ /* If it's null then something's really wrong because there should be a root in every svg file... */ ++ if(svgNode == NULL) { ++ DEBUGMSG(debug_loaders, "get_number_of_frames_from_svg: couldn't load the root from the svgFile: %s", file_name); ++ xmlFreeDoc(svgFile); /* be clean */ ++ return 0; ++ } ++ ++ nodeIterator = svgNode->children; ++ while(nodeIterator) { ++ if(xmlStrcasecmp(nodeIterator->name, (const xmlChar*)"desc") == 0) { ++ sscanf((const char*)xmlNodeGetContent(nodeIterator), "%d", &number_of_frames); ++ xmlFreeDoc(svgFile); ++ return number_of_frames; ++ } ++ nodeIterator = nodeIterator->next; ++ } ++ ++ /* if we get here we had no description, which means something's really wrong */ ++ DEBUGMSG(debug_loaders, "get_number_of_frames_from_svg: couldn't find the description frame number count from svgFile: %s", file_name); ++ xmlFreeDoc(svgFile); ++ return 0; ++} ++ ++ + /* Load a layer of SVG file and resize it to given dimensions. + If width or height is negative no resizing is applied. +@@ -215,5 +257,5 @@ + + /* get number of frames from description */ +- sscanf(rsvg_handle_get_desc(file_handle), "%d", &new_sprite->num_frames); ++ new_sprite->num_frames = get_number_of_frames_from_svg(file_name); + DEBUGMSG(debug_loaders, "load_svg_sprite(): loading %d frames\n", new_sprite->num_frames); + diff --git a/dev-games/t4k-common/t4k-common-0.1.1.ebuild b/dev-games/t4k-common/t4k-common-0.1.1-r1.ebuild similarity index 90% rename from dev-games/t4k-common/t4k-common-0.1.1.ebuild rename to dev-games/t4k-common/t4k-common-0.1.1-r1.ebuild index e0a6d5009ab..8360d663ab3 100644 --- a/dev-games/t4k-common/t4k-common-0.1.1.ebuild +++ b/dev-games/t4k-common/t4k-common-0.1.1-r1.ebuild @@ -1,4 +1,4 @@ -# Copyright 1999-2020 Gentoo Authors +# Copyright 1999-2021 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 EAPI=7 @@ -39,6 +39,8 @@ PATCHES=( "${FILESDIR}"/${P}-libpng.patch "${FILESDIR}"/${P}-fno-common.patch "${FILESDIR}"/${P}-ICONV_CONST.patch + "${FILESDIR}"/${P}-fix-declaration.patch + "${FILESDIR}"/${P}-svg-libxml2.patch ) src_prepare() { -- 2.30.0