[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-cvs: pcb.git: branch: master updated (d2ae471045ac81b6e97d5b441860081bc95eb2e7)



The branch, master has been updated
       via  d2ae471045ac81b6e97d5b441860081bc95eb2e7 (commit)
      from  9b760b0d62ec4b62ef3b4d5e4ae35e52af38ed39 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


=========
 Summary
=========

 src/file.c |   46 ++++++++++++++++++++++++++++++++++++++++++++--
 src/file.h |    5 +++++
 2 files changed, 49 insertions(+), 2 deletions(-)


=================
 Commit Messages
=================

commit d2ae471045ac81b6e97d5b441860081bc95eb2e7
Author: DJ Delorie <dj@xxxxxxxxxxx>
Commit: DJ Delorie <dj@xxxxxxxxxxx>

    Make file version smarter.
    
    Restructure the FileVersion[] output to only output the actual
    needed version, in cases where a rarely used feature requires a new
    pcb.  This avoids unnecessary backwards incompatibility.

:100644 100644 973db62... b1c8182... M	src/file.c
:100644 100644 4b9ecf2... d36fdfa... M	src/file.h

=========
 Changes
=========

commit d2ae471045ac81b6e97d5b441860081bc95eb2e7
Author: DJ Delorie <dj@xxxxxxxxxxx>
Commit: DJ Delorie <dj@xxxxxxxxxxx>

    Make file version smarter.
    
    Restructure the FileVersion[] output to only output the actual
    needed version, in cases where a rarely used feature requires a new
    pcb.  This avoids unnecessary backwards incompatibility.

diff --git a/src/file.c b/src/file.c
index 973db62..b1c8182 100644
--- a/src/file.c
+++ b/src/file.c
@@ -135,6 +135,47 @@ static char *pcb_basename (char *p);
 
 /* --------------------------------------------------------------------------- */
 
+/* The idea here is to avoid gratuitously breaking backwards
+   compatibility due to a new but rarely used feature.  The first such
+   case, for example, was the polygon Hole - if your design included
+   polygon holes, you needed a newer PCB to read it, but if your
+   design didn't include holes, PCB would produce a file that older
+   PCBs could read, if only it had the correct version number in it.
+
+   If, however, you have to add or change a feature that really does
+   require a new PCB version all the time, it's time to remove all the
+   tests below and just always output the new version.
+
+   Note: Best practices here is to add support for a feature *first*
+   (and bump PCB_FILE_VERSION in file.h), and note the version that
+   added that support below, and *later* update the file format to
+   need that version (which may then be older than PCB_FILE_VERSION).
+   Hopefully, that allows for one release between adding support and
+   needing it, which should minimize breakage.  Of course, that's not
+   *always* possible, practical, or desirable.
+
+*/
+
+/* Hole[] in Polygon.  */
+#define PCB_FILE_VERSION_HOLES 20100606
+/* First version ever saved.  */
+#define PCB_FILE_VERSION_BASELINE 20070407
+
+int
+PCBFileVersionNeeded (void)
+{
+  ALLPOLYGON_LOOP (PCB->Data);
+  {
+    if (polygon->HoleIndexN > 0)
+      return PCB_FILE_VERSION_HOLES;
+  }
+  ENDALL_LOOP;
+
+  return PCB_FILE_VERSION_BASELINE;
+}
+
+/* --------------------------------------------------------------------------- */
+
 static int
 string_cmp (const char *a, const char *b)
 {
@@ -516,14 +557,15 @@ WritePCBDataHeader (FILE * FP)
    * ************************** README *******************
    *
    * If the file format is modified in any way, update
-   * PCB_FILE_VERSION in file.h
+   * PCB_FILE_VERSION in file.h as well as PCBFileVersionNeeded()
+   * at the top of this file.
    *  
    * ************************** README *******************
    * ************************** README *******************
    */
 
   fprintf (FP, "\n# To read pcb files, the pcb version (or the git source date) must be >= the file version\n");
-  fprintf (FP, "FileVersion[%i]\n", PCB_FILE_VERSION);
+  fprintf (FP, "FileVersion[%i]\n", PCBFileVersionNeeded ());
 
   fputs ("\nPCB[", FP);
   PrintQuotedString (FP, (char *)EMPTY (PCB->Name));
diff --git a/src/file.h b/src/file.h
index 4b9ecf2..d36fdfa 100644
--- a/src/file.h
+++ b/src/file.h
@@ -56,6 +56,11 @@ void sort_netlist (void);
  * guidance to the user as to what the minimum version of pcb required
  * is.
  */
+
+/* This is the version needed by the file we're saving.  */
+int PCBFileVersionNeeded (void);
+
+/* This is the version we support.  */
 #define PCB_FILE_VERSION 20100606
 
 




_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs