[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gEDA: a_basic.nw problems



Hi everybody!

I am new to geda and must admit, it is quiet impressive. But it still 
needs some work to be done and I am willing to help.

So, I started to look ad the code to understand, what is going on in 
gschem. I started with libgeda, and in the first file a_basic.nw I 
found a problem:

in o_save_embedded(TOPLEVEL *w_current, OBJECT *object_list, FILE *fp) 
there is the following code:

>           case(OBJ_COMPLEX):
>             out = (char *) o_complex_save(buf, o_current);
>             if (strncmp(
>                         o_current->complex_clib,
>                         "EMBEDDED", 8) == 0) {
>               fprintf(fp, "[\n");
>
>               o_save_embedded(
>                               w_current,
>                               o_current->
>                               complex->prim_objs,
>                               fp);
>
>               fprintf(fp, "]\n");
>             }
>             break;

In o_save(TOPLEVEL *w_current, char *filename) the code looks a bit 
different:

>           case(OBJ_COMPLEX):
>             out = (char *) o_complex_save(buf, o_current);
> ---->       fprintf(fp, "%s\n", out);
> ---->       already_wrote=1;
>             if (strncmp(
>                         o_current->complex_clib,
>                         "EMBEDDED", 8) == 0) {
>               fprintf(fp, "[\n");
>
>               o_save_embedded(
>                               w_current,
>                               o_current->
>                               complex->prim_objs,
>                               fp);
>
>               fprintf(fp, "]\n");
>             }
>             break;

The contents of the buffer returned by o_complex_save is written out 
first, prior to writing the embedded data, while the first function 
does first write the embedded data, the buffer is written later in the 
code.

I also cannot see, why there are two, almost identical functions and 
would try to change the code, that there will only be one function, 
which saves all the data. I also would like to change the functions 
like o_complex_save() o take a FILE* as their first argument instead of 
a buffer. The buffer approach need some management to be sure, no 
buffer overflow problem occurs.

Using a FILE*, not only the fprintf() in the code above can be 
eliminated, but also the flag-variable already_wrote (which could be 
replaced by 'out=NULL) anyway).

There seems to be no other invocation of the o_*_save() functions, so 
this change should be possible.

However, I am new to geda, so I do not know, how to introduce these 
changes.

73, Mario
-- 
Mario Klebsch                                           mario@klebsch.de
PGP-Key available at http://www.klebsch.de/public.key
Fingerprint DSS: EE7C DBCC D9C8 5DC1 D4DB  1483 30CE 9FB2 A047 9CE0
  Diffie-Hellman: D447 4ED6 8A10 2C65 C5E5  8B98 9464 53FF 9382 F518