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 17foreach fileName [getSourceFileNames] { 18 set funcStart 0 19 set funcName "" 20 set lineNumber 1 21 foreach line [getAllLines $fileName] { 22 if {[regexp {^((static |const )*\w+ )*\w+ \(.*[,\)]} $line]} { 23 set type {} 24 set modifier {} 25 if {$funcStart == 0} { 26 regexp {^((static |const )*\w+ )*(\w+) \(} $line matched type modifier funcName 27 } 28 } 29 30 if {[regexp {^\{$} $line]} { 31 set funcStart 1 32 } 33 34 if {$funcStart == 1} { 35 if {[regexp {^\}$} $line] && [string length $funcName] != 0} { 36 report $fileName $lineNumber "missing comment at the end of function: /* $funcName */" 37 set funcStart 0 38 } elseif {[regexp {^\} /\*\s*\w+\s*\*/$} $line] && [string length $funcName] != 0} { 39 set comment {} 40 regexp {^\} /\*\s*(\w+)\s*\*/$} $line -> comment 41 if {$comment != $funcName} { 42 report $fileName $lineNumber "comment missmatch. (Current: $comment, Expected: $funcName) " 43 } 44 set funcStart 0 45 } elseif {[regexp {^\}.*;?$} $line]} { 46 set funcStart 0 47 } 48 } 49 50 incr lineNumber 51 } 52} 53