Re: [CODE] strtok?!?

From: Daniel A. Koepke (
Date: 01/29/01

On Mon, 29 Jan 2001, Kaun Lazaro wrote:

> I've been working on my rename code and have redone my entire cast system so
> that ALL of the argument is sent to manual spells, the only problem I'mm
> having is that I can't find a way to remove the obj part of the argument so
> that only the last half of it remains...

strtok() is a silly function.  If you're rewriting the cast code, don't
use strtok().  You can expand the one_word function to support the quoting
for the cast command (just copy the code for the " delimited substrings
and change \" to \'), and then parse it that way:

  char spellname[MAX_INPUT_LENGTH];
  char spelltarg[MAX_INPUT_LENGTH];

  /* Get the spell name and target. */
  argument = one_word(argument, spellname);
  argument = one_word(argument, spelltarg);

  /* argument now contains whatever came after the target of the spell. */

This has the interesting side-effect that the apostrophe/single-quote is
no longer a magic character.  If the spell is more than one word long,
they have to quote it using single or double quotes (cast 'magi missi'
buffy; cast "magi missi" boffo; cast rename dagger bongo's dagger), but if
only word is needed to refer without ambiguity to the spell, then quotes
aren't required.


   | FAQ: |
   | Archives: |

This archive was generated by hypermail 2b30 : 12/03/01 PST