From: <oli...@t-...> - 2011-10-16 15:11:33
|
Hi Germán, Thanks for your bug report. Going back to the original mail from Alejandro Imass (http://sourceforge.net/mailarchive/forum.php?thread_name=AANLkTimiVOtXNg6RSuMuPgBjD8a%3D7prL4B0TzawCBXL0%40mail.gmail.com&forum_name=dia2code-general), I realize that nobody ever answered to that mail. Alejandro wrote: > [...] > I think these 2 patches are quite harmless to the current 0.83 and > maybe to more current versions of dia2code. I have seen a couple of > postings regarding the "unnamed association bug" like this one: > https://bugs.launchpad.net/ubuntu/+source/dia2code/+bug/442295 I read up on that bug report and applied the parse_diagram.patch : RCS file: /cvsroot/dia2code/dia2code/dia2code/parse_diagram.c,v Working file: dia2code/parse_diagram.c ---------------------------- revision 1.4 date: 2011/10/16 14:22:33; author: okellogg; state: Exp; lines: +38 -37 Attachment 2146249 from https://bugs.launchpad.net/ubuntu/+source/dia2code/+bug/442295 lets dia2code find the name of an association given in the diagram. Thanks to Evgeny Shpilevsky (ftdebugger) for the parse_diagram.patch. ---------------------------- However, now the patch to parse_diagram.c by Alejandro cannot be applied. Could you have a look? Thanks, Oliver ----- Original message ----- From: Germán <ger...@ya...> To: dia...@li... Subject: Re: [Dia2code-general] Newcomer, old user, help offered, patch for SQL module 0.83 Date: Sat, 15 Oct 2011 02:34:00 +0200 Hello, and thanks for the info about the "association bugs". I was bumping into the same problem of the foreign keys. Then I found your work on svn. But when I tried it returned me a warning telling me the name of the association had to end with '_id'. And indeed, the name ended with '_id', then I dared to modify your code and I was able to make it work (was only a little error). Here is the patch. --- generate_code_sql.c (revisión: 7) +++ generate_code_sql.c (copia de trabajo) @@ -156,9 +156,8 @@ */ - char tail[4]; const char *fk_col = temp->name; - strncpy(tail, fk_col+sizeof(fk_col)-2, 3); + const char *tail=&fk_col[strlen(fk_col)-3]; if(!strcmp("_id", tail)){ fk_col = "id"; } Warning: Never use sizeof() to take care of the length of an string. If applied to a pointer is going to return the size it occupies in memory the pointer, usually will get value 4 for 32-bit machines. Therefore, always use strlen. Be careful also to put the null terminator for strings. Anyway, here you have an alternative way to cut the tail of a string. Greetings from Argentina. (That explains my poor English) -- Germán <ger...@ya...> ------------------------------------------------------------------------------ All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2d-oct _______________________________________________ Dia2code-general mailing list Dia...@li... https://lists.sourceforge.net/lists/listinfo/dia2code-general |