Mail Archives: geda-user/2023/04/03/09:26:28
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 -