Browse Source

filename extension check should be case-insensitive

David Rose 14 years ago
parent
commit
5f42b92027
1 changed files with 9 additions and 2 deletions
  1. 9 2
      panda/src/pnmimage/pnmFileTypeRegistry.cxx

+ 9 - 2
panda/src/pnmimage/pnmFileTypeRegistry.cxx

@@ -164,8 +164,15 @@ get_type_from_extension(const string &filename) const {
   Extensions::const_iterator ei;
   Extensions::const_iterator ei;
   ei = _extensions.find(extension);
   ei = _extensions.find(extension);
   if (ei == _extensions.end() || (*ei).second.empty()) {
   if (ei == _extensions.end() || (*ei).second.empty()) {
-    // Nothing matches that string.
-    return NULL;
+    // Nothing matches that string.  Try again with a downcased string
+    // in case we got an all-uppercase filename (most of our
+    // extensions are downcased).
+    ei = _extensions.find(downcase(extension));
+
+    if (ei == _extensions.end() || (*ei).second.empty()) {
+      // Nothing matches that string.
+      return NULL;
+    }
   }
   }
 
 
   // Return the first file type associated with the given extension.
   // Return the first file type associated with the given extension.