]> code.delx.au - refind/commitdiff
Support Arch Linux kernel naming by treating "linux" and "linux-lts" as digits
authorJames Bunton <jamesbunton@delx.net.au>
Mon, 13 Mar 2017 09:48:00 +0000 (20:48 +1100)
committerJames Bunton <jamesbunton@delx.net.au>
Mon, 13 Mar 2017 09:48:00 +0000 (20:48 +1100)
refind/mystrings.c

index 645511cb0fb03f617986aa9dcaef4fafe7e522f8..539aba20bd0fac540949f319ff41725379192524 100644 (file)
@@ -238,14 +238,29 @@ BOOLEAN LimitStringLength(CHAR16 *TheString, UINTN Limit) {
 // non-digit characters. For instance, if InString is "foo-3.3.4-7.img",
 // this function returns "3.3.4-7". If InString contains no digits,
 // the return value is NULL.
+// As a special case for Arch Linux the strings "linux" and "linux-lts"
+// are considered to be digits.
 CHAR16 *FindNumbers(IN CHAR16 *InString) {
-    UINTN i, StartOfElement, EndOfElement = 0, CopyLength;
+    UINTN i, StartOfElement = 0, EndOfElement = 0, CopyLength;
     CHAR16 *Found = NULL;
 
     if (InString == NULL)
         return NULL;
 
-    StartOfElement = StrLen(InString);
+    // Find "linux-lts" or "linux"
+    Found = MyStrStr(InString, L"linux-lts");
+    if (Found != NULL) {
+        StartOfElement = Found - InString;
+        EndOfElement = StartOfElement + StrLen(L"linux-lts") - 1;
+    } else {
+        Found = MyStrStr(InString, L"linux");
+        if (Found != NULL) {
+            StartOfElement = Found - InString;
+            EndOfElement = StartOfElement + StrLen(L"linux") - 1;
+        } // if
+    } // if/else
+    Found = NULL;
+
     // Find start & end of target element
     for (i = 0; InString[i] != L'\0'; i++) {
         if ((InString[i] >= L'0') && (InString[i] <= L'9')) {
@@ -255,6 +270,7 @@ CHAR16 *FindNumbers(IN CHAR16 *InString) {
                 EndOfElement = i;
         } // if
     } // for
+
     // Extract the target element
     if (EndOfElement > 0) {
         if (EndOfElement >= StartOfElement) {