firstversions.awk 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. # Script to preprocess Versions.all lists based on "earliest version"
  2. # specifications in the shlib-versions file.
  3. # Return -1, 0 or 1 according to whether v1 is less than, equal to or
  4. # greater than v2 as a version string. Simplified from GNU Autoconf
  5. # version; this one does not need to handle .0x fraction-style versions.
  6. function vers_compare (v1, v2)
  7. {
  8. while (length(v1) && length(v2)) {
  9. if (v1 ~ /^[0-9]/ && v2 ~ /^[0-9]/) {
  10. for (len1 = 1; substr(v1, len1 + 1) ~ /^[0-9]/; len1++) continue;
  11. for (len2 = 1; substr(v2, len2 + 1) ~ /^[0-9]/; len2++) continue;
  12. d1 = substr(v1, 1, len1); v1 = substr(v1, len1 + 1);
  13. d2 = substr(v2, 1, len2); v2 = substr(v2, len2 + 1);
  14. d1 += 0;
  15. d2 += 0;
  16. } else {
  17. d1 = substr(v1, 1, 1); v1 = substr(v1, 2);
  18. d2 = substr(v2, 1, 1); v2 = substr(v2, 2);
  19. }
  20. if (d1 < d2) return -1;
  21. if (d1 > d2) return 1;
  22. }
  23. if (length(v2)) return -1;
  24. if (length(v1)) return 1;
  25. return 0;
  26. }
  27. NF > 2 && $2 == ":" {
  28. for (i = 0; i <= NF - 3; ++i)
  29. firstversion[$1, i] = $(3 + i);
  30. idx[$1] = 0;
  31. next;
  32. }
  33. NF == 2 && $2 == "{" { thislib = $1; print; next }
  34. $1 == "}" {
  35. if ((thislib, idx[thislib]) in firstversion) {
  36. # We haven't seen the stated version, but have produced
  37. # others pointing to it, so we synthesize it now.
  38. printf " %s\n", firstversion[thislib, idx[thislib]];
  39. idx[thislib]++;
  40. }
  41. print;
  42. next;
  43. }
  44. /GLIBC_PRIVATE/ { print; next }
  45. {
  46. if ((thislib, idx[thislib]) in firstversion) {
  47. f = v = firstversion[thislib, idx[thislib]];
  48. while (vers_compare($1, v) >= 0) {
  49. delete firstversion[thislib, idx[thislib]];
  50. idx[thislib]++;
  51. if ((thislib, idx[thislib]) in firstversion) {
  52. # If we're skipping a referenced version to jump ahead to a
  53. # later version, synthesize the earlier referenced version now.
  54. if (v != $1 && (thislib, v) in usedversion)
  55. print " " v;
  56. v = firstversion[thislib, idx[thislib]];
  57. } else
  58. break;
  59. }
  60. if ($1 == v || $1 == f)
  61. # This version was the specified earliest version itself.
  62. print;
  63. else if (vers_compare($1, v) < 0) {
  64. # This version is older than the specified earliest version.
  65. print " " $1, "=", v;
  66. # Record that V has been referred to, so we will be sure to emit it
  67. # if we hit a later one without hitting V itself.
  68. usedversion[thislib, v] = 1;
  69. }
  70. else {
  71. # This version is newer than the specified earliest version.
  72. # We haven't seen that version itself or else we wouldn't be here
  73. # because we would have removed it from the firstversion array.
  74. # If there were any earlier versions that used that one, emit it now.
  75. if ((thislib, v) in usedversion) {
  76. print " " v;
  77. }
  78. print " " $1;
  79. }
  80. }
  81. else
  82. print;
  83. }