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
02e1f839
Commit
02e1f839
authored
Dec 28, 2010
by
Dick Hollenbeck
Browse files
Options
Browse Files
Download
Plain Diff
fix utf8 IO_ERROR() compile problem
parents
a6e21516
53249cda
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
48 additions
and
44 deletions
+48
-44
kicad_exceptions.h
include/kicad_exceptions.h
+4
-8
sch_dir_lib_source.cpp
new/sch_dir_lib_source.cpp
+7
-7
sch_lib_table.cpp
new/sch_lib_table.cpp
+23
-20
sch_lib_table.h
new/sch_lib_table.h
+5
-5
toolchain-mingw.cmake
new/toolchain-mingw.cmake
+9
-4
No files found.
include/kicad_exceptions.h
View file @
02e1f839
...
...
@@ -30,6 +30,7 @@
#include <wx/string.h>
#include <string>
/**
* Struct IO_ERROR
...
...
@@ -41,18 +42,13 @@ struct IO_ERROR
{
wxString
errorText
;
IO_ERROR
(
const
wxChar
*
aMsg
)
:
errorText
(
aMsg
)
{
}
IO_ERROR
(
const
wxString
&
aMsg
)
:
errorText
(
aMsg
)
{
}
IO_ERROR
(
const
char
*
aMsg
)
:
errorText
(
wxConvertMB2WX
(
aMsg
)
)
IO_ERROR
(
const
std
::
string
&
aMsg
)
:
errorText
(
wxConvertMB2WX
(
aMsg
.
c_str
()
)
)
{
}
};
...
...
@@ -66,7 +62,7 @@ struct IO_ERROR
*/
struct
PARSE_ERROR
:
public
IO_ERROR
{
wxString
source
;
///< filename typically,
unless from RAM
wxString
source
;
///< filename typically,
or other source
int
lineNumber
;
int
byteIndex
;
///< char offset, starting from 1, into the problem line.
...
...
new/sch_dir_lib_source.cpp
View file @
02e1f839
...
...
@@ -309,7 +309,7 @@ void DIR_LIB_SOURCE::readString( STRING* aResult, const STRING& aFileName ) thro
{
STRING
msg
=
strerror
(
errno
);
msg
+=
"; cannot open(O_RDONLY) file "
+
aFileName
;
throw
(
IO_ERROR
(
msg
.
c_str
()
)
);
throw
(
IO_ERROR
(
msg
)
);
}
struct
stat
fs
;
...
...
@@ -321,7 +321,7 @@ void DIR_LIB_SOURCE::readString( STRING* aResult, const STRING& aFileName ) thro
{
STRING
msg
=
aFileName
;
msg
+=
" seems too big. ( > 1 mbyte )"
;
throw
IO_ERROR
(
msg
.
c_str
()
);
throw
IO_ERROR
(
msg
);
}
// reuse same readBuffer, which is not thread safe, but the API
...
...
@@ -334,7 +334,7 @@ void DIR_LIB_SOURCE::readString( STRING* aResult, const STRING& aFileName ) thro
{
STRING
msg
=
strerror
(
errno
);
msg
+=
"; cannot read file "
+
aFileName
;
throw
(
IO_ERROR
(
msg
.
c_str
()
)
);
throw
(
IO_ERROR
(
msg
)
);
}
// std::string chars are not guaranteed to be contiguous in
...
...
@@ -447,7 +447,7 @@ void DIR_LIB_SOURCE::ReadPart( STRING* aResult, const STRING& aPartName, const S
if
(
it
==
partnames
.
end
()
)
// part not found
{
partName
+=
" not found."
;
throw
IO_ERROR
(
partName
.
c_str
()
);
throw
IO_ERROR
(
partName
);
}
readString
(
aResult
,
makeFileName
(
partName
)
);
...
...
@@ -466,7 +466,7 @@ void DIR_LIB_SOURCE::ReadPart( STRING* aResult, const STRING& aPartName, const S
if
(
it
==
partnames
.
end
()
||
it
->
compare
(
0
,
search
.
size
(),
search
)
!=
0
)
{
partName
+=
" rev not found."
;
throw
IO_ERROR
(
partName
.
c_str
()
);
throw
IO_ERROR
(
partName
);
}
readString
(
aResult
,
makeFileName
(
*
it
)
);
...
...
@@ -531,7 +531,7 @@ void DIR_LIB_SOURCE::cacheOneDir( const STRING& aCategory ) throw( IO_ERROR )
{
STRING
msg
=
strerror
(
errno
);
msg
+=
"; scanning directory "
+
curDir
;
throw
(
IO_ERROR
(
msg
.
c_str
()
)
);
throw
(
IO_ERROR
(
msg
)
);
}
struct
stat
fs
;
...
...
@@ -557,7 +557,7 @@ void DIR_LIB_SOURCE::cacheOneDir( const STRING& aCategory ) throw( IO_ERROR )
{
STRING
msg
=
partName
;
msg
+=
" has already been encountered"
;
throw
IO_ERROR
(
msg
.
c_str
()
);
throw
IO_ERROR
(
msg
);
}
}
...
...
new/sch_lib_table.cpp
View file @
02e1f839
...
...
@@ -33,7 +33,7 @@ using namespace SCH;
LIB_TABLE
::
LIB_TABLE
(
LIB_TABLE
*
aFallBackTable
)
:
fallBack
(
aFallBackTable
)
{
/* not copying fall back, simply search
it
separately if "logicalName not found".
/* not copying fall back, simply search
aFallBackTable
separately if "logicalName not found".
if( aFallBackTable )
{
const ROWS& t = aFallBackTable->rows;
...
...
@@ -130,9 +130,9 @@ void LIB_TABLE::Parse( SCH_LIB_TABLE_LEXER* in ) throw( IO_ERROR )
// all logicalNames within this table fragment must be unique, so we do not
// replace. However a fallBack table can have a conflicting logicalName
// and ours will supercede that one since in
f
indLib() we search this table
// and ours will supercede that one since in
F
indLib() we search this table
// before any fall back.
if
(
!
Insert
Lib
(
row
)
)
if
(
!
Insert
Row
(
row
)
)
{
char
buf
[
300
];
...
...
@@ -163,30 +163,33 @@ void LIB_TABLE::ROW::Format( OUTPUTFORMATTER* out, int nestLevel ) const
}
const
LIB_TABLE
::
ROW
*
LIB_TABLE
::
Find
Lib
(
const
STRING
&
aLogicalName
)
const
LIB_TABLE
::
ROW
*
LIB_TABLE
::
Find
Row
(
const
STRING
&
aLogicalName
)
{
// this function must be *super* fast, so therefore should not instantiate
// anything which would require using the heap. This function is the reason
// ptr_map<> was used instead of ptr_set<>, which would have required
// instantiating a ROW just to find a ROW.
LIB_TABLE
*
cur
=
this
;
ROWS_CITER
it
;
ROWS_CITER
it
=
rows
.
find
(
aLogicalName
);
do
{
it
=
cur
->
rows
.
find
(
aLogicalName
);
if
(
it
!=
rows
.
end
()
)
if
(
it
!=
cur
->
rows
.
end
()
)
{
// reference: http://myitcorner.com/blog/?p=361
return
(
const
LIB_TABLE
::
ROW
*
)
it
->
second
;
// found
}
// not found, search fall back table
if
(
fallBack
)
return
fallBack
->
FindLib
(
aLogicalName
);
// not found, search fall back table(s), if any
}
while
(
(
cur
=
cur
->
fallBack
)
!=
0
);
return
0
;
// not found
}
bool
LIB_TABLE
::
Insert
Lib
(
auto_ptr
<
ROW
>&
aRow
,
bool
doReplace
)
bool
LIB_TABLE
::
Insert
Row
(
auto_ptr
<
ROW
>&
aRow
,
bool
doReplace
)
{
ROWS_ITER
it
=
rows
.
find
(
aRow
->
logicalName
);
...
...
@@ -209,9 +212,9 @@ bool LIB_TABLE::InsertLib( auto_ptr<ROW>& aRow, bool doReplace )
void
LIB_TABLE
::
Test
()
{
// the null string is not really a legal DSN token since any d
ouble quotes
//
are assumed to be a single quote. To pass an empty string, we pass " "
// to (options " ")
// the null string is not really a legal DSN token since any d
uplicated
//
double quote ("") is assumed to be a single double quote (").
//
To pass an empty string, we can pass " "
to (options " ")
SCH_LIB_TABLE_LEXER
slr
(
"(lib_table
\n
"
" (lib (logical meparts) (type dir) (full_uri /tmp/eeschema-lib) (options
\"
\"
))
\n
"
...
...
@@ -249,12 +252,12 @@ void LIB_TABLE::Test()
printf
(
"%s"
,
sf
.
GetString
().
c_str
()
);
printf
(
"
\n
test a lookup of 'www':
\n
"
);
sf
.
Clear
();
const
LIB_TABLE
::
ROW
*
www
=
FindLib
(
"www"
);
const
LIB_TABLE
::
ROW
*
www
=
FindRow
(
"www"
);
if
(
www
)
{
// found, print it just to prove it.
sf
.
Clear
();
www
->
Format
(
&
sf
,
1
);
printf
(
"%s"
,
sf
.
GetString
().
c_str
()
);
}
...
...
new/sch_lib_table.h
View file @
02e1f839
...
...
@@ -273,7 +273,7 @@ public:
protected
:
// only a table editor can use these
/**
* Function Insert
Lib
* Function Insert
Row
* adds aRow if it does not already exist or if doReplace is true. If doReplace
* is not true and the key for aRow already exists, the function fails and returns false.
* @param aRow is the new row to insert, or to forcibly add if doReplace is true.
...
...
@@ -281,13 +281,13 @@ protected: // only a table editor can use these
* if the key already exists.
* @return bool - true if the operation succeeded.
*/
bool
Insert
Lib
(
std
::
auto_ptr
<
ROW
>&
aRow
,
bool
doReplace
=
false
);
bool
Insert
Row
(
std
::
auto_ptr
<
ROW
>&
aRow
,
bool
doReplace
=
false
);
/**
* Function Find
Lib
* returns a ROW* if aLogicalName is found in this table or in fallBack.
* Function Find
Row
* returns a ROW* if aLogicalName is found in this table or in fallBack
, else NULL
.
*/
const
ROW
*
Find
Lib
(
const
STRING
&
aLogicalName
);
const
ROW
*
Find
Row
(
const
STRING
&
aLogicalName
);
private
:
...
...
new/toolchain-mingw.cmake
View file @
02e1f839
...
...
@@ -9,14 +9,13 @@
set
(
CMAKE_SYSTEM_NAME Linux
)
# Specific to Dick's machine, again for testing only:
include_directories
(
/svn/wxWidgets/include
)
#-----<configuration>-----------------------------------------------
# configure only the lines within this <configure> block, typically
# default is specific to Dick's machine, again for testing only:
set
(
WX_MINGW_BASE /opt/wx2.8-mingw
)
# specify the cross compiler
set
(
CMAKE_C_COMPILER i586-mingw32msvc-gcc
)
set
(
CMAKE_CXX_COMPILER i586-mingw32msvc-g++
)
...
...
@@ -24,6 +23,9 @@ set( CMAKE_CXX_COMPILER i586-mingw32msvc-g++ )
# where is the target environment
set
(
CMAKE_FIND_ROOT_PATH /usr/i586-mingw32msvc
)
include_directories
(
${
WX_MINGW_BASE
}
/include
)
#-----</configuration>-----------------------------------------------
...
...
@@ -33,3 +35,6 @@ set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER )
# for libraries and headers in the target directories
set
(
CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY
)
set
(
CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY
)
# try and pre-load this variable, or do it later in ccmake
set
(
wxWidgets_CONFIG_EXECUTABLE
${
WX_MINGW_BASE
}
/bin/wx-config
)
\ No newline at end of file
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