src/misc/string.c, rewrite using `copy_substring()'