Commit 2dd12871 authored by Dick Hollenbeck's avatar Dick Hollenbeck
Browse files

filter_reader.cpp

parent 2a603275
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -111,7 +111,7 @@ void DSNLEXER::PushReader( LINE_READER* aLineReader )
{
    readerStack.push_back( aLineReader );
    reader = aLineReader;
    start  = (char*) (*reader);
    start  = (const char*) (*reader);

    // force a new readLine() as first thing.
    limit = start;
@@ -127,7 +127,7 @@ bool DSNLEXER::PopReader()
        readerStack.pop_back();

        reader = readerStack.back();
        start  = (char*) (*reader);
        start  = (const char*) (*reader);

        // force a new readLine() as first thing.
        limit = start;
@@ -336,8 +336,8 @@ static inline bool isSpace( int cc )

int DSNLEXER::NextTok() throw( IO_ERROR )
{
    char*   cur  = next;
    char*   head = cur;
    const char*   cur  = next;
    const char*   head = cur;

    prevTok = curTok;

+5 −7
Original line number Diff line number Diff line
@@ -107,12 +107,12 @@ unsigned FILE_LINE_READER::ReadLine() throw( IO_ERROR )
    length  = 0;
    line[0] = 0;

    // fgets always put a terminating nul at end of its read.
    // fgets always puts a terminating nul at end of its read.
    while( fgets( line + length, capacity - length, fp ) )
    {
        length += strlen( line + length );

        if( length == maxLineLength )
        if( length >= maxLineLength )
            THROW_IO_ERROR( _("Line length exceeded") );

        // a normal line breaks here, once through while loop
@@ -122,10 +122,8 @@ unsigned FILE_LINE_READER::ReadLine() throw( IO_ERROR )
        expandCapacity( capacity * 2 );
    }

    /* if( length ) RHH: this may now refer to a non-existent line but
     * that leads to better error reporting on unexpected end of file.
     */

    // lineNum is incremented even if there was no line read, because this
    // leads to better error reporting when we hit an end of file.
    ++lineNum;

    return length;
+10 −7
Original line number Diff line number Diff line
@@ -114,8 +114,11 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist()
    }

    // FILE_LINE_READER will close the file.
    FILE_LINE_READER netlistReader( source, m_NetlistFileName.GetFullPath(), BUFFER_CHAR_SIZE );
    char* Line = netlistReader;
    FILE_LINE_READER netlistReader( source, m_NetlistFileName.GetFullPath() );

    // 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" )
     * or "# EESchema Netlist"
@@ -194,11 +197,11 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist()

        /* idx points the component 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 )
        {
            wxString msg;
            msg.Printf( _( "Netlist error: %s" ), Line );
            msg.Printf( _( "Netlist error: %s" ), (const wxChar*) CONV_FROM_UTF8( Line ) );
            DisplayError( this, msg );
            k = 0;
        }
@@ -213,7 +216,7 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist()
        }
        cbuffer[jj] = 0;
        // 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);

        if( (Line[++idx] == '(') && (Line[k - 1] == ')' ) )
@@ -271,7 +274,7 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist()

int ReadFootprintFilterList(  FILE_LINE_READER& aNetlistReader, COMPONENT_LIST& aComponentsList )
{
    char*       Line = aNetlistReader;
    const char* Line = aNetlistReader;
    wxString    CmpRef;
    COMPONENT*  Cmp = NULL;

+3 −3
Original line number Diff line number Diff line
@@ -77,9 +77,9 @@ enum DSN_SYNTAX_T {
class DSNLEXER
{
    bool                iOwnReaders;            ///< on readerStack, should I delete them?
    char*               start;
    char*               next;
    char*               limit;
    const char*         start;
    const char*         next;
    const char*         limit;

    typedef std::vector<LINE_READER*>  READER_STACK;

+19 −4
Original line number Diff line number Diff line
@@ -205,8 +205,14 @@ protected:

    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 );


public:

    /**
@@ -238,11 +244,20 @@ public:
     * of lines of text.  The returned string is useful for reporting error
     * messages.
     */
    const wxString& GetSource() const
    virtual const wxString& GetSource() const
    {
        return source;
    }

    /**
     * Function Line
     * returns a pointer to the last line that was read in.
     */
    virtual char* Line() const
    {
        return line;
    }

    /**
     * Operator char*
     * is a casting operator that returns a char* pointer to the start of the
@@ -250,7 +265,7 @@ public:
     */
    operator char* () const
    {
        return line;
        return Line();
    }

    /**
@@ -258,7 +273,7 @@ public:
     * returns the line number of the last line read from this LINE_READER.  Lines
     * start from 1.
     */
    unsigned LineNumber() const
    virtual unsigned LineNumber() const
    {
        return lineNum;
    }
@@ -267,7 +282,7 @@ public:
     * Function Length
     * returns the number of bytes in the last line read from this LINE_READER.
     */
    unsigned Length() const
    virtual unsigned Length() const
    {
        return length;
    }
Loading