Repository: GuillaumeGomez/sysinfo (language: rust)

Issue:
Spelling of macOS in `long_os_version`
On laptop, desktop, and server computers produced by Apple Inc., `System::long_os_version()` returns strings that are not historically accurate based on https://en.wikipedia.org/wiki/MacOS_version_history. The naming used by Apple for these operating systems was "Mac OS X", then "OS X", then "macOS".

<table>
<tr><td>"MacOS 10.0 Cheetah"</td><td rowspan="8"><b>Mac OS X</b><br><br><br><br><br><br><br><br><br><br><br><br></td></tr>
<tr><td>"MacOS 10.1 Puma"</td></tr>
<tr><td>"MacOS 10.2 Jaguar"</td></tr>
<tr><td>"MacOS 10.3 Panther"</td></tr>
<tr><td>"MacOS 10.4 Tiger"</td></tr>
<tr><td>"MacOS 10.5 Leopard"</td></tr>
<tr><td>"MacOS 10.6 Snow Leopard"</td></tr>
<tr><td>"MacOS 10.7 Lion"</td></tr>
<tr><td>"MacOS 10.8 Mountain Lion"</td><td rowspan="4"><b>OS X</b><br><br><br><br><br></td></tr>
<tr><td>"MacOS 10.9 Mavericks"</td></tr>
<tr><td>"MacOS 10.10 Yosemite"</td></tr>
<tr><td>"MacOS 10.11 El Capitan"</td></tr>
<tr><td>"MacOS 10.12 Sierra"</td><td rowspan="9"><b>macOS</b><br><br><br><br><br><br><br><br><br><br><br><br><br></td></tr>
<tr><td>"MacOS 10.13 High Sierra"</td></tr>
<tr><td>"MacOS 10.14 Mojave"</td></tr>
<tr><td>"MacOS 10.15 Catalina"</td></tr>
<tr><td>"MacOS 11.0 Big Sur"</td></tr>
<tr><td>"MacOS 12.0 Monterey"</td></tr>
<tr><td>"MacOS 13.0 Ventura"</td></tr>
<tr><td>"MacOS 14.0 Sonoma"</td></tr>
<tr><td>"MacOS 15.0 Sequoia"</td></tr>
</table>

I would expect `sysinfo` to render these names in a way that is consistent with Apple's name for each of these operating systems: "macOS 15.0 Sequoia", "OS X 10.11 El Capitan", "Mac OS X 10.7 Lion"


Discussion / hints:
Makes sense. Currently in the middle of moving to a new place so I'll take a look  at it likely next week if no did until then.

Fix patch:
diff --git a/src/common/system.rs b/src/common/system.rs
index 7c1907dad..4be9a95ff 100644
--- a/src/common/system.rs
+++ b/src/common/system.rs
@@ -726,7 +726,7 @@ impl System {
         SystemInner::kernel_version()
     }
 
-    /// Returns the system version (e.g. for MacOS this will return 15.1 rather than the kernel
+    /// Returns the system version (e.g. for macOS this will return 15.1 rather than the kernel
     /// version).
     ///
     /// | example platform | value of `System::os_version()` |
@@ -753,7 +753,7 @@ impl System {
     /// |---|---|
     /// | linux laptop | "Linux 24.04 Ubuntu" |
     /// | android phone | "Android 15 Pixel 9 Pro" |
-    /// | apple laptop | "MacOS 15.1.1 Sequoia" |
+    /// | apple laptop | "macOS 15.1.1 Sequoia" |
     /// | windows server | "Windows Server 2022 Datacenter" |
     ///
     /// **Important**: this information is computed every time this function is called.
@@ -1338,7 +1338,7 @@ impl Process {
     ///
     /// This value has limitations though. Depending on the operating system and type of process,
     /// this value might be a good indicator of the total memory that the process will be using over
-    /// its lifetime. However, for example, in the version 14 of MacOS this value is in the order of
+    /// its lifetime. However, for example, in the version 14 of macOS this value is in the order of
     /// the hundreds of gigabytes for every process, and thus not very informative. Moreover, if a
     /// process maps into memory a very large file, this value will increase accordingly, even if
     /// the process is not actively using the memory.
diff --git a/src/unix/apple/macos/ffi.rs b/src/unix/apple/macos/ffi.rs
index 662f7cf06..0bc21c83d 100644
--- a/src/unix/apple/macos/ffi.rs
+++ b/src/unix/apple/macos/ffi.rs
@@ -36,7 +36,7 @@ use libc::c_char;
 ))]
 use libc::kern_return_t;
 
