changeset 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 b2f1ce24f81b
children 7e4087e2740d
files src/dmlib.h src/dmstring.c tools/gfxconv.c
diffstat 3 files changed, 26 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/src/dmlib.h	Mon Dec 10 15:41:58 2018 +0200
+++ b/src/dmlib.h	Mon Dec 10 19:24:45 2018 +0200
@@ -428,8 +428,6 @@
 char *     dm_strdup_vprintf(const char *fmt, va_list args);
 char *     dm_strdup_printf(const char *fmt, ...);
 
-char *     dm_basefilename(const char *filename);
-char *     dm_strdup_fext(const char *filename, const char *fmt);
 int        dm_strcasecmp(const char *haystack, const char *needle);
 int        dm_strncasecmp(const char *haystack, const char *needle, size_t n);
 char *     dm_strrcasecmp(char *str, const char *needle);
--- 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)
--- a/tools/gfxconv.c	Mon Dec 10 15:41:58 2018 +0200
+++ b/tools/gfxconv.c	Mon Dec 10 19:24:45 2018 +0200
@@ -262,6 +262,32 @@
 }
 
 
+/* 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, *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;
+    }
+
+    result = dm_strdup_printf(fmt, tmp);
+
+    dmFree(tmp);
+
+    return result;
+}
+
+
 //
 // Return a "matching" ANSI colour code for given C64 palette index.
 // As the standard 16 ANSI colours are not exact match and some C64