[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  Regex and Function
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Regex and Function

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Flelm   (15 posts)  [Biography] 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?
[Go to top] top

Posted by Flelm   (15 posts)  [Biography] 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\))?\.$
[Go to top] top

Posted by Larkin   (278 posts)  [Biography] 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.
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] 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
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] 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
[Go to top] 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.


5,364 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]