#!/usr/bin/gawk -f BEGIN { ntags = 0; # each of these patterns, followed by digits, is matched in # order in the input string. The "" ones match the traditional # digits, so linux-2.6.3 gives a "2" to the first pattern below # # a field is produced from each tag in the list in the order # given, initialized to the numbers below. this field is sortable # by sort(1) such that the order represents the logical intent # of kernel numbering schemes. tagcompare[ntags] = 0; taglist[ntags++] = ""; tagcompare[ntags] = 0; taglist[ntags++] = ""; tagcompare[ntags] = 0; taglist[ntags++] = ""; tagcompare[ntags] = 0; taglist[ntags++] = ""; tagcompare[ntags] = 999; taglist[ntags++] = "test"; tagcompare[ntags] = 999; taglist[ntags++] = "pre"; tagcompare[ntags] = 999; taglist[ntags++] = "rc"; tagcompare[ntags] = 999; taglist[ntags++] = "bk"; wildtag = ntags; tagcompare[ntags] = 0; taglist[ntags++] = "[a-z]+"; } { s = $1 # skip ahead to first digit s = substr(s, match(s, "[0-9]")); nf = split(s, fields, "[^a-zA-Z0-9]"); sortable = ""; dotted = ""; undotted = ""; #print nf, s, $0 #for (i = 1; i <= nf; i++) { #print i ": " fields[i] #} for (i = 0; i < ntags; i++) { tag = taglist[i]; n = tagcompare[i]; # print "processing tag '" tag "'" pattern = "^(" tag ")([0-9]+)"; for (k = 1; k <= nf; k++) { if ((j = match(tolower(fields[k]), pattern, matches)) == 1) { tag = matches[1]; digits = matches[2]; fields[k] = "" n = digits; # print "..... digits for", tag, digits, "substr now", s; if (dotted != "") { if (tag == "") dotted = dotted "." else dotted = dotted "-" } dotted = dotted tag digits; if (undotted != "") undotted = undotted "_" undotted = undotted toupper(tag) digits; break } } if (i == wildtag && tag == taglist[wildtag]) tag = "00"; if (sortable != "") sortable = sortable "." sortable = sortable tag sprintf("%03d", n); } # k = 0; # for (i = 1; i <= nf; i++) { # if (fields[i] != "") k++; # } # if (k == 0) { print sortable "\t" $1 "\t" dotted "\tCVS" undotted # } }