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
2dd12871
Commit
2dd12871
authored
Jan 12, 2011
by
Dick Hollenbeck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
filter_reader.cpp
parent
2a603275
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
101 additions
and
25 deletions
+101
-25
dsnlexer.cpp
common/dsnlexer.cpp
+4
-4
richio.cpp
common/richio.cpp
+5
-7
readschematicnetlist.cpp
cvpcb/readschematicnetlist.cpp
+10
-7
dsnlexer.h
include/dsnlexer.h
+3
-3
richio.h
include/richio.h
+19
-4
CMakeLists.txt
new/CMakeLists.txt
+1
-0
filter_reader.cpp
new/filter_reader.cpp
+59
-0
No files found.
common/dsnlexer.cpp
View file @
2dd12871
...
@@ -111,7 +111,7 @@ void DSNLEXER::PushReader( LINE_READER* aLineReader )
...
@@ -111,7 +111,7 @@ void DSNLEXER::PushReader( LINE_READER* aLineReader )
{
{
readerStack
.
push_back
(
aLineReader
);
readerStack
.
push_back
(
aLineReader
);
reader
=
aLineReader
;
reader
=
aLineReader
;
start
=
(
char
*
)
(
*
reader
);
start
=
(
c
onst
c
har
*
)
(
*
reader
);
// force a new readLine() as first thing.
// force a new readLine() as first thing.
limit
=
start
;
limit
=
start
;
...
@@ -127,7 +127,7 @@ bool DSNLEXER::PopReader()
...
@@ -127,7 +127,7 @@ bool DSNLEXER::PopReader()
readerStack
.
pop_back
();
readerStack
.
pop_back
();
reader
=
readerStack
.
back
();
reader
=
readerStack
.
back
();
start
=
(
char
*
)
(
*
reader
);
start
=
(
c
onst
c
har
*
)
(
*
reader
);
// force a new readLine() as first thing.
// force a new readLine() as first thing.
limit
=
start
;
limit
=
start
;
...
@@ -336,8 +336,8 @@ static inline bool isSpace( int cc )
...
@@ -336,8 +336,8 @@ static inline bool isSpace( int cc )
int
DSNLEXER
::
NextTok
()
throw
(
IO_ERROR
)
int
DSNLEXER
::
NextTok
()
throw
(
IO_ERROR
)
{
{
char
*
cur
=
next
;
c
onst
c
har
*
cur
=
next
;
char
*
head
=
cur
;
c
onst
c
har
*
head
=
cur
;
prevTok
=
curTok
;
prevTok
=
curTok
;
...
...
common/richio.cpp
View file @
2dd12871
...
@@ -107,12 +107,12 @@ unsigned FILE_LINE_READER::ReadLine() throw( IO_ERROR )
...
@@ -107,12 +107,12 @@ unsigned FILE_LINE_READER::ReadLine() throw( IO_ERROR )
length
=
0
;
length
=
0
;
line
[
0
]
=
0
;
line
[
0
]
=
0
;
// fgets always put a terminating nul at end of its read.
// fgets always put
s
a terminating nul at end of its read.
while
(
fgets
(
line
+
length
,
capacity
-
length
,
fp
)
)
while
(
fgets
(
line
+
length
,
capacity
-
length
,
fp
)
)
{
{
length
+=
strlen
(
line
+
length
);
length
+=
strlen
(
line
+
length
);
if
(
length
=
=
maxLineLength
)
if
(
length
>
=
maxLineLength
)
THROW_IO_ERROR
(
_
(
"Line length exceeded"
)
);
THROW_IO_ERROR
(
_
(
"Line length exceeded"
)
);
// a normal line breaks here, once through while loop
// a normal line breaks here, once through while loop
...
@@ -122,11 +122,9 @@ unsigned FILE_LINE_READER::ReadLine() throw( IO_ERROR )
...
@@ -122,11 +122,9 @@ unsigned FILE_LINE_READER::ReadLine() throw( IO_ERROR )
expandCapacity
(
capacity
*
2
);
expandCapacity
(
capacity
*
2
);
}
}
/* if( length ) RHH: this may now refer to a non-existent line but
// lineNum is incremented even if there was no line read, because this
* that leads to better error reporting on unexpected end of file.
// leads to better error reporting when we hit an end of file.
*/
++
lineNum
;
++
lineNum
;
return
length
;
return
length
;
}
}
...
...
cvpcb/readschematicnetlist.cpp
View file @
2dd12871
...
@@ -91,7 +91,7 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist()
...
@@ -91,7 +91,7 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist()
char
alim
[
1024
];
char
alim
[
1024
];
int
idx
,
jj
,
k
,
l
;
int
idx
,
jj
,
k
,
l
;
char
cbuffer
[
BUFFER_CHAR_SIZE
];
/* temporary storage */
char
cbuffer
[
BUFFER_CHAR_SIZE
];
/* temporary storage */
char
*
ptchar
;
char
*
ptchar
;
COMPONENT
*
Cmp
;
COMPONENT
*
Cmp
;
FILE
*
source
;
FILE
*
source
;
...
@@ -114,8 +114,11 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist()
...
@@ -114,8 +114,11 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist()
}
}
// FILE_LINE_READER will close the file.
// FILE_LINE_READER will close the file.
FILE_LINE_READER
netlistReader
(
source
,
m_NetlistFileName
.
GetFullPath
(),
BUFFER_CHAR_SIZE
);
FILE_LINE_READER
netlistReader
(
source
,
m_NetlistFileName
.
GetFullPath
()
);
char
*
Line
=
netlistReader
;
// hopes netlistReader's line buffer does not move. It won't unless you encounter
// a line larger than LINE_READER_LINE_INITIAL_SIZE = 5000
const
char
*
Line
=
netlistReader
.
Line
();
/* Read the file header (must be "( { OrCAD PCB" or "({ OrCAD PCB" )
/* Read the file header (must be "( { OrCAD PCB" or "({ OrCAD PCB" )
* or "# EESchema Netlist"
* or "# EESchema Netlist"
...
@@ -194,11 +197,11 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist()
...
@@ -194,11 +197,11 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist()
/* idx points the component value.
/* idx points the component value.
* Read value */
* Read value */
ptchar
=
strstr
(
&
Line
[
idx
],
" "
);
// Search end of value field (space)
ptchar
=
strstr
(
(
char
*
)
&
Line
[
idx
],
" "
);
// Search end of value field (space)
if
(
ptchar
==
0
)
if
(
ptchar
==
0
)
{
{
wxString
msg
;
wxString
msg
;
msg
.
Printf
(
_
(
"Netlist error: %s"
),
Line
);
msg
.
Printf
(
_
(
"Netlist error: %s"
),
(
const
wxChar
*
)
CONV_FROM_UTF8
(
Line
)
);
DisplayError
(
this
,
msg
);
DisplayError
(
this
,
msg
);
k
=
0
;
k
=
0
;
}
}
...
@@ -213,7 +216,7 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist()
...
@@ -213,7 +216,7 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist()
}
}
cbuffer
[
jj
]
=
0
;
cbuffer
[
jj
]
=
0
;
// Copy footprint name:
// Copy footprint name:
if
(
m_isEESchemaNetlist
&&
(
strnicmp
(
cbuffer
,
"$noname"
,
7
)
!=
0
)
)
if
(
m_isEESchemaNetlist
&&
strnicmp
(
cbuffer
,
"$noname"
,
7
)
!=
0
)
Cmp
->
m_Module
=
CONV_FROM_UTF8
(
cbuffer
);
Cmp
->
m_Module
=
CONV_FROM_UTF8
(
cbuffer
);
if
(
(
Line
[
++
idx
]
==
'('
)
&&
(
Line
[
k
-
1
]
==
')'
)
)
if
(
(
Line
[
++
idx
]
==
'('
)
&&
(
Line
[
k
-
1
]
==
')'
)
)
...
@@ -271,7 +274,7 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist()
...
@@ -271,7 +274,7 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist()
int
ReadFootprintFilterList
(
FILE_LINE_READER
&
aNetlistReader
,
COMPONENT_LIST
&
aComponentsList
)
int
ReadFootprintFilterList
(
FILE_LINE_READER
&
aNetlistReader
,
COMPONENT_LIST
&
aComponentsList
)
{
{
c
har
*
Line
=
aNetlistReader
;
c
onst
char
*
Line
=
aNetlistReader
;
wxString
CmpRef
;
wxString
CmpRef
;
COMPONENT
*
Cmp
=
NULL
;
COMPONENT
*
Cmp
=
NULL
;
...
...
include/dsnlexer.h
View file @
2dd12871
...
@@ -77,9 +77,9 @@ enum DSN_SYNTAX_T {
...
@@ -77,9 +77,9 @@ enum DSN_SYNTAX_T {
class
DSNLEXER
class
DSNLEXER
{
{
bool
iOwnReaders
;
///< on readerStack, should I delete them?
bool
iOwnReaders
;
///< on readerStack, should I delete them?
c
har
*
start
;
c
onst
char
*
start
;
c
har
*
next
;
c
onst
char
*
next
;
c
har
*
limit
;
c
onst
char
*
limit
;
typedef
std
::
vector
<
LINE_READER
*>
READER_STACK
;
typedef
std
::
vector
<
LINE_READER
*>
READER_STACK
;
...
...
include/richio.h
View file @
2dd12871
...
@@ -205,8 +205,14 @@ protected:
...
@@ -205,8 +205,14 @@ protected:
wxString
source
;
///< origin of text lines, e.g. filename or "clipboard"
wxString
source
;
///< origin of text lines, e.g. filename or "clipboard"
/**
* Function expandCapacity
* will exand the capacity of @a line up to maxLineLength but not greater, so
* be careful about making assumptions of @a capacity after calling this.
*/
void
expandCapacity
(
unsigned
newsize
);
void
expandCapacity
(
unsigned
newsize
);
public
:
public
:
/**
/**
...
@@ -238,11 +244,20 @@ public:
...
@@ -238,11 +244,20 @@ public:
* of lines of text. The returned string is useful for reporting error
* of lines of text. The returned string is useful for reporting error
* messages.
* messages.
*/
*/
const
wxString
&
GetSource
()
const
virtual
const
wxString
&
GetSource
()
const
{
{
return
source
;
return
source
;
}
}
/**
* Function Line
* returns a pointer to the last line that was read in.
*/
virtual
char
*
Line
()
const
{
return
line
;
}
/**
/**
* Operator char*
* Operator char*
* is a casting operator that returns a char* pointer to the start of the
* is a casting operator that returns a char* pointer to the start of the
...
@@ -250,7 +265,7 @@ public:
...
@@ -250,7 +265,7 @@ public:
*/
*/
operator
char
*
()
const
operator
char
*
()
const
{
{
return
line
;
return
Line
()
;
}
}
/**
/**
...
@@ -258,7 +273,7 @@ public:
...
@@ -258,7 +273,7 @@ public:
* returns the line number of the last line read from this LINE_READER. Lines
* returns the line number of the last line read from this LINE_READER. Lines
* start from 1.
* start from 1.
*/
*/
unsigned
LineNumber
()
const
virtual
unsigned
LineNumber
()
const
{
{
return
lineNum
;
return
lineNum
;
}
}
...
@@ -267,7 +282,7 @@ public:
...
@@ -267,7 +282,7 @@ public:
* Function Length
* Function Length
* returns the number of bytes in the last line read from this LINE_READER.
* returns the number of bytes in the last line read from this LINE_READER.
*/
*/
unsigned
Length
()
const
virtual
unsigned
Length
()
const
{
{
return
length
;
return
length
;
}
}
...
...
new/CMakeLists.txt
View file @
2dd12871
...
@@ -85,6 +85,7 @@ add_executable( test_sch_lib_table
...
@@ -85,6 +85,7 @@ add_executable( test_sch_lib_table
sch_lib_table_keywords.cpp
sch_lib_table_keywords.cpp
sch_lib.cpp
sch_lib.cpp
sch_lpid.cpp
sch_lpid.cpp
filter_reader.cpp
sch_dir_lib_source.cpp
sch_dir_lib_source.cpp
sch_part.cpp
sch_part.cpp
sweet_keywords.cpp
sweet_keywords.cpp
...
...
new/filter_reader.cpp
0 → 100644
View file @
2dd12871
#include <richio.h>
#include <string.h>
/**
* Class FILTER_READER
* reads lines of text from another LINE_READER, but only returns non-comment
* lines and non-blank lines from its ReadLine() function.
*/
class
FILTER_READER
:
public
LINE_READER
{
LINE_READER
&
reader
;
public
:
/**
* Constructor ( LINE_READER& )
* does not take ownership over @a aReader, so will not destroy it.
*/
FILTER_READER
(
LINE_READER
&
aReader
)
:
reader
(
aReader
)
{
}
unsigned
ReadLine
()
throw
(
IO_ERROR
)
{
unsigned
ret
;
while
(
(
ret
=
reader
.
ReadLine
()
)
!=
0
)
{
if
(
!
strchr
(
"#
\n\r
"
,
reader
[
0
]
)
)
break
;
}
return
ret
;
}
const
wxString
&
GetSource
()
const
{
return
reader
.
GetSource
();
}
char
*
Line
()
const
{
return
reader
.
Line
();
}
unsigned
LineNumber
()
const
{
return
reader
.
LineNumber
();
}
unsigned
Length
()
const
{
return
reader
.
Length
();
}
};
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