← Back to team overview

geda-developers team mailing list archive

[PATCH] gnetlist: allow net= attributes without a pin number

 

[Cc-ing geda-user as geda-developers seems to be dead these days]

Hello,

the attached patch allows one to specify the net= attribute
without a pin number, which is very convenient for components
with a single pin. The pin number defaults to 1 and a warning
is printed (it would be nicer if the warning were printed only
for components with multiple pins).

The patch is based on the original patch by Wojciech Kazubski,
but that never got applied. See the discussion at
http://ftp.sunet.se/geda/mailinglist/geda-dev68/msg00090.html.

Could someone please apply this?

-- 
Ivan Stankovic, pokemon@xxxxxxxxxxxxxx

"Protect your digital freedom and privacy, eliminate DRM, 
learn more at http://www.defectivebydesign.org/what_is_drm";
commit 75400cf8bccafb50a8a4fe67a7ed298112d181a0
Author: Ivan Stankovic <pokemon@xxxxxxxxxxxxxx>
Date:   Sat Jul 7 21:09:55 2012 +0200

    gnetlist: allow net= attributes without a pin number
    
    The pin number defaults to 1 and a warning is printed.
    Original patch by Wojciech Kazubski. See the discussion
    at http://ftp.sunet.se/geda/mailinglist/geda-dev68/msg00090.html.

diff --git a/gnetlist/src/s_netattrib.c b/gnetlist/src/s_netattrib.c
index 461458d..59f6e8a 100644
--- a/gnetlist/src/s_netattrib.c
+++ b/gnetlist/src/s_netattrib.c
@@ -235,10 +235,12 @@ char *s_netattrib_net_search (OBJECT * o_current, char *wanted_pin)
 
     char_ptr = strchr (value, ':');
     if (char_ptr == NULL) {
-      fprintf (stderr, "Got an invalid net= attrib [net=%s]\n"
-                       "Missing : in net= attrib\n", value);
-      g_free (value);
-      return NULL;
+      fprintf (stderr, "Warning: net= attrib [net=%s] without pin number, "
+                       "defaulting to 1\n", value);
+      char_ptr = value;
+      value = g_strdup_printf ("%s:1", value);
+      g_free (char_ptr);
+      char_ptr = strchr (value, ':');
     }
 
     net_name = s_netattrib_extract_netname (value);
@@ -266,10 +268,12 @@ char *s_netattrib_net_search (OBJECT * o_current, char *wanted_pin)
 
     char_ptr = strchr (value, ':');
     if (char_ptr == NULL) {
-      fprintf (stderr, "Got an invalid net= attrib [net=%s]\n"
-                       "Missing : in net= attrib\n", value);
-      g_free (value);
-      return NULL;
+      fprintf (stderr, "Warning: net= attrib [net=%s] without pin number, "
+                       "defaulting to 1\n", value);
+      char_ptr = value;
+      value = g_strdup_printf ("%s:1", value);
+      g_free (char_ptr);
+      char_ptr = strchr (value, ':');
     }
 
     net_name = s_netattrib_extract_netname (value);