explode.wiz

./lib/manuals/explode.wiz · 2.0 KB

From the archive h7v3.0a.tar.gz

Download the archive   « Back to the archive contents

Efun Explode:

This efun has undergone a lot of change, exhibiting quite varied
results depending on the driver. Explode, 'explodes' a string
into an array of strings.  The best way to see differences is to
look at some examples.

Amylaar Driver:

  Explode                   Exploded Array

explode("","a")           ({ "", })
explode("a","a")          ({ "", "", })
explode("aa","a")         ({ "", "", "", })
explode("baa","a")        ({ "b", "", "", })
explode("aba","b")        ({ "a", "a", })
explode("abab","b")       ({ "a", "a", "", })
explode("abc","")         ({ "a", "b", "c", })



312 Driver:

explode("","a")           ({ "", })
explode("a","a")          0 /* should use simul_efun fix!!! */
explode("aa","a")         0
explode("baa","a")        ({ "b", "", "", })
explode("aba","b")        ({ "a", "a", })
explode("abab","b")       ({ "a", "a", })
explode("abc","")         ({ "abc", })

Mudos Driver:

explode("","a")           ({ "", })
explode("a","a")          ({ }) /* should use simul_efun fix!!! */
explode("aa","a")         ({ })
explode("baa","a")        ({ "b", "", "", })
explode("aba","b")        ({ "a", "a", })
explode("abab","b")       ({ "a", "a", })
explode("abc","")         ({ "abc", })


Amylaar explode behaviour can be approximated with a simul_efun
fix, and by adding the delimiter to the string. The exception is
using an empty string, "", as a delimiter.

eg.      Amylaar Driver                  312/Mudos
       explode("abab","b")   ==   explode("abab" +"b","b")

The main reason it has been changed is so the following expression
returns true,

  implode(explode(str,delimiter),delimiter) == str

312 fails, whereas the amylaar doesn't. It is better to use the
amylaar behaviour. So that the mudlib can be used on both, the flag OLD_EXPLODE
has been used. When using the explode efun, esp. in the mainmain mudlib,
do the following,

#ifdef OLD_EXPLODE
  txt_list = explode(txt +"\n","\n");
#else
  txt_list = explode(txt,"\n");
#endif /* OLD_EXPLODE */

This will allow the mudlib to be moved between 312 and amylaar.

                    Zilanthius

Site Stats

Snippets: 1791
Codebases: 571