This would be better done using MCStringFormat and MCStringRefs. Also, you mustn't modify homename as it is const char * and owned by the MCStringRef.

You can do something like:
```
MCAutoStringRef t_open_path;
/* UNCHECKED */ MCStringFormat(&t_open_path, "%.*s/%s", MCStringEndsWithCString(*t_homename, "/", kMCCompareExact) ? MCStringGetLength(*t_homename) - 1, MCStringGetCString(*t_homename), tname);
```