From 4536dd81ff91b1e9fcaa1dcc5a5e0c7d6770a5ad Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Wed, 12 Jan 2005 03:37:26 +0000 Subject: [PATCH] Fixed standard 'backward iteration with unsigned var' bug. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10682 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/storage/mime/AssociatedTypes.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/kits/storage/mime/AssociatedTypes.cpp b/src/kits/storage/mime/AssociatedTypes.cpp index 4429e1b757..54f92354a9 100644 --- a/src/kits/storage/mime/AssociatedTypes.cpp +++ b/src/kits/storage/mime/AssociatedTypes.cpp @@ -102,15 +102,13 @@ AssociatedTypes::GuessMimeType(const char *filename, BString *result) err = BuildAssociatedTypesTable(); if (!err) { // Extract the extension from the file - uint i = strlen(filename); - while (i-1 >= 0 && filename[i-1] != '.') - i--; + const char *rawExtension = strrchr(filename, '.'); // If there was an extension, grab it and look up its associated // type(s). Otherwise, the best guess we can offer is // "application/octect-stream" - if (i > 0) { - std::string extension = PrepExtension(&(filename[i])); + if (rawExtension && rawExtension[1] != '\0') { + std::string extension = PrepExtension(rawExtension + 1); /*! \todo I'm just grabbing the first item in the set here. Should we perhaps do something different?