Blob Blame History Raw
From 273d6c3a7f76e2c1c3f5634a1c1274323b12745c Mon Sep 17 00:00:00 2001
From: Josh Stone <jistone@redhat.com>
Date: Tue, 7 Oct 2014 12:38:39 -0700
Subject: [PATCH] RHBZ1150166: Handle the filename of compressed modules

This allows filenames like ".ko.xz" in modname_from_path().
---
 setupdwfl.cxx | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/setupdwfl.cxx b/setupdwfl.cxx
index fe44828f8bf1..33239fe67cb9 100644
--- a/setupdwfl.cxx
+++ b/setupdwfl.cxx
@@ -114,11 +114,20 @@ static const string abrt_path =
 string
 modname_from_path(const string &path)
 {
-  size_t dot = path.rfind('.');
   size_t slash = path.rfind('/');
-  if (dot == string::npos || slash == string::npos || dot < slash)
+  if (slash == string::npos)
     return "";
-  string name = path.substr(slash + 1, dot - slash - 1);
+  string name = path.substr(slash + 1);
+
+  // First look for .ko extension variants like ".ko" or ".ko.xz"
+  // If that fails, look for any ".*" extension at all.
+  size_t extension = name.rfind(".ko");
+  if (extension == string::npos)
+    extension = name.rfind('.');
+  if (extension == string::npos)
+    return "";
+
+  name.erase(extension);
   replace_if(name.begin(), name.end(), is_comma_dash, '_');
   return name;
 }
-- 
1.9.3