3 ## Copyright (C) 1996-2021 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);
35 # Keep in sync with FileNameHash() in src/base/Here.cc!
41 my(@na) = split(//, $name);
42 for($j=0; $j < @na; $j++) {
43 $n = $n ^ (271 * ord($na[$j]));
45 return $n ^ ($j *271);
52 # Keep in sync with SourceLocation::id() in src/base/Here.cc!
54 my $fullHash = &FileNameHash
($file);
55 my $hash = $fullHash % 0x3FFFF;
57 if(!open(IN
, "<$file")) {
58 printf STDERR
"error opening file $file. Ignore ...";
64 next if $line =~ /^\s*#/; # ignore simple single-line C++ macros
65 $line =~ s@
//.*@@
; # strip simple // comments
66 $line =~ s@
/[*].*?[*]/@@
; # strip simple single-line /* comments */
69 if ($line =~ /\bMust\s*\(/ || # Must(...)
70 $line =~ /\bTexcHere\s*\(/ || # TexcHere(...)
71 $line =~ /\bHere\s*\(\s*\)/) { # Here()
73 $id= ($hash <<14) | ($. & 0x3FFF);
74 $id += ERR_DETAIL_EXCEPTION_START
;
75 # print "$file:$.: $id $line";
76 printf "%s:%d: 0x%X %s", $file, $., $id, $line;