This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

rehash crashes - restart doesn't (also empty string prob)

Old posts that have not been replied to for several years.
Locked
r
ribot
Voice
Posts: 17
Joined: Mon Sep 08, 2003 4:01 pm
Location: eggbeer
Contact:

rehash crashes - restart doesn't (also empty string prob)

Post by ribot »

As I update the code for my module, and run "make" without errors, copy the module to eggdrop's modules, sometimes everything goes smoothly. But sometimes the bot crashes because of a segment violation. I guess it can happen even if it works to compile the mod, but the strange thing is that after my segment violation I can start the bot again, and after that rehash it again, and the module works, and there doesn't seem to exist any problem. Strange innit? Bug or is it some subtle error in my code perhaps?

Then a smaller problem, with pub bind, if the text variable is empty, it doesn't seem to be true that (text == "") nor (text == {}) neither (text == NULL). How do I make the condition that checks if the text variable is empty?
whatever path you choose in life you get nowhere. note that you can choose a path with or without heart.
p
pnp

Post by pnp »

To help your smaller problem.

(string == "") is a logical expression, true/false 1/0

try using string:

Code: Select all

if {[string equal -nocase $text ""]} { puts stdout "text isemtpy" }

Code: Select all

if {[string match $text ""]} { puts stdout "text matches \"\"" }
r
ribot
Voice
Posts: 17
Joined: Mon Sep 08, 2003 4:01 pm
Location: eggbeer
Contact:

Post by ribot »

I think I am supposed to have a logical expression. And the question is about c, because I know how to do it in tcl.

This is how to do it in tcl:

Code: Select all

if {$text == ""} {}
How do I make this true in c, with var text, (if text is empty the expression should return true).
whatever path you choose in life you get nowhere. note that you can choose a path with or without heart.
M
MtX

Post by MtX »

ribot wrote:I think I am supposed to have a logical expression. And the question is about c, because I know how to do it in tcl.

This is how to do it in tcl:

Code: Select all

if {$text == ""} {}
How do I make this true in c, with var text, (if text is empty the expression should return true).
Try this:
if (text == NULL) {

}
p
pelefanten
Voice
Posts: 27
Joined: Thu Apr 17, 2003 4:37 pm

Post by pelefanten »

This one should take care of text == NULL and text = ""

Code: Select all

#include <string.h>

if (strlen(text) == 0) {
    ....
}
Or if you dont want to use strlen

Code: Select all

if (!text || !*text) {
    ....
}
r
ribot
Voice
Posts: 17
Joined: Mon Sep 08, 2003 4:01 pm
Location: eggbeer
Contact:

Post by ribot »

welll does anyone else have the same problem as me? how do you fix bugs, after changing the code? do you rehash, or restart perhaps? maybe im doing something wrong...? or maybe the bot just crashes because it's not supposed to handle mod changes while it's running?
whatever path you choose in life you get nowhere. note that you can choose a path with or without heart.
Locked