# HG changeset patch # User zas_ # Date 1209760847 0 # Node ID 8de7cdde59dd56211db6681a377571655328dff4 # Parent b68fd1eb3243a7c57342e0b29a504d57319404dc Simplify remove_extension_from_path(). diff -r b68fd1eb3243 -r 8de7cdde59dd src/ui_fileops.c --- a/src/ui_fileops.c Fri May 02 20:27:47 2008 +0000 +++ b/src/ui_fileops.c Fri May 02 20:40:47 2008 +0000 @@ -765,18 +765,18 @@ gchar *remove_extension_from_path(const gchar *path) { - gchar *new_path; - const gchar *ptr = path; - gint p; + gint p = 0, n = -1; if (!path) return NULL; - if (strlen(path) < 2) return g_strdup(path); - p = strlen(path) - 1; - while (ptr[p] != '.' && p > 0) p--; - if (p == 0) p = strlen(path) - 1; - new_path = g_strndup(path, (guint)p); - return new_path; + while (path[p]) + { + if (path[p] == '.') n = p; + p++; + } + if (n < 0) n = p; + + return g_strndup(path, (gsize) n); } void parse_out_relatives(gchar *path)