On 05/24/2013 04:25 PM, Dick Hollenbeck wrote:
> On 05/22/2013 04:34 PM, Dick Hollenbeck wrote:
>> I think a bug was introduced recently that is putting tilda characters into 
>> library files.
>>
>> If a field such as Footprint is blank in the eeschema library part editor, 
>> it gets put
>> into the library now with "~" rather than being omitted.  Even if you 
>> restart eeschema,
>> come back and delete the ~ character, save the part again into the library, 
>> you find the
>> filed with the ~ in there again.
>>
>> Somebody broke something.
>>
>> I have not filed a bug report, but can if this does not ring a bell.
>>
>> Dick
>>
> 
> 
> Blank fields are not round tripping.  They come back with a damn tilda in 
> them.
> 
> Somebody broke something!
> 
> 
> 


I got annoyed because it took so long to find, and this bug simply should never 
have
happened.  It is bull crap.

You only saw the problem if you saved a component with a blank datasheet into 
your
library.  Then exited eeschema.  Then restarted it.  Then when loading the 
component back
into the library editor and showing the text fields, you was a ~ for any blank 
field.


Fixed in 4166.


Library component fields will now be saved, when blank, as "" rather than as 
"~".

Main diff attached.

Library files will automatically get fixed upon first write, "~" -> ""







=== modified file 'eeschema/lib_field.cpp'
--- eeschema/lib_field.cpp	2013-05-18 09:38:23 +0000
+++ eeschema/lib_field.cpp	2013-05-24 23:56:13 +0000
@@ -100,8 +100,14 @@
     else if( m_VJustify == GR_TEXT_VJUSTIFY_TOP )
         vjustify = 'T';
 
+    /*  Dick 24-May-2013:
+        What the hell is this?.  There was no comment here.
+        Hell no.  You don't want this in the *.lib files, it is crap.  Fields get read
+        back in and they have a tilda in them.
+
     if( text.IsEmpty() )
         text = wxT( "~" );
+    */
 
     aFormatter.Print( 0, "F%d %s %d %d %d %c %c %c %c%c%c",
                       m_id,
@@ -136,7 +142,9 @@
     char  textVisible;
     char  textHJustify;
     char  textVJustify[256];
+
     char* line = (char*) aLineReader;
+    char*   limit = line + aLineReader.Length();
 
     if( sscanf( line + 1, "%d", &m_id ) != 1 || m_id < 0 )
     {
@@ -144,23 +152,20 @@
         return false;
     }
 
-    /* Search the beginning of the data. */
-    while( *line != 0 )
-        line++;
-
-    while( *line == 0 )
-        line++;
-
-    while( *line && (*line != '"') )
+    // Caller did a strtok(), which inserts a nul, so next few bytes are ugly:
+    // digit(s), a nul, some whitespace, then a double quote.
+    while( line < limit && *line != '"' )
         line++;
 
-    if( *line == 0 )
+    if( line == limit )
         return false;
 
     line += ReadDelimitedText( &m_Text, line );
 
-    if( *line == 0 )
-        return false;
+    // Doctor the *.lib file field which has a "~" in blank fields.  New saves will
+    // not save like this, and eventually these two lines can be removed.
+    if( m_Text.size()==1  &&  m_Text[0]==wxChar( '~' ) )
+        m_Text.clear();
 
     memset( textVJustify, 0, sizeof( textVJustify ) );
 

_______________________________________________
Mailing list: https://launchpad.net/~kicad-developers
Post to     : kicad-developers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~kicad-developers
More help   : https://help.launchpad.net/ListHelp

Reply via email to