forked from jcgregorio/uri-templates
-
Notifications
You must be signed in to change notification settings - Fork 2
/
idnits
executable file
·3677 lines (3232 loc) · 144 KB
/
idnits
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
#
# 'idnits' looks for violations of Section 2.1 and 2.2 of the
# requirements listed on http://www.ietf.org/ID-Checklist.html
# Copyright:
# -----------------------------------------------------------------
#
# Copyright 2002-2010 Henrik Levkowetz
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# -----------------------------------------------------------------
version="2.12.12";
progdatste="";
export LC_ALL=C
program=${0##*/}
progdir=${0%/*} ; [ "$progdir" ] || progdir=.
system=$(uname)
today=$(date +"%Y-%m-%d")
[ "$HOME" ] || HOME=/var/tmp
statusdir=$HOME/.idnits
statusfile=$statusdir/rfc-status
wordlist=$statusdir/rfc-wordlist
obslist=$statusdir/rfcs-obsoleted
updlist=$statusdir/rfcs-updated
exclist=$statusdir/downref-exceptions
# ----------------------------------------------------------------------
# Utilities
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# Error exit
function die() { echo "$program: Error: $*" >&2; exit 1; }
# ----------------------------------------------------------------------
# Message
function msg() { [ "$optsilent" ] || echo $* >&2; }
# ----------------------------------------------------------------------
# Note
function note() { [ "$optverbose" ] && echo $* >&2; }
# ----------------------------------------------------------------------
# Note
function debug() { [ "$optdebug" ] && echo $* >&2; }
# ----------------------------------------------------------------------
# Find an executable
lookfor() {
default="$1"; shift
for b in "$@"; do
found=$(which "$b" 2>/dev/null)
if [ -n "$found" ]; then
if [ -x "$found" -o -x "$found.exe" ]; then
echo "$found"
return
fi
fi
done
echo "$default"
}
# ----------------------------------------------------------------------
# Set up which program to use
FDATE='date +%Y-%m-%d -r'
[ "$system" = "Darwin" ] && FDATE='stat -f %Sm -t %Y-%m-%d'
SED="sed -r"
[ "$system" = "Darwin" ] && SED="sed -E"
AWK=$(lookfor gawk $AWK gawk nawk awk)
WGET=$(lookfor wget $WGET wget curl lynx)
[ ${WGET##*/} = wget ] && [ "$system" = "Darwin" ] && WARG="--timeout=5 -q -O - "
[ ${WGET##*/} = wget ] && [ "$system" = "Darwin" ] || WARG="--timeout=5 -q -O - --no-check-certificate"
[ ${WGET##*/} = curl ] && WARG="--connect-timeout 5 -s -k"
[ ${WGET##*/} = lynx ] && WARG="-connect_timeout=5 -dump"
SPELL=$(lookfor "" aspell)
GRAMMAR=$(lookfor "" languagetool)
# ----------------------------------------------------------------------
# Convert DOS (^M^J) and MAC (^M) line ending to Unix (^J)
# ----------------------------------------------------------------------
fixnl() {
$AWK '
BEGIN { RS = "\r"; }
{ sub(/^\n/, ""); print; }
' "$1"
}
# ----------------------------------------------------------------------
# Strip headers and footers, end-of-line whitespace and \r (CR)
# ----------------------------------------------------------------------
hfstrip() {
$AWK '
BEGIN {
expiration = 0;
longestpage = 1;
textcolumn=8; # initialise minimum indentation we found
}
{ gsub(/\r/, ""); }
{ gsub(/[ \t]+$/, ""); }
{ pagelength++; }
tolower($0) ~ / *expire on.*20[0-9][0-9]/ { if (FNR <= 58 ) expiration = 1; }
tolower($0) ~ / *expires.*20[0-9][0-9]/ { if (FNR <= 58 ) expiration = 1; }
tolower($0) ~ / *expiration.*20[0-9][0-9]/ { if (FNR <= 58 ) expiration = 1; }
/FORMFEED[ \t]*\[Page/ { missing_nroff_postprocessing ++; }
/\[?[Pp]age [0-9ivx]+\]?[ \t\f]*$/ {
match($0, /[Pp]age [0-9ivx]+/);
num = substr($0, RSTART+5, RLENGTH-5);
if (num+0 > maxpage) maxpage = num+0;
pagecount++;
countedpage=1;
if (pagelength > 58) longpagecount++;
if (maxlength < pagelength) {
maxlength = pagelength;
longestpage = num;
}
if (!firstpagelength) firstpagelength = outline;
pagelength = 0;
}
/\f/ { newpage=1;
ffcount++;
if (pagelength > 58) longpagecount++;
if (! countedpage) {
pagecount++;
countedpage=0;
}
if (maxlength < pagelength) {
maxlength = pagelength;
longestpage = pagecount;
}
pagelength=1;
}
/\f$/ {
# a form feed followed by a \n does not contribute to the
# line count. (But a \f followed by something else does.)
pagelength--;
}
/\f/ { next; }
/\[?[Pp]age [0-9ivx]+\]?[ \t\f]*$/ { preindent = indent; next; }
/^ *Internet.Draft.+[12][0-9][0-9][0-9] *$/ && (FNR > 15) { newpage=1; next; }
/^ *INTERNET.DRAFT.+[12][0-9][0-9][0-9] *$/ && (FNR > 15) { newpage=1; next; }
/^ *INTERNET.DRAFT / && (FNR > 15) { newpage=1; next; }
/^ *Draft.+( +)[12][0-9][0-9][0-9] *$/ && (FNR > 15) { newpage=1; next; }
/^RFC[ -]?[0-9]+.*( +)[12][0-9][0-9][0-9]$/ && (FNR > 15) { newpage=1; next; }
/^draft-[-a-z0-9_.]+.*[0-9][0-9][0-9][0-9]$/ && (FNR > 15) { newpage=1; next; }
/(Jan|Feb|Mar|March|Apr|April|May|Jun|June|Jul|July|Aug|Sep|Oct|Nov|Dec) (19[89][0-9]|20[0-9][0-9]) *$/ && pagelength < 3 { newpage=1; next; }
newpage && $0 ~ /^ *draft-[-a-z0-9_.]+ *$/ { newpage=1; next; }
/^[ \t]+\[/ { sentence=1; }
/[^ \t]/ {
indent = match($0, /[^ ]/);
if (indent < preindent) {
sentence = 1;
}
if (newpage) {
if (sentence) {
outline++; print "";
}
} else {
if (haveblank) {
outline++; print "";
}
}
haveblank=0;
sentence=0;
newpage=0;
line = $0;
sub(/^ *\t/, " ", line);
thiscolumn = match(line, /[^ ]/);
if (thiscolumn && thiscolumn < textcolumn) textcolumn = thiscolumn;
}
/[.:][ \t]*$/ { sentence=1; }
/\(http:\/\/trustee\.ietf\.org\/license-info\)\./ { sentence=0; }
/^[ \t]*$/ { haveblank=1; next; }
{ outline++; print; }
END {
if (pagecount == 0) pagecount = 1;
if (longpagecount == 0 && pagelength > 58) longpagecount++;
if (firstpagelength > 58) firstpagelenght = 58;
if (firstpagelength == 0) firstpagelength = 58;
print "";
printf "-+- Pagecount: %d -+-\n", (pagecount > maxpage ? pagecount : maxpage);
printf "-+- Firstpagelength: %d -+-\n", firstpagelength;
printf "-+- Maxpagelength: %d -+-\n", (pagelength > maxlength ? pagelength : maxlength);
printf "-+- Longpagecount: %d -+-\n", longpagecount;
printf "-+- Longestpage: %d -+-\n", longestpage;
printf "-+- Formfeedcount: %d -+-\n", ffcount;
printf "-+- Expiration: %s -+-\n", expiration;
printf "-+- NoNroffPostproc: %s -+-\n", missing_nroff_postprocessing;
}
' $1
}
tmpfile() {
prefix=$(basename $0)
for tmpdir in $TMPDIR $TMP $TEMP /tmp .; do
if [ -d $tmpdir -a -w $tmpdir ]; then
tmpfn=$tmpdir/$prefix-$$.tmp
if [ -f $tmpfn ]; then rm $tmpfn; fi
echo $tmpfn
exit
fi
done
if [ -z $tmpfn ]; then
msg "Can't find any writable directory for temporary files; this won't work..."
fi
}
checknits() {
program=$(tmpfile)
cat << 'EOF' > $program
BEGIN {
option_verbose = 0;
option_warn = 1;
split(ENVIRON["CHECKNITS"], argv);
columns = ENVIRON["COLUMNS"];
if (! columns ) columns = 78;
if (columns > 80) columns = 80;
if (columns < 16) columns = 16;
if (columns < 73) bpcols = columns; else bpcols = 73;
indentation = 8;
errmark = "**";
warnmark = "==";
infomark = "--";
notemark = " ";
for (i in argv) {
# Deprecated
if (argv[i] == "--rfc3667") {
printf "\nOption %s does nothing any more\n", argv[i];
argv[i] = "";
}
if (argv[i] == "--no3667") {
printf "\nOption %s does nothing any more\n", argv[i];
argv[i] = "";
}
if (argv[i] == "--rfc2026") {
printf "\nOption %s does nothing any more\n", argv[i];
argv[i] = "";
}
if (argv[i] == "--nowarn") {
option_warn = 0;
argv[i] = "";
}
if (argv[i] == "--filename") {
option_filename = argv[i+1];
argv[i] = "";
argv[i+1] = "";
}
if (argv[i] == "--debug") {
option_debug = 1;
argv[i] = "";
}
if (argv[i] == "--nitcount") {
option_nitcount = 1;
argv[i] = "";
}
if (argv[i] == "--pass1") {
option_pass1 = 1;
argv[i] = "";
}
if (argv[i] == "--verbose") {
option_verbose++;
argv[i] = "";
}
if (argv[i] == "--list-matches") {
option_list_matches = 1;
argv[i] = "";
}
if (argv[i] == "--year") {
option_year = argv[i+1];
argv[i] = "";
argv[i+1] = "";
}
if (argv[i] == "--checklistwarn") {
option_checklistwarn++;
argv[i] = "";
}
if (argv[i] == "--submitcheck") {
option_submitcheck++;
argv[i] = "";
}
if (argv[i] == "--status") {
option_status = argv[i+1];
argv[i] = "";
argv[i+1] = "";
}
if (argv[i] == "--") {
argv[i] = "";
}
if (argv[i] ~ "^-.+") {
printf "\nUnknown option: %s\n\n", argv[i];
usage();
exit 1;
}
if (argv[i] ~ "^--.+") {
printf "\nUnknown option: %s\n\n", argv[i];
usage();
exit 1;
}
}
option_pass2 = ! option_pass1;
split("SOH STX ETX EOT ENQ ACK BEL BS TAB LF VT FF CR SO SI DLE DC1 DC2 DC3 DC4 NAK SYN ETB CAN EM SUB ESC FS GS RS US", controlchar)
for (i in controlchar) {
controlchar[sprintf("%c",i+0)] = controlchar[i];
delete controlchar[i];
}
split("January February March April May June July August September October November December", month);
for (i in month) {
month[month[i]] = i
month[substr(month[i], 1, 3)] = i
delete month[i];
}
doc_date = 0;
# Extract a list of hyphenated words from the document, and build an array of valid fragments
if ( length(option_filename) ) {
cmd = sprintf("cat %s | sed 's/[^A-Za-z0-9_-]/\\n/g' | sort | uniq | egrep -- '-' | egrep -v -- '-$' | egrep '^[A-Za-z0-9]'", option_filename )
while ( cmd | getline > 0 ) {
word = $0
frag = ""
for (;;) {
if ( length(word) == 0 ) break
pos = index(word, "-")
if ( pos == 0 ) break
frag = frag substr(word, 1, pos )
hyphenfrags[frag]
has_hyphenlist = 1
word = substr(word, pos+1)
}
}
}
# get current year
if ( option_year > 1990 ) {
year = option_year;
} else if ( "date +'%Y'" | getline year <= 0 ) {
year = "[0-9]+"
}
# establish the format we expect references to have, for later use
has_refs = 0;
one_ref_format = "(([0-9A-Z-]|I-?D.)[0-9A-Za-z-]*( [0-9A-Z-]+)?|(IEEE|ieee)[A-Za-z0-9.-]+)";
reference_format = "\\[" one_ref_format "(, ?" one_ref_format ")*\\]";
abnf_rule_format = "^ +([A-Za-z0-9-]+ *=|;).*";
imap_rule_format = "^ *S: (\\*|[A-Za-z0-9]+) (OK|NO|BAD|PREAUTH|BYE) \\[[-A-Za-z]+\\]";
code_start_format = "(/\\*|\\*/|^ *#|<CODE BEGINS>)";
code_end_format = "(<CODE ENDS>)";
# read obsoleted RFC information from file
if (obslist) {
while ( getline < obslist > 0 ) {
oldrfc = $1; $1 = "";
obsoleted[oldrfc] = $0;
}
} else {
obsoleted[""] = "";
}
# read the rfc status information from file
if (statusfile) {
while ( getline < statusfile > 0 ) {
rfcstatus = rfcstatus $0;
}
} else {
rfcstatus = "";
}
# read exception RFC information from file
if (exclist) {
while ( getline < exclist > 0 ) {
exception[$1] = $1;
}
} else {
exception[""] = "";
}
status2code["bcp"] = "B";
status2code["best current"] = "B";
status2code["best current practice"] = "B";
status2code["experimental"] = "E";
status2code["experimental track"] = "E";
status2code["informational"] = "I";
status2code["ps"] = "P";
status2code["proposed standard"] = "P";
status2code["proposed standards"] = "P";
status2code["standards track"] = "P";
status2code["standard track"] = "P";
status2code["ds"] = "D";
status2code["draft standard"] = "D";
status2code["standard"] = "S";
status2code["full standard"] = "S";
status2code["historic"] = "H";
status2code["not issued"] = "N";
code2status["O"] = "Obsolete";
code2status["U"] = "Unknown state";
code2status["E"] = "Experimental";
code2status["I"] = "Informational";
code2status["B"] = "Best Current Practice";
code2status["P"] = "Proposed Standard";
code2status["D"] = "Draft Standard";
code2status["S"] = "Full Standard";
code2status["H"] = "Historic";
code2status["N"] = "Not Issued";
warncodes["H"] = "N";
warncodes["E"] = "N O";
warncodes["I"] = "N O";
warncodes["B"] = "N E I O U H";
warncodes["P"] = "N E I O U H";
warncodes["D"] = "N E I O U H P";
warncodes["S"] = "N E I P U H P D";
split("B P D S", ietfstreamcodes)
has[""]; # make sure this exists as a global variable here
seen_ref[""];
miss_ref[""];
# ------------------------------------------------------------------
# 3978 and 3979 section texts
#
bp["any_text"] = ".*"
bp["rfc3667_3_claim"] = "This document is an Internet-Draft and is subject to all provisions " \
"of (S|s)ection 3 of( | \\])RFC( |.?)(3667|3667\\])\\.$";
bp["rfc3667_5_1"] = "By submitting this Internet-Draft, (I|we) certify that any applicable " \
"patent or other IPR claims of which (I am|we are) aware have been disclosed,( or " \
"will be disclosed,)? and any of which (I|we) become aware will be disclosed, " \
"in accordance with RFC 3668.$";
bp["rfc3978_5_1"] = "By submitting this Internet-Draft, each author represents that any " \
"applicable patent or other IPR claims of which he or she is aware " \
"have been or will be disclosed, and any of which he or she becomes " \
"aware will be disclosed, in accordance with Section 6 of BCP 79.$";
bp["rfc3978_5_1_a"] = "By submitting this Internet-Draft, (each|the) author represents that any " \
"applicable patent or other IPR claims of which (he or she|he|she) is aware " \
"have been or will be disclosed, and any of which (he or she|he|she) becomes? " \
"aware will be disclosed, in accordance with( (S|s)ection 6 of)? (BCP 79|RFC 3979|RFC 3668).$";
bp["rfc3978_5_2a"] = "This document may not be modified, and derivative works of it may " \
"not be created, except to publish it as an RFC and to translate it " \
"into languages other than English\\.$";
bp["rfc3978_5_2ax"] = "This document may not be modified, and derivative works of it may " \
"not be created, except to publish it as an RFC and to translate it " \
"into languages other than English other than to extract section " \
"[0-9.]+ as-is for separate use\\.$";
bp["rfc3978_5_2b"] = "This document may not be modified, and derivative works of it may " \
"not be created\\.$";
bp["rfc3978_5_2bx"] = "This document may not be modified, and derivative works of it may " \
"not be created other than to extract section [0-9.]+ as-is for separate use.$";
bp["rfc3978_5_3"] = "This document may only be posted in an Internet-Draft.$";
bp["rfc3978_5_4_p1"] = "Copyright \\(C\\) The Internet Society \\(?[0-9][0-9][0-9][0-9]\\)?.$"
bp["rfc3978_5_4_p1_u4748"] = "Copyright \\(C\\) The IETF Trust \\(?[0-9][0-9][0-9][0-9]\\)?.$"
bp["rfc3978_5_4_p1_e"] = ".+Copyright \\(C\\) The Internet Society \\(?[0-9][0-9][0-9][0-9]\\)?\\..+"
bp["rfc3978_5_4_p1_u4748_e"] = ".+Copyright \\(C\\) The IETF Trust \\(?[0-9][0-9][0-9][0-9]\\)?\\..+"
bp["rfc3978_5_4_p1_now"] = sprintf("Copyright \\(C\\) The Internet Society \\(?%s\\)?", year);
bp["rfc3978_5_4_p1_u4748_now"] = sprintf("Copyright \\(C\\) The IETF Trust \\(?%s\\)?", year);
bp["trust-16-oct-2008_6_b_p2_now"] = sprintf("Copyright \\(c\\) %s IETF Trust and " \
"the persons identified as the document authors", year);
bp["trust-12-feb-2009_6_b_p2_now"] = sprintf("Copyright \\(c\\) %s IETF Trust and " \
"the persons identified as the document authors", year);
bp["trust-12-sep-2009_6_b_p2_now"] = sprintf("Copyright \\(c\\) %s IETF Trust and " \
"the persons identified as the document authors.", year);
bp["trust-28-dec-2009_6_b_i_p2_now"] = sprintf("Copyright \\(c\\) %s IETF Trust and " \
"the persons identified as the document authors.", year);
# ----------------------------------------------------------------------------------------------
bp["rfc3978_5_4_p2"] = "This document is subject to the rights, licenses and restrictions contained in BCP " \
"78, and except as set forth therein, the authors retain all their rights.$";
bp["rfc3978_5_5"] = "This document and the information contained herein are provided " \
"on an \"AS IS\" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE " \
"REPRESENTS OR IS SPONSORED BY \\(IF ANY\\), THE INTERNET SOCIETY AND " \
"THE INTERNET ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, " \
"EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT " \
"THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR " \
"ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A " \
"PARTICULAR PURPOSE.$";
bp["rfc3978_5_5_u4748"] = "This document and the information contained herein are provided " \
"on an \"AS IS\" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE " \
"REPRESENTS OR IS SPONSORED BY \\(IF ANY\\), THE INTERNET SOCIETY, THE IETF TRUST AND " \
"THE INTERNET ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, " \
"EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT " \
"THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR " \
"ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A " \
"PARTICULAR PURPOSE.$";
bp["rfc3979_5_p1"] = "The IETF takes no position regarding the validity or scope of any " \
"Intellectual Property Rights or other rights that might be claimed " \
"to pertain to the implementation or use of the technology " \
"described in this document or the extent to which any license " \
"under such rights might or might not be available; nor does it " \
"represent that it has made any independent effort to identify any " \
"such rights. Information on the procedures with respect to rights " \
"in RFC documents can be found in BCP 78 and BCP 79.$";
bp["rfc3979_5_p2"] = "Copies of IPR disclosures made to the IETF Secretariat and any " \
"assurances of licenses to be made available, or the result of an " \
"attempt made to obtain a general license or permission for the use " \
"of such proprietary rights by implementers or users of this " \
"specification can be obtained from the IETF on-line IPR repository " \
"at http://www.ietf.org/ipr.$";
bp["rfc3979_5_p3"] = "The IETF invites any interested party to bring to its attention " \
"any copyrights, patents or patent applications, or other " \
"proprietary rights that may cover technology that may be required " \
"to implement this standard. Please address the information to the " \
"IETF at [email protected].$";
# ----------------------------------------------------------------------------------------------
bp["trust-16-oct-2008_6_a"] = "This Internet-Draft is submitted to IETF in full " \
"conformance with the provisions of BCP 78 and BCP 79\\.$";
bp["trust-16-oct-2008_6_b_p2"] = "Copyright \\(c\\) [0-9][0-9][0-9][0-9] IETF Trust and " \
"the persons identified as the document authors\\. All rights reserved\\.$";
bp["trust-16-oct-2008_6_b_p3"] = "This document is subject to BCP 78 and the " \
"IETF Trust's Legal Provisions Relating to IETF Documents " \
"\\(http://trustee.ietf.org/license-inf(o|o/)\\) " \
"in effect on the date of publication of this document. " \
"Please review these documents " \
"carefully, as they describe your rights and restrictions with respect to " \
"this document\\.$";
bp["trust-16-oct-2008_6_c_i"] = "This document may not be modified, and derivative " \
"works of it may not be created, except to format it for publication " \
"as an RFC and to translate it into languages other than English\\.$";
# ----------------------------------------------------------------------------------------------
bp["trust-12-feb-2009_6_a"] = bp["trust-16-oct-2008_6_a"]
bp["trust-12-feb-2009_6_b_p2"] = bp["trust-16-oct-2008_6_b_p2"]
bp["trust-12-feb-2009_6_b_p3"] = \
"This document is subject to BCP 78 and the IETF Trust's Legal " \
"Provisions Relating to IETF Documents in effect on the date of " \
"publication of this document \\(http://trustee.ietf.org/license-inf(o|o/)\\)\\. " \
"Please review these documents carefully, as they describe your " \
"rights and restrictions with respect to this document\\.$"
bp["trust-12-feb-2009_6_c_i"] = "This document may not be modified, and derivative " \
"works of it may not be created, except to format it for publication " \
"as an RFC or to translate it into languages other than English\\.$";
bp["trust-12-feb-2009_6_c_ii"] = "This document may not be modified, and " \
"derivative works of it may not be created, and it may not be published " \
"except as an Internet-Draft\\.$"
bp["trust-12-feb-2009_6_c_iii"] = \
"This document may contain material from IETF Documents or IETF " \
"Contributions published or made publicly available before November " \
"10, 2008\\. The person\\(s\\) controlling the copyright in some of this " \
"material may not have granted the IETF Trust the right to allow " \
"modifications of such material outside the IETF Standards Process\\. " \
"Without obtaining an adequate license from the person\\(s\\) " \
"controlling the copyright in such materials, this document may not " \
"be modified outside the IETF Standards Process, and derivative " \
"works of it may not be created outside the IETF Standards Process, " \
"except to format it for publication as an RFC or to translate it " \
"into languages other than English\\.$"
# ----------------------------------------------------------------------------------------------
bp["trust-12-sep-2009_6_a"] = bp["trust-12-feb-2009_6_a"]
bp["trust-12-sep-2009_6_b_p2"] = bp["trust-12-feb-2009_6_b_p2"]
bp["trust-12-sep-2009_6_c_i"] = bp["trust-12-feb-2009_6_c_i"]
bp["trust-12-sep-2009_6_c_ii"] = bp["trust-12-feb-2009_6_c_ii"]
bp["trust-12-sep-2009_6_c_iii"] = bp["trust-12-feb-2009_6_c_iii"]
bp["trust-12-sep-2009_6_b_p3"] = \
"This document is subject to BCP 78 and the IETF Trust's Legal " \
"Provisions Relating to IETF Documents \\(http://trustee.ietf.org/license-inf(o|o/)\\) " \
"in effect on the date of publication of this document\\. " \
"Please review these documents carefully, as they describe your " \
"rights and restrictions with respect to this document\\. " \
"Code Components extracted from this document must include " \
"Simplified BSD License text as described in Section 4.e of the " \
"Trust Legal Provisions and are provided without warranty as described " \
"in the BSD License\\.$"
# ----------------------------------------------------------------------------------------------
bp["trust-28-dec-2009_6_b_i_p2"] = bp["trust-12-sep-2009_6_b_p2"]
bp["trust-28-dec-2009_6_c_i"] = bp["trust-12-sep-2009_6_c_i"]
bp["trust-28-dec-2009_6_c_ii"] = bp["trust-12-sep-2009_6_c_ii"]
bp["trust-28-dec-2009_6_c_iii"] = bp["trust-12-sep-2009_6_c_iii"]
bp["trust-28-dec-2009_6_a"] = "This Internet-Draft is submitted in full " \
"conformance with the provisions of BCP 78 and BCP 79\\.$";
# This applies to the IETF stream
bp["trust-28-dec-2009_6_b_i_p3"] = \
"This document is subject to BCP 78 and the IETF Trust's Legal Provisions " \
"Relating to IETF Documents \\(http://trustee\\.ietf\\.org/license-inf(o|o/)\\) " \
"in effect on the date of publication of this document\\. " \
"Please review these documents carefully, as they describe your " \
"rights and restrictions with respect to this document\\. " \
"Code Components extracted from this document must include " \
"Simplified BSD License text as described in Section 4.e of the " \
"Trust Legal Provisions and are provided without warranty as described " \
"in the Simplified BSD License\\.$"
# This applies to non-IETF streams
bp["trust-28-dec-2009_6_b_ii_p3"] = \
"This document is subject to BCP 78 and the IETF Trust's Legal Provisions " \
"Relating to IETF Documents \\(http://trustee\\.ietf\\.org/license-inf(o|o/)\\) " \
"in effect on the date of publication of this document\\. " \
"Please review these documents carefully, as they describe your " \
"rights and restrictions with respect to this document\\.$"
# ----------------------------------------------------------------------------------------------
bp["rfc2026_10_4A"] = "The IETF takes no position regarding the validity or scope of " \
"any intellectual property or other rights that might be claimed " \
"to pertain to the implementation or use of the technology " \
"described in this document or the extent to which any license " \
"under such rights might or might not be available; neither does " \
"it represent that it has made any effort to identify any such " \
"rights. Information on the IETF\047s procedures with respect to " \
"rights in standards-track and standards-related documentation " \
"can be found in BCP-11. Copies of claims of rights made " \
"available for publication and any assurances of licenses to " \
"be made available, or the result of an attempt made " \
"to obtain a general license or permission for the use of such " \
"proprietary rights by implement[oe]rs or users of this " \
"specification can be obtained from the IETF Secretariat.$";
bp["rfc2026_10_4B"] = "The IETF invites any interested party to bring to its " \
"attention any copyrights, patents or patent applications, or " \
"other proprietary rights which may cover technology that may be " \
"required to practice this standard. Please address the " \
"information to the IETF Executive Director.$";
bp["rfc2026_10_4C_p1"] = "Copyright \\([Cc]\\) The Internet Society \\(?[0-9][0-9][0-9][0-9]\\)?. All Rights " \
"Reserved.$";
bp["rfc2026_10_4C_p2"] = "This document and translations of it may be copied and " \
"furnished to others, and derivative works that comment on or " \
"otherwise explain it or assist in its implementation may be " \
"prepared, copied, published and distributed, in whole or in " \
"part, without restriction of any kind, provided that the above " \
"copyright notice and this paragraph are included on all such " \
"copies and derivative works. However, this document itself may " \
"not be modified in any way, such as by removing the copyright " \
"notice or references to the Internet Society or other Internet " \
"organizations, except as needed for the purpose of developing " \
"Internet standards in which case the procedures for copyrights " \
"defined in the Internet Standards process must be followed, or " \
"as required to translate it into languages other than English.$";
bp["rfc2026_10_4C_p3"] = "The limited permissions granted above are perpetual and will " \
"not be revoked by the Internet Society or its successors or " \
"assign(ee)?s.$";
bp["rfc2026_10_4C_p4"] = "This document and the information contained herein is provided " \
"on an \"AS IS\" basis and THE INTERNET SOCIETY AND THE INTERNET " \
"ENGINEERING TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR " \
"IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE " \
"OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY " \
"IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A " \
"PARTICULAR PURPOSE.$";
bp["rfc2026_10_4D"] = "The IETF has been notified of intellectual property rights " \
"claimed in regard to some or all of the specification contained " \
"in this document. For more information consult the online list " \
"of claimed rights.$";
bp["rfc2026_claim"] = "This document is an Internet-Draft and is in full conformance " \
"with all provisions of Section 10 of( | \\])RFC( |.?)(2026|2026\\])\\.";
bp["rfc2026_lax_claim"] = "This document is an Internet-Draft and is in full conformance " \
"with all provisions of Section 10 of( | \\])RFC( |.?)(2026|2026\\])( ?\\[[0-9]+\\].*)?.";
bp["rfc2026b_claim"] = "This document is an Internet-Draft and is subject to all provisions " \
"of Section 10 of( | \\])RFC( |.?)(2026|2026\\])\\.";
bp["rfc2026b_lax_claim"] = "This document is an Internet-Draft and is subject to all provisions " \
"of Section 10 of( | \\])RFC( |.?)(2026|2026\\])( ?\\[[0-9]+\\].*)?.";
bp["rfc3978_3_claim"] = "This document is an Internet-Draft and is subject to all provisions " \
"of (S|s)ection 3 of( | \\])RFC( |.?)(3978|3978\\])\\.$";
bp["rfc2119_p2"] = "The key words \"MUST\", \"MUST NOT\", \"REQUIRED\", \"SHALL\", " \
"\"SHALL NOT\", \"SHOULD\", \"SHOULD NOT\", \"RECOMMENDED\",( | \"NOT RECOMMENDED\", )\"MAY\", " \
"and \"OPTIONAL\" in this document are to be interpreted as described in" \
"( | \\[| BCP 14, | BCP 14, \\[)RFC( |.?)2119(\\.|.*\\.|\\].*\\.)$";
bp["rfc2119_p2a"] = "The key words \"MUST\", \"MUST NOT\", \"REQUIRED\", \"SHALL\", " \
"\"SHALL NOT\", \"SHOULD\", \"SHOULD NOT\", \"RECOMMENDED\",( | \"NOT RECOMMENDED\", )\"MAY\", " \
"and \"OPTIONAL\" in this document are to be interpreted as described in " \
"(['\"]?Key words for use in RFCs to Indicate Requirement Levels['\"]? )?" \
"\\[[0-9A-Z-][0-9A-Za-z-]* ?[0-9A-Z-]*\\].*\\.$";
bp["1id_guidelines_p1"] = "Internet-Drafts are working documents of the Internet Engineering " \
"Task Force \\(IETF\\), its areas, and its working groups. Note that other " \
"groups may also distribute working documents as Internet-Drafts.$";
bp["1id_guidelines_p1a"] = "Internet-Drafts are working documents of the Internet Engineering " \
"Task Force \\(IETF\\). Note that other groups may also distribute " \
"working documents as Internet-Drafts. The list of current "\
"Internet-Drafts is at http://datatracker.ietf.org/drafts/current/? ?\\.$";
bp["1id_guidelines_p2"] = "Internet-Drafts are draft documents valid for a maximum of six months " \
"and may be updated, replaced, or obsoleted by other documents at any " \
"time. It is inappropriate to use Internet-Drafts as reference " \
"material or to cite them other than as \"?work in progress(\\.\"|\"?\\.)$";
bp["1id_guidelines_p2a"] = "Internet-Drafts are draft documents valid for a maximum of six months " \
"and may be updated, replaced, or obsoleted by other documents at any " \
"time. It is inappropriate to use Internet-Drafts as reference " \
"material or to cite them other than as \"?work in progress(\\.\"|\"?\\.)$";
bp["1id_guidelines_p3"] = "The list of current Internet-Drafts can be accessed at " \
"http://www.ietf.org/1id-abstracts.html$";
bp["1id_guidelines_p3a"] = "The list of current Internet-Drafts can be accessed at:? " \
"http:// *www.ietf.org/ *(ietf/)?1id-abstracts.(txt|html) ?\\.?$";
bp["1id_guidelines_p4"] = "The list of Internet-Draft Shadow Directories can be accessed at " \
"http://www.ietf.org/shadow.html$";
bp["1id_guidelines_p4a"] = "The list of Internet-Draft Shadow Directories can be accessed at:? " \
"http:// *www.ietf.org/ *shadow.html ?\\.?$";
bad["MUST not"] = "Using lowercase 'not' together with uppercase 'MUST', "\
"'SHALL', 'SHOULD', or 'RECOMMENDED' is not an " \
"accepted usage according to RFC 2119. Please use uppercase 'NOT' " \
"together with RFC 2119 keywords (if that is what you mean)."
bad["SHALL not"] = bad["MUST not"]
bad["SHOULD not"] = bad["MUST not"]
bad["not RECOMMENDED"] = bad["MUST not"]
bad["MAY NOT"] = "The expression 'MAY NOT', while looking like RFC 2119 requirements " \
"text, is not defined in RFC 2119, and should not be used. Consider " \
"using 'MUST NOT' instead (if that is what you mean)."
}
# ----------------------------------------------------------------------
# usage()
#
function usage() {
print "" \
"Usage: idnits [options] filename\n" \
"\n" \
" Options:\n" \
" --version Print the version and exit\n" \
" --help Print this text and exit\n" \
" --nowarn Don\047t issue warnings, only ID-Checklist violations\n" \
" --verbose Show more information about offending lines\n" \
" --nitcount Show a count of nits\n" \
" --debug Debug output, especially of boilerplate matching\n" \
" --year NNNN Expect the given year in the boilerplate\n" \
" --checklistwarn Only warn (no errors) for ID-Checklist volations\n" \
" --submitcheck Only output errors and warnings related to 1id-guidelines\n" \
" --status doctype Assume the given intended document type\n" \
""
}
# ----------------------------------------------------------------------
# strip()
#
function strip(str) {
sub(/^[ \t\f\r]+/, "", str);
sub(/[ \t\f\r]+$/, "", str);
return str;
}
# ----------------------------------------------------------------------
# list()
function list(str, lst) {
split(str, lst)
for (i in lst) {
lst[lst[i]] = i
delete lst[i];
}
}
# ----------------------------------------------------------------------
# findall()
#
function findall(str, re, array, i) {
array[0] = str
while (match(str, re) > 0) {
i += 1
array[i] = substr(str, RSTART, RLENGTH)
str = substr(str, RSTART+RLENGTH)
}
delete array[0]
}
# ----------------------------------------------------------------------
# get_para()
#
function get_para() {
para = strip($0);
while ((getline > 0) && (text = strip($0)) != "") {
check_line()
if (para ~ /-$/) {
para = para text;
} else if (para ~ /[A-Za-z0-9]\/$/ && text ~ /^[a-z0-9_-]+([)\/]|\.[a-z])/) {
para = para text;
} else if (para ~ /[0-9A-Fa-f]:$/ && text ~ /^[0-9A-Fa-f]+:/) {
para = para text;
} else {
para = para " " text;
}
}
return para;
}
# ----------------------------------------------------------------------
# match_para()
#
function match_para(para, name1, name2, name3, name4) {
name[1] = name1; name[2] = name2; name[3] = name3; name[4] = name4;
for (i=1; i <= 4; i++) {
pat[i] = bp[name[i]];
}
orig = para;
gsub(/ +/, " ", para);
pattern = "";
for (i=1; i <= 4; i++) {
if (!pat[i]) {
almost_boilerplate[name[1]] = orig;
if (option_debug && option_pass2) {
print "** End of patterns **"
}
return 0;
}
gsub(/. /,". ?", pat[i]);
pattern = pattern pat[i];
if (option_debug && option_pass2) {
print "\n----",name[i],"----"
print "line", FNR, "\n"
print ""
print "'"para"'"
print ""
print "'"pattern"'"
print ""
if (para ~ pattern) {
print "** Matches **"
} else {
print "** No Match **"
}
}
if (para ~ pattern) {
for (j=1; j<= i; j++) has[name[j]] = FNR-1;
if (option_debug && option_pass2) {
print "** Exit **"
}
return 1;
}
sub(/ *\$?$/," +", pattern);
if (para ~ pattern) {
if (option_debug && option_pass2) {
print "** Match with trailing text **"
}
for (j=1; j<= i; j++) has[name[j]] = FNR-1;
if (!pat[i+1]) {
if (option_debug && option_pass2) {
print "** Exit: end of patterns **"
}
return 1;
}
} else {
if (option_debug && option_pass2) {
print "** Exit: No prefix match **"
}
for (k=1; k < i; k++) {
pref = pat[k];
sub(/ *\$?$/," +", pref);
sub(pref, "", orig);
}
if (index(substr(bp[name[i]], 1, 32), substr(stripped_orig, 1, 14))) {
almost_boilerplate[name[i]] = orig;
}
return 0;
}
}
almost_boilerplate[name[1]] = orig;
return 0
}
# ----------------------------------------------------------------------
# rindex(str, find)
#
function rindex(str, find, start, pos, incr, i) {
start = 0;
pos = 0;
incr = length(find);
while (1) {
i = index(str, find);
if ( i == 0 ) return pos;
pos = start + i;
str = substr(str, i+incr);
start = start+i+incr-1;
}
}
# ----------------------------------------------------------------------
# fold(str)
#
# This could have been done by piping through fold, too, but we'd have
# to postprocess to add indentation anyway, and this should be a lot
# quicker for short texts.
#
function fold(str, indent, cols, width, pos, lpos, npos) {
pos = 1;
#print "str: ", str;
#print "indent: ", indent;
#print "cols: ", cols;
insert = "\n" indent;
width = cols;
while (pos+width-1 < length(str)) {
frag = substr(str, pos, width);
lpos = rindex(frag, " ");
npos = index(frag, "\n");
if (npos && npos < lpos) lpos = npos;
if (!lpos) {
frag = substr(str, pos+width);
lpos = index(frag, " ");
if (lpos) lpos += width;
}
if (lpos) {
#print "** before break :", "..." substr(str, pos+lpos-9, 8)
#print "** after break :", substr(str, pos+lpos, 8) "..."
str = substr(str, 1, pos+lpos-2) insert substr(str, pos+lpos);
pos = pos + lpos + length(insert);