← Back to team overview

kicad-developers team mailing list archive

[PATCH] Improve matchDpSuffix() to match a wider range of differential pair names.

 

As before but with fewer tabs...
diff --git a/pcbnew/router/pns_kicad_iface.cpp b/pcbnew/router/pns_kicad_iface.cpp
index 2960f41e2..922a9a7a5 100644
--- a/pcbnew/router/pns_kicad_iface.cpp
+++ b/pcbnew/router/pns_kicad_iface.cpp
@@ -233,9 +233,9 @@ int PNS_PCBNEW_RULE_RESOLVER::matchDpSuffix( wxString aNetName, wxString& aCompl
         aComplementNet = "-";
         rv = 1;
     }
-    else if( aNetName.EndsWith( "_P" ) )
+    else if( aNetName.EndsWith( "P" ) )
     {
-        aComplementNet = "_N";
+        aComplementNet = "N";
         rv = 1;
     }
     else if( aNetName.EndsWith( "-" ) )
@@ -243,12 +243,35 @@ int PNS_PCBNEW_RULE_RESOLVER::matchDpSuffix( wxString aNetName, wxString& aCompl
         aComplementNet = "+";
         rv = -1;
     }
-    else if( aNetName.EndsWith( "_N" ) )
+    else if( aNetName.EndsWith( "N" ) )
     {
-        aComplementNet = "_P";
+        aComplementNet = "P";
         rv = -1;
     }
-
+	//Match P followed by 2 digits
+    else if( aNetName.Right(2).IsNumber() && aNetName.Right(3).Left(1) == "P" )
+    {
+        aComplementNet = "N" + aNetName.Right(2);
+        rv = 1;
+    }
+	//Match P followed by 1 digit
+    else if( aNetName.Right(1).IsNumber() && aNetName.Right(2).Left(1) == "P" )
+    {
+        aComplementNet = "N" + aNetName.Right(1);
+        rv = 1;
+    }
+	//Match N followed by 2 digits
+    else if( aNetName.Right(2).IsNumber() && aNetName.Right(3).Left(1) == "N" )
+    {
+        aComplementNet = "P" + aNetName.Right(2);
+        rv = 1;
+    }
+	//Match N followed by 1 digit
+    else if( aNetName.Right(1).IsNumber() && aNetName.Right(2).Left(1) == "N" )
+    {
+        aComplementNet = "P" + aNetName.Right(1);
+        rv = 1;
+    }
     if( rv != 0 )
     {
         aBaseDpName = aNetName.Left( aNetName.Length() - aComplementNet.Length() );