delorie.com/archives/browse.cgi   search  
Mail Archives: geda-user/2023/04/03/09:26:28

X-Authentication-Warning: delorie.com: mail set sender to geda-user-bounces using -f
X-Recipient: geda-user AT delorie DOT com
X-Mailer: exmh version 2.8.0 04/21/2012 with nmh-1.7+dev
X-Exmh-Isig-CompType: repl
X-Exmh-Isig-Folder: geda
From: "karl AT aspodata DOT se [via geda-user AT delorie DOT com]" <geda-user AT delorie DOT com>
To: geda-user AT delorie DOT com
Subject: Re: [geda-user] lepton-sch2pcb strangeness
In-reply-to: <20230403094123.9A99885F72E8@turkos.aspodata.se>
References: <20230331155450 DOT 2BD3E85F72C3 AT turkos DOT aspodata DOT se> <20230331223557 DOT E0D6985F72C3 AT turkos DOT aspodata DOT se> <20230401093809 DOT 4F4B985F72DB AT turkos DOT aspodata DOT se> <20230402132731 DOT 3D1EA85F72E6 AT turkos DOT aspodata DOT se> <20230402232740 DOT 02322499 AT demon> <20230403094123 DOT 9A99885F72E8 AT turkos DOT aspodata DOT se>
Comments: In-reply-to "karl AT aspodata DOT se [via geda-user AT delorie DOT com]" <geda-user AT delorie DOT com>
message dated "Mon, 03 Apr 2023 11:41:23 +0200."
Mime-Version: 1.0
Message-Id: <20230403130617.5153385F72E8@turkos.aspodata.se>
Date: Mon, 3 Apr 2023 15:06:17 +0200 (CEST)
X-Virus-Scanned: ClamAV using ClamSMTP
Reply-To: geda-user AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: geda-user AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

This is a multipart MIME message.

--==_Exmh_1680527155_3450
Content-Type: text/plain

 I added this debug code:
$ git diff liblepton/src/sch2pcb.c 
diff --git a/liblepton/src/sch2pcb.c b/liblepton/src/sch2pcb.c
index 74238c701..e7d36e395 100644
--- a/liblepton/src/sch2pcb.c
+++ b/liblepton/src/sch2pcb.c
@@ -294,6 +294,7 @@ sch2pcb_set_element_directory_list (GList *list)
 void
 sch2pcb_element_directory_list_append (char *dir)
 {
+  printf("sch2pcb_element_directory_list_append: %p <%s>\n", dir, dir);
   sch2pcb_set_element_directory_list (
     g_list_append (sch2pcb_get_element_directory_list (), dir));
 }
@@ -301,6 +302,7 @@ sch2pcb_element_directory_list_append (char *dir)
 void
 sch2pcb_element_directory_list_prepend (char *dir)
 {
+  printf("sch2pcb_element_directory_list_prepend: %p <%s>\n", dir, dir);
   sch2pcb_set_element_directory_list (
     g_list_prepend (sch2pcb_get_element_directory_list (), dir));
 }
