1#!/usr/bin/env perl 2#*************************************************************************** 3# _ _ ____ _ 4# Project ___| | | | _ \| | 5# / __| | | | |_) | | 6# | (__| |_| | _ <| |___ 7# \___|\___/|_| \_\_____| 8# 9# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 10# 11# This software is licensed as described in the file COPYING, which 12# you should have received as part of this distribution. The terms 13# are also available at https://curl.se/docs/copyright.html. 14# 15# You may opt to use, copy, modify, merge, publish, distribute and/or sell 16# copies of the Software, and permit persons to whom the Software is 17# furnished to do so, under the terms of the COPYING file. 18# 19# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 20# KIND, either express or implied. 21# 22# SPDX-License-Identifier: curl 23# 24########################################################################### 25 26my $root=$ARGV[0] || ".."; 27 28my @m = `git ls-files -- $root`; 29 30my $errors; 31 32my %accepted=('curl' => 1, 33 'libcurl' => 1, 34 'macOS' => 1, 35 'wolfSSL' => 1, 36 'mbedTLS' => 1, 37 'rustls' => 1, 38 'c-ares' => 1); 39 40sub checkfile { 41 my ($f) = @_; 42 chomp $f; 43 if($f !~ /\.md\z/) { 44 return; 45 } 46 open(my $fh, "<", "$f"); 47 my $l; 48 my $prevl; 49 my $ignore = 0; 50 my $metadata = 0; 51 while(<$fh>) { 52 my $line = $_; 53 chomp $line; 54 $l++; 55 if(($l == 1) && ($line =~ /^---/)) { 56 # first line is a meta-data divider, skip to the next one 57 $metadata = 1; 58 next; 59 } 60 elsif($metadata) { 61 if($line !~ /^---/) { 62 next; 63 } 64 $metadata = 0; 65 next; 66 } 67 if($line =~ /^(\`\`\`|\~\~\~)/) { 68 # start or stop ignore-mode 69 $ignore ^= 1; 70 } 71 if(!$ignore) { 72 if(($prevl =~ /\.\z/) && ($line =~ /^( *)([a-z][A-Za-z-]*)/)) { 73 my ($prefix, $word) = ($1, $2); 74 if($word =~ /^[a-z]/ && !$accepted{$word}) { 75 my $c = length($prefix); 76 print STDERR 77 "$f:$l:$c:error: lowercase $word after period\n"; 78 print STDERR "$line\n"; 79 print STDERR ' ' x $c; 80 print STDERR "^\n"; 81 $errors++; 82 } 83 } 84 elsif($line =~ /^(.*)\. +([a-z-]+)/) { 85 my ($prefix, $word) = ($1, $2); 86 87 if(($prefix =~ /\.\.\z/) || 88 ($prefix =~ /[0-9]\z/) || 89 ($prefix =~ /e.g\z/) || 90 ($prefix =~ /i.e\z/) || 91 ($prefix =~ /E.g\z/) || 92 ($prefix =~ /etc\z/) || 93 ($word !~ /^[a-z]/) || 94 $accepted{$word}) { 95 } 96 else { 97 my $c = length($prefix) + 2; 98 print STDERR 99 "$f:$l:$c:error: lowercase $word after period\n"; 100 print STDERR "$line\n"; 101 print STDERR ' ' x $c; 102 print STDERR "^\n"; 103 $errors++; 104 } 105 } 106 } 107 $prevl = $line; 108 } 109 close($fh); 110} 111 112 113for my $f (@m) { 114 checkfile($f); 115} 116 117if($errors) { 118 exit 1; 119} 120print "ok\n"; 121