my $codespellfile = "/usr/share/codespell/dictionary.txt";
my $user_codespellfile = "";
my $conststructsfile = "$D/const_structs.checkpatch";
+if (!$OpenOCD) {
my $docsfile = "$D/../Documentation/dev-tools/checkpatch.rst";
+} # !$OpenOCD
+# OpenOCD Specific: Begin
+my $docsfile = "$D/../../doc/checkpatch.rst";
+# OpenOCD Specific: End
my $typedefsfile;
my $color = "auto";
my $allow_c99_comments = 1; # Can be overridden by --ignore C99_COMMENT_TOLERANCE
return 0;
}
+# OpenOCD specific: Begin: Load list of allowed CamelCase symbols
+if (show_type("CAMELCASE")) {
+ my $allowed_camelcase_file = "$root/tools/scripts/camelcase.txt";
+ if (open(my $words, '<', $allowed_camelcase_file)) {
+ while (<$words>) {
+ my $line = $_;
+
+ $line =~ s/\s*\n?$//g;
+ $line =~ s/^\s*//g;
+
+ next if ($line =~ m/^\s*#/);
+ next if ($line =~ m/^\s*$/);
+ if ($line =~ /\s/) {
+ print("$allowed_camelcase_file: '$line' invalid - ignored\n");
+ next;
+ }
+
+ $camelcase{$line} = 1;
+ }
+ close($allowed_camelcase_file);
+ } else {
+ warn "No camelcase symbols to ignore - file '$allowed_camelcase_file': $!\n";
+ }
+}
+# OpenOCD specific: End
+
my $const_structs;
if (show_type("CONST_STRUCT")) {
read_words(\$const_structs, $conststructsfile)
my @lines = split('\n', $text);
foreach my $line (@lines) {
+ if (!$OpenOCD) {
next if ($line !~ /(?:[A-Z][a-z]|[a-z][A-Z])/);
if ($line =~ /^[ \t]*(?:#[ \t]*define|typedef\s+$Type)\s+(\w*(?:[A-Z][a-z]|[a-z][A-Z])\w*)/) {
$camelcase{$1} = 1;
} elsif ($line =~ /^\s*(?:union|struct|enum)\s+(\w*(?:[A-Z][a-z]|[a-z][A-Z])\w*)\s*[;\{]/) {
$camelcase{$1} = 1;
}
+ } # !$OpenOCD
+ # OpenOCD Specific: Begin: extend to camel[0-9_]*CASE
+ next if ($line !~ /(?:[A-Z][0-9_]*[a-z]|[a-z][0-9_]*[A-Z])/);
+ if ($line =~ /^[ \t]*(?:#[ \t]*define|typedef\s+$Type)\s+(\w*(?:[A-Z][0-9_]*[a-z]|[a-z][0-9_]*[A-Z])\w*)/) {
+ $camelcase{$1} = 1;
+ } elsif ($line =~ /^\s*$Declare\s+(\w*(?:[A-Z][0-9_]*[a-z]|[a-z][0-9_]*[A-Z])\w*)\s*[\(\[,;]/) {
+ $camelcase{$1} = 1;
+ } elsif ($line =~ /^\s*(?:union|struct|enum)\s+(\w*(?:[A-Z][0-9_]*[a-z]|[a-z][0-9_]*[A-Z])\w*)\s*[;\{]/) {
+ $camelcase{$1} = 1;
+ }
+ # OpenOCD Specific: End
}
}
my $var = $1;
#CamelCase
+ if (!$OpenOCD) {
if ($var !~ /^$Constant$/ &&
$var =~ /[A-Z][a-z]|[a-z][A-Z]/ &&
#Ignore some autogenerated defines and enum values
$var !~ /^(?:[a-z0-9_]*|[A-Z0-9_]*)?_?[a-z][A-Z](?:_[a-z0-9_]+|_[A-Z0-9_]+)?$/ &&
#Ignore some three character SI units explicitly, like MiB and KHz
$var !~ /^(?:[a-z_]*?)_?(?:[KMGT]iB|[KMGT]?Hz)(?:_[a-z_]+)?$/) {
+ }
+ } # !$OpenOCD
+ # OpenOCD Specific: Begin: remove Linux exceptions, extend to camel[0-9_]*CASE
+ if ($var !~ /^$Constant$/ &&
+ $var =~ /[A-Z][0-9_]*[a-z]|[a-z][0-9_]*[A-Z]/) {
+ # OpenOCD Specific: End
while ($var =~ m{\b($Ident)}g) {
my $word = $1;
+ if (!$OpenOCD) {
next if ($word !~ /[A-Z][a-z]|[a-z][A-Z]/);
+ } # !$OpenOCD
+ # OpenOCD Specific: Begin: extend to camel[0-9_]*CASE
+ next if ($word !~ /[A-Z][0-9_]*[a-z]|[a-z][0-9_]*[A-Z]/);
+ # OpenOCD Specific: End
+ if (!$OpenOCD) {
+ # This will not work for OpenOCD jenkins because it runs
+ # checkpatch from a tree already patched. Any new camelcase
+ # in include file will be ignored as it was pre-existing.
if ($check) {
seed_camelcase_includes();
if (!$file && !$camelcase_file_seeded) {
$camelcase_file_seeded = 1;
}
}
+ } # !$OpenOCD
if (!defined $camelcase{$word}) {
$camelcase{$word} = 1;
CHK("CAMELCASE",