Date: Tue, 7 Jun 2016 04:14:38 +0000 (UTC) From: Don Lewis <truckman@FreeBSD.org> To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r416493 - head/graphics/inkscape/files Message-ID: <201606070414.u574EcTK075335@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: truckman Date: Tue Jun 7 04:14:37 2016 New Revision: 416493 URL: https://svnweb.freebsd.org/changeset/ports/416493 Log: Fix type for abs() calls in graphics/inkscape During the exp-run in bug 208158, it was found that graphics/inkscape gives errors with libc++ 3.8.0: libavoid/connector.cpp:888:29: error: call to 'abs' is ambiguous COLA_ASSERT(abs(i->pathNext->id.objID - i->id.objID) != 2); ^~~ This is because abs() is called with unsigned arguments. Fix it by casting the arguments to the appropriate signed types. This mimics what happens with older libraries where the only version of abs() was the one in <stdlib.h>, which is prototyped: int abs(int) The expression used in ConnRef::generatePath() is not strictly correct because it depends on details of integer overflow that are undefined by the C++ standard. PR: 209675 Submitted by: dim Added: head/graphics/inkscape/files/ head/graphics/inkscape/files/patch-src_libavoid_connector.cpp (contents, props changed) head/graphics/inkscape/files/patch-src_ui_tools_flood-tool.cpp (contents, props changed) Added: head/graphics/inkscape/files/patch-src_libavoid_connector.cpp ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/graphics/inkscape/files/patch-src_libavoid_connector.cpp Tue Jun 7 04:14:37 2016 (r416493) @@ -0,0 +1,11 @@ +--- src/libavoid/connector.cpp.orig 2014-11-30 18:45:32 UTC ++++ src/libavoid/connector.cpp +@@ -885,7 +885,7 @@ bool ConnRef::generatePath(void) + { + // Check for consecutive points on opposite + // corners of two touching shapes. +- COLA_ASSERT(abs(i->pathNext->id.objID - i->id.objID) != 2); ++ COLA_ASSERT(abs((int)(i->pathNext->id.objID - i->id.objID)) != 2); + } + } + } Added: head/graphics/inkscape/files/patch-src_ui_tools_flood-tool.cpp ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/graphics/inkscape/files/patch-src_ui_tools_flood-tool.cpp Tue Jun 7 04:14:37 2016 (r416493) @@ -0,0 +1,33 @@ +--- src/ui/tools/flood-tool.cpp.orig 2014-11-30 18:45:32 UTC ++++ src/ui/tools/flood-tool.cpp +@@ -252,13 +252,13 @@ static bool compare_pixels(guint32 check + + switch (method) { + case FLOOD_CHANNELS_ALPHA: +- return abs(static_cast<int>(ac) - ao) <= threshold; ++ return abs(static_cast<int>(ac) - static_cast<int>(ao)) <= threshold; + case FLOOD_CHANNELS_R: +- return abs(static_cast<int>(ac ? unpremul_alpha(rc, ac) : 0) - (ao ? unpremul_alpha(ro, ao) : 0)) <= threshold; ++ return abs(static_cast<int>(ac ? unpremul_alpha(rc, ac) : 0) - static_cast<int>(ao ? unpremul_alpha(ro, ao) : 0)) <= threshold; + case FLOOD_CHANNELS_G: +- return abs(static_cast<int>(ac ? unpremul_alpha(gc, ac) : 0) - (ao ? unpremul_alpha(go, ao) : 0)) <= threshold; ++ return abs(static_cast<int>(ac ? unpremul_alpha(gc, ac) : 0) - static_cast<int>(ao ? unpremul_alpha(go, ao) : 0)) <= threshold; + case FLOOD_CHANNELS_B: +- return abs(static_cast<int>(ac ? unpremul_alpha(bc, ac) : 0) - (ao ? unpremul_alpha(bo, ao) : 0)) <= threshold; ++ return abs(static_cast<int>(ac ? unpremul_alpha(bc, ac) : 0) - static_cast<int>(ao ? unpremul_alpha(bo, ao) : 0)) <= threshold; + case FLOOD_CHANNELS_RGB: + guint32 amc, rmc, bmc, gmc; + //amc = 255*255 - (255-ac)*(255-ad); amc = (amc + 127) / 255; +@@ -268,9 +268,9 @@ static bool compare_pixels(guint32 check + gmc = (255-ac)*gd + 255*gc; gmc = (gmc + 127) / 255; + bmc = (255-ac)*bd + 255*bc; bmc = (bmc + 127) / 255; + +- diff += abs(static_cast<int>(amc ? unpremul_alpha(rmc, amc) : 0) - (amop ? unpremul_alpha(rmop, amop) : 0)); +- diff += abs(static_cast<int>(amc ? unpremul_alpha(gmc, amc) : 0) - (amop ? unpremul_alpha(gmop, amop) : 0)); +- diff += abs(static_cast<int>(amc ? unpremul_alpha(bmc, amc) : 0) - (amop ? unpremul_alpha(bmop, amop) : 0)); ++ diff += abs(static_cast<int>(amc ? unpremul_alpha(rmc, amc) : 0) - static_cast<int>(amop ? unpremul_alpha(rmop, amop) : 0)); ++ diff += abs(static_cast<int>(amc ? unpremul_alpha(gmc, amc) : 0) - static_cast<int>(amop ? unpremul_alpha(gmop, amop) : 0)); ++ diff += abs(static_cast<int>(amc ? unpremul_alpha(bmc, amc) : 0) - static_cast<int>(amop ? unpremul_alpha(bmop, amop) : 0)); + return ((diff / 3) <= ((threshold * 3) / 4)); + + case FLOOD_CHANNELS_H:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201606070414.u574EcTK075335>