gnome-commander r1476 - in branches/gcmd-1-3: . src



Author: epiotr
Date: Mon Jan  7 18:36:33 2008
New Revision: 1476
URL: http://svn.gnome.org/viewvc/gnome-commander?rev=1476&view=rev

Log:
Simplified gnome_cmd_file_get_extension()

Modified:
   branches/gcmd-1-3/ChangeLog
   branches/gcmd-1-3/src/gnome-cmd-file.cc

Modified: branches/gcmd-1-3/ChangeLog
==============================================================================
--- branches/gcmd-1-3/ChangeLog	(original)
+++ branches/gcmd-1-3/ChangeLog	Mon Jan  7 18:36:33 2008
@@ -1,3 +1,8 @@
+2008-01-07  Piotr Eljasiak  <epiotr use pl>
+
+	* src/gnome-cmd-file.cc:
+	Simplified gnome_cmd_file_get_extension()
+
 2008-01-06  Piotr Eljasiak  <epiotr use pl>
 
 	* src/gnome-cmd-file-selector.cc:

Modified: branches/gcmd-1-3/src/gnome-cmd-file.cc
==============================================================================
--- branches/gcmd-1-3/src/gnome-cmd-file.cc	(original)
+++ branches/gcmd-1-3/src/gnome-cmd-file.cc	Mon Jan  7 18:36:33 2008
@@ -391,22 +391,16 @@
 
 const gchar *gnome_cmd_file_get_extension (GnomeCmdFile *file)
 {
-    gint i, len;
-
     g_return_val_if_fail (file != NULL, NULL);
     g_return_val_if_fail (file->info != NULL, NULL);
 
     if (file->info->type == GNOME_VFS_FILE_TYPE_DIRECTORY)
         return NULL;
 
-    len = strlen (file->info->name);
-    for (i=len; i>0; i--)
-    {
-        if (file->info->name[i] == '.')
-            return &file->info->name[i+1];
-    }
+    const char *s = strrchr (file->info->name, '.');        // does NOT work on UTF-8 strings, should be (MUCH SLOWER):
+    // const char *s = g_utf8_strrchr (file->info->name, -1, '.');
 
-    return NULL;
+    return s ? s+1 : NULL;
 }
 
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]