Skip to content

Commit 2dc71ba

Browse files
committed
badwords: check indented lines in source code, fix fallouts
- badwords.pl: add `-a` option to check all lines in source code files. Before this patch indented lines were skipped (to avoid Markdown code fences.) - GHA/checksrc: use `-a` when verifying the source code. - GHA/checksrc: disable `So` and `But` rules for source code. - GHA/checksrc: add docs/examples to the verified sources. - badwords.txt: delete 4 duplicates. - badwords.txt: group and sort contractions. - badwords.txt: allow ` url = `, `DIR`, `<file name`. Closes curl#19536
1 parent 8a96809 commit 2dc71ba

73 files changed

Lines changed: 146 additions & 144 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/scripts/badwords.pl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@
2020
my @whitelist;
2121
my %alt;
2222
my %exactcase;
23+
my $skip_indented = 1;
2324

25+
if($ARGV[0] eq "-a") {
26+
shift @ARGV;
27+
$skip_indented = 0;
28+
}
2429
my %wl;
2530
if($ARGV[0] eq "-w") {
2631
shift @ARGV;
@@ -68,7 +73,7 @@ sub file {
6873
my $in = $_;
6974
$l++;
7075
chomp $in;
71-
if($in =~ /^ /) {
76+
if($skip_indented && $in =~ /^ /) {
7277
next;
7378
}
7479
# remove the link part

.github/scripts/badwords.txt

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -10,59 +10,56 @@ tool chain:toolchain
1010
tool-chain:toolchain
1111
wild-card:wildcard
1212
wild card:wildcard
13+
\bit's:it is
14+
aren't:are not
15+
can't:cannot
16+
could've:could have
17+
couldn't:could not
18+
didn't:did not
19+
doesn't:does not
20+
don't=do not
1321
i'm:I am
14-
you've:You have
15-
we've:we have
16-
we're:we are
17-
we'll:we will
18-
we'd:we would
19-
they've:They have
20-
they're:They are
21-
they'll:They will
22+
isn't:is not
23+
it'd:it would
24+
should've:should have
25+
that's:that is
26+
there's:there is
2227
they'd:They would
23-
you've:you have
28+
they'll:They will
29+
they're:They are
30+
they've:They have
31+
we'd:we would
32+
we'll:we will
33+
we're:we are
34+
we've:we have
35+
won't:will not
2436
you'd:you would
2537
you'll:you will
2638
you're:you are
27-
should've:should have
28-
don't=do not
29-
could've:could have
30-
doesn't:does not
31-
isn't:is not
32-
aren't:are not
39+
you've:you have
3340
a html: an html
3441
a http: an http
3542
a ftp: an ftp
3643
a IPv4: an IPv4
3744
a IPv6: an IPv6
38-
url =URL
45+
url [^=]=URL
3946
[^/]internet\b=Internet
4047
isation:ization
41-
\bit's:it is
42-
it'd:it would
43-
there's:there is
4448
[^.]\. And: Rewrite it somehow?
4549
^(And|So|But) = Rewrite it somehow?
4650
\. But: Rewrite it somehow?
4751
\. So : Rewrite without "so" ?
48-
dir [^=]:directory
52+
dir [^=]=directory
53+
Dir [^=]=Directory
4954
sub-director:subdirector
50-
you'd:you would
51-
you'll:you will
52-
can't:cannot
53-
that's:that is
5455
web page:webpage
5556
host name\b:hostname
5657
host names\b:hostnames
57-
[^;]file name\b:filename
58+
[^;<]file name\b:filename
5859
file names\b:filenames
5960
\buser name\b:username
6061
\buser names\b:usernames
6162
\bpass phrase:passphrase
62-
didn't:did not
63-
doesn't:does not
64-
won't:will not
65-
couldn't:could not
6663
\bwill\b:rewrite to present tense
6764
\b32bit=32-bit
6865
\b64bit=64-bit

.github/workflows/checksrc.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ jobs:
174174
- name: 'yamlcheck'
175175
run: .github/scripts/yamlcheck.sh
176176

177-
# we allow some extra in source code
178177
- name: 'badwords'
179-
run: grep -Ev '(\\bwill)' .github/scripts/badwords.txt | .github/scripts/badwords.pl src lib include
178+
run: |
179+
# we allow some extra in source code
180+
grep -Ev '(\\bwill| But: | So : )' .github/scripts/badwords.txt | .github/scripts/badwords.pl -a src lib include docs/examples

docs/examples/anyauthput.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ int main(int argc, char **argv)
152152
data twice!!! */
153153
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
154154

155-
/* set user name and password for the authentication */
155+
/* set username and password for the authentication */
156156
curl_easy_setopt(curl, CURLOPT_USERPWD, "user:password");
157157

158158
/* Now run off and do what you have been told! */

docs/examples/connect-to.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ int main(void)
4040
/*
4141
Each single string should be written using the format
4242
HOST:PORT:CONNECT-TO-HOST:CONNECT-TO-PORT where HOST is the host of the
43-
request, PORT is the port of the request, CONNECT-TO-HOST is the host name
43+
request, PORT is the port of the request, CONNECT-TO-HOST is the hostname
4444
to connect to, and CONNECT-TO-PORT is the port to connect to.
4545
*/
4646
/* instead of curl.se:443, it resolves and uses example.com:443 but in other
@@ -53,12 +53,12 @@ int main(void)
5353
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
5454
curl_easy_setopt(curl, CURLOPT_URL, "https://curl.se/");
5555

56-
/* since this connects to the wrong host, checking the host name in the
56+
/* since this connects to the wrong host, checking the hostname in the
5757
server certificate fails, so unless we disable the check libcurl
5858
returns CURLE_PEER_FAILED_VERIFICATION */
5959
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
6060

61-
/* Letting the wrong host name in the certificate be okay, the transfer
61+
/* Letting the wrong hostname in the certificate be okay, the transfer
6262
goes through but (most likely) causes a 404 or similar because it sends
6363
an unknown name in the Host: header field */
6464
res = curl_easy_perform(curl);

docs/examples/cookie_interface.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static int print_cookies(CURL *curl)
4747
printf("Cookies, curl knows:\n");
4848
res = curl_easy_getinfo(curl, CURLINFO_COOKIELIST, &cookies);
4949
if(res != CURLE_OK) {
50-
fprintf(stderr, "Curl curl_easy_getinfo failed: %s\n",
50+
fprintf(stderr, "curl curl_easy_getinfo failed: %s\n",
5151
curl_easy_strerror(res));
5252
return 1;
5353
}
@@ -85,7 +85,7 @@ main(void)
8585
curl_easy_setopt(curl, CURLOPT_COOKIEFILE, ""); /* start cookie engine */
8686
res = curl_easy_perform(curl);
8787
if(res != CURLE_OK) {
88-
fprintf(stderr, "Curl perform failed: %s\n", curl_easy_strerror(res));
88+
fprintf(stderr, "curl perform failed: %s\n", curl_easy_strerror(res));
8989
return 1;
9090
}
9191

@@ -105,7 +105,7 @@ main(void)
105105
"PREF", "hello example, I like you!");
106106
res = curl_easy_setopt(curl, CURLOPT_COOKIELIST, nline);
107107
if(res != CURLE_OK) {
108-
fprintf(stderr, "Curl curl_easy_setopt failed: %s\n",
108+
fprintf(stderr, "curl curl_easy_setopt failed: %s\n",
109109
curl_easy_strerror(res));
110110
return 1;
111111
}
@@ -120,7 +120,7 @@ main(void)
120120
"expires=Sun, 17-Jan-2038 19:14:07 GMT; path=/; domain=.example.com");
121121
res = curl_easy_setopt(curl, CURLOPT_COOKIELIST, nline);
122122
if(res != CURLE_OK) {
123-
fprintf(stderr, "Curl curl_easy_setopt failed: %s\n",
123+
fprintf(stderr, "curl curl_easy_setopt failed: %s\n",
124124
curl_easy_strerror(res));
125125
return 1;
126126
}
@@ -129,14 +129,14 @@ main(void)
129129

130130
res = curl_easy_perform(curl);
131131
if(res != CURLE_OK) {
132-
fprintf(stderr, "Curl perform failed: %s\n", curl_easy_strerror(res));
132+
fprintf(stderr, "curl perform failed: %s\n", curl_easy_strerror(res));
133133
return 1;
134134
}
135135

136136
curl_easy_cleanup(curl);
137137
}
138138
else {
139-
fprintf(stderr, "Curl init failed!\n");
139+
fprintf(stderr, "curl init failed!\n");
140140
return 1;
141141
}
142142

docs/examples/debug.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static void dump(const char *text, FILE *stream, unsigned char *ptr,
6969
}
7070
fprintf(stream, "%c",
7171
(ptr[i + c] >= 0x20) && (ptr[i + c] < 0x80) ? ptr[i + c] : '.');
72-
/* check again for 0D0A, to avoid an extra \n if it's at width */
72+
/* check again for 0D0A, to avoid an extra \n if it is at width */
7373
if(nohex && (i + c + 2 < size) && ptr[i + c + 1] == 0x0D &&
7474
ptr[i + c + 2] == 0x0A) {
7575
i += (c + 3 - width);

docs/examples/ephiperfifo.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ static void mcode_or_die(const char *where, CURLMcode code)
133133

134134
static void timer_cb(struct GlobalInfo *g, int revents);
135135

136-
/* Update the timer after curl_multi library does its thing. Curl informs the
136+
/* Update the timer after curl_multi library does its thing. curl informs the
137137
* application through this callback what it wants the new timeout to be,
138138
* after it does some work. */
139139
static int multi_timer_cb(CURLM *multi, long timeout_ms, struct GlobalInfo *g)
@@ -219,7 +219,7 @@ static void timer_cb(struct GlobalInfo *g, int revents)
219219
err = read(g->tfd, &count, sizeof(uint64_t));
220220
if(err == -1) {
221221
/* Note that we may call the timer callback even if the timerfd is not
222-
* readable. It's possible that there are multiple events stored in the
222+
* readable. It is possible that there are multiple events stored in the
223223
* epoll buffer (i.e. the timer may have fired multiple times). The event
224224
* count is cleared after the first call so future events in the epoll
225225
* buffer fails to read from the timer. */

docs/examples/ftpupload.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ int main(void)
9090
/* get a FILE * of the file */
9191
hd_src = fopen(LOCAL_FILE, "rb");
9292
if(!hd_src) {
93-
printf("Couldn't open '%s': %s\n", LOCAL_FILE, strerror(errno));
93+
printf("Could not open '%s': %s\n", LOCAL_FILE, strerror(errno));
9494
return 2;
9595
}
9696

docs/examples/htmltidy.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void dumpNode(TidyDoc doc, TidyNode tnod, int indent)
5050
for(child = tidyGetChild(tnod); child; child = tidyGetNext(child) ) {
5151
ctmbstr name = tidyNodeGetName(child);
5252
if(name) {
53-
/* if it has a name, then it's an HTML tag ... */
53+
/* if it has a name, then it is an HTML tag ... */
5454
TidyAttr attr;
5555
printf("%*.*s%s ", indent, indent, "<", name);
5656
/* walk the attribute list */
@@ -62,7 +62,7 @@ void dumpNode(TidyDoc doc, TidyNode tnod, int indent)
6262
printf(">\n");
6363
}
6464
else {
65-
/* if it does not have a name, then it's probably text, cdata, etc... */
65+
/* if it does not have a name, then it is probably text, cdata, etc... */
6666
TidyBuffer buf;
6767
tidyBufInit(&buf);
6868
tidyNodeGetText(doc, child, &buf);

0 commit comments

Comments
 (0)