From 5208489a5906907a1ee8b15f6715b10b69ff438c Mon Sep 17 00:00:00 2001 From: Yevgen Muntyan <17531749+muntyan@users.noreply.github.com> Date: Sun, 9 Apr 2006 03:25:57 -0500 Subject: [PATCH] Fixed getting lang for files with backup suffixes --- moo/mooedit/moolangmgr.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/moo/mooedit/moolangmgr.c b/moo/mooedit/moolangmgr.c index 2ec4aac1..973f8aca 100644 --- a/moo/mooedit/moolangmgr.c +++ b/moo/mooedit/moolangmgr.c @@ -857,10 +857,9 @@ lang_mgr_get_lang_for_bak_filename (MooLangMgr *mgr, const char *filename) { MooLang *lang = NULL; - char *base = NULL; + char *utf8_name, *utf8_base = NULL; int len; guint i; - char *utf8_name; static const char *bak_globs[] = {"*~", "*.bak", "*.in"}; @@ -875,20 +874,20 @@ lang_mgr_get_lang_for_bak_filename (MooLangMgr *mgr, if (len > ext_len && g_pattern_match_simple (bak_globs[i], utf8_name)) { - base = g_strndup (utf8_name, len - ext_len); + utf8_base = g_strndup (utf8_name, len - ext_len); break; } } - if (base) + if (utf8_base) { - char *opsys_name = g_filename_from_utf8 (base, len, NULL, NULL, NULL); + char *base = g_filename_from_utf8 (utf8_base, -1, NULL, NULL, NULL); - if (opsys_name) - lang = moo_lang_mgr_get_lang_for_filename (mgr, opsys_name); + if (base) + lang = moo_lang_mgr_get_lang_for_filename (mgr, base); - g_free (opsys_name); g_free (base); + g_free (utf8_base); } g_free (utf8_name);