MOO-cows Mailing List Archive


Re: commands like " and ;

> 2. How do I get the verb to take what is adjacent to the command as
> the args? (this is the hard part) I have been trying to get stuff so
> you can have your args not seperated by a space but this doesn't seem
> to work.

Hacking the server is the only way to do this correctly.
Finding the relevant code should be easy; just grep the sources for
the string "case ';':" though you may need to go through some escape
gymnastics to get this past your shell.  Assuming the code hasn't
changed since 1.7.8p2, you can just add another case to
the function parse_command() in parse_cmd.c

  case '%':
    verb = "%";
    goto finish_specials;

In theory, when we get in-db parsing, this issue will be moot.

>  > 2) What is adjacent to the command is considered to be PART of the
>  > command.  Hence, if you use what I use for page: `` 'player Heya '', then
>  > the verb == "'player".  On the first line of the verb, simply do
>  > something like args = {verb[2..length(verb)], @args}.
>  Generally (I'll use eval here as an example), you'd add a verb like:
>    ;*
>  with arguments 'any any any' (although this, too, isn't required; it'd make
>  things more interesting to do it otherwise) and appropriate security 
and bits.
>  Before dealing with the arguments, you'd need to grab the part attached to
>  the verb, so you'd use a code segment like:
>    if (length(verb) > 1)
>      args = {verb[2..length(verb)], @args};
>      argstr = args[1] + " " + argstr;
>    endif;

This loses because it doesn't treat quotes and backslashes correctly
when they occur in or around `verb'.  Nor is it possible to do this
in moo-code.

(Hint:  Give yourself a frob* verb and try

  frob" hi mom \"\\ " one "two" \"three\"

argstr will correctly capture the quoting around the args ("one \"two...")
but the only way you can even tell that there were quotes in the verb is
by the fact that it contains a space; even then you can't tell whether it

  frob" hi mom \"\\ "


  fr"ob ""hi "mom" \"\\ "

or even

  frob" ""h""i ""m""o""m ""\""\\" "

This, by the way, is why it's impossible to write a subst command for the
verb/note/list-editor and have it work correctly...).

Home | Subject Index | Thread Index