Wrap up querying for version of 'Linux C Library', and the resulting
formatted output in an awk function.

Signed-off-by: Alexander Kapshuk <alexander.kaps...@gmail.com>
---
 scripts/ver_linux | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/scripts/ver_linux b/scripts/ver_linux
index bb51c5d..d3faf4a 100755
--- a/scripts/ver_linux
+++ b/scripts/ver_linux
@@ -30,12 +30,16 @@ BEGIN {
        printversion("Isdn4k-utils", version("isdnctrl 2>&1"))
        printversion("Nfs-utils", version("showmount --version 2>&1"))
 
-test -r /proc/self/maps &&
-sed '
-       /.*libc-\(.*\)\.so$/!d
-       s//Linux C Library\t\t\1/
-       q
-' /proc/self/maps
+       if (system("test -r /proc/self/maps") == 0) {
+               while (getline <"/proc/self/maps" > 0) {
+                       n = split($0, procmaps, "/")
+                       if (/libc.*so$/ && match(procmaps[n], 
/[0-9]+([.]?[0-9]+)+/)) {
+                               ver = substr(procmaps[n], RSTART, RLENGTH)
+                               printversion("Linux C Library", ver)
+                               break
+                       }
+               }
+       }
 
 ldd --version 2>&1 |
 awk '/^ldd/{
-- 
2.7.3

Reply via email to