]> git.saurik.com Git - wxWidgets.git/blobdiff - src/unix/mimetype.cpp
wxTinderbox build fix.
[wxWidgets.git] / src / unix / mimetype.cpp
index 8c2ddad03e862c56b88bd96a7daed2ab09641a9b..628f7a071ca6ccffa04f2e8bcc633446ebe44df7 100644 (file)
@@ -124,6 +124,11 @@ public:
             if ( idx )
                 *idx = n;
         }
+        else if ( idx )
+        {
+            // different from any valid index
+            *idx = (size_t)-1;
+        }
 
         return s;
     }
@@ -646,7 +651,9 @@ void wxMimeTypesManagerImpl::LoadGnomeDataFromKeyFile(const wxString& filename,
         nLine++;
     } // end of while, save any data
 
-    if (! curMimeType.empty())
+    if ( curMimeType.empty() )
+        delete entry;
+    else
         AddToMimeData( curMimeType, curIconFile, entry, strExtensions, strDesc);
 }
 
@@ -1398,13 +1405,17 @@ size_t wxFileTypeImpl::GetAllCommands(wxArrayString *verbs,
                  count++;
                  if ( vrb.IsSameAs(wxT("open")))
                  {
-                     verbs->Insert(vrb, 0u);
-                     commands ->Insert(cmd, 0u);
+                     if ( verbs )
+                        verbs->Insert(vrb, 0u);
+                     if ( commands )
+                        commands ->Insert(cmd, 0u);
                  }
                  else
                  {
-                     verbs->Add(vrb);
-                     commands->Add(cmd);
+                     if ( verbs )
+                        verbs->Add(vrb);
+                     if ( commands )
+                        commands->Add(cmd);
                  }
              }
         }
@@ -1465,17 +1476,16 @@ wxFileTypeImpl::SetCommand(const wxString& cmd,
     wxArrayString strExtensions;
     wxString strDesc, strIcon;
 
-    wxMimeTypeCommands *entry = new wxMimeTypeCommands();
-    entry->Add(verb + wxT("=")  + cmd + wxT(" %s "));
-
     wxArrayString strTypes;
     GetMimeTypes(strTypes);
-    if (strTypes.GetCount() < 1)
+    if ( strTypes.IsEmpty() )
         return false;
 
-    size_t i;
+    wxMimeTypeCommands *entry = new wxMimeTypeCommands();
+    entry->Add(verb + wxT("=")  + cmd + wxT(" %s "));
+
     bool ok = true;
-    for (i = 0; i < strTypes.GetCount(); i++)
+    for ( size_t i = 0; i < strTypes.GetCount(); i++ )
     {
         if (!m_manager->DoAssociation(strTypes[i], strIcon, entry, strExtensions, strDesc))
             ok = false;
@@ -1493,19 +1503,26 @@ bool wxFileTypeImpl::SetDefaultIcon(const wxString& strIcon, int WXUNUSED(index)
     wxArrayString strExtensions;
     wxString strDesc;
 
-    wxMimeTypeCommands *entry = new wxMimeTypeCommands();
-
     wxArrayString strTypes;
     GetMimeTypes(strTypes);
-    if (strTypes.GetCount() < 1)
+    if ( strTypes.IsEmpty() )
         return false;
 
-    size_t i;
+    wxMimeTypeCommands *entry = new wxMimeTypeCommands();
     bool ok = true;
-    for (i = 0; i < strTypes.GetCount(); i++)
+    for ( size_t i = 0; i < strTypes.GetCount(); i++ )
     {
-        if (!m_manager->DoAssociation(strTypes[i], strIcon, entry, strExtensions, strDesc))
+        if ( !m_manager->DoAssociation
+                         (
+                            strTypes[i],
+                            strIcon,
+                            entry,
+                            strExtensions,
+                            strDesc
+                         ) )
+        {
             ok = false;
+        }
     }
 
     return ok;
@@ -2378,8 +2395,8 @@ bool wxMimeTypesManagerImpl::ReadMimeTypes(const wxString& strFileName)
                 pEnd = wxStrchr(++pc, wxT('"'));
                 if ( pEnd == NULL )
                 {
-                    wxLogWarning(wxT("Mime.types file %s, line %d: unterminated quoted string."),
-                                 strFileName.c_str(), nLine + 1);
+                    wxLogWarning(wxT("Mime.types file %s, line %lu: unterminated quoted string."),
+                                 strFileName.c_str(), nLine + 1L);
                 }
             }
             else
@@ -2436,8 +2453,8 @@ bool wxMimeTypesManagerImpl::ReadMimeTypes(const wxString& strFileName)
                 // unregistered extensions according to the standard practice,
                 // but it may be worth telling the user about other junk in
                 // his mime.types file
-                wxLogWarning(wxT("Unknown field in file %s, line %d: '%s'."),
-                             strFileName.c_str(), nLine + 1, strLHS.c_str());
+                wxLogWarning(wxT("Unknown field in file %s, line %lu: '%s'."),
+                             strFileName.c_str(), nLine + 1L, strLHS.c_str());
             }
 
             if ( !entryEnded )
@@ -2663,7 +2680,7 @@ bool wxMimeTypesManagerImpl::ReadMailcap(const wxString& strFileName,
 
                             wxLogDebug(wxT("Mailcap file %s, line %lu: '\\' on the end of the last line ignored."),
                                        strFileName.c_str(),
-                                       (unsigned long)nLine + 1);
+                                       nLine + 1L);
                         }
                         else
                         {
@@ -2727,7 +2744,7 @@ bool wxMimeTypesManagerImpl::ReadMailcap(const wxString& strFileName,
                                 (
                                     wxT("Mailcap file %s, line %lu: unknown field '%s' for the MIME type '%s' ignored."),
                                     strFileName.c_str(),
-                                    (unsigned long)nLine + 1,
+                                    nLine + 1L,
                                     curField.c_str(),
                                     data.type.c_str()
                                 );
@@ -2764,8 +2781,8 @@ bool wxMimeTypesManagerImpl::ReadMailcap(const wxString& strFileName,
         // check that we really read something reasonable
         if ( currentToken < Field_Other )
         {
-            wxLogWarning(wxT("Mailcap file %s, line %d: incomplete entry ignored."),
-                         strFileName.c_str(), nLine + 1);
+            wxLogWarning(wxT("Mailcap file %s, line %lu: incomplete entry ignored."),
+                         strFileName.c_str(), nLine + 1L);
 
             continue;
         }