[AD] al_path_set_extension

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


I'm going through the path functions, making them use the new UTF-8
routines and writing a test suite for them.

One behaviour which surprised me initially was al_path_set_extension.

    al_path_set_extension("abc", "ext")	     ==> "abc.ext"
    al_path_set_extension("abc.ext", "def")  ==> "abc.def"
    al_path_set_extension("abc.def", "")     ==> "abc."

which makes sense, yet I was expecting the last call to result in "abc".

One way to resolve this is to define an extension to include the dot as
well.  Then:

    al_path_set_extension("abc", ".ext")     ==> "abc.ext"
    al_path_set_extension("abc.ext", ".def") ==> "abc.def"
    al_path_set_extension("abc.def", "")     ==> "abc"

Then al_path_set_extension could be used to remove the extension.  Also
the first call doesn't magically grow a dot character out of nowhere.
al_path_get_extension would return the leading dot.

What do you think?

Peter





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/