diff --git a/includes/theme.inc b/includes/theme.inc
index 806e5ee..93aacc9 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -1082,7 +1082,13 @@ function drupal_find_theme_templates($cache, $extension, $path) {
       $matches = preg_grep('/^' . $pattern . '/', $patterns);
       if ($matches) {
         foreach ($matches as $match) {
-          $file = substr($match, 0, strpos($match, '.'));
+          if (($pos = strpos($match, '.')) !== FALSE) {
+            $file = substr($match, 0, $pos);
+          }
+          else {
+            $file = $match;
+          }
+
           // Put the underscores back in for the hook name and register this pattern.
           $arg_name = isset($info['variables']) ? 'variables' : 'render element';
           $implementations[strtr($file, '-', '_')] = array(