-// Note: IOKit is only available on MacOS up until very recent iOS versions: https://developer.apple.com/documentation/iokit
+// Note: IOKit is only available on macOS up until very recent iOS versions: https://developer.apple.com/documentation/iokit
 
 #[cfg(any(
     feature = "system",
diff --git a/src/unix/apple/system.rs b/src/unix/apple/system.rs
index c4ca7549b..11b28f7cb 100644
--- a/src/unix/apple/system.rs
+++ b/src/unix/apple/system.rs
@@ -396,39 +396,41 @@ impl SystemInner {
     pub(crate) fn long_os_version() -> Option<String> {
         #[cfg(target_os = "macos")]
         {
-            let mut long_name = "MacOS".to_owned();
-            if let Some(os_version) = Self::os_version() {
-                long_name.push(' ');
-                long_name.push_str(&os_version);
-                if let Some(friendly_name) = match os_version.as_str() {
-                    f_n if f_n.starts_with("15") => Some("Sequoia"),
-                    f_n if f_n.starts_with("14") => Some("Sonoma"),
-                    f_n if f_n.starts_with("13") => Some("Ventura"),
-                    f_n if f_n.starts_with("12") => Some("Monterey"),
-                    f_n if f_n.starts_with("11") | f_n.starts_with("10.16") => Some("Big Sur"),
-                    f_n if f_n.starts_with("10.15") => Some("Catalina"),
-                    f_n if f_n.starts_with("10.14") => Some("Mojave"),
-                    f_n if f_n.starts_with("10.13") => Some("High Sierra"),
-                    f_n if f_n.starts_with("10.12") => Some("Sierra"),
-                    f_n if f_n.starts_with("10.11") => Some("El Capitan"),
-                    f_n if f_n.starts_with("10.10") => Some("Yosemite"),
-                    f_n if f_n.starts_with("10.9") => Some("Mavericks"),
-                    f_n if f_n.starts_with("10.8") => Some("Mountain Lion"),
-                    f_n if f_n.starts_with("10.7") => Some("Lion"),
-                    f_n if f_n.starts_with("10.6") => Some("Snow Leopard"),
-                    f_n if f_n.starts_with("10.5") => Some("Leopard"),
-                    f_n if f_n.starts_with("10.4") => Some("Tiger"),
-                    f_n if f_n.starts_with("10.3") => Some("Panther"),
-                    f_n if f_n.starts_with("10.2") => Some("Jaguar"),
-                    f_n if f_n.starts_with("10.1") => Some("Puma"),
-                    f_n if f_n.starts_with("10.0") => Some("Cheetah"),
-                    _ => None,
-                } {
-                    long_name.push(' ');
-                    long_name.push_str(friendly_name);
+            let Some(os_version) = Self::os_version() else {
+                return Some("macOS".to_owned());
+            };
+            // https://en.wikipedia.org/wiki/MacOS_version_history
+            for (version_prefix, macos_spelling, friendly_name) in [
+                ("15", "macOS", "Sequoia"),
+                ("14", "macOS", "Sonoma"),
+                ("13", "macOS", "Ventura"),
+                ("12", "macOS", "Monterey"),
+                ("11", "macOS", "Big Sur"),
+                // Big Sur identifies itself as 10.16 in some situations.
+                // https://en.wikipedia.org/wiki/MacOS_Big_Sur#Development_history
+                ("10.16", "macOS", "Big Sur"),
+                ("10.15", "macOS", "Catalina"),
+                ("10.14", "macOS", "Mojave"),
+                ("10.13", "macOS", "High Sierra"),
+                ("10.12", "macOS", "Sierra"),
+                ("10.11", "OS X", "El Capitan"),
+                ("10.10", "OS X", "Yosemite"),
+                ("10.9", "OS X", "Mavericks"),
+                ("10.8", "OS X", "Mountain Lion"),
+                ("10.7", "Mac OS X", "Lion"),
+                ("10.6", "Mac OS X", "Snow Leopard"),
+                ("10.5", "Mac OS X", "Leopard"),
+                ("10.4", "Mac OS X", "Tiger"),
+                ("10.3", "Mac OS X", "Panther"),
+                ("10.2", "Mac OS X", "Jaguar"),
+                ("10.1", "Mac OS X", "Puma"),
+                ("10.0", "Mac OS X", "Cheetah"),
+            ] {
+                if os_version.starts_with(version_prefix) {
+                    return Some(format!("{macos_spelling} {os_version} {friendly_name}"));
                 }
             }
-            Some(long_name)
+            Some(format!("macOS {os_version}"))
         }
 
         #[cfg(target_os = "ios")]


Test patch: