Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
e5452a7a
Commit
e5452a7a
authored
Jun 24, 2012
by
Dick Hollenbeck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove "long double" dependency, mingw was falling over when using it.
parent
4019284e
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
57 deletions
+53
-57
legacy_plugin.cpp
pcbnew/legacy_plugin.cpp
+22
-35
legacy_plugin.h
pcbnew/legacy_plugin.h
+2
-5
test-nm-biu-to-ascii-mm-round-tripping.cpp
tools/test-nm-biu-to-ascii-mm-round-tripping.cpp
+10
-11
uncrustify.cfg
uncrustify.cfg
+19
-6
No files found.
pcbnew/legacy_plugin.cpp
View file @
e5452a7a
...
@@ -355,12 +355,6 @@ void LEGACY_PLUGIN::loadGENERAL()
...
@@ -355,12 +355,6 @@ void LEGACY_PLUGIN::loadGENERAL()
{
{
#if defined( USE_PCBNEW_NANOMETRES )
#if defined( USE_PCBNEW_NANOMETRES )
diskToBiu
=
IU_PER_MM
;
diskToBiu
=
IU_PER_MM
;
#elif defined(DEBUG)
// mm to deci-mils:
// advanced testing of round tripping only, not supported in non DEBUG build
diskToBiu
=
IU_PER_MM
;
#else
#else
THROW_IO_ERROR
(
_
(
"May not load millimeter *.brd file into 'Pcbnew compiled for deci-mils'"
)
);
THROW_IO_ERROR
(
_
(
"May not load millimeter *.brd file into 'Pcbnew compiled for deci-mils'"
)
);
#endif
#endif
...
@@ -2567,15 +2561,12 @@ void LEGACY_PLUGIN::loadPCB_TARGET()
...
@@ -2567,15 +2561,12 @@ void LEGACY_PLUGIN::loadPCB_TARGET()
int
LEGACY_PLUGIN
::
biuSprintf
(
char
*
buf
,
BIU
aValue
)
const
int
LEGACY_PLUGIN
::
biuSprintf
(
char
*
buf
,
BIU
aValue
)
const
{
{
long
double
engUnits
=
biuToDisk
*
aValue
;
double
engUnits
=
biuToDisk
*
aValue
;
int
len
;
int
len
;
if
(
engUnits
!=
0.0
&&
fabsl
(
engUnits
)
<=
0.0001
)
if
(
engUnits
!=
0.0
&&
fabsl
(
engUnits
)
<=
0.0001
)
{
{
// Windows printf and sprintf do not support long double, but MinGW replaces
len
=
snprintf
(
buf
,
SPBUFZ
,
"%.10f"
,
engUnits
);
// snprintf and vsnprintf only with versions that do.
// http://gcc.gnu.org/ml/libstdc++/2008-02/msg00081.html
len
=
snprintf
(
buf
,
SPBUFZ
,
"%.10Lf"
,
engUnits
);
while
(
--
len
>
0
&&
buf
[
len
]
==
'0'
)
while
(
--
len
>
0
&&
buf
[
len
]
==
'0'
)
buf
[
len
]
=
'\0'
;
buf
[
len
]
=
'\0'
;
...
@@ -2584,9 +2575,16 @@ int LEGACY_PLUGIN::biuSprintf( char* buf, BIU aValue ) const
...
@@ -2584,9 +2575,16 @@ int LEGACY_PLUGIN::biuSprintf( char* buf, BIU aValue ) const
}
}
else
else
{
{
// Windows printf and sprintf do not support long double, but MinGW replaces
// The %.10g is about optimal since we are dealing with a bounded
// snprintf and vsnprintf only with versions that do.
// range on aValue, and we can be sure that there will never
len
=
snprintf
(
buf
,
SPBUFZ
,
"%.10Lg"
,
engUnits
);
// be a reason to have more than 6 digits to the right of the
// decimal point because we are converting from integer
// (signed whole numbers) nanometers to mm. A value of
// 0.000001 is one nanometer, the smallest positive nonzero value
// that we can ever have here. If you ever see a board file with
// more digits to the right of the decimal point than 6, this is a
// possibly a bug in a formatting string nearby.
len
=
snprintf
(
buf
,
SPBUFZ
,
"%.10g"
,
engUnits
);
}
}
return
len
;
return
len
;
}
}
...
@@ -2636,12 +2634,7 @@ BIU LEGACY_PLUGIN::biuParse( const char* aValue, const char** nptrptr )
...
@@ -2636,12 +2634,7 @@ BIU LEGACY_PLUGIN::biuParse( const char* aValue, const char** nptrptr )
errno
=
0
;
errno
=
0
;
// The strategy in this function, which utilizes "long double" was verified using
double
fval
=
strtod
(
aValue
,
&
nptr
);
// tools/test-nm-biu-to-ascii-mm-round-tripping.cpp. For it to work "long double" must
// have more precision than double. gcc has this, and its all we care about.
// MINGW does have a working strtold()
long
double
fval
=
strtold
(
aValue
,
&
nptr
);
if
(
errno
)
if
(
errno
)
{
{
...
@@ -2708,20 +2701,20 @@ void LEGACY_PLUGIN::init( PROPERTIES* aProperties )
...
@@ -2708,20 +2701,20 @@ void LEGACY_PLUGIN::init( PROPERTIES* aProperties )
// conversion factor for saving RAM BIUs to KICAD legacy file format.
// conversion factor for saving RAM BIUs to KICAD legacy file format.
#if defined( USE_PCBNEW_NANOMETRES )
#if defined( USE_PCBNEW_NANOMETRES )
biuToDisk
=
1.0
L
/
IU_PER_MM
;
// BIUs are nanometers & file is mm
biuToDisk
=
1.0
/
IU_PER_MM
;
// BIUs are nanometers & file is mm
#else
#else
biuToDisk
=
1.0
L
;
// BIUs are deci-mils
biuToDisk
=
1.0
;
// BIUs are deci-mils
#endif
#endif
// conversion factor for loading KICAD legacy file format into BIUs in RAM
// Conversion factor for loading KICAD legacy file format into BIUs in RAM
// Start by assuming the *.brd file is in deci-mils.
// Start by assuming the *.brd file is in deci-mils.
//
i
f we see "Units mm" in the $GENERAL section, set diskToBiu to 1000000.0
//
I
f we see "Units mm" in the $GENERAL section, set diskToBiu to 1000000.0
// then, during the file loading process, to start a conversion from
// then, during the file loading process, to start a conversion from
// mm to nanometers.
// mm to nanometers. The deci-mil legacy files have no such "Units" marker
// so we must assume the file is in deci-mils until told otherwise.
diskToBiu
=
IU_PER_DECIMILS
;
// BIUs are nanometers if
USE_PCBNEW_NANOMETRES
diskToBiu
=
IU_PER_DECIMILS
;
// BIUs are nanometers if
defined(USE_PCBNEW_NANOMETRES)
//
or BIUs
are deci-mils
//
else
are deci-mils
}
}
...
@@ -3859,12 +3852,6 @@ void FPL_CACHE::ReadAndVerifyHeader( LINE_READER* aReader )
...
@@ -3859,12 +3852,6 @@ void FPL_CACHE::ReadAndVerifyHeader( LINE_READER* aReader )
{
{
#if defined( USE_PCBNEW_NANOMETRES )
#if defined( USE_PCBNEW_NANOMETRES )
m_owner
->
diskToBiu
=
IU_PER_MM
;
m_owner
->
diskToBiu
=
IU_PER_MM
;
#elif defined(DEBUG)
// mm to deci-mils:
// advanced testing of round tripping only, not supported in non DEBUG build
m_owner
->
diskToBiu
=
IU_PER_MM
;
#else
#else
THROW_IO_ERROR
(
_
(
"May not load millimeter legacy library file into 'Pcbnew compiled for deci-mils'"
)
);
THROW_IO_ERROR
(
_
(
"May not load millimeter legacy library file into 'Pcbnew compiled for deci-mils'"
)
);
#endif
#endif
...
...
pcbnew/legacy_plugin.h
View file @
e5452a7a
...
@@ -126,16 +126,13 @@ protected:
...
@@ -126,16 +126,13 @@ protected:
int
m_loading_format_version
;
///< which BOARD_FORMAT_VERSION am I Load()ing?
int
m_loading_format_version
;
///< which BOARD_FORMAT_VERSION am I Load()ing?
FPL_CACHE
*
m_cache
;
FPL_CACHE
*
m_cache
;
/// initialize PLUGIN like a constructor would, and futz with fresh BOARD if needed.
/// initialize PLUGIN like a constructor would, and futz with fresh BOARD if needed.
void
init
(
PROPERTIES
*
aProperties
);
void
init
(
PROPERTIES
*
aProperties
);
// Use of long double might affect MSVC++'s ability to make KiCad.
double
biuToDisk
;
///< convert from BIUs to disk engineering units
long
double
biuToDisk
;
///< convert from BIUs to disk engineering units
///< with this scale factor
///< with this scale factor
long
double
diskToBiu
;
///< convert from disk engineering units to BIUs
double
diskToBiu
;
///< convert from disk engineering units to BIUs
///< with this scale factor
///< with this scale factor
/**
/**
...
...
tools/test-nm-biu-to-ascii-mm-round-tripping.cpp
View file @
e5452a7a
...
@@ -27,25 +27,23 @@ static inline int KiROUND( double v )
...
@@ -27,25 +27,23 @@ static inline int KiROUND( double v )
typedef
int
BIU
;
typedef
int
BIU
;
#define BIU_PER_MM 1e6
L
#define BIU_PER_MM 1e6
//double scale = BIU_PER_MM;
//double scale = BIU_PER_MM;
//double scale = UM_PER_BIU;
//double scale = UM_PER_BIU;
long
double
scale
=
1.0
L
/
BIU_PER_MM
;
double
scale
=
1.0
/
BIU_PER_MM
;
std
::
string
biuFmt
(
BIU
aValue
)
std
::
string
biuFmt
(
BIU
aValue
)
{
{
long
double
engUnits
=
aValue
*
scale
;
double
engUnits
=
aValue
*
scale
;
char
temp
[
48
];
char
temp
[
48
];
int
len
;
int
len
;
if
(
engUnits
!=
0.0
&&
fabsl
(
engUnits
)
<=
0.0001
)
if
(
engUnits
!=
0.0
&&
fabsl
(
engUnits
)
<=
0.0001
)
{
{
snprintf
(
temp
,
sizeof
(
temp
),
"%.10Lf"
,
engUnits
);
len
=
snprintf
(
temp
,
sizeof
(
temp
),
"%.16f"
,
engUnits
);
len
=
strlen
(
temp
);
while
(
--
len
>
0
&&
temp
[
len
]
==
'0'
)
while
(
--
len
>
0
&&
temp
[
len
]
==
'0'
)
temp
[
len
]
=
'\0'
;
temp
[
len
]
=
'\0'
;
...
@@ -54,7 +52,7 @@ std::string biuFmt( BIU aValue )
...
@@ -54,7 +52,7 @@ std::string biuFmt( BIU aValue )
}
}
else
else
{
{
len
=
snprintf
(
temp
,
sizeof
(
temp
),
"%.10L
g"
,
engUnits
);
len
=
snprintf
(
temp
,
sizeof
(
temp
),
"%.16
g"
,
engUnits
);
}
}
return
std
::
string
(
temp
,
len
);;
return
std
::
string
(
temp
,
len
);;
...
@@ -63,8 +61,9 @@ std::string biuFmt( BIU aValue )
...
@@ -63,8 +61,9 @@ std::string biuFmt( BIU aValue )
int
parseBIU
(
const
char
*
s
)
int
parseBIU
(
const
char
*
s
)
{
{
long
double
d
=
strtol
d
(
s
,
NULL
);
double
d
=
strto
d
(
s
,
NULL
);
return
KiROUND
(
double
(
d
*
BIU_PER_MM
)
);
return
KiROUND
(
double
(
d
*
BIU_PER_MM
)
);
// return int( d * BIU_PER_MM );
}
}
...
@@ -84,7 +83,7 @@ int main( int argc, char** argv )
...
@@ -84,7 +83,7 @@ int main( int argc, char** argv )
printf
(
"%s: s:%s
\n
"
,
__func__
,
s
.
c_str
()
);
printf
(
"%s: s:%s
\n
"
,
__func__
,
s
.
c_str
()
);
exit
(
1
);
exit
(
0
);
}
}
// printf( "sizeof(long double): %zd\n", sizeof( long double ) );
// printf( "sizeof(long double): %zd\n", sizeof( long double ) );
...
...
uncrustify.cfg
View file @
e5452a7a
...
@@ -99,6 +99,9 @@ indent_class = true # false/true
...
@@ -99,6 +99,9 @@ indent_class = true # false/true
# Whether to indent the stuff after a leading class colon
# Whether to indent the stuff after a leading class colon
indent_class_colon = false # false/true
indent_class_colon = false # false/true
# Virtual indent from the ':' for member initializers. Default is 2
indent_ctor_init_leading = 2 # number
# Additional indenting for constructor initializer list
# Additional indenting for constructor initializer list
indent_ctor_init = 0 # number
indent_ctor_init = 0 # number
...
@@ -221,6 +224,12 @@ sp_arith = force # ignore/add/remove/force
...
@@ -221,6 +224,12 @@ sp_arith = force # ignore/add/remove/force
# Add or remove space around assignment operator '=', '+=', etc
# Add or remove space around assignment operator '=', '+=', etc
sp_assign = force # ignore/add/remove/force
sp_assign = force # ignore/add/remove/force
# Add or remove space around '=' in C++11 lambda capture specifications. Overrides sp_assign
sp_cpp_lambda_assign = ignore # ignore/add/remove/force
# Add or remove space after the capture specification in C++11 lambda.
sp_cpp_lambda_paren = ignore # ignore/add/remove/force
# Add or remove space around assignment operator '=' in a prototype
# Add or remove space around assignment operator '=' in a prototype
sp_assign_default = ignore # ignore/add/remove/force
sp_assign_default = ignore # ignore/add/remove/force
...
@@ -326,6 +335,10 @@ sp_angle_word = ignore # ignore/add/remove/force
...
@@ -326,6 +335,10 @@ sp_angle_word = ignore # ignore/add/remove/force
# Add or remove space between '>' and '>' in '>>' (template stuff C++/C# only). Default=Add
# Add or remove space between '>' and '>' in '>>' (template stuff C++/C# only). Default=Add
sp_angle_shift = add # ignore/add/remove/force
sp_angle_shift = add # ignore/add/remove/force
# Permit removal of the space between '>>' in 'foo<bar<int> >' (C++11 only). Default=False
# sp_angle_shift cannot remove the space without this option.
sp_permit_cpp11_shift = false # false/true
# Add or remove space before '(' of 'if', 'for', 'switch', and 'while'
# Add or remove space before '(' of 'if', 'for', 'switch', and 'while'
sp_before_sparen = remove # ignore/add/remove/force
sp_before_sparen = remove # ignore/add/remove/force
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment