Return to version-check.pl CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / curl / docs / examples |
1.1 ! misho 1: #!/usr/bin/env perl ! 2: #*************************************************************************** ! 3: # _ _ ____ _ ! 4: # Project ___| | | | _ \| | ! 5: # / __| | | | |_) | | ! 6: # | (__| |_| | _ <| |___ ! 7: # \___|\___/|_| \_\_____| ! 8: # ! 9: # Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al. ! 10: # ! 11: # This software is licensed as described in the file COPYING, which ! 12: # you should have received as part of this distribution. The terms ! 13: # are also available at https://curl.haxx.se/docs/copyright.html. ! 14: # ! 15: # You may opt to use, copy, modify, merge, publish, distribute and/or sell ! 16: # copies of the Software, and permit persons to whom the Software is ! 17: # furnished to do so, under the terms of the COPYING file. ! 18: # ! 19: # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY ! 20: # KIND, either express or implied. ! 21: # ! 22: ########################################################################### ! 23: ! 24: # This script accepts a source file as input on the command line. ! 25: # ! 26: # It first loads the 'symbols-in-versions' document and stores a lookup ! 27: # table for all known symbols for which version they were introduced. ! 28: # ! 29: # It then scans the given source file to dig up all symbols starting with CURL. ! 30: # Finally, it sorts the internal list of found symbols (using the version ! 31: # number as sort key) and then it outputs the most recent version number and ! 32: # the symbols from that version that are used. ! 33: # ! 34: # Usage: ! 35: # ! 36: # version-check.pl [source file] ! 37: # ! 38: ! 39: open(S, "<../libcurl/symbols-in-versions") || die; ! 40: ! 41: my %doc; ! 42: my %rem; ! 43: while(<S>) { ! 44: if(/(^CURL[^ \n]*) *(.*)/) { ! 45: my ($sym, $rest)=($1, $2); ! 46: my @a=split(/ +/, $rest); ! 47: ! 48: $doc{$sym}=$a[0]; # when it was introduced ! 49: ! 50: if($a[2]) { ! 51: # this symbol is documented to have been present the last time ! 52: # in this release ! 53: $rem{$sym}=$a[2]; ! 54: } ! 55: } ! 56: ! 57: } ! 58: ! 59: close(S); ! 60: ! 61: sub age { ! 62: my ($ver)=@_; ! 63: ! 64: my @s=split(/\./, $ver); ! 65: return $s[0]*10000+$s[1]*100+$s[2]; ! 66: } ! 67: ! 68: my %used; ! 69: open(C, "<$ARGV[0]") || die; ! 70: ! 71: while(<C>) { ! 72: if(/\W(CURL[_A-Z0-9v]+)\W/) { ! 73: #print "$1\n"; ! 74: $used{$1}++; ! 75: } ! 76: } ! 77: ! 78: close(C); ! 79: ! 80: sub sortversions { ! 81: my $r = age($doc{$a}) <=> age($doc{$b}); ! 82: if(!$r) { ! 83: $r = $a cmp $b; ! 84: } ! 85: return $r; ! 86: } ! 87: ! 88: my @recent = reverse sort sortversions keys %used; ! 89: ! 90: # the most recent symbol ! 91: my $newsym = $recent[0]; ! 92: # the most recent version ! 93: my $newver = $doc{$newsym}; ! 94: ! 95: print "The scanned source uses these symbols introduced in $newver:\n"; ! 96: ! 97: for my $w (@recent) { ! 98: if($doc{$w} eq $newver) { ! 99: printf " $w\n"; ! 100: next; ! 101: } ! 102: last; ! 103: }