DG Script oddity + proposed fix

From: Chris Jacobson (fear@ATHENET.NET)
Date: 01/17/98


Ok, now I am using a different version of DG scripts than the one that is
out there (I ported mine over to AvP before the other ports were
started), but since the codebase for them is the same, maybe some of you
have noticed this little oddity:

attempting to substring-check (/=) a string to another will fail if you
use quotations (") around the strings.  Example:

-- Trig Number:  [1200]
1) Script Name : test script
2) Script Class: Mob Script
3) Triggers    : Command
4) Arg         : test
5) Num Arg     : 0
6) Script      :
eval var ("dogs suck a lot" /= "suck")
say "dogs suck a lot" /= "suck" = %var%
eval var ("dogs suck a lot" /= "not")
say "dogs suck a lot" /= "not" = %var%


Attach that to a mob, type "test".
Result:
Jake says, '"dogs suck a lot" /= "suck" = 0'
Jake says, '"dogs suck a lot" /= "not" = 0'


Now with the following version of the script:

eval var (dogs suck a lot /= suck)
say dogs suck a lot /= suck = %var%
eval var (dogs suck a lot /= not)
say dogs suck a lot /= not = %var%

Gets these results:

Jake says, 'dogs suck a lot /= suck = 1'
Jake says, 'dogs suck a lot /= not = 0'


Also, doing the same script, with the main string in quotations and the
substring not in quotations, like:

eval var ("dogs suck a lot" /= suck)
say "dogs suck a lot" /= suck = %var%
eval var ("dogs suck a lot" /= not)
say "dogs suck a lot" /= not = %var%

produced the same results:

Jake says, '"dogs suck a lot" /= suck = 1'
Jake says, '"dogs suck a lot" /= not = 0'


This is a bit odd, considering eval_lhs_op_rhs takes (or at least appears
to take) everything within a pair of quotations as a single token (minus
the quotations).
So "dogs suck a lot" should be tokenized without the quotations.

As a final test, I simply did:

eval var "dogs suck a lot"
say %var%

Now, since the line is being evaluated before being stored in %var%, the
quotations should be removed for tokenization.
The following results:

Jake says, '"dogs suck a lot"'

So, it is now apparent that eval_lhs_op_rhs tokenizes by including the
quotations in tokens.  Should this occur at all?  One would think that
the quotations are useless in an evaluated expression, like in C, since
one can use \" to aquire a quotation mark within a quotation-string that
is being tokenized, also like in C.

I am looking at how to change this to aquire C-style processing, and will
post my changes when I find them.  However, if someone like Mark beats me
to it, I won't complain, since as you all well know by now my
descriptions of fixes/etc are either too brief and uncommented or too
long and drawn out (what can I say, I'm a coder, not a technical author
:-)

- Chris Jacobson


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST