Mercurial > hg > dmlib
diff src/dmstring.c @ 2079:9b6027d51f76
Move dm_strdup_fext() and dm_basefilename() to gfxconv, as they are only used there.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 10 Dec 2018 19:24:45 +0200 |
parents | eeddaf411083 |
children | 63dd0a611586 |
line wrap: on
line diff
--- a/src/dmstring.c Mon Dec 10 15:41:58 2018 +0200 +++ b/src/dmstring.c Mon Dec 10 19:24:45 2018 +0200 @@ -2,46 +2,6 @@ #include <stdarg.h> -/* Returns the filename and path without the last filename extension, - * E.g. everything before the last '.', if any. - */ -char *dm_basefilename(const char *filename) -{ - char *tmp, *fext; - - if (filename == NULL || - (tmp = dm_strdup(filename)) == NULL) - return NULL; - - if ((fext = strrchr(tmp, '.')) != NULL) - { - char *fpath = strrchr(tmp, DM_DIR_SEPARATOR); - if (fpath == NULL || (fpath != NULL && fext > fpath)) - *fext = 0; - } - - return tmp; -} - - -/* Replace filename extension based on format pattern. - * Usage: res = dm_strdup_fext(orig_filename, "foo_%s.cmp"); - */ -char *dm_strdup_fext(const char *filename, const char *fmt) -{ - char *result, *tmp; - - if ((tmp = dm_basefilename(filename)) == NULL) - return NULL; - - result = dm_strdup_printf(fmt, tmp); - - dmFree(tmp); - - return result; -} - - /* Compare two strings ignoring case [strcasecmp, strncasecmp] */ int dm_strcasecmp(const char *haystack, const char *needle)