delorie.com/archives/browse.cgi   search  
Mail Archives: geda-user/2012/04/18/18:16:07

X-Authentication-Warning: delorie.com: mail set sender to geda-user-bounces using -f
X-Recipient: geda-user AT delorie DOT com
Date: Wed, 18 Apr 2012 23:48:53 +0200
From: Levente Kovacs <leventelist AT gmail DOT com>
To: gEDA User Mailing List <geda-user AT delorie DOT com>
Subject: [geda-user] gsch2pcb vs. unit suffixes at PCB file
Message-ID: <20120418234853.2e044c26@jive.levalinux.org>
Organization: logonex.eu
X-Mailer: Claws Mail 3.7.6 (GTK+ 2.20.1; x86_64-pc-linux-gnu)
Mime-Version: 1.0
Reply-To: geda-user AT delorie DOT com

--MP_/1YwQhhjKgwKZIMyBT=+nwQn
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hi everybody,


My message of yesterday didn't go through, I hope this does.

Recent versions of PCB uses suffixes at coordinates. gsch2pcb has hard time to
deal with them. It strips (atoi()) the suffix, when it updates an element.

So if an element was placed at 14.6mm; 43.3mm it'll interpret as 14 and 43.

I fixed this bug by simply treating the coordinates as strings.

Patch attached.

Levente

-- 
Levente Kovacs
CTO, CSO
http://levente.logonex.eu

--MP_/1YwQhhjKgwKZIMyBT=+nwQn
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename=git_diff_gsch2pcb_c.txt

diff --git a/utils/src/gsch2pcb.c b/utils/src/gsch2pcb.c
index 9f8dc42..c4d39ba 100644
--- a/utils/src/gsch2pcb.c
+++ b/utils/src/gsch2pcb.c
@@ -45,7 +45,7 @@ typedef struct
 {
   gchar *refdes, *value, *description, *changed_description, *changed_value;
   gchar *flags, *tail;
-  gint x, y;
+  gchar *x, *y;
   gchar *pkg_name_fix;
   gchar res_char;
 
@@ -418,13 +418,8 @@ pcb_element_line_parse (gchar * line)
   el->refdes = token (NULL, NULL, NULL);
   el->value = token (NULL, NULL, NULL);
 
-  s = token (NULL, NULL, NULL);
-  el->x = atoi (s);
-  g_free (s);
-
-  s = token (NULL, &t, NULL);
-  el->y = atoi (s);
-  g_free (s);
+  el->x = token (NULL, NULL, NULL);
+  el->y = token (NULL, &t, NULL);
 
   el->tail = g_strdup (t ? t : "");
   if ((s = strrchr (el->tail, (gint) '\n')) != NULL)
@@ -470,6 +465,8 @@ pcb_element_free (PcbElement * el)
   g_free (el->changed_value);
   g_free (el->refdes);
   g_free (el->value);
+  g_free (el->x);
+  g_free (el->y);
   g_free (el->tail);
   g_free (el->pkg_name_fix);
   g_free (el);
@@ -540,15 +537,9 @@ pcb_element_exists (PcbElement * el_test, gboolean record)
 static void
 simple_translate (PcbElement * el)
 {
-  gint factor;
-
-  if (el->new_format) {
-    factor = el->hi_res_format ? 100 : 1;
-    if (el->x > 1000 * factor)
-      el->x = 500 * factor;
-    if (el->y > 1000 * factor)
-      el->y = 500 * factor;
-  }
+
+  el->x=strdup("0");
+  el->y=strdup("0");
 }
 
 static gboolean
@@ -588,13 +579,13 @@ insert_element (FILE * f_out, gchar * element_file,
     if ((el = pcb_element_line_parse (s)) != NULL) {
       simple_translate (el);
       fmt = el->quoted_flags ?
-        "Element%c\"%s\" \"%s\" \"%s\" \"%s\" %d %d%s\n" :
-        "Element%c%s \"%s\" \"%s\" \"%s\" %d %d%s\n";
+        "Element%c\"%s\" \"%s\" \"%s\" \"%s\" %s %s%s\n" :
+        "Element%c%s \"%s\" \"%s\" \"%s\" %s %s%s\n";
 
       fprintf (f_out, fmt,
                el->res_char, el->flags, footprint, refdes, value,
                el->x, el->y, el->tail);
-      retval = TRUE;;
+      retval = TRUE;
     } else if (*s != '#')
       fputs (buf, f_out);
     pcb_element_free (el);
@@ -959,8 +950,8 @@ update_element_descriptions (gchar * pcb_file, gchar * bak)
         && (el_exists = pcb_element_exists (el, FALSE)) != NULL
         && el_exists->changed_description) {
       fmt = el->quoted_flags ?
-        "Element%c\"%s\" \"%s\" \"%s\" \"%s\" %d %d%s\n" :
-        "Element%c%s \"%s\" \"%s\" \"%s\" %d %d%s\n";
+        "Element%c\"%s\" \"%s\" \"%s\" \"%s\" %s %s%s\n" :
+        "Element%c%s \"%s\" \"%s\" \"%s\" %s %s%s\n";
       fprintf (f_out, fmt,
                el->res_char,
                el->flags, el_exists->changed_description,
@@ -1040,8 +1031,8 @@ prune_elements (gchar * pcb_file, gchar * bak)
     }
     if (el_exists && el_exists->changed_value) {
       fmt = el->quoted_flags ?
-        "Element%c\"%s\" \"%s\" \"%s\" \"%s\" %d %d%s\n" :
-        "Element%c%s \"%s\" \"%s\" \"%s\" %d %d%s\n";
+        "Element%c\"%s\" \"%s\" \"%s\" \"%s\" %s %s%s\n" :
+        "Element%c%s \"%s\" \"%s\" \"%s\" %s %s%s\n";
       fprintf (f_out, fmt,
                el->res_char, el->flags, el->description, el->refdes,
                el_exists->changed_value, el->x, el->y, el->tail);

--MP_/1YwQhhjKgwKZIMyBT=+nwQn--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019