@@ -1042,6 +1044,7 @@ search_element_directories (PcbElement * el)
     printf ("\tSearching directories looking for file element: %s\n", elname);
   for (list = element_directory_list; list; list = g_list_next (list)) {
     dir_path = (gchar *) list->data;
+    printf("search_element_directories: %p <%s>\n", dir_path, dir_path);
     if (verbose > 1)
       printf ("\tLooking in directory: \"%s\"\n", dir_path);
     path = find_element (dir_path, elname);
$

 Which gives me:

$ rm -rf ~/.cache/guile/* 
$ lepton-sch2pcb a.sch 2> log
sch2pcb_element_directory_list_prepend: 0x7616c29310 <.>
sch2pcb_element_directory_list_prepend: 0x7616c2aa10 </home/karl/git/openhw/share/pcb/>
sch2pcb_element_directory_list_prepend: 0x7616c2ae70 </usr/local/share/pcb/pcblib-newlib/>
sch2pcb_element_directory_list_prepend: 0x7616c2aed0 </usr/local/share/pcb/newlib/>
sch2pcb_element_directory_list_append: 0x7616c2af20 </home/local/share/pcb/pcblib-newlib>
sch2pcb_element_directory_list_append: 0x7616c2af50 </home/local/share/pcb/newlib>
search_element_directories: 0x7616c2aed0 <??v>
search_element_directories: 0x7616c2ae70 <?£v>
search_element_directories: 0x7616c2aa10 <?£>
search_element_directories: 0x7616c29310 <??v>
search_element_directories: 0x7616c2af20 <?ãv>
search_element_directories: 0x7616c2af50 <>

----------------------------------
Done processing.  Work performed:
No elements to add so not creating a.new.pcb
1 elements could not be found.
$

 So, while appending/prepending the directories, the correct values are 
 inserted. But then in search_element_directories(), the stored pointers
 are the same but the data has been altered.

 Working on something a little more complex, 
https://aspodata.se/git/openhw/share/gschem/_sub_page/pt100if_microchip_MCP6N16.sch
 with some symbols removed, I always gets similar errors, not just 
 after a fresh guile compile:

$ lepton-sch2pcb pt100if_microchip_MCP6N16b.sch 2>/dev/null
sch2pcb_element_directory_list_prepend: 0x555f11f6d0 <.>
sch2pcb_element_directory_list_prepend: 0x555f120b60 </home/karl/git/openhw/share/pcb/>
sch2pcb_element_directory_list_prepend: 0x555f120fc0 </usr/local/share/pcb/pcblib-newlib/>
sch2pcb_element_directory_list_prepend: 0x555f121020 </usr/local/share/pcb/newlib/>
sch2pcb_element_directory_list_append: 0x555f121050 </home/local/share/pcb/pcblib-newlib>
sch2pcb_element_directory_list_append: 0x555f1210a0 </home/local/share/pcb/newlib>
search_element_directories: 0x555f121020 <??GZU>
search_element_directories: 0x555f120fc0 <??GZU>
search_element_directories: 0x555f120b60 < ?EZU>
search_element_directories: 0x555f11f6d0 <??GZU>
search_element_directories: 0x555f121050 <Layer(4 "bottom silk" "silk")>
search_element_directories: 0x555f1210a0 <Layer(5 "top silk" "silk")>

----------------------------------
Done processing.  Work performed:
No elements to add so not creating pt100if_microchip_MCP6N16b.new.pcb
1 elements could not be found.
$

 So the pointers is saved, but the data is altered elsewhere.
 Doing g_strdup() solves the problem. Patch attached.

Regards,
/Karl Hammar


--==_Exmh_1680527155_3450
Content-Type: text/plain; charset="utf-8" ; name="patch"
Content-Description: patch
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment; filename="patch"

diff --git a/liblepton/src/sch2pcb.c b/liblepton/src/sch2pcb.c
index 74238c701..cc2d8c658 100644
--- a/liblepton/src/sch2pcb.c
+++ b/liblepton/src/sch2pcb.c
@@ -294,15 +294,17 @@ sch2pcb_set_element_directory_list (GList *list)
 void
 sch2pcb_element_directory_list_append (char *dir)
 {
+  char *dd =3D g_strdup(dir);
   sch2pcb_set_element_directory_list (
-    g_list_append (sch2pcb_get_element_directory_list (), dir));
+    g_list_append (sch2pcb_get_element_directory_list (), dd));
 }
 =

 void
 sch2pcb_element_directory_list_prepend (char *dir)
 {
+  char *dd =3D g_strdup(dir);
   sch2pcb_set_element_directory_list (
-    g_list_prepend (sch2pcb_get_element_directory_list (), dir));
+    g_list_prepend (sch2pcb_get_element_directory_list (), dd));
 }
 =

 =

--==_Exmh_1680527155_3450--


- Raw text -


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