Index: trunk/src/action_helper.c =================================================================== --- trunk/src/action_helper.c (revision 2395) +++ trunk/src/action_helper.c (revision 2396) @@ -556,8 +556,8 @@ wx = Note.X - Crosshair.AttachedBox.Point1.X; wy = Note.Y - Crosshair.AttachedBox.Point1.Y; - if (XOR(Crosshair.AttachedBox.otherway, labs(wy) > labs(wx))) { - Crosshair.AttachedBox.Point2.X = Crosshair.AttachedBox.Point1.X + labs(wy) * SGNZ(wx); + if (XOR(Crosshair.AttachedBox.otherway, coord_abs(wy) > coord_abs(wx))) { + Crosshair.AttachedBox.Point2.X = Crosshair.AttachedBox.Point1.X + coord_abs(wy) * SGNZ(wx); sa = (wx >= 0) ? 0 : 180; #ifdef ARC45 if (abs(wy) / 2 >= abs(wx)) @@ -567,7 +567,7 @@ dir = (SGNZ(wx) == SGNZ(wy)) ? 90 : -90; } else { - Crosshair.AttachedBox.Point2.Y = Crosshair.AttachedBox.Point1.Y + labs(wx) * SGNZ(wy); + Crosshair.AttachedBox.Point2.Y = Crosshair.AttachedBox.Point1.Y + coord_abs(wx) * SGNZ(wy); sa = (wy >= 0) ? -90 : 90; #ifdef ARC45 if (abs(wx) / 2 >= abs(wy)) @@ -577,11 +577,11 @@ dir = (SGNZ(wx) == SGNZ(wy)) ? -90 : 90; wy = wx; } - if (labs(wy) > 0 && (arc = CreateNewArcOnLayer(CURRENT, + if (coord_abs(wy) > 0 && (arc = CreateNewArcOnLayer(CURRENT, Crosshair.AttachedBox.Point2.X, Crosshair.AttachedBox.Point2.Y, - labs(wy), - labs(wy), + coord_abs(wy), + coord_abs(wy), sa, dir, conf_core.design.line_thickness, Index: trunk/src/crosshair.c =================================================================== --- trunk/src/crosshair.c (revision 2395) +++ trunk/src/crosshair.c (revision 2396) @@ -152,11 +152,11 @@ return; arc.X = Crosshair.AttachedBox.Point1.X; arc.Y = Crosshair.AttachedBox.Point1.Y; - if (XOR(Crosshair.AttachedBox.otherway, labs(wy) > labs(wx))) { - arc.X = Crosshair.AttachedBox.Point1.X + labs(wy) * SGNZ(wx); + if (XOR(Crosshair.AttachedBox.otherway, coord_abs(wy) > coord_abs(wx))) { + arc.X = Crosshair.AttachedBox.Point1.X + coord_abs(wy) * SGNZ(wx); sa = (wx >= 0) ? 0 : 180; #ifdef ARC45 - if (labs(wy) >= 2 * labs(wx)) + if (coord_abs(wy) >= 2 * coord_abs(wx)) dir = (SGNZ(wx) == SGNZ(wy)) ? 45 : -45; else #endif @@ -163,10 +163,10 @@ dir = (SGNZ(wx) == SGNZ(wy)) ? 90 : -90; } else { - arc.Y = Crosshair.AttachedBox.Point1.Y + labs(wx) * SGNZ(wy); + arc.Y = Crosshair.AttachedBox.Point1.Y + coord_abs(wx) * SGNZ(wy); sa = (wy >= 0) ? -90 : 90; #ifdef ARC45 - if (labs(wx) >= 2 * labs(wy)) + if (coord_abs(wx) >= 2 * coord_abs(wy)) dir = (SGNZ(wx) == SGNZ(wy)) ? -45 : 45; else #endif @@ -173,7 +173,7 @@ dir = (SGNZ(wx) == SGNZ(wy)) ? -90 : 90; wy = wx; } - wy = labs(wy); + wy = coord_abs(wy); arc.StartAngle = sa; arc.Delta = dir; arc.Width = arc.Height = wy; @@ -204,7 +204,7 @@ ox = dy * h + 0.5 * SGN(dy); oy = -(dx * h + 0.5 * SGN(dx)); gui->draw_line(Crosshair.GC, x1 + ox, y1 + oy, x2 + ox, y2 + oy); - if (labs(ox) >= pixel_slop || labs(oy) >= pixel_slop) { + if (coord_abs(ox) >= pixel_slop || coord_abs(oy) >= pixel_slop) { Angle angle = atan2(dx, dy) * 57.295779; gui->draw_line(Crosshair.GC, x1 - ox, y1 - oy, x2 - ox, y2 - oy); gui->draw_arc(Crosshair.GC, x1, y1, thick / 2, thick / 2, angle - 180, 180); @@ -743,7 +743,7 @@ } } -#define close_enough(v1, v2) (labs((v1)-(v2)) < 10) +#define close_enough(v1, v2) (coord_abs((v1)-(v2)) < 10) static int onpoint_arc_callback(const BoxType * box, void *cl) { Index: trunk/src/global.h =================================================================== --- trunk/src/global.h (revision 2395) +++ trunk/src/global.h (revision 2396) @@ -558,4 +558,12 @@ #define AUSAGE(x) Message ("Usage:\n%s\n", (x##_syntax)) #define AFAIL(x) { Message ("Syntax error. Usage:\n%s\n", (x##_syntax)); return 1; } +#if COORD_MAX == LONG_MAX +#define coord_abs labs +#elif COORD_MAX == INT_MAX +#define coord_abs abs +#else +#error Can not find abs() for coord type. +#endif + #endif /* PCB_GLOBAL_H */ Index: trunk/src/hid_draw_helpers.c =================================================================== --- trunk/src/hid_draw_helpers.c (revision 2395) +++ trunk/src/hid_draw_helpers.c (revision 2396) @@ -230,7 +230,7 @@ gui->draw_line(gc, x1 + ox, y1 + oy, x2 + ox, y2 + oy); - if (labs(ox) >= pixel_slop || labs(oy) >= pixel_slop) { + if (labs(ox) >= pixel_slop || coord_abs(oy) >= pixel_slop) { Angle angle = atan2(dx, dy) * 57.295779; gui->draw_line(gc, x1 - ox, y1 - oy, x2 - ox, y2 - oy); gui->draw_arc(gc, x1, y1, t, t, angle - 180, 180); Index: trunk/src/line.c =================================================================== --- trunk/src/line.c (revision 2395) +++ trunk/src/line.c (revision 2396) @@ -111,8 +111,8 @@ if (dx < 0) direction += 4; - dx = labs(dx); - dy = labs(dy); + dx = coord_abs(dx); + dy = coord_abs(dy); min = MIN(dx, dy); /* now set up the second pair of coordinates */ @@ -179,23 +179,23 @@ dx = Crosshair.X - line->Point1.X; dy = Crosshair.Y - line->Point1.Y; if (!way) { - if (labs(dx) > labs(dy)) { - line->Point2.X = Crosshair.X - SGN(dx) * labs(dy); + if (coord_abs(dx) > coord_abs(dy)) { + line->Point2.X = Crosshair.X - SGN(dx) * coord_abs(dy); line->Point2.Y = line->Point1.Y; } else { line->Point2.X = line->Point1.X; - line->Point2.Y = Crosshair.Y - SGN(dy) * labs(dx); + line->Point2.Y = Crosshair.Y - SGN(dy) * coord_abs(dx); } } else { - if (labs(dx) > labs(dy)) { - line->Point2.X = line->Point1.X + SGN(dx) * labs(dy); + if (coord_abs(dx) > coord_abs(dy)) { + line->Point2.X = line->Point1.X + SGN(dx) * coord_abs(dy); line->Point2.Y = Crosshair.Y; } else { line->Point2.X = Crosshair.X; - line->Point2.Y = line->Point1.Y + SGN(dy) * labs(dx);; + line->Point2.Y = line->Point1.Y + SGN(dy) * coord_abs(dx);; } } } @@ -278,13 +278,13 @@ line1.Point1.Y = Crosshair.AttachedLine.Point1.Y; dy = end->Y - line1.Point1.Y; dx = end->X - line1.Point1.X; - if (labs(dx) > labs(dy)) { + if (coord_abs(dx) > coord_abs(dy)) { x_is_long = true; - length = labs(dx); + length = coord_abs(dx); } else { x_is_long = false; - length = labs(dy); + length = coord_abs(dy); } group = GetGroupOfLayer(INDEXOFCURRENT); comp = max_group + 10; /* this out-of-range group might save a call */ @@ -304,12 +304,12 @@ if (x_is_long) { dx = SGN(dx) * length; dy = end->Y - line1.Point1.Y; - length2 = labs(dy); + length2 = coord_abs(dy); } else { dy = SGN(dy) * length; dx = end->X - line1.Point1.X; - length2 = labs(dx); + length2 = coord_abs(dx); } temp2 = length2; f2 = 1.0; @@ -322,24 +322,24 @@ else dx = SGN(dx) * length2; two_lines = true; - if (labs(dx) > labs(dy) && x_is_long) { - line1.Point2.X = line1.Point1.X + (way ? SGN(dx) * labs(dy) : dx - SGN(dx) * labs(dy)); + if (coord_abs(dx) > coord_abs(dy) && x_is_long) { + line1.Point2.X = line1.Point1.X + (way ? SGN(dx) * coord_abs(dy) : dx - SGN(dx) * coord_abs(dy)); line1.Point2.Y = line1.Point1.Y + (way ? dy : 0); } - else if (labs(dy) >= labs(dx) && !x_is_long) { + else if (coord_abs(dy) >= coord_abs(dx) && !x_is_long) { line1.Point2.X = line1.Point1.X + (way ? dx : 0); - line1.Point2.Y = line1.Point1.Y + (way ? SGN(dy) * labs(dx) : dy - SGN(dy) * labs(dx)); + line1.Point2.Y = line1.Point1.Y + (way ? SGN(dy) * coord_abs(dx) : dy - SGN(dy) * coord_abs(dx)); } else if (x_is_long) { /* we've changed which axis is long, so only do one line */ line1.Point2.X = line1.Point1.X + dx; - line1.Point2.Y = line1.Point1.Y + (way ? SGN(dy) * labs(dx) : 0); + line1.Point2.Y = line1.Point1.Y + (way ? SGN(dy) * coord_abs(dx) : 0); two_lines = false; } else { /* we've changed which axis is long, so only do one line */ line1.Point2.Y = line1.Point1.Y + dy; - line1.Point2.X = line1.Point1.X + (way ? SGN(dx) * labs(dy) : 0); + line1.Point2.X = line1.Point1.X + (way ? SGN(dx) * coord_abs(dy) : 0); two_lines = false; } line2.Point1.X = line1.Point2.X; Index: trunk/src/misc.c =================================================================== --- trunk/src/misc.c (revision 2395) +++ trunk/src/misc.c (revision 2396) @@ -1763,7 +1763,7 @@ else return 0; - if (labs(dx) > labs(dy)) + if (coord_abs(dx) > coord_abs(dy)) return dx > 0 ? 0 : 2; return dy > 0 ? 3 : 1; } Index: trunk/src/polygon.c =================================================================== --- trunk/src/polygon.c (revision 2395) +++ trunk/src/polygon.c (revision 2396) @@ -1306,8 +1306,8 @@ if (!conf_core.editor.all_direction_lines) { Coord dx, dy; - dx = labs(Crosshair.AttachedPolygon.Points[n - 1].X - Crosshair.AttachedPolygon.Points[0].X); - dy = labs(Crosshair.AttachedPolygon.Points[n - 1].Y - Crosshair.AttachedPolygon.Points[0].Y); + dx = coord_abs(Crosshair.AttachedPolygon.Points[n - 1].X - Crosshair.AttachedPolygon.Points[0].X); + dy = coord_abs(Crosshair.AttachedPolygon.Points[n - 1].Y - Crosshair.AttachedPolygon.Points[0].Y); if (!(dx == 0 || dy == 0 || dx == dy)) { Message(_("Cannot close polygon because 45 degree lines are requested.\n")); return; Index: trunk/src/rubberband.c =================================================================== --- trunk/src/rubberband.c (revision 2395) +++ trunk/src/rubberband.c (revision 2396) @@ -112,9 +112,9 @@ * circle to the corners of the rectangle since the * closest part of the rectangular region is the corner. */ - x = MIN(labs(i->box.X1 - line->Point1.X), labs(i->box.X2 - line->Point1.X)); + x = MIN(coord_abs(i->box.X1 - line->Point1.X), coord_abs(i->box.X2 - line->Point1.X)); x *= x; - y = MIN(labs(i->box.Y1 - line->Point1.Y), labs(i->box.Y2 - line->Point1.Y)); + y = MIN(coord_abs(i->box.Y1 - line->Point1.Y), coord_abs(i->box.Y2 - line->Point1.Y)); y *= y; x = x + y - (t * t); @@ -133,9 +133,9 @@ touches = 1; } else { - x = MIN(labs(i->box.X1 - line->Point2.X), labs(i->box.X2 - line->Point2.X)); + x = MIN(coord_abs(i->box.X1 - line->Point2.X), coord_abs(i->box.X2 - line->Point2.X)); x *= x; - y = MIN(labs(i->box.Y1 - line->Point2.Y), labs(i->box.Y2 - line->Point2.Y)); + y = MIN(coord_abs(i->box.Y1 - line->Point2.Y), coord_abs(i->box.Y2 - line->Point2.Y)); y *= y; x = x + y - (t * t);