Index: trunk/src/Makefile.in =================================================================== --- trunk/src/Makefile.in (revision 1908) +++ trunk/src/Makefile.in (revision 1909) @@ -67,6 +67,7 @@ main_act.o mirror.o misc.o + misc_util.o move.o mymem.o netlist.o @@ -101,6 +102,7 @@ thermal.o undo.o undo_act.o + unit.o vtlibrary.o vtonpoint.o vtptr.o Index: trunk/src/box.h =================================================================== --- trunk/src/box.h (revision 1908) +++ trunk/src/box.h (revision 1909) @@ -40,7 +40,7 @@ #include #include "global.h" -#include "misc.h" +#include "misc_util.h" typedef enum { NORTH = 0, EAST = 1, SOUTH = 2, WEST = 3, NE = 4, SE = 5, SW = 6, NW = 7, ALL = 8 } direction_t; Index: trunk/src/buffer.c =================================================================== --- trunk/src/buffer.c (revision 1908) +++ trunk/src/buffer.c (revision 1909) @@ -45,6 +45,7 @@ #include "plug_io.h" #include "mirror.h" #include "misc.h" +#include "misc_util.h" #include "polygon.h" #include "rotate.h" #include "remove.h" Index: trunk/src/change_act.c =================================================================== --- trunk/src/change_act.c (revision 1908) +++ trunk/src/change_act.c (revision 1909) @@ -46,6 +46,7 @@ #include "error.h" #include "undo.h" #include "rubberband.h" +#include "misc_util.h" static void ChangeFlag(char *, char *, int, char *); static int ActionChangeSize(int argc, char **argv, Coord x, Coord y); Index: trunk/src/conf.c =================================================================== --- trunk/src/conf.c (revision 1908) +++ trunk/src/conf.c (revision 1909) @@ -26,7 +26,7 @@ #include "conf.h" #include "conf_core.h" #include "hid_cfg.h" -#include "misc.h" +#include "misc_util.h" #include "error.h" lht_doc_t *conf_root[CFR_max]; Index: trunk/src/conf.h =================================================================== --- trunk/src/conf.h (revision 1908) +++ trunk/src/conf.h (revision 1909) @@ -28,6 +28,7 @@ #include #include #include +#include "unit.h" int conf_rev; /* icreased by one each time there's a change in any of the config binaries */ Index: trunk/src/conf_act.c =================================================================== --- trunk/src/conf_act.c (revision 1908) +++ trunk/src/conf_act.c (revision 1909) @@ -30,6 +30,7 @@ #include "conf_core.h" #include "error.h" #include "misc.h" +#include "misc_util.h" static const char conf_syntax[] = "conf(set, path, value, [role], [policy]) - change a config setting\n" Index: trunk/src/create.c =================================================================== --- trunk/src/create.c (revision 1908) +++ trunk/src/create.c (revision 1909) @@ -49,6 +49,7 @@ #include "stub_vendor.h" #include "hid_actions.h" #include "paths.h" +#include "misc_util.h" RCSID("$Id$"); Index: trunk/src/crosshair.c =================================================================== --- trunk/src/crosshair.c (revision 1908) +++ trunk/src/crosshair.c (revision 1909) @@ -47,6 +47,8 @@ #include "rtree.h" #include "search.h" #include "polygon.h" +#include "misc.h" +#include "misc_util.h" #include "hid_actions.h" Index: trunk/src/find.c =================================================================== --- trunk/src/find.c (revision 1908) +++ trunk/src/find.c (revision 1909) @@ -91,6 +91,7 @@ #include "rats.h" #include "plug_io.h" #include "hid_actions.h" +#include "misc_util.h" #undef DEBUG Index: trunk/src/global_typedefs.h =================================================================== --- trunk/src/global_typedefs.h (revision 1908) +++ trunk/src/global_typedefs.h (revision 1909) @@ -33,12 +33,6 @@ typedef struct AttributeListType AttributeListType, *AttributeListTypePtr; typedef struct rats_patch_line_s rats_patch_line_t; -typedef struct unit Unit; -typedef struct increments Increments; - -typedef COORD_TYPE Coord; /* pcb base unit */ -typedef double Angle; /* degrees */ - #ifndef XtSpecificationRelease typedef unsigned int Cardinal; /*typedef unsigned int Pixel;*/ @@ -48,5 +42,7 @@ #endif typedef unsigned char BYTE; +#include "unit.h" + #endif Index: trunk/src/gui_act.c =================================================================== --- trunk/src/gui_act.c (revision 1908) +++ trunk/src/gui_act.c (revision 1909) @@ -38,6 +38,7 @@ #include "find.h" #include "set.h" #include "misc.h" +#include "misc_util.h" #include "stub_stroke.h" #include "hid_actions.h" #include "hid_init.h" Index: trunk/src/hid_attrib.c =================================================================== --- trunk/src/hid_attrib.c (revision 1908) +++ trunk/src/hid_attrib.c (revision 1909) @@ -4,6 +4,7 @@ #include "global.h" #include "hid_attrib.h" #include "misc.h" +#include "misc_util.h" #include "pcb-printf.h" #include "compat_fs.h" #include "error.h" Index: trunk/src/hid_flags.c =================================================================== --- trunk/src/hid_flags.c (revision 1908) +++ trunk/src/hid_flags.c (revision 1909) @@ -14,6 +14,8 @@ #include "hid_flags.h" #include "genht/hash.h" #include "genht/htsp.h" +#include "error.h" +#include "hid_actions.h" RCSID("$Id$"); Index: trunk/src/hid_init.c =================================================================== --- trunk/src/hid_init.c (revision 1908) +++ trunk/src/hid_init.c (revision 1909) @@ -31,8 +31,8 @@ #include "plugins.h" #include "hid_attrib.h" #include "hid_flags.h" +#include "misc_util.h" - RCSID("$Id$"); HID **hid_list = 0; Index: trunk/src/insert.c =================================================================== --- trunk/src/insert.c (revision 1908) +++ trunk/src/insert.c (revision 1909) @@ -45,8 +45,8 @@ #include "select.h" #include "set.h" #include "undo.h" +#include "misc_util.h" - RCSID("$Id$"); Index: trunk/src/misc.c =================================================================== --- trunk/src/misc.c (revision 1908) +++ trunk/src/misc.c (revision 1909) @@ -74,7 +74,6 @@ static char *BumpName(char *); static void GetGridLockCoordinates(int, void *, void *, void *, Coord *, Coord *); - /* Local variables */ /* @@ -89,26 +88,6 @@ int cnt; } SavedStack; -/* Distance() should be used so that there is only one - * place to deal with overflow/precision errors - */ -double Distance(double x1, double y1, double x2, double y2) -{ - double delta_x = (x2 - x1); - double delta_y = (y2 - y1); - return sqrt(delta_x * delta_x + delta_y * delta_y); -} - -/* Distance2() should be used so that there is only one - * place to deal with overflow/precision errors - */ -double Distance2(double x1, double y1, double x2, double y2) -{ - double delta_x = (x2 - x1); - double delta_y = (y2 - y1); - return delta_x * delta_x + delta_y * delta_y; -} - /* Bring an angle into [0, 360) range */ Angle NormalizeAngle(Angle a) { @@ -119,98 +98,6 @@ return a; } -/* Get Value returns a numeric value passed from the string and sets the - * bool variable absolute to false if it leads with a +/- character - */ -double GetValue(const char *val, const char *units, bool * absolute, bool *success) -{ - return GetValueEx(val, units, absolute, NULL, "cmil", success); -} - -double GetValueEx(const char *val, const char *units, bool * absolute, UnitList extra_units, const char *default_unit, bool *success) -{ - double value; - int n = -1; - bool scaled = 0; - bool dummy; - - /* Allow NULL to be passed for absolute */ - if (absolute == NULL) - absolute = &dummy; - - /* if the first character is a sign we have to add the - * value to the current one - */ - if (*val == '=') { - *absolute = true; - sscanf(val + 1, "%lf%n", &value, &n); - n++; - } - else { - if (isdigit((int) *val)) - *absolute = true; - else - *absolute = false; - sscanf(val, "%lf%n", &value, &n); - } - if (n <= 0) - goto fail; - - if (!units && n > 0) - units = val + n; - - while (units && isspace(*units)) - units++; - - if (units && *units) { - int i, unit_ok = 0; - const Unit *unit = get_unit_struct(units); - if (unit != NULL) { - value = unit_to_coord(unit, value); - scaled = 1; - unit_ok = 1; - } - if (extra_units) { - for (i = 0; *extra_units[i].suffix; ++i) { - if (strncmp(units, extra_units[i].suffix, strlen(extra_units[i].suffix)) == 0) { - value *= extra_units[i].scale; - if (extra_units[i].flags & UNIT_PERCENT) - value /= 100.0; - scaled = 1; - unit_ok = 1; - } - } - } - if ((!unit_ok) && (success != NULL)) /* there was something after the number but it doesn't look like a valid unit */ - goto fail; - } - - /* Apply default unit */ - if (!scaled && default_unit && *default_unit) { - int i; - const Unit *unit = get_unit_struct(default_unit); - if (extra_units) - for (i = 0; *extra_units[i].suffix; ++i) - if (strcmp(extra_units[i].suffix, default_unit) == 0) { - value *= extra_units[i].scale; - if (extra_units[i].flags & UNIT_PERCENT) - value /= 100.0; - scaled = 1; - } - if (!scaled && unit != NULL) - value = unit_to_coord(unit, value); - } - - if (success != NULL) - *success = 1; - return value; - - fail:; - if (success != NULL) - *success = 0; - return 0; -} - /* --------------------------------------------------------------------------- * sets the bounding box of a point (which is silly) */ @@ -1655,37 +1542,6 @@ Crosshair.AttachedObject.Ptr1, Crosshair.AttachedObject.Ptr2, Crosshair.AttachedObject.Ptr3); } -char *Concat(const char *first, ...) -{ - char *rv; - int len; - va_list a; - - len = strlen(first); - rv = (char *) malloc(len + 1); - strcpy(rv, first); - - va_start(a, first); - while (1) { - const char *s = va_arg(a, const char *); - if (!s) - break; - len += strlen(s); - rv = (char *) realloc(rv, len + 1); - strcat(rv, s); - } - va_end(a); - return rv; -} - -int mem_any_set(unsigned char *ptr, int bytes) -{ - while (bytes--) - if (*ptr++) - return 1; - return 0; -} - /* This just fills in a FlagType with current flags. */ FlagType MakeFlags(unsigned int flags) { @@ -1840,6 +1696,7 @@ } } +#warning TODO: move this to io_pcb /* In future all use of this should be supplanted by * pcb-printf and %mr/%m# spec */ const char *c_dtostr(double d) Index: trunk/src/misc.h =================================================================== --- trunk/src/misc.h (revision 1908) +++ trunk/src/misc.h (revision 1909) @@ -25,7 +25,7 @@ * RCS: $Id$ */ -/* prototypes for misc routines +/* prototypes for misc routines - PCB data type dependent ones */ #ifndef PCB_MISC_H @@ -36,20 +36,10 @@ #include #include "mymem.h" -enum unitflags { UNIT_PERCENT = 1 }; +const char *pcb_author(void); -typedef struct { - const char *suffix; - double scale; - enum unitflags flags; -} UnitList[]; - -double Distance(double x1, double y1, double x2, double y2); -double Distance2(double x1, double y1, double x2, double y2); /* distance square */ Angle NormalizeAngle(Angle a); -const char *pcb_author(void); - void r_delete_element(DataTypePtr, ElementTypePtr); void SetLineBoundingBox(LineTypePtr); void SetArcBoundingBox(ArcTypePtr); @@ -96,9 +86,6 @@ void ChangeArcAngles(LayerTypePtr, ArcTypePtr, Angle, Angle); char *UniqueElementName(DataTypePtr, char *); void AttachForCopy(Coord, Coord); -double GetValue(const char *, const char *, bool *, bool *success); -double GetValueEx(const char *, const char *, bool *, UnitList, const char *, bool *success); -char *Concat(const char *, ...); /* end with NULL */ /* Returns NULL if the name isn't found, else the value for that named attribute. */ Index: trunk/src/misc_util.c =================================================================== --- trunk/src/misc_util.c (nonexistent) +++ trunk/src/misc_util.c (revision 1909) @@ -0,0 +1,184 @@ +/* $Id$ */ + +/* + * COPYRIGHT + * + * PCB, interactive printed circuit board design + * Copyright (C) 1994,1995,1996,2004,2006 Thomas Nau + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Contact addresses for paper mail and Email: + * Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany + * Thomas.Nau@rz.uni-ulm.de + * + */ + +/* misc functions used by several modules + */ + +#include "config.h" +#include +#include +#include +#include +#include +#include +#include +#include "misc_util.h" +#include "unit.h" + +/* Distance() should be used so that there is only one + * place to deal with overflow/precision errors + */ +double Distance(double x1, double y1, double x2, double y2) +{ + double delta_x = (x2 - x1); + double delta_y = (y2 - y1); + return sqrt(delta_x * delta_x + delta_y * delta_y); +} + +/* Distance2() should be used so that there is only one + * place to deal with overflow/precision errors + */ +double Distance2(double x1, double y1, double x2, double y2) +{ + double delta_x = (x2 - x1); + double delta_y = (y2 - y1); + return delta_x * delta_x + delta_y * delta_y; +} + +/* Get Value returns a numeric value passed from the string and sets the + * bool variable absolute to false if it leads with a +/- character + */ +double GetValue(const char *val, const char *units, bool * absolute, bool *success) +{ + return GetValueEx(val, units, absolute, NULL, "cmil", success); +} + +double GetValueEx(const char *val, const char *units, bool * absolute, UnitList extra_units, const char *default_unit, bool *success) +{ + double value; + int n = -1; + bool scaled = 0; + bool dummy; + + /* Allow NULL to be passed for absolute */ + if (absolute == NULL) + absolute = &dummy; + + /* if the first character is a sign we have to add the + * value to the current one + */ + if (*val == '=') { + *absolute = true; + sscanf(val + 1, "%lf%n", &value, &n); + n++; + } + else { + if (isdigit((int) *val)) + *absolute = true; + else + *absolute = false; + sscanf(val, "%lf%n", &value, &n); + } + if (n <= 0) + goto fail; + + if (!units && n > 0) + units = val + n; + + while (units && isspace(*units)) + units++; + + if (units && *units) { + int i, unit_ok = 0; + const Unit *unit = get_unit_struct(units); + if (unit != NULL) { + value = unit_to_coord(unit, value); + scaled = 1; + unit_ok = 1; + } + if (extra_units) { + for (i = 0; *extra_units[i].suffix; ++i) { + if (strncmp(units, extra_units[i].suffix, strlen(extra_units[i].suffix)) == 0) { + value *= extra_units[i].scale; + if (extra_units[i].flags & UNIT_PERCENT) + value /= 100.0; + scaled = 1; + unit_ok = 1; + } + } + } + if ((!unit_ok) && (success != NULL)) /* there was something after the number but it doesn't look like a valid unit */ + goto fail; + } + + /* Apply default unit */ + if (!scaled && default_unit && *default_unit) { + int i; + const Unit *unit = get_unit_struct(default_unit); + if (extra_units) + for (i = 0; *extra_units[i].suffix; ++i) + if (strcmp(extra_units[i].suffix, default_unit) == 0) { + value *= extra_units[i].scale; + if (extra_units[i].flags & UNIT_PERCENT) + value /= 100.0; + scaled = 1; + } + if (!scaled && unit != NULL) + value = unit_to_coord(unit, value); + } + + if (success != NULL) + *success = 1; + return value; + + fail:; + if (success != NULL) + *success = 0; + return 0; +} + +char *Concat(const char *first, ...) +{ + char *rv; + int len; + va_list a; + + len = strlen(first); + rv = (char *) malloc(len + 1); + strcpy(rv, first); + + va_start(a, first); + while (1) { + const char *s = va_arg(a, const char *); + if (!s) + break; + len += strlen(s); + rv = (char *) realloc(rv, len + 1); + strcat(rv, s); + } + va_end(a); + return rv; +} + +int mem_any_set(unsigned char *ptr, int bytes) +{ + while (bytes--) + if (*ptr++) + return 1; + return 0; +} Index: trunk/src/misc_util.h =================================================================== --- trunk/src/misc_util.h (nonexistent) +++ trunk/src/misc_util.h (revision 1909) @@ -0,0 +1,51 @@ +/* + * COPYRIGHT + * + * PCB, interactive printed circuit board design + * Copyright (C) 1994,1995,1996,2006 Thomas Nau + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Contact addresses for paper mail and Email: + * Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany + * Thomas.Nau@rz.uni-ulm.de + * + * RCS: $Id$ + */ + +/* prototypes for misc routines - independent of PCB data types + */ + +#ifndef PCB_MISC_UTIL_H +#define PCB_MISC_UTIL_H + +double Distance(double x1, double y1, double x2, double y2); +double Distance2(double x1, double y1, double x2, double y2); /* distance square */ + +enum unitflags { UNIT_PERCENT = 1 }; + +typedef struct { + const char *suffix; + double scale; + enum unitflags flags; +} UnitList[]; + +double GetValue(const char *, const char *, bool *, bool *success); +double GetValueEx(const char *, const char *, bool *, UnitList, const char *, bool *success); + +char *Concat(const char *, ...); /* end with NULL */ +int mem_any_set(unsigned char *ptr, int bytes); + +#endif Index: trunk/src/object_act.c =================================================================== --- trunk/src/object_act.c (revision 1908) +++ trunk/src/object_act.c (revision 1909) @@ -46,6 +46,7 @@ #include "buffer.h" #include "remove.h" #include "create.h" +#include "misc_util.h" /* --------------------------------------------------------------------------- */ Index: trunk/src/pcb-printf.c =================================================================== --- trunk/src/pcb-printf.c (revision 1908) +++ trunk/src/pcb-printf.c (revision 1909) @@ -38,233 +38,6 @@ #include "pcb-printf.h" -/* Helper macros for tables */ -#define MM_TO_COORD3(a,b,c) MM_TO_COORD (a), MM_TO_COORD (b), MM_TO_COORD (c) -#define MIL_TO_COORD3(a,b,c) MIL_TO_COORD (a), MIL_TO_COORD (b), MIL_TO_COORD (c) -#define MM_TO_COORD5(a,b,c,d,e) MM_TO_COORD (a), MM_TO_COORD (b), MM_TO_COORD (c), \ - MM_TO_COORD (d), MM_TO_COORD (e) -#define MIL_TO_COORD5(a,b,c,d,e) MIL_TO_COORD (a), MIL_TO_COORD (b), MIL_TO_COORD (c), \ - MIL_TO_COORD (d), MIL_TO_COORD (e) - -/* These should be kept in order of smallest scale_factor - * to largest -- the code uses this ordering when finding - * the best scale to use for a group of measures */ -static Unit Units[] = { - {0, "km", NULL, 'k', 0.000001, METRIC, ALLOW_KM, 5, - 0.00005, 0.0005, 0.0025, 0.05, 0.25, - {""}}, - {0, "m", NULL, 'f', 0.001, METRIC, ALLOW_M, 5, - 0.0005, 0.005, 0.025, 0.5, 2.5, - {""}}, - {0, "cm", NULL, 'e', 0.1, METRIC, ALLOW_CM, 5, - 0.005, 0.05, 0.25, 5, 25, - {""}}, - {0, "mm", NULL, 'm', 1, METRIC, ALLOW_MM, 4, - 0.005, 0.05, 0.25, 5, 25, - {""}}, - {0, "um", NULL, 'u', 1000, METRIC, ALLOW_UM, 2, - 0.005, 0.05, 0.25, 5, 25, - {""}}, - {0, "nm", NULL, 'n', 1000000, METRIC, ALLOW_NM, 0, - 5, 50, 2500, 5000, 25000, - {""}}, - - {0, "in", NULL, 'i', 0.001, IMPERIAL, ALLOW_IN, 5, - 0.1, 1.0, 5.0, 25, 100, - {"inch"}}, - {0, "mil", NULL, 'l', 1, IMPERIAL, ALLOW_MIL, 2, - 0.1, 1.0, 10, 100, 1000, - {""}}, - {0, "cmil", NULL, 'c', 100, IMPERIAL, ALLOW_CMIL, 0, - 1, 10, 100, 1000, 10000, - {"pcb"}} -}; - -#define N_UNITS ((int) (sizeof Units / sizeof Units[0])) -/* \brief Initialize non-static data for pcb-printf - * \par Function Description - * Assigns each unit its index for quick access through the - * main units array, and internationalize the units for GUI - * display. - */ -void initialize_units() -{ - int i; - for (i = 0; i < N_UNITS; ++i) { - Units[i].index = i; - Units[i].in_suffix = _(Units[i].suffix); - } -} - -/* This list -must- contain all printable units from the above list */ -/* For now I have just copy/pasted the same values for all metric - * units and the same values for all imperial ones */ -static Increments increments[] = { - /* TABLE FORMAT | default | min | max - * grid | | | - * size | | | - * line | | | - * clear | | | - */ - {"km", MM_TO_COORD3(0.1, 0.01, 1.0), - MM_TO_COORD3(0.2, 0.01, 0.5), - MM_TO_COORD3(0.1, 0.005, 0.5), - MM_TO_COORD3(0.05, 0.005, 0.5)}, - {"m", MM_TO_COORD3(0.1, 0.01, 1.0), - MM_TO_COORD3(0.2, 0.01, 0.5), - MM_TO_COORD3(0.1, 0.005, 0.5), - MM_TO_COORD3(0.05, 0.005, 0.5)}, - {"cm", MM_TO_COORD3(0.1, 0.01, 1.0), - MM_TO_COORD3(0.2, 0.01, 0.5), - MM_TO_COORD3(0.1, 0.005, 0.5), - MM_TO_COORD3(0.05, 0.005, 0.5)}, - {"mm", MM_TO_COORD3(0.1, 0.01, 1.0), - MM_TO_COORD3(0.2, 0.01, 0.5), - MM_TO_COORD3(0.1, 0.005, 0.5), - MM_TO_COORD3(0.05, 0.005, 0.5)}, - {"um", MM_TO_COORD3(0.1, 0.01, 1.0), - MM_TO_COORD3(0.2, 0.01, 0.5), - MM_TO_COORD3(0.1, 0.005, 0.5), - MM_TO_COORD3(0.05, 0.005, 0.5)}, - {"nm", MM_TO_COORD3(0.1, 0.01, 1.0), - MM_TO_COORD3(0.2, 0.01, 0.5), - MM_TO_COORD3(0.1, 0.005, 0.5), - MM_TO_COORD3(0.05, 0.005, 0.5)}, - - {"cmil", MIL_TO_COORD3(5, 1, 25), - MIL_TO_COORD3(10, 1, 10), - MIL_TO_COORD3(5, 0.5, 10), - MIL_TO_COORD3(2, 0.5, 10)}, - {"mil", MIL_TO_COORD3(5, 1, 25), - MIL_TO_COORD3(10, 1, 10), - MIL_TO_COORD3(5, 0.5, 10), - MIL_TO_COORD3(2, 0.5, 10)}, - {"in", MIL_TO_COORD3(5, 1, 25), - MIL_TO_COORD3(10, 1, 10), - MIL_TO_COORD3(5, 0.5, 10), - MIL_TO_COORD3(2, 0.5, 10)}, -}; - -#define N_INCREMENTS (sizeof increments / sizeof increments[0]) - -/* \brief Obtain a unit object from its suffix - * \par Function Description - * Looks up a given suffix in the main units array. Internationalized - * unit suffixes are not supported, though pluralized units are, for - * backward-compatibility. - * - * \param [in] const_suffix The suffix to look up - * - * \return A const pointer to the Unit struct, or NULL if none was found - */ -const Unit *get_unit_struct(const char *suffix) -{ - int i; - int s_len = 0; - - /* Determine bounds */ - while (isspace(*suffix)) - suffix++; - while (isalnum(suffix[s_len])) - s_len++; - - /* Also understand plural suffixes: "inches", "mils" */ - if (s_len > 2) { - if (suffix[s_len - 2] == 'e' && suffix[s_len - 1] == 's') - s_len -= 2; - else if (suffix[s_len - 1] == 's') - s_len -= 1; - } - - /* Do lookup */ - if (s_len > 0) - for (i = 0; i < N_UNITS; ++i) - if (strncmp(suffix, Units[i].suffix, s_len) == 0 || strncmp(suffix, Units[i].alias[0], s_len) == 0) - return &Units[i]; - - return NULL; -} - -/* ACCESSORS */ -/* \brief Returns the master unit list. This may not be modified. */ -const Unit *get_unit_list(void) -{ - return Units; -} - -/* \brief Returns the unit by its index */ -const Unit *get_unit_by_idx(int idx) -{ - if ((idx < 0) || (idx >= N_UNITS)) - return NULL; - return Units + idx; -} - -/* \brief Returns the length of the master unit list. */ -int get_n_units(void) -{ - return N_UNITS; -} - -/* \brief Obtain an increment object from its suffix - * \par Function Description - * Looks up a given suffix in the main increments array. Internationalized - * unit suffixes are not supported, nor are pluralized units. - * - * \param [in] suffix The suffix to look up - * - * \return A const pointer to the Increments struct, or NULL if none was found - */ -Increments *get_increments_struct(const char *suffix) -{ - int i; - /* Do lookup */ - for (i = 0; i < N_INCREMENTS; ++i) - if (strcmp(suffix, increments[i].suffix) == 0) - return &increments[i]; - return NULL; -} - -/* \brief Convert a pcb coord to the given unit - * - * \param [in] unit The unit to convert to - * \param [in] x The quantity to convert - * - * \return The converted measure - */ -double coord_to_unit(const Unit * unit, Coord x) -{ - double base; - if (unit == NULL) - return -1; - base = unit->family == METRIC ? COORD_TO_MM(1) - : COORD_TO_MIL(1); - return x * unit->scale_factor * base; -} - -/* \brief Convert a given unit to pcb coords - * - * \param [in] unit The unit to convert from - * \param [in] x The quantity to convert - * - * \return The converted measure - */ -Coord unit_to_coord(const Unit * unit, double x) -{ - return x / coord_to_unit(unit, 1); -} - -/* \brief Return how many PCB-internal-Coord-unit a unit translates to - * - * \param [in] unit The unit to convert - * - * \return The converted measure - */ -double unit_to_factor(const Unit * unit) -{ - return 1.0 / coord_to_unit(unit, 1); -} - static int min_sig_figs(double d) { char buf[50]; @@ -364,7 +137,7 @@ /* Determine scale factor -- find smallest unit that brings * the whole group above unity */ - for (n = 0; n < N_UNITS; ++n) { + for (n = 0; n < get_n_units(); ++n) { if ((Units[n].allow & allow) != 0 && (Units[n].family == family)) { int n_above_one = 0; @@ -376,7 +149,7 @@ } } /* If nothing worked, wind back to the smallest allowable unit */ - if (n == N_UNITS) { + if (n == get_n_units()) { do { --n; } while ((Units[n].allow & allow) == 0 || Units[n].family != family); @@ -630,7 +403,7 @@ case '*': { int found = 0; - for (i = 0; i < N_UNITS; ++i) { + for (i = 0; i < get_n_units(); ++i) { if (strcmp(ext_unit, Units[i].suffix) == 0) { if (CoordsToString(string, value, 1, &spec, Units[i].allow, suffix) != 0) goto err; found = 1; @@ -654,7 +427,7 @@ default: { int found = 0; - for (i = 0; i < N_UNITS; ++i) { + for (i = 0; i < get_n_units(); ++i) { if (*fmt == Units[i].printf_code) { if (CoordsToString(string, value, 1, &spec, Units[i].allow, suffix) != 0) goto err; found = 1; Index: trunk/src/pcb-printf.h =================================================================== --- trunk/src/pcb-printf.h (revision 1908) +++ trunk/src/pcb-printf.h (revision 1909) @@ -70,85 +70,10 @@ #define PCB_PCB_PRINTF_H #include +#include "unit.h" -enum e_allow { - NO_PRINT = 0, /* suffixes we can read but not print (i.e., "inch") */ - ALLOW_NM = 1, - ALLOW_UM = 2, - ALLOW_MM = 4, - ALLOW_CM = 8, - ALLOW_M = 16, - ALLOW_KM = 32, - - ALLOW_CMIL = 1024, - ALLOW_MIL = 2048, - ALLOW_IN = 4096, - - ALLOW_METRIC = ALLOW_NM | ALLOW_UM | ALLOW_MM | ALLOW_CM | ALLOW_M | ALLOW_KM, - ALLOW_IMPERIAL = ALLOW_CMIL | ALLOW_MIL | ALLOW_IN, - /* This is all units allowed in parse_l.l */ -#if 0 - ALLOW_READABLE = ALLOW_NM | ALLOW_UM | ALLOW_MM | ALLOW_M | ALLOW_KM | ALLOW_CMIL | ALLOW_MIL | ALLOW_IN, -#else - ALLOW_READABLE = ALLOW_CMIL, -#endif - - ALLOW_ALL = ~0 -}; - -enum e_family { METRIC, IMPERIAL }; -enum e_suffix { NO_SUFFIX, SUFFIX, FILE_MODE }; - -struct unit { - int index; /* Index into Unit[] list */ - const char *suffix; - const char *in_suffix; /* internationalized suffix */ - char printf_code; - double scale_factor; - enum e_family family; - enum e_allow allow; - int default_prec; - /* used for gui spinboxes */ - double step_tiny; - double step_small; - double step_medium; - double step_large; - double step_huge; - /* aliases -- right now we only need 1 ("inch"->"in"), add as needed */ - const char *alias[1]; -}; - -struct increments { - const char *suffix; - /* key g and g value */ - Coord grid; - Coord grid_min; - Coord grid_max; - /* key s and s value */ - Coord size; - Coord size_min; - Coord size_max; - /* key l and l value */ - Coord line; - Coord line_min; - Coord line_max; - /* key k and k value */ - Coord clear; - Coord clear_min; - Coord clear_max; -}; - void initialize_units(); -const Unit *get_unit_struct(const char *suffix); -const Unit *get_unit_list(void); -const Unit *get_unit_by_idx(int idx); -int get_n_units(void); -double coord_to_unit(const Unit *, Coord); -double unit_to_factor(const Unit * unit); -Coord unit_to_coord(const Unit *, double); -Increments *get_increments_struct(const char *suffix); - int pcb_fprintf(FILE * f, const char *fmt, ...); int pcb_sprintf(char *string, const char *fmt, ...); int pcb_snprintf(char *string, size_t len, const char *fmt, ...); Index: trunk/src/polygon.c =================================================================== --- trunk/src/polygon.c (revision 1908) +++ trunk/src/polygon.c (revision 1909) @@ -92,6 +92,7 @@ #include "set.h" #include "thermal.h" #include "undo.h" +#include "misc.h" #define ROUND(x) ((long)(((x) >= 0 ? (x) + 0.5 : (x) - 0.5))) Index: trunk/src/search.c =================================================================== --- trunk/src/search.c (revision 1908) +++ trunk/src/search.c (revision 1909) @@ -44,6 +44,7 @@ #include "polygon.h" #include "rtree.h" #include "search.h" +#include "misc.h" RCSID("$Id$"); Index: trunk/src/search.h =================================================================== --- trunk/src/search.h (revision 1908) +++ trunk/src/search.h (revision 1909) @@ -32,6 +32,7 @@ #define PCB_SEARCH_H #include "global.h" +#include "misc_util.h" int lines_intersect(Coord ax1, Coord ay1, Coord ax2, Coord ay2, Coord bx1, Coord by1, Coord bx2, Coord by2); Index: trunk/src/unit.c =================================================================== --- trunk/src/unit.c (nonexistent) +++ trunk/src/unit.c (revision 1909) @@ -0,0 +1,258 @@ +/* + * COPYRIGHT + * + * PCB, interactive printed circuit board design + * Copyright (C) 2011 Andrew Poelstra + * Copyright (C) 2016 Tibor 'Igor2' Palinkas + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Contact addresses for paper mail and Email: + * Andrew Poelstra, 16966 60A Ave, V3S 8X5 Surrey, BC, Canada + * asp11@sfu.ca + * + */ +#include "config.h" +#include +#include +#include "global.h" +#include "unit.h" + +/* Helper macros for tables */ +#define MM_TO_COORD3(a,b,c) MM_TO_COORD (a), MM_TO_COORD (b), MM_TO_COORD (c) +#define MIL_TO_COORD3(a,b,c) MIL_TO_COORD (a), MIL_TO_COORD (b), MIL_TO_COORD (c) +#define MM_TO_COORD5(a,b,c,d,e) MM_TO_COORD (a), MM_TO_COORD (b), MM_TO_COORD (c), \ + MM_TO_COORD (d), MM_TO_COORD (e) +#define MIL_TO_COORD5(a,b,c,d,e) MIL_TO_COORD (a), MIL_TO_COORD (b), MIL_TO_COORD (c), \ + MIL_TO_COORD (d), MIL_TO_COORD (e) + +/* These should be kept in order of smallest scale_factor + * to largest -- the code uses this ordering when finding + * the best scale to use for a group of measures */ +Unit Units[] = { + {0, "km", NULL, 'k', 0.000001, METRIC, ALLOW_KM, 5, + 0.00005, 0.0005, 0.0025, 0.05, 0.25, + {""}}, + {0, "m", NULL, 'f', 0.001, METRIC, ALLOW_M, 5, + 0.0005, 0.005, 0.025, 0.5, 2.5, + {""}}, + {0, "cm", NULL, 'e', 0.1, METRIC, ALLOW_CM, 5, + 0.005, 0.05, 0.25, 5, 25, + {""}}, + {0, "mm", NULL, 'm', 1, METRIC, ALLOW_MM, 4, + 0.005, 0.05, 0.25, 5, 25, + {""}}, + {0, "um", NULL, 'u', 1000, METRIC, ALLOW_UM, 2, + 0.005, 0.05, 0.25, 5, 25, + {""}}, + {0, "nm", NULL, 'n', 1000000, METRIC, ALLOW_NM, 0, + 5, 50, 2500, 5000, 25000, + {""}}, + + {0, "in", NULL, 'i', 0.001, IMPERIAL, ALLOW_IN, 5, + 0.1, 1.0, 5.0, 25, 100, + {"inch"}}, + {0, "mil", NULL, 'l', 1, IMPERIAL, ALLOW_MIL, 2, + 0.1, 1.0, 10, 100, 1000, + {""}}, + {0, "cmil", NULL, 'c', 100, IMPERIAL, ALLOW_CMIL, 0, + 1, 10, 100, 1000, 10000, + {"pcb"}} +}; + +#define N_UNITS ((int) (sizeof Units / sizeof Units[0])) +/* \brief Initialize non-static data for pcb-printf + * \par Function Description + * Assigns each unit its index for quick access through the + * main units array, and internationalize the units for GUI + * display. + */ +void initialize_units() +{ + int i; + for (i = 0; i < N_UNITS; ++i) { + Units[i].index = i; + Units[i].in_suffix = _(Units[i].suffix); + } +} + +/* This list -must- contain all printable units from the above list */ +/* For now I have just copy/pasted the same values for all metric + * units and the same values for all imperial ones */ +Increments increments[] = { + /* TABLE FORMAT | default | min | max + * grid | | | + * size | | | + * line | | | + * clear | | | + */ + {"km", MM_TO_COORD3(0.1, 0.01, 1.0), + MM_TO_COORD3(0.2, 0.01, 0.5), + MM_TO_COORD3(0.1, 0.005, 0.5), + MM_TO_COORD3(0.05, 0.005, 0.5)}, + {"m", MM_TO_COORD3(0.1, 0.01, 1.0), + MM_TO_COORD3(0.2, 0.01, 0.5), + MM_TO_COORD3(0.1, 0.005, 0.5), + MM_TO_COORD3(0.05, 0.005, 0.5)}, + {"cm", MM_TO_COORD3(0.1, 0.01, 1.0), + MM_TO_COORD3(0.2, 0.01, 0.5), + MM_TO_COORD3(0.1, 0.005, 0.5), + MM_TO_COORD3(0.05, 0.005, 0.5)}, + {"mm", MM_TO_COORD3(0.1, 0.01, 1.0), + MM_TO_COORD3(0.2, 0.01, 0.5), + MM_TO_COORD3(0.1, 0.005, 0.5), + MM_TO_COORD3(0.05, 0.005, 0.5)}, + {"um", MM_TO_COORD3(0.1, 0.01, 1.0), + MM_TO_COORD3(0.2, 0.01, 0.5), + MM_TO_COORD3(0.1, 0.005, 0.5), + MM_TO_COORD3(0.05, 0.005, 0.5)}, + {"nm", MM_TO_COORD3(0.1, 0.01, 1.0), + MM_TO_COORD3(0.2, 0.01, 0.5), + MM_TO_COORD3(0.1, 0.005, 0.5), + MM_TO_COORD3(0.05, 0.005, 0.5)}, + + {"cmil", MIL_TO_COORD3(5, 1, 25), + MIL_TO_COORD3(10, 1, 10), + MIL_TO_COORD3(5, 0.5, 10), + MIL_TO_COORD3(2, 0.5, 10)}, + {"mil", MIL_TO_COORD3(5, 1, 25), + MIL_TO_COORD3(10, 1, 10), + MIL_TO_COORD3(5, 0.5, 10), + MIL_TO_COORD3(2, 0.5, 10)}, + {"in", MIL_TO_COORD3(5, 1, 25), + MIL_TO_COORD3(10, 1, 10), + MIL_TO_COORD3(5, 0.5, 10), + MIL_TO_COORD3(2, 0.5, 10)}, +}; + +#define N_INCREMENTS (sizeof increments / sizeof increments[0]) + +/* \brief Obtain a unit object from its suffix + * \par Function Description + * Looks up a given suffix in the main units array. Internationalized + * unit suffixes are not supported, though pluralized units are, for + * backward-compatibility. + * + * \param [in] const_suffix The suffix to look up + * + * \return A const pointer to the Unit struct, or NULL if none was found + */ +const Unit *get_unit_struct(const char *suffix) +{ + int i; + int s_len = 0; + + /* Determine bounds */ + while (isspace(*suffix)) + suffix++; + while (isalnum(suffix[s_len])) + s_len++; + + /* Also understand plural suffixes: "inches", "mils" */ + if (s_len > 2) { + if (suffix[s_len - 2] == 'e' && suffix[s_len - 1] == 's') + s_len -= 2; + else if (suffix[s_len - 1] == 's') + s_len -= 1; + } + + /* Do lookup */ + if (s_len > 0) + for (i = 0; i < N_UNITS; ++i) + if (strncmp(suffix, Units[i].suffix, s_len) == 0 || strncmp(suffix, Units[i].alias[0], s_len) == 0) + return &Units[i]; + + return NULL; +} + +/* ACCESSORS */ +/* \brief Returns the master unit list. This may not be modified. */ +const Unit *get_unit_list(void) +{ + return Units; +} + +/* \brief Returns the unit by its index */ +const Unit *get_unit_by_idx(int idx) +{ + if ((idx < 0) || (idx >= N_UNITS)) + return NULL; + return Units + idx; +} + +/* \brief Returns the length of the master unit list. */ +int get_n_units(void) +{ + return N_UNITS; +} + +/* \brief Convert a pcb coord to the given unit + * + * \param [in] unit The unit to convert to + * \param [in] x The quantity to convert + * + * \return The converted measure + */ +double coord_to_unit(const Unit * unit, Coord x) +{ + double base; + if (unit == NULL) + return -1; + base = unit->family == METRIC ? COORD_TO_MM(1) + : COORD_TO_MIL(1); + return x * unit->scale_factor * base; +} + +/* \brief Convert a given unit to pcb coords + * + * \param [in] unit The unit to convert from + * \param [in] x The quantity to convert + * + * \return The converted measure + */ +Coord unit_to_coord(const Unit * unit, double x) +{ + return x / coord_to_unit(unit, 1); +} + +/* \brief Return how many PCB-internal-Coord-unit a unit translates to + * + * \param [in] unit The unit to convert + * + * \return The converted measure + */ +double unit_to_factor(const Unit * unit) +{ + return 1.0 / coord_to_unit(unit, 1); +} + +/* \brief Obtain an increment object from its suffix + * \par Function Description + * Looks up a given suffix in the main increments array. Internationalized + * unit suffixes are not supported, nor are pluralized units. + * + * \param [in] suffix The suffix to look up + * + * \return A const pointer to the Increments struct, or NULL if none was found + */ +Increments *get_increments_struct(const char *suffix) +{ + int i; + /* Do lookup */ + for (i = 0; i < N_INCREMENTS; ++i) + if (strcmp(suffix, increments[i].suffix) == 0) + return &increments[i]; + return NULL; +} Index: trunk/src/unit.h =================================================================== --- trunk/src/unit.h (nonexistent) +++ trunk/src/unit.h (revision 1909) @@ -0,0 +1,118 @@ +/* + * COPYRIGHT + * + * PCB, interactive printed circuit board design + * Copyright (C) 2011 Andrew Poelstra + * Copyright (C) 2016 Tibor 'Igor2' Palinkas + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Contact addresses for paper mail and Email: + * Andrew Poelstra, 16966 60A Ave, V3S 8X5 Surrey, BC, Canada + * asp11@sfu.ca + * + */ + +#ifndef PCB_UNIT_H +#define PCB_UNIT_H + +#include "config.h" + +typedef COORD_TYPE Coord; /* pcb base unit */ +typedef double Angle; /* degrees */ + +enum e_allow { + NO_PRINT = 0, /* suffixes we can read but not print (i.e., "inch") */ + ALLOW_NM = 1, + ALLOW_UM = 2, + ALLOW_MM = 4, + ALLOW_CM = 8, + ALLOW_M = 16, + ALLOW_KM = 32, + + ALLOW_CMIL = 1024, + ALLOW_MIL = 2048, + ALLOW_IN = 4096, + + ALLOW_METRIC = ALLOW_NM | ALLOW_UM | ALLOW_MM | ALLOW_CM | ALLOW_M | ALLOW_KM, + ALLOW_IMPERIAL = ALLOW_CMIL | ALLOW_MIL | ALLOW_IN, + /* This is all units allowed in parse_l.l */ +#if 0 + ALLOW_READABLE = ALLOW_NM | ALLOW_UM | ALLOW_MM | ALLOW_M | ALLOW_KM | ALLOW_CMIL | ALLOW_MIL | ALLOW_IN, +#else + ALLOW_READABLE = ALLOW_CMIL, +#endif + + ALLOW_ALL = ~0 +}; + +enum e_family { METRIC, IMPERIAL }; +enum e_suffix { NO_SUFFIX, SUFFIX, FILE_MODE }; + +struct unit { + int index; /* Index into Unit[] list */ + const char *suffix; + const char *in_suffix; /* internationalized suffix */ + char printf_code; + double scale_factor; + enum e_family family; + enum e_allow allow; + int default_prec; + /* used for gui spinboxes */ + double step_tiny; + double step_small; + double step_medium; + double step_large; + double step_huge; + /* aliases -- right now we only need 1 ("inch"->"in"), add as needed */ + const char *alias[1]; +}; + +struct increments { + const char *suffix; + /* key g and g value */ + Coord grid; + Coord grid_min; + Coord grid_max; + /* key s and s value */ + Coord size; + Coord size_min; + Coord size_max; + /* key l and l value */ + Coord line; + Coord line_min; + Coord line_max; + /* key k and k value */ + Coord clear; + Coord clear_min; + Coord clear_max; +}; + +typedef struct unit Unit; +typedef struct increments Increments; +extern Unit Units[]; +extern Increments increments[]; + +const Unit *get_unit_struct(const char *suffix); +const Unit *get_unit_list(void); +const Unit *get_unit_by_idx(int idx); +int get_n_units(void); +double coord_to_unit(const Unit *, Coord); +double unit_to_factor(const Unit * unit); +Coord unit_to_coord(const Unit *, double); +Increments *get_increments_struct(const char *suffix); + + +#endif Index: trunk/src_plugins/export_png/png.c =================================================================== --- trunk/src_plugins/export_png/png.c (revision 1908) +++ trunk/src_plugins/export_png/png.c (revision 1909) @@ -38,6 +38,7 @@ #include "data.h" #include "error.h" #include "misc.h" +#include "misc_util.h" #include "plugins.h" #include "hid.h" Index: trunk/src_plugins/gpmi/pcb-gpmi/gpmi_plugin/gpmi_plugin.c =================================================================== --- trunk/src_plugins/gpmi/pcb-gpmi/gpmi_plugin/gpmi_plugin.c (revision 1908) +++ trunk/src_plugins/gpmi/pcb-gpmi/gpmi_plugin/gpmi_plugin.c (revision 1909) @@ -4,6 +4,7 @@ #include #include #include "src/misc.h" +#include "src/misc_util.h" #include "src/event.h" #include "src/paths.h" #include "src/error.h" Index: trunk/src_plugins/gpmi/pcb-gpmi/gpmi_plugin/manage_scripts.c =================================================================== --- trunk/src_plugins/gpmi/pcb-gpmi/gpmi_plugin/manage_scripts.c (revision 1908) +++ trunk/src_plugins/gpmi/pcb-gpmi/gpmi_plugin/manage_scripts.c (revision 1909) @@ -4,6 +4,7 @@ #include #include #include "src/misc.h" +#include "src/misc_util.h" #include "src/event.h" #include "gpmi_plugin.h" #include "scripts.h" Index: trunk/src_plugins/gpmi/pcb-gpmi/gpmi_plugin/scripts.c =================================================================== --- trunk/src_plugins/gpmi/pcb-gpmi/gpmi_plugin/scripts.c (revision 1908) +++ trunk/src_plugins/gpmi/pcb-gpmi/gpmi_plugin/scripts.c (revision 1909) @@ -6,11 +6,13 @@ #include #include #include "src/misc.h" +#include "src/misc_util.h" #include "src/event.h" #include "src/error.h" #include "gpmi_plugin.h" #include "scripts.h" + #define CONFNAME "pcb-rnd-gpmi.conf" hid_gpmi_script_info_t *hid_gpmi_script_info = NULL; Index: trunk/src_plugins/hid_gtk/ghid-coord-entry.h =================================================================== --- trunk/src_plugins/hid_gtk/ghid-coord-entry.h (revision 1908) +++ trunk/src_plugins/hid_gtk/ghid-coord-entry.h (revision 1909) @@ -7,6 +7,7 @@ #include #include +#include "unit.h" G_BEGIN_DECLS /* keep c++ happy */ #define GHID_COORD_ENTRY_TYPE (ghid_coord_entry_get_type ()) Index: trunk/src_plugins/hid_gtk/ghid-main-menu.c =================================================================== --- trunk/src_plugins/hid_gtk/ghid-main-menu.c (revision 1908) +++ trunk/src_plugins/hid_gtk/ghid-main-menu.c (revision 1909) @@ -12,6 +12,7 @@ #include "gtkhid.h" #include "gui.h" #include "pcb-printf.h" +#include "misc_util.h" #include "ghid-main-menu.h" #include "ghid-layer-selector.h" Index: trunk/src_plugins/hid_gtk/gtkhid-main.c =================================================================== --- trunk/src_plugins/hid_gtk/gtkhid-main.c (revision 1908) +++ trunk/src_plugins/hid_gtk/gtkhid-main.c (revision 1909) @@ -26,6 +26,7 @@ #include "hid_flags.h" #include "hid_actions.h" #include "plug_footprint.h" +#include "misc_util.h" #include "gtkhid.h" Index: trunk/src_plugins/hid_gtk/gui-config.c =================================================================== --- trunk/src_plugins/hid_gtk/gui-config.c (revision 1908) +++ trunk/src_plugins/hid_gtk/gui-config.c (revision 1909) @@ -48,6 +48,7 @@ #include "set.h" #include "hid_attrib.h" #include "conf.h" +#include "misc_util.h" /* for MKDIR() */ #include "compat_fs.h" Index: trunk/src_plugins/hid_gtk/gui-dialog-print.c =================================================================== --- trunk/src_plugins/hid_gtk/gui-dialog-print.c (revision 1908) +++ trunk/src_plugins/hid_gtk/gui-dialog-print.c (revision 1909) @@ -39,6 +39,7 @@ #include "pcb-printf.h" #include "hid_attrib.h" #include "hid_init.h" +#include "misc_util.h" RCSID("$Id$"); Index: trunk/src_plugins/hid_gtk/gui-misc.c =================================================================== --- trunk/src_plugins/hid_gtk/gui-misc.c (revision 1908) +++ trunk/src_plugins/hid_gtk/gui-misc.c (revision 1909) @@ -34,6 +34,7 @@ #include "action_helper.h" #include "set.h" #include "pcb-printf.h" +#include "misc_util.h" #include "gui.h" #include Index: trunk/src_plugins/hid_lesstif/dialogs.c =================================================================== --- trunk/src_plugins/hid_lesstif/dialogs.c (revision 1908) +++ trunk/src_plugins/hid_lesstif/dialogs.c (revision 1909) @@ -23,6 +23,7 @@ #include "hid_actions.h" #include "hid_init.h" #include "stdarg.h" +#include "misc_util.h" RCSID("$Id$"); Index: trunk/src_plugins/hid_lesstif/main.c =================================================================== --- trunk/src_plugins/hid_lesstif/main.c (revision 1908) +++ trunk/src_plugins/hid_lesstif/main.c (revision 1909) @@ -42,6 +42,7 @@ #include "hid_flags.h" #include "hid_actions.h" #include "stdarg.h" +#include "misc_util.h" #include Index: trunk/src_plugins/hid_lesstif/styles.c =================================================================== --- trunk/src_plugins/hid_lesstif/styles.c (revision 1908) +++ trunk/src_plugins/hid_lesstif/styles.c (revision 1909) @@ -22,6 +22,7 @@ #include "lesstif.h" #include "hid_flags.h" #include "stdarg.h" +#include "misc_util.h" RCSID("$Id$"); Index: trunk/src_plugins/import_sch/import_sch.c =================================================================== --- trunk/src_plugins/import_sch/import_sch.c (revision 1908) +++ trunk/src_plugins/import_sch/import_sch.c (revision 1909) @@ -42,6 +42,7 @@ #include "rats.h" #include "hid_actions.h" #include "import_sch_conf.h" +#include "misc_util.h" conf_import_sch_t conf_import_sch; Index: trunk/src_plugins/puller/puller.c =================================================================== --- trunk/src_plugins/puller/puller.c (revision 1908) +++ trunk/src_plugins/puller/puller.c (revision 1909) @@ -69,6 +69,7 @@ #include "undo.h" #include "plugins.h" #include "hid_actions.h" +#include "misc_util.h" RCSID("$Id$"); Index: trunk/src_plugins/report/report.c =================================================================== --- trunk/src_plugins/report/report.c (revision 1908) +++ trunk/src_plugins/report/report.c (revision 1909) @@ -50,6 +50,7 @@ #include "pcb-printf.h" #include "plugins.h" #include "hid_actions.h" +#include "misc_util.h" #ifdef HAVE_REGEX_H #include