File fltk-flu-2.14-glib210.patch of Package fltk-flu

Index: src/Flu_File_Chooser.cpp
===================================================================
--- src/Flu_File_Chooser.cpp.orig
+++ src/Flu_File_Chooser.cpp
@@ -2712,16 +2712,10 @@ int Flu_File_Chooser :: popupContextMenu
 {
   int type = entry ? entry->type : ENTRY_NONE;
   const char *filename = entry ? entry->filename.c_str() : NULL;
-  char *ext = NULL;
+  const char *ext = NULL;
 
   if( filename )
-    ext = strrchr( filename, '.' );
-  if( ext )
-    {
-      ext = strdup( ext+1 ); // skip the '.'
-      for( unsigned int i = 0; i < strlen(ext); i++ )
-	ext[i] = tolower( ext[i] );
-    }
+    ext = strrchr( filename, '.' ) + 1;
 
   enum { ACTION_NEW_FOLDER = -1, ACTION_RENAME = -2, ACTION_DELETE = -3 };
 
@@ -2762,12 +2756,10 @@ int Flu_File_Chooser :: popupContextMenu
       if( !(contextHandlers[i].type & type) )
 	continue;
       if( type == ENTRY_FILE )
-	if( contextHandlers[i].ext.size() && contextHandlers[i].ext != ext )
+	if( contextHandlers[i].ext.size() && contextHandlers[i].ext.casecompare(ext) )
 	  continue;
       entryPopup.add( contextHandlers[i].name.c_str(), 0, 0, (void*)i );
     }
-  if( ext )
-    free( ext );
 
   entryPopup.position( Fl::event_x(), Fl::event_y() );
   const Fl_Menu_Item *selection = entryPopup.popup();
@@ -3128,7 +3120,7 @@ void Flu_File_Chooser :: cleanupPath( Fl
 	      newPos--;
 	      newS[newPos] = '\0';
 	      // look for the previous '/'
-	      char *lastSlash = strrchr( newS.c_str(), '/' );
+	      const char *lastSlash = strrchr( newS.c_str(), '/' );
 	      // make the new string position after the slash
 	      newPos = (lastSlash-newS.c_str())+1;
 	      oldPos += 3;
@@ -3743,11 +3735,12 @@ void Flu_File_Chooser :: cd( const char
   // try to split into path and file
   if( currentDir[currentDir.size()-1] != '/' )
     {
-      char *lastSlash = strrchr( currentDir.c_str(), '/' );
+      const char *currentDirArray = currentDir.c_str();
+      const char *lastSlash = strrchr( currentDirArray, '/' );
       if( lastSlash )
 	{
 	  currentFile = lastSlash+1;
-	  lastSlash[1] = '\0';
+	  currentDir[lastSlash - currentDirArray + 1] = '\0';
 	}
     }
   // make sure currentDir ends in '/'
@@ -4177,14 +4170,15 @@ static const char* _flu_file_chooser( co
 	    {
 	      // if pattern is different, remove name but leave old directory:
 	      retname = fc->value();
-	      char *p = strrchr( retname.c_str(), '/' );
+	      const char *retnameArray = retname.c_str();
+	      const char *p = strrchr( retnameArray, '/' );
 	      if( p )
 		{
 		  // If the filename is "/foo", then the directory will be "/", not ""
 		  if( p == retname.c_str() )
 		    retname[1] = '\0';
 		  else
-		    p[1] = '\0';
+		    retname[p - retnameArray + 1] = '\0';
 		}
 	    }
 	  fc->filter( pattern );
openSUSE Build Service is sponsored by