3 ## Copyright (C) 1996-2015 The Squid Software Foundation and contributors
5 ## Squid software is distributed under GPLv2+ license and includes
6 ## contributions from numerous individuals and organizations.
7 ## Please see the COPYING and CONTRIBUTORS files for details.
10 # Author: Tsantilas Christos
11 # (C) 2010 The Measurement Factory
14 # calc-must-ids.pl file1 file2 ...
15 # Compute the ids of Must expressions of the given files.
16 # It returns one line per Must expression in the form:
17 # filename: line: MustID 'Must Text'
23 # This constant should be synced with ERR_DETAIL_EXCEPTION_START enum
24 # defined in src/err_detail_type.h
25 use constant ERR_DETAIL_EXCEPTION_START
=> 110000;
28 while ($file = shift @ARGV) {
29 ComputeMustIds
($file);
33 # Please keep in sync this function with the FileNameHash function in
34 # src/base/TextException.cc file
40 my(@na) = split(//, $name);
41 for($j=0; $j < @na; $j++) {
42 $n = $n ^ (271 * ord($na[$j]));
46 # Currently 18bits of a 32 bit integer used for filename hash
47 # (max hash=262143), and 14 bits for storing line number
55 my($hash) = FileNameHash
($file);
56 if(!open(IN
, "<$file")) {
57 printf STDERR
"error opening file $file. Ignore ...";
63 if ( $line =~ /^\s*Must\s*\(/ || $line =~ /^\s*throw\s*TexcHere\s*\(/){
65 $id= ($hash <<14) | ($. & 0x3FFF);
66 $id += ERR_DETAIL_EXCEPTION_START
;
67 # print "$file:$.: $id $line";
68 printf "%s:%d: 0x%X %s", $file, $., $id, $line;