Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Entire forum
➜ MUSHclient
➜ Lua
➜ Regex and Function
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Flelm
(15 posts) Bio
|
Date
| Thu 25 Aug 2005 02:12 AM (UTC) |
Message
| This Regex and this function make MUSHClient crash.
^ ([A-Za-z]+) was in the sign of( the)? ([A-Za-z ]+)( \(retrograde\))?\.$
function Nativity (name, link, wildcards, extraneous)
if (wildcards[1] == "Sun") then
Note (wildcards[1] .. " Ray - " .. signs[wildcards[3]].damage_type .. " Damage")
elseif (wildcards[1] == "Moon" or wildcards[1] == "Tarox" or wildcards[1] == "Aapek" or wildcards[1] == "Papaxi" or wildcards[1] == "Eroee" or wildcards[1] == "Sidiak") then
Note (wildcards[1] .. " Ray - " .. planets[wildcards[1]][signs[wildcards[3]].sign_type])
end
end
This Regex and the same function does not cause a crash.
^ ([A-Za-z]+) was in the sign of( the)? ([A-Za-z ]+)\.$
What am I missing? | Top |
|
Posted by
| Flelm
(15 posts) Bio
|
Date
| Reply #1 on Thu 25 Aug 2005 02:24 AM (UTC) |
Message
| Well, this Regex, and changing wildcards[3] to wildcards[2] worked. I still would like to know why that first Regex didn't work.
^ ([A-Za-z]+) was in the sign of (?:the)? ([A-Za-z ]+)(?: \(retrograde\))?\.$ | Top |
|
Posted by
| Larkin
(278 posts) Bio
|
Date
| Reply #2 on Thu 25 Aug 2005 03:48 AM (UTC) |
Message
| I've seen this problem before. When you have a variable number of captures, especially your optional capturing of "the" in this pattern, it causes the wildcards to shift in the array. You weren't taking that into account, and so using the (?:) to avoid the match fixes the number of entries in your wildcards, thus correcting your problem. | Top |
|
Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Date
| Reply #3 on Sat 27 Aug 2005 04:54 AM (UTC) |
Message
| I can reproduce the problem, which occurs in lua.dll, although I am not sure why. If I run it in the debugger I get a nice error message. Lua should not crash, and I am trying to reproduce it without needing MUSHclient, triggers etc., so far without luck.
Effectively you are doing something like this:
a = {} -- empty table
print (a [nil].b) -- index of nil into table, then index by b
However trying this in the command-line version gives:
stdin:1: attempt to index field `?' (a nil value)
stack traceback:
stdin:1: in main chunk
[C]: ?
It seems the problem is caused by the nil index into the array, but why that causes a MUSHclient crash is a mystery.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Date
| Reply #4 on Fri 14 Oct 2005 10:06 PM (UTC) |
Message
| I have determined the cause of the crash, which is described in the release notes for version 3.67. This is fixed in that version. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
18,391 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top