Re: more on g_strconcat problem
Hi, [EMAIL PROTECTED] writes: You haven't looked at much C code, have you? :) Rest assured that I did. http://www.lysator.liu.se/c/duffs-device.html for the infamous Duff Device. I consider Duff's device a very elegant hack and have even used it myself (for DirectFB's software renderer). Or just wander over to http://www.ioccc.org :) Obfuscated doesn't necessarily mean ugly. Sven ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: more on g_strconcat problem
Sven Neumann wrote: Obfuscated doesn't necessarily mean ugly. Not if well explained... But in that respect I have been a sinner more than once :-/ Speeking of DirectFB This project (free desktop) looks wery X centered, but it a lot of stuff is quite relevant for other open / free desktops. And both QT and GTK+ run to some extent on DirectFB. What is the relation between Free desktop and DirectFB? /LaH ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: more on g_strconcat problem
Carl B. Constantine wrote: sql = g_strconcat(insert into customers (id_req) values(', toggleTest, '),0L); g_print(First sql: %s\n,sql); This code prints the following when the checkbox is unchecked: insert into customers (id_req) values(' so it doesn't even complete the string. That same code crashes with a segfault 11 if I check the checkbox in the dialog. This makes absolutely NO sense what so ever! Well, judging from the working part of your example, your toggleTest variable is not a string, but an integer. g_strconcat() wants strings. If you use an int in place of a string a segfault makes a lot of sense! -- Christer Palm ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: more on g_strconcat problem
On Wed, Nov 26, 2003 at 09:30:40PM -0800, Carl B. Constantine wrote: Ok, I've definately nailed the problem down to an issue with the check button in my data entry box. But it still doesn't make sense. consider the following code: idRequired = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(customers, cust_id_req))); g_print(ID Required status: %d\n, idRequired); toggleTest = (gint)idRequired; g_print(ID Required status: %d\n, toggleTest); the above code prints 0 if the checkbox is unchecked and 1 if it is checked. With that in mind, consider the following additional code: sql = g_strconcat(insert into customers (id_req) values(', toggleTest, '),0L); g_print(First sql: %s\n,sql); This code prints the following when the checkbox is unchecked: insert into customers (id_req) values(' so it doesn't even complete the string. That same code crashes with a segfault 11 if I check the checkbox in the dialog. This makes absolutely NO sense what so ever! Well, this seems to make much sense, could it be, that you are passing an Integer into g_strconcat? Try this: char *helper; if(toogleTest) helper = YES; else helper = NO; sql = g_strconcat(insert into customers (id_req) values(', helper, '),0L); Basically, in the unchecked case, you are passing 0, which is interpreted as the end of arguments, which makes g_strconcat ignore all further arguments. In the toogleTest == 1 case, it's interpreted as an char pointer, and accessing the address 1 is a relative safe way to segfault an app ;) Andreas Kostyrka ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: more on g_strconcat problem
Hi, Carl B. Constantine [EMAIL PROTECTED] writes: Ok, I've definately nailed the problem down to an issue with the check button in my data entry box. But it still doesn't make sense. consider the following code: idRequired = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(customers, cust_id_req))); g_print(ID Required status: %d\n, idRequired); toggleTest = (gint)idRequired; g_print(ID Required status: %d\n, toggleTest); the above code prints 0 if the checkbox is unchecked and 1 if it is checked. With that in mind, consider the following additional code: sql = g_strconcat(insert into customers (id_req) values(', toggleTest, '),0L); You must pass strings to g_strconcat(). Strings are NULL-terminated character arrays, not integers. BTW. your g_strconcat() construct from the last mail gets the price for the ugliest piece of C code I've ever seen. Sven ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: more on g_strconcat problem
On Thu, 27 Nov 2003 13:33:57 +0100, Sven Neumann said: BTW. your g_strconcat() construct from the last mail gets the price for the ugliest piece of C code I've ever seen. You haven't looked at much C code, have you? :) http://www.lysator.liu.se/c/duffs-device.html for the infamous Duff Device. Or just wander over to http://www.ioccc.org :) Now *that* site has some of the ugliest C code *EVER* seen (Yes, the Larry Wall who won several times is the same Larry Wall who did Perl. Draw your own conclusions :) pgp0.pgp Description: PGP signature
more on g_strconcat problem
Ok, I've definately nailed the problem down to an issue with the check button in my data entry box. But it still doesn't make sense. consider the following code: idRequired = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(customers, cust_id_req))); g_print(ID Required status: %d\n, idRequired); toggleTest = (gint)idRequired; g_print(ID Required status: %d\n, toggleTest); the above code prints 0 if the checkbox is unchecked and 1 if it is checked. With that in mind, consider the following additional code: sql = g_strconcat(insert into customers (id_req) values(', toggleTest, '),0L); g_print(First sql: %s\n,sql); This code prints the following when the checkbox is unchecked: insert into customers (id_req) values(' so it doesn't even complete the string. That same code crashes with a segfault 11 if I check the checkbox in the dialog. This makes absolutely NO sense what so ever! Please help, this is driving me NUTSO! -- .''`. Carl B. Constantine : :' : [EMAIL PROTECTED] `. `'GnuPG: 135F FC30 7A02 B0EB 61DB 34E3 3AF1 DC6C 9F7A 3FF8 `- Debian GNU/Linux -- The power of freedom Claiming that your operating system is the best in the world because more people use it is like saying McDonalds makes the best food in the world. ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: more on g_strconcat problem
On Wed, 2003-11-26 at 23:30, Carl B. Constantine wrote: Ok, I've definately nailed the problem down to an issue with the check button in my data entry box. But it still doesn't make sense. consider the following code: [snip] sql = g_strconcat(insert into customers (id_req) values(', toggleTest, '),0L); [snip] I'm not really informed on whether NULL is ever != 0, but have you tried terminating the string with NULL instead of 0L? -- Peace, Jim Cape http://ignore-your.tv It is literally true that, like Christianity, Socialism has conquered the world by defeating itself. -- Alexander Berkman, ABC of Anarchism signature.asc Description: This is a digitally signed message part