From 5ac75d6f09e4de35ef33289c69bc1d46c2a04970 Mon Sep 17 00:00:00 2001 From: Barak Itkin Date: Sat, 15 Nov 2014 17:03:10 +0200 Subject: [PATCH] Multiple fixes to allow usage with other compilers 1. Fix many signed/unsigned comparisons 2. Avoid having multiple C files with the same name 3. Add return statements after failing asserts, just to calm the compiler --- poly2tri-c/p2t/common/shapes.c | 15 +++++++++++---- poly2tri-c/p2t/sweep/sweep.c | 10 ++++++---- poly2tri-c/p2t/sweep/sweep_context.c | 8 ++++---- poly2tri-c/refine/cdt-flipfix.h | 4 ++-- poly2tri-c/refine/cluster.c | 2 +- poly2tri-c/refine/delaunay-terminator.c | 6 +++--- poly2tri-c/refine/delaunay-terminator.h | 2 +- poly2tri-c/refine/mesh.c | 2 +- poly2tri-c/refine/mesh.h | 2 +- poly2tri-c/refine/pslg.h | 2 +- poly2tri-c/refine/{cdt.c => rcdt.c} | 4 ++-- poly2tri-c/refine/{cdt.h => rcdt.h} | 4 ++-- poly2tri-c/refine/refine.h | 4 ++-- poly2tri-c/refine/refiner.c | 2 +- poly2tri-c/refine/refiner.h | 2 +- poly2tri-c/refine/{utils.c => rutils.c} | 2 +- poly2tri-c/refine/{utils.h => rutils.h} | 4 ++-- poly2tri-c/refine/triangle.c | 2 +- poly2tri-c/refine/vedge.h | 2 +- poly2tri-c/refine/visibility.c | 2 +- poly2tri-c/render/mesh-render.c | 2 +- 21 files changed, 46 insertions(+), 37 deletions(-) rename poly2tri-c/refine/{cdt.c => rcdt.c} (99%) rename poly2tri-c/refine/{cdt.h => rcdt.h} (98%) rename poly2tri-c/refine/{utils.c => rutils.c} (98%) rename poly2tri-c/refine/{utils.h => rutils.h} (98%) diff --git a/poly2tri-c/p2t/common/shapes.c b/poly2tri-c/p2t/common/shapes.c index 62fec89..41e5048 100644 --- a/poly2tri-c/p2t/common/shapes.c +++ b/poly2tri-c/p2t/common/shapes.c @@ -290,7 +290,7 @@ p2t_triangle_legalize_pt_pt (P2tTriangle* THIS, P2tPoint *opoint, P2tPoint *npoi } else { - assert (0); + g_assert_not_reached (); } } @@ -309,7 +309,9 @@ p2t_triangle_index (P2tTriangle* THIS, const P2tPoint* p) { return 2; } - assert (0); + g_assert_not_reached (); + /* Return a value to silence some compilers */ + return -1; } int @@ -399,7 +401,10 @@ p2t_triangle_point_cw (P2tTriangle* THIS, P2tPoint* point) { return THIS->points_[1]; } - assert (0); + + g_assert_not_reached (); + /* Return a value to silence some compilers */ + return NULL; } /* The point counter-clockwise to given point */ @@ -419,7 +424,9 @@ p2t_triangle_point_ccw (P2tTriangle* THIS, P2tPoint* point) { return THIS->points_[0]; } - assert (0); + g_assert_not_reached (); + /* Return a value to silence some compilers */ + return NULL; } /* The neighbor clockwise to given point */ diff --git a/poly2tri-c/p2t/sweep/sweep.c b/poly2tri-c/p2t/sweep/sweep.c index 7680075..6d415cf 100644 --- a/poly2tri-c/p2t/sweep/sweep.c +++ b/poly2tri-c/p2t/sweep/sweep.c @@ -61,7 +61,7 @@ p2t_sweep_new () void p2t_sweep_destroy (P2tSweep* THIS) { - int i; + guint i; /* Clean up memory */ for (i = 0; i < THIS->nodes_->len; i++) { @@ -94,7 +94,8 @@ p2t_sweep_triangulate (P2tSweep *THIS, P2tSweepContext *tcx) void p2t_sweep_sweep_points (P2tSweep *THIS, P2tSweepContext *tcx) { - int i, j; + int i; + guint j; for (i = 1; i < p2t_sweepcontext_point_count (tcx); i++) { P2tPoint* point = p2t_sweepcontext_get_point (tcx, i); @@ -983,8 +984,9 @@ p2t_sweep_next_flip_point (P2tSweep *THIS, P2tPoint* ep, P2tPoint* eq, P2tTriang } else { - /*throw new RuntimeException("[Unsupported] Opposing point on constrained edge");*/ - assert (0); + g_error ("[Unsupported] Opposing point on constrained edge"); + /* Return a value to silence some compilers */ + return NULL; } } diff --git a/poly2tri-c/p2t/sweep/sweep_context.c b/poly2tri-c/p2t/sweep/sweep_context.c index 18c278a..a672e13 100644 --- a/poly2tri-c/p2t/sweep/sweep_context.c +++ b/poly2tri-c/p2t/sweep/sweep_context.c @@ -62,7 +62,7 @@ p2t_sweepcontext_edgeevent_init (P2tSweepContextEdgeEvent* THIS) void p2t_sweepcontext_init (P2tSweepContext* THIS, P2tPointPtrArray polyline) { - int i; + guint i; THIS->front_ = NULL; THIS->head_ = NULL; @@ -98,7 +98,7 @@ void p2t_sweepcontext_destroy (P2tSweepContext* THIS) { GList* iter; - int i; + guint i; /* Clean up memory */ p2t_point_free (THIS->head_); @@ -138,7 +138,7 @@ p2t_sweepcontext_delete (P2tSweepContext* THIS) void p2t_sweepcontext_add_hole (P2tSweepContext *THIS, P2tPointPtrArray polyline) { - int i; + guint i; p2t_sweepcontext_init_edges (THIS, polyline); for (i = 0; i < polyline->len; i++) { @@ -167,7 +167,7 @@ p2t_sweepcontext_get_map (P2tSweepContext *THIS) void p2t_sweepcontext_init_triangulation (P2tSweepContext *THIS) { - int i; + guint i; double xmax = point_index (THIS->points_, 0)->x, xmin = point_index (THIS->points_, 0)->x; double ymax = point_index (THIS->points_, 0)->y, ymin = point_index (THIS->points_, 0)->y; double dx, dy; diff --git a/poly2tri-c/refine/cdt-flipfix.h b/poly2tri-c/refine/cdt-flipfix.h index dad11b2..2b5a83d 100644 --- a/poly2tri-c/refine/cdt-flipfix.h +++ b/poly2tri-c/refine/cdt-flipfix.h @@ -37,8 +37,8 @@ #include "edge.h" #include "vedge.h" -#include "cdt.h" -#include "utils.h" +#include "rcdt.h" +#include "rutils.h" /** * Flip-Fix all the virtual edges inside the given set diff --git a/poly2tri-c/refine/cluster.c b/poly2tri-c/refine/cluster.c index ccf9217..ae678b6 100644 --- a/poly2tri-c/refine/cluster.c +++ b/poly2tri-c/refine/cluster.c @@ -33,7 +33,7 @@ #include #include -#include "utils.h" +#include "rutils.h" #include "point.h" #include "edge.h" diff --git a/poly2tri-c/refine/delaunay-terminator.c b/poly2tri-c/refine/delaunay-terminator.c index 1de1fea..a434d32 100644 --- a/poly2tri-c/refine/delaunay-terminator.c +++ b/poly2tri-c/refine/delaunay-terminator.c @@ -34,7 +34,7 @@ #include #include -#include "utils.h" +#include "rutils.h" #include "rmath.h" #include "point.h" @@ -42,7 +42,7 @@ #include "triangle.h" #include "mesh.h" -#include "cdt.h" +#include "rcdt.h" #include "cluster.h" #include "vedge.h" @@ -368,7 +368,7 @@ SplitPermitted (P2trDelaunayTerminator *self, P2trEdge *s, gdouble d) { P2trCluster *startCluster = p2tr_cluster_get_for (P2TR_EDGE_START(s), s); P2trCluster *endCluster = p2tr_cluster_get_for (s->end, s); - P2trCluster *S_NOREF; + P2trCluster *S_NOREF = NULL; GList *iter; gboolean permitted = FALSE; diff --git a/poly2tri-c/refine/delaunay-terminator.h b/poly2tri-c/refine/delaunay-terminator.h index fe0ef5d..33f4a77 100644 --- a/poly2tri-c/refine/delaunay-terminator.h +++ b/poly2tri-c/refine/delaunay-terminator.h @@ -34,7 +34,7 @@ #define __P2TC_REFINE_DELAUNAY_TERMINATOR_H__ #include -#include "cdt.h" +#include "rcdt.h" #include "refiner.h" #include "vedge.h" diff --git a/poly2tri-c/refine/mesh.c b/poly2tri-c/refine/mesh.c index 7fc192f..493b232 100644 --- a/poly2tri-c/refine/mesh.c +++ b/poly2tri-c/refine/mesh.c @@ -31,7 +31,7 @@ */ #include -#include "utils.h" +#include "rutils.h" #include "mesh.h" #include "point.h" diff --git a/poly2tri-c/refine/mesh.h b/poly2tri-c/refine/mesh.h index f62c351..846c29d 100644 --- a/poly2tri-c/refine/mesh.h +++ b/poly2tri-c/refine/mesh.h @@ -36,7 +36,7 @@ #include #include #include "vector2.h" -#include "utils.h" +#include "rutils.h" #include "triangulation.h" /** diff --git a/poly2tri-c/refine/pslg.h b/poly2tri-c/refine/pslg.h index ef06bf3..2b2ed85 100644 --- a/poly2tri-c/refine/pslg.h +++ b/poly2tri-c/refine/pslg.h @@ -33,7 +33,7 @@ #ifndef __P2TC_REFINE_PSLG_H__ #define __P2TC_REFINE_PSLG_H__ -#include "utils.h" +#include "rutils.h" #include "vector2.h" #include "line.h" #include "bounded-line.h" diff --git a/poly2tri-c/refine/cdt.c b/poly2tri-c/refine/rcdt.c similarity index 99% rename from poly2tri-c/refine/cdt.c rename to poly2tri-c/refine/rcdt.c index 4929d34..d61b488 100644 --- a/poly2tri-c/refine/cdt.c +++ b/poly2tri-c/refine/rcdt.c @@ -37,7 +37,7 @@ #include "edge.h" #include "triangle.h" -#include "cdt.h" +#include "rcdt.h" #include "visibility.h" #include "cdt-flipfix.h" @@ -82,7 +82,7 @@ p2tr_cdt_new (P2tCDT *cdt) P2trVEdgeSet *new_edges = p2tr_vedge_set_new (); - gint i, j; + guint i, j; rmesh->mesh = p2tr_mesh_new (); rmesh->outline = p2tr_pslg_new (); diff --git a/poly2tri-c/refine/cdt.h b/poly2tri-c/refine/rcdt.h similarity index 98% rename from poly2tri-c/refine/cdt.h rename to poly2tri-c/refine/rcdt.h index 23455a6..55bd3b3 100644 --- a/poly2tri-c/refine/cdt.h +++ b/poly2tri-c/refine/rcdt.h @@ -30,8 +30,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef __P2TC_REFINE_CDT_H__ -#define __P2TC_REFINE_CDT_H__ +#ifndef __P2TC_REFINE_RCDT_H__ +#define __P2TC_REFINE_RCDT_H__ #include #include "mesh.h" diff --git a/poly2tri-c/refine/refine.h b/poly2tri-c/refine/refine.h index 7828887..5bfb3ee 100644 --- a/poly2tri-c/refine/refine.h +++ b/poly2tri-c/refine/refine.h @@ -33,7 +33,7 @@ #ifndef __P2TC_REFINE_H__ #define __P2TC_REFINE_H__ -#include "utils.h" +#include "rutils.h" #include "rmath.h" #include "vector2.h" @@ -53,7 +53,7 @@ #include "vtriangle.h" #include "cluster.h" -#include "cdt.h" +#include "rcdt.h" #include "refiner.h" #endif diff --git a/poly2tri-c/refine/refiner.c b/poly2tri-c/refine/refiner.c index 92e2c32..a56d162 100644 --- a/poly2tri-c/refine/refiner.c +++ b/poly2tri-c/refine/refiner.c @@ -31,7 +31,7 @@ */ #include -#include "cdt.h" +#include "rcdt.h" #include "delaunay-terminator.h" #include "refiner.h" diff --git a/poly2tri-c/refine/refiner.h b/poly2tri-c/refine/refiner.h index ffeba91..739bb97 100644 --- a/poly2tri-c/refine/refiner.h +++ b/poly2tri-c/refine/refiner.h @@ -34,7 +34,7 @@ #define __P2TC_REFINE_REFINER_H__ #include -#include "cdt.h" +#include "rcdt.h" typedef struct P2trRefiner_ P2trRefiner; diff --git a/poly2tri-c/refine/utils.c b/poly2tri-c/refine/rutils.c similarity index 98% rename from poly2tri-c/refine/utils.c rename to poly2tri-c/refine/rutils.c index d9d7db4..589e42c 100644 --- a/poly2tri-c/refine/utils.c +++ b/poly2tri-c/refine/rutils.c @@ -33,7 +33,7 @@ #include #include -#include "utils.h" +#include "rutils.h" GList* p2tr_utils_new_reversed_pointer_list (int count, ...) diff --git a/poly2tri-c/refine/utils.h b/poly2tri-c/refine/rutils.h similarity index 98% rename from poly2tri-c/refine/utils.h rename to poly2tri-c/refine/rutils.h index 576476f..0163f79 100644 --- a/poly2tri-c/refine/utils.h +++ b/poly2tri-c/refine/rutils.h @@ -30,8 +30,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef __P2TC_REFINE_UTILS_H__ -#define __P2TC_REFINE_UTILS_H__ +#ifndef __P2TC_REFINE_RUTILS_H__ +#define __P2TC_REFINE_RUTILS_H__ #ifdef __cplusplus extern "C" diff --git a/poly2tri-c/refine/triangle.c b/poly2tri-c/refine/triangle.c index ce28dcc..71c6d17 100644 --- a/poly2tri-c/refine/triangle.c +++ b/poly2tri-c/refine/triangle.c @@ -33,7 +33,7 @@ #include #include -#include "utils.h" +#include "rutils.h" #include "rmath.h" #include "point.h" diff --git a/poly2tri-c/refine/vedge.h b/poly2tri-c/refine/vedge.h index 30f0e8f..4fb7541 100644 --- a/poly2tri-c/refine/vedge.h +++ b/poly2tri-c/refine/vedge.h @@ -34,7 +34,7 @@ #define __P2TC_REFINE_VEDGE_H__ #include -#include "utils.h" +#include "rutils.h" #include "triangulation.h" /** diff --git a/poly2tri-c/refine/visibility.c b/poly2tri-c/refine/visibility.c index eab71ed..3862e7f 100644 --- a/poly2tri-c/refine/visibility.c +++ b/poly2tri-c/refine/visibility.c @@ -425,7 +425,7 @@ p2tr_visibility_is_visible_from_edges (P2trPSLG *pslg, guint line_count) { P2trPSLG *edges = p2tr_pslg_new (); - gint i; + guint i; gboolean result; for (i = 0; i < line_count; i++) diff --git a/poly2tri-c/render/mesh-render.c b/poly2tri-c/render/mesh-render.c index 6794b71..e4d3025 100644 --- a/poly2tri-c/render/mesh-render.c +++ b/poly2tri-c/render/mesh-render.c @@ -76,7 +76,7 @@ p2tr_mesh_render_cache_uvt_exact (P2trMesh *T, gint dest_len, P2trImageConfig *config) { - gint x, y, n = dest_len; + guint x, y, n = dest_len; P2trUVT *uvt = dest; P2trTriangle *tr_prev = NULL; P2trVector2 pt; -- 2.40.0