<commit_before>#!/usr/bin/tclsh
# Checks if there is pragma once and there is no ifdef

proc checkGuards { fileName } {
  if {![regexp -nocase {.*.h$} $fileName] } { return }
  set lineCount 1 
  set guardFound 0
  foreach line [getAllLines $fileName] {
    if {[regexp {^[\t ]*#pragma once[\t\r\n ]*} $line] } {
      set guardFound 1 
    }
    if {[regexp {^[\t ]*#ifn?def .*} $line] } {
      set nextLine [getLine $fileName [expr $lineCount + 1]]
      if {[regexp {^[\t ]*#define .*} $nextLine]} {
	set guardFound 1
	report $fileName $lineCount "Old-style include guard"
      }
    }
    incr lineCount
  }
  if {![expr $guardFound]} {
    puts "$fileName: No include guard in header file"
  }
}

foreach fileName [getSourceFileNames] {
  checkGuards $fileName
}<commit_msg>moved all vera++ messages to stderr<commit_after>#!/usr/bin/tclsh
# Checks if there is pragma once and there is no ifdef

proc checkGuards { fileName } {
  if {![regexp -nocase {.*.h$} $fileName] } { return }
  set lineCount 1 
  set guardFound 0
  foreach line [getAllLines $fileName] {
    if {[regexp {^[\t ]*#pragma once[\t\r\n ]*} $line] } {
      set guardFound 1 
    }
    if {[regexp {^[\t ]*#ifn?def .*} $line] } {
      set nextLine [getLine $fileName [expr $lineCount + 1]]
      if {[regexp {^[\t ]*#define .*} $nextLine]} {
	set guardFound 1
	report $fileName $lineCount "Old-style include guard"
      }
    }
    incr lineCount
  }
  if {![expr $guardFound]} {
    report "$fileName: No include guard in header file"
  }
}

foreach fileName [getSourceFileNames] {
  checkGuards $fileName
}
{'fraction_non_alphanumeric': 0.15006305170239598, 'fraction_numerical': 0.006305170239596469, 'mean_word_length': 3.027918781725888, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2878981', 'n_tokens_mistral': 580, 'n_tokens_neox': 581, 'n_words': 173}