History

ver_linux: Eliminate duplicate code in ldconfig processing logic

The code that acquires the version strings for libc and libcpp is identical, as is the printversion call. The only difference being the name of the library being printed. Refactor the code by unifying the bits that are common to both libraries.

Alexander Kapshuk committed 5 years ago

Commit afe90171 parent d0259c41 file · +5 −7Browse files

Showing the changes to scripts (1 of 1 file). Show all

Unified · Split

scripts/ver_linux+5−7
@@ -15,7 +15,7 @@ BEGIN { · 14 unmodified lines
1515
1616 vernum = "[0-9]+([.]?[0-9]+)+"
1717 libc = "libc[.]so[.][0-9]+$"
18− libcpp = "(libg|stdc)[+]+[.]so[.][0-9]+$"
18+ libcpp = "(libg|stdc)[+]+[.]so([.][0-9]+)+$"
1919
2020 printversion("GNU C", version("gcc -dumpversion"))
2121 printversion("GNU Make", version("make --version"))
@@ -37,12 +37,10 @@ BEGIN { · 15 unmodified lines
3737 printversion("Bison", version("bison --version"))
3838 printversion("Flex", version("flex --version"))
3939
40− while ("ldconfig -p 2>/dev/null" | getline > 0) {
41− if ($NF ~ libc && !seen[ver = version("readlink " $NF)]++)
42− printversion("Linux C Library", ver)
43− else if ($NF ~ libcpp && !seen[ver = version("readlink " $NF)]++)
44− printversion("Linux C++ Library", ver)
45− }
40+ while ("ldconfig -p 2>/dev/null" | getline > 0)
41+ if ($NF ~ libc || $NF ~ libcpp)
42+ if (!seen[ver = version("readlink " $NF)]++)
43+ printversion("Linux C" ($NF ~ libcpp? "++" : "") " Library", ver)
4644
4745 printversion("Dynamic linker (ldd)", version("ldd --version"))
4846 printversion("Procps", version("ps --version"))