diff options
author | Debian CLI Applications Team <pkg-cli-apps-team@lists.alioth.debian.org> | 2017-05-24 21:06:47 +0100 |
---|---|---|
committer | Andreas Moog <andreas.moog@warperbbs.de> | 2017-05-24 21:06:47 +0100 |
commit | 03613067bee93e875c915c4f4a43e19c59e6484c (patch) | |
tree | cca9bb4977eaf751cd93dd9fdbc295ce531ef3c0 | |
parent | 411fc5915410a4304482a041c8bd3e07662f68b9 (diff) |
better_xorg_parsing
Gbp-Pq: Name 10-better_xorg_parsing.diff
-rw-r--r-- | Sysinfo/SystemInfo.cs | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/Sysinfo/SystemInfo.cs b/Sysinfo/SystemInfo.cs index e4bfa5d..840c9d2 100644 --- a/Sysinfo/SystemInfo.cs +++ b/Sysinfo/SystemInfo.cs @@ -336,6 +336,7 @@ namespace Sysinfo { String temp; Boolean xorgB = false; + int index; try { @@ -345,17 +346,40 @@ namespace Sysinfo { while ( xorgB == false ) { temp = textread.ReadLine(); + + // EOF + if (temp == null) { + + break; + } + + // Blank line + if (temp.Trim().Length == 0) { + + continue; + } //version - if ( temp.StartsWith("X Window System Version")) { - - system_xorg = temp.Remove(0, 24); + index = temp.IndexOf("X Window System Version"); + + if (index >= 0 && system_xorg == "unknown") { + + system_xorg = temp.Substring(index + 24); + } + + index = temp.IndexOf("X.Org X Server"); + + if (index >= 0 && system_xorg == "unknown") { + + system_xorg = temp.Substring(index + 15); } //build date - if ( temp.StartsWith("Build Date")) { - - system_xorg = system_xorg + " (" + temp.Remove(0, 12) + ")"; + index = temp.IndexOf("Build Date"); + + if (index >= 0) { + + system_xorg = system_xorg + " (" + temp.Substring(index + 12) + ")"; xorgB = true; } |