Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ver_linux: Assign constant RE to variable name for clarity

The regular expression that matches the version number of a utility
being queried is used as a constant expression in the current
implementation. Assigning the RE in question to a variable gives it a
meaningful name that clearly expresses the intended use of the expression
without having to think about the details of implementation.

Signed-off-by: Alexander Kapshuk <alexander.kapshuk@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Alexander Kapshuk and committed by
Greg Kroah-Hartman
2ca46ed2 d7ac3c6e

+4 -2
+4 -2
scripts/ver_linux
··· 13 13 system("uname -a") 14 14 printf("\n") 15 15 16 + vernum = "[0-9]+([.]?[0-9]+)+" 17 + 16 18 printversion("GNU C", version("gcc -dumpversion")) 17 19 printversion("GNU Make", version("make --version")) 18 20 printversion("Binutils", version("ld -v")) ··· 36 34 while (getline <"/proc/self/maps" > 0) { 37 35 if (/libc.*\.so$/) { 38 36 n = split($0, procmaps, "/") 39 - if (match(procmaps[n], /[0-9]+([.]?[0-9]+)+/)) { 37 + if (match(procmaps[n], vernum)) { 40 38 ver = substr(procmaps[n], RSTART, RLENGTH) 41 39 printversion("Linux C Library", ver) 42 40 break ··· 72 70 function version(cmd, ver) { 73 71 cmd = cmd " 2>&1" 74 72 while (cmd | getline > 0) { 75 - if (match($0, /[0-9]+([.]?[0-9]+)+/)) { 73 + if (match($0, vernum)) { 76 74 ver = substr($0, RSTART, RLENGTH) 77 75 break 78 76 }