Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Tue Dec 04, 2007 10:06 pm   

[2.14] %regex not setting parameters correctly
 
I am finding that once %regex is used with a certain number of parameters it always want to have that many parameters.

1. Launch CMud
2. Close Sessions window (ESC)
3. Enter at the command line
Code:
#SHOW %regex("1234567890","(4)..(7)",$var1,$var2,$var3) '$var1' '$var2' '$var3'

4. Enter at the command line
Code:
#SHOW %regex("1234567890","(4)",$var1,$var2) '$var1' '$var2'

We see with the second command that $var2 is unchanged, the final parameter was not properly set. It is still 7 from our previous test.
5. Enter at the command line
Code:
#SHOW %regex("1234567890","(45)",$var1,$var2,$var3) '$var1' '$var2' '$var3'

Now we see that %regex forgot to blank out $var2. $var3 was properly set to the last character matched.
5. Enter at the command line
Code:
#SHOW %regex("1234567890","(45)",$var1,$var2,$var3, $var4) '$var1' '$var2' '$var3' '$var4'

Now we see that $var3 was properly blanked, $var4 is correctly set, but $var2 was not blanked. It seems to be a problem with that specific position of 4th parameter.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Tue Dec 04, 2007 10:35 pm   
 
Yeah, currently CMUD assumes that you are going to give it the proper number of variables and it doesn't look for extras to blank out. I think you'll find that the same thing happens with regular variables (vs local variables). I'll add this to the bug list.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Tue Dec 04, 2007 11:59 pm   
 
This issue might be more pressing than you'd think because it's possible for this to return improper results. For example, running this after running all the other tests:

#SHOW %regex("1234567890","(4)(10)?",$var1,$var2) '$var1' '$var2'

gives the result

4 '4' '7'

which implies that there was a match when there wasn't.

Also, even more perplexing is why the local variables from each test still exist when you run the next test. Any other time you define a local variable on one command line and try to use them again in another command line, it fails.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Wed Dec 05, 2007 12:38 am   
 
Internally, CMUD needs to do a kludge to handle creation of on-the-fly local variables within functions like %regex. Instead of passing the name of a variable, CMUD passes a number, which is the index value of the local variable being referenced. When %regex needs to set the value of the variable, it checks to see if the variable name is a number and if so, it calls back to the execution routine (which has access to the local variables on the stack) and tells it to set the local variable value.

My guess is that you aren't really getting the *value* of the local variable, but are getting this internal numeric reference somehow. But I'll look into this just in case it's a more severe parser issue.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net