1#!/usr/bin/tclsh 2 3# Copyright JS Foundation and other contributors, http://js.foundation 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17proc check_part_of_the_file {file line_num col_start col_end} { 18 if {$col_start == $col_end} { 19 return 20 } 21 22 set line [getLine $file $line_num] 23 set line [string range $line $col_start $col_end] 24 25 if {[regexp {\w\*\s\w+} $line] 26 || [regexp {\w\*\)} $line] 27 || [regexp {\w\*$} $line]} { 28 report $file $line_num "there should be a space between the referenced type and the pointer declarator." 29 } 30} 31 32foreach fileName [getSourceFileNames] { 33 set checkLine 1 34 set checkColStart 0 35 set seenOmitToken false 36 foreach token [getTokens $fileName 1 0 -1 -1 {}] { 37 set lineNumber [lindex $token 1] 38 set colNumber [lindex $token 2] 39 set tokenType [lindex $token 3] 40 41 if {$checkLine != $lineNumber} { 42 if {!$seenOmitToken} { 43 check_part_of_the_file $fileName $checkLine $checkColStart end 44 } 45 set checkColStart $colNumber 46 set checkLine $lineNumber 47 } elseif {$seenOmitToken} { 48 set checkColStart $colNumber 49 } 50 51 if {$tokenType in {ccomment cppcomment stringlit}} { 52 check_part_of_the_file $fileName $checkLine $checkColStart $colNumber 53 set seenOmitToken true 54 } else { 55 set seenOmitToken false 56 } 57 } 58} 59