← Back to team overview

kicad-developers team mailing list archive

Re: S-expression footprint library format.

 

On 10/07/2012 11:36 AM, Wayne Stambaugh wrote:
> I finally committed the changes to allow Pcbnew to save libraries in the 
> new s-expression format.  You can test this feature by building KiCad 
> with the -DUSE_PCBNEW_SEXPR_FOOTPRINT_LIBS=ON CMake definition.  This 
> will add an entry into the library editor file menu that will allow you 
> to save the current library to the new file format.  Please note that 
> the new file format will create a file for each footprint in the current 
> library file in a directory named from the current library file name. 
> The new format will not be used for loading and/or editing libraries 
> until I get the library table designed and implemented.  Once that 
> happens we should be able to begin using the new file formats as well as 
> editing and saving libraries in any format that is supported by the 
> appropriate PLUGIN.  Please take some time to make sure that the 
> footprint files and directories are generated correctly and that I 
> didn't miss anything.
>
> Thanks,
>
> Wayne


Wunderbar!


(Just a minor suggestion on  INPUTSTREAM_LINE_READER::ReadLine
see attached patch request.  Fixes a couple of things: return value on EOF, and EOF
testing according to docs.)


The day that the nanometer build is the standard default is now within sight.


=== modified file 'common/richio.cpp'
--- common/richio.cpp	2012-10-07 15:37:25 +0000
+++ common/richio.cpp	2012-10-07 18:15:48 +0000
@@ -195,9 +195,8 @@
 unsigned INPUTSTREAM_LINE_READER::ReadLine() throw( IO_ERROR )
 {
     length  = 0;
-    line[0] = 0;
 
-    while( !m_stream->Eof() )
+    for(;;)
     {
         if( length >= maxLineLength )
             THROW_IO_ERROR( _( "Maximum line length exceeded" ) );
@@ -205,15 +204,19 @@
         if( length + 1 > capacity )
             expandCapacity( capacity * 2 );
 
-        line[ length ] = m_stream->GetC();
-        length++;
-
-        if( line[ length - 1 ] == '\n' )
+        // this read may fail, docs say to test LastRead() before trusting cc.
+        char cc = m_stream->GetC();
+
+        if( !m_stream->LastRead() )
+            break;
+
+        line[ length++ ] = cc;
+
+        if( cc == '\n' )
             break;
     }
 
     line[ length ] = 0;
-    length -= 1;
 
     // lineNum is incremented even if there was no line read, because this
     // leads to better error reporting when we hit an end of file.


Follow ups

References