draft-ietf-netmod-artwork-folding-03.txt | draft-ietf-netmod-artwork-folding-04.txt | |||
---|---|---|---|---|
NETMOD Working Group K. Watsen | NETMOD Working Group K. Watsen | |||
Internet-Draft Watsen Networks | Internet-Draft Watsen Networks | |||
Intended status: Best Current Practice A. Farrel | Intended status: Best Current Practice A. Farrel | |||
Expires: December 1, 2019 Old Dog Consulting | Expires: December 19, 2019 Old Dog Consulting | |||
Q. Wu | Q. Wu | |||
Huawei Technologies | Huawei Technologies | |||
May 30, 2019 | June 17, 2019 | |||
Handling Long Lines in Inclusions in Internet-Drafts and RFCs | Handling Long Lines in Inclusions in Internet-Drafts and RFCs | |||
draft-ietf-netmod-artwork-folding-03 | draft-ietf-netmod-artwork-folding-04 | |||
Abstract | Abstract | |||
This document defines two strategies for handling long lines in | This document defines two strategies for handling long lines in | |||
width-bounded text content. One strategy is based on the historic | width-bounded text content. One strategy is based on the historic | |||
use of a single backslash ('\') character to indicate where line- | use of a single backslash ('\') character to indicate where line- | |||
folding has occurred, with the continuation occurring with the first | folding has occurred, with the continuation occurring with the first | |||
non-space (' ') character on the next line. The second strategy | non-space (' ') character on the next line. The second strategy | |||
extends the first strategy by adding a second backslash character to | extends the first strategy by adding a second backslash character to | |||
identify where the continuation begins and thereby able to handle | identify where the continuation begins and thereby able to handle | |||
skipping to change at page 1, line 42 ¶ | skipping to change at page 1, line 42 ¶ | |||
Internet-Drafts are working documents of the Internet Engineering | Internet-Drafts are working documents of the Internet Engineering | |||
Task Force (IETF). Note that other groups may also distribute | Task Force (IETF). Note that other groups may also distribute | |||
working documents as Internet-Drafts. The list of current Internet- | working documents as Internet-Drafts. The list of current Internet- | |||
Drafts is at https://datatracker.ietf.org/drafts/current/. | Drafts is at https://datatracker.ietf.org/drafts/current/. | |||
Internet-Drafts are draft documents valid for a maximum of six months | Internet-Drafts are draft documents valid for a maximum of six months | |||
and may be updated, replaced, or obsoleted by other documents at any | and may be updated, replaced, or obsoleted by other documents at any | |||
time. It is inappropriate to use Internet-Drafts as reference | time. It is inappropriate to use Internet-Drafts as reference | |||
material or to cite them other than as "work in progress." | material or to cite them other than as "work in progress." | |||
This Internet-Draft will expire on December 1, 2019. | This Internet-Draft will expire on December 19, 2019. | |||
Copyright Notice | Copyright Notice | |||
Copyright (c) 2019 IETF Trust and the persons identified as the | Copyright (c) 2019 IETF Trust and the persons identified as the | |||
document authors. All rights reserved. | document authors. All rights reserved. | |||
This document is subject to BCP 78 and the IETF Trust's Legal | This document is subject to BCP 78 and the IETF Trust's Legal | |||
Provisions Relating to IETF Documents | Provisions Relating to IETF Documents | |||
(https://trustee.ietf.org/license-info) in effect on the date of | (https://trustee.ietf.org/license-info) in effect on the date of | |||
publication of this document. Please review these documents | publication of this document. Please review these documents | |||
skipping to change at page 3, line 12 ¶ | skipping to change at page 3, line 12 ¶ | |||
9.3.1. Using '\' . . . . . . . . . . . . . . . . . . . . . . 14 | 9.3.1. Using '\' . . . . . . . . . . . . . . . . . . . . . . 14 | |||
9.3.2. Using '\\' . . . . . . . . . . . . . . . . . . . . . 15 | 9.3.2. Using '\\' . . . . . . . . . . . . . . . . . . . . . 15 | |||
10. Security Considerations . . . . . . . . . . . . . . . . . . . 16 | 10. Security Considerations . . . . . . . . . . . . . . . . . . . 16 | |||
11. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 16 | 11. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 16 | |||
12. References . . . . . . . . . . . . . . . . . . . . . . . . . 16 | 12. References . . . . . . . . . . . . . . . . . . . . . . . . . 16 | |||
12.1. Normative References . . . . . . . . . . . . . . . . . . 16 | 12.1. Normative References . . . . . . . . . . . . . . . . . . 16 | |||
12.2. Informative References . . . . . . . . . . . . . . . . . 16 | 12.2. Informative References . . . . . . . . . . . . . . . . . 16 | |||
Appendix A. POSIX Shell Script . . . . . . . . . . . . . . . . . 18 | Appendix A. POSIX Shell Script . . . . . . . . . . . . . . . . . 18 | |||
Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . 25 | Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . 25 | |||
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 25 | Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 26 | |||
1. Introduction | 1. Introduction | |||
[RFC7994] sets out the requirements for plain-text RFCs and states | [RFC7994] sets out the requirements for plain-text RFCs and states | |||
that each line of an RFC (and hence of an Internet-Draft) must be | that each line of an RFC (and hence of an Internet-Draft) must be | |||
limited to 72 characters followed by the character sequence that | limited to 72 characters followed by the character sequence that | |||
denotes an end-of-line (EOL). | denotes an end-of-line (EOL). | |||
Internet-Drafts and RFCs often include example text or code | Internet-Drafts and RFCs often include example text or code | |||
fragments. Many times the example text or code exceeds the 72 | fragments. Many times the example text or code exceeds the 72 | |||
skipping to change at page 19, line 9 ¶ | skipping to change at page 19, line 9 ¶ | |||
echo | echo | |||
echo "Usage: $0 [-s <strategy>] [-c <col>] [-r] -i <infile>" | echo "Usage: $0 [-s <strategy>] [-c <col>] [-r] -i <infile>" | |||
echo " -o <outfile>" | echo " -o <outfile>" | |||
echo | echo | |||
echo " -s: strategy to use, '1' or '2' (default: try 1, else 2)" | echo " -s: strategy to use, '1' or '2' (default: try 1, else 2)" | |||
echo " -c: column to fold on (default: 69)" | echo " -c: column to fold on (default: 69)" | |||
echo " -r: reverses the operation" | echo " -r: reverses the operation" | |||
echo " -i: the input filename" | echo " -i: the input filename" | |||
echo " -o: the output filename" | echo " -o: the output filename" | |||
echo " -d: show debug messages" | echo " -d: show debug messages" | |||
echo " -q: quiet (suppress error messages)" | ||||
echo " -h: show this message" | echo " -h: show this message" | |||
echo | echo | |||
echo "Exit status code: zero on success, non-zero otherwise." | echo "Exit status code: zero on success, non-zero otherwise." | |||
echo | echo | |||
} | } | |||
# global vars, do not edit | # global vars, do not edit | |||
strategy=0 # auto | strategy=0 # auto | |||
debug=0 | debug=0 | |||
quiet=0 | ||||
reversed=0 | reversed=0 | |||
infile="" | infile="" | |||
outfile="" | outfile="" | |||
maxcol=69 # default, may be overridden by param | maxcol=69 # default, may be overridden by param | |||
hdr_txt_1="NOTE: '\\' line wrapping per BCP XX (RFC XXXX)" | hdr_txt_1="NOTE: '\\' line wrapping per BCP XX (RFC XXXX)" | |||
hdr_txt_2="NOTE: '\\\\' line wrapping per BCP XX (RFC XXXX)" | hdr_txt_2="NOTE: '\\\\' line wrapping per BCP XX (RFC XXXX)" | |||
equal_chars="==============================================" | equal_chars="==============================================" | |||
space_chars=" " | space_chars=" " | |||
temp_dir="" | temp_dir="" | |||
fold_it_1() { | fold_it_1() { | |||
# ensure input file doesn't contain the fold-sequence already | # ensure input file doesn't contain the fold-sequence already | |||
pcregrep -M "\\\\\n" $infile >> /dev/null 2>&1 | pcregrep -M "\\\\\n" $infile >> /dev/null 2>&1 | |||
if [ $? -eq 0 ]; then | if [[ $? -eq 0 ]]; then | |||
echo | if [[ $quiet -eq 0 ]]; then | |||
echo "Error: infile $infile has a line ending with a '\\'" | echo | |||
echo "character. This file cannot be folded." | echo "Error: infile $infile has a line ending with a '\\'" | |||
echo | echo "character. This file cannot be folded using the '\\'" | |||
echo "strategy." | ||||
echo | ||||
fi | ||||
return 1 | return 1 | |||
fi | fi | |||
# stash some vars | # stash some vars | |||
testcol=`expr "$maxcol" + 1` | testcol=`expr "$maxcol" + 1` | |||
foldcol=`expr "$maxcol" - 1` # for the inserted '\' char | foldcol=`expr "$maxcol" - 1` # for the inserted '\' char | |||
# ensure input file doesn't contain whitespace on the fold column | # ensure input file doesn't contain whitespace on the fold column | |||
grep "^.\{$foldcol\} " $infile >> /dev/null 2>&1 | grep "^.\{$foldcol\} " $infile >> /dev/null 2>&1 | |||
if [ $? -eq 0 ]; then | if [[ $? -eq 0 ]]; then | |||
echo | if [[ $quiet -eq 0 ]]; then | |||
echo "Error: infile has a space character occuring on the" | echo | |||
echo "folding column. This file cannot be folded." | echo "Error: infile has a space character occuring on the" | |||
echo | echo "folding column. This file cannot be folded using the" | |||
echo "'\\' strategy." | ||||
echo | ||||
fi | ||||
return 1 | return 1 | |||
fi | fi | |||
# center header text | # center header text | |||
length=`expr ${#hdr_txt_1} + 2` | length=`expr ${#hdr_txt_1} + 2` | |||
left_sp=`expr \( "$maxcol" - "$length" \) / 2` | left_sp=`expr \( "$maxcol" - "$length" \) / 2` | |||
right_sp=`expr "$maxcol" - "$length" - "$left_sp"` | right_sp=`expr "$maxcol" - "$length" - "$left_sp"` | |||
header=`printf "%.*s %s %.*s" "$left_sp" "$equal_chars"\ | header=`printf "%.*s %s %.*s" "$left_sp" "$equal_chars"\ | |||
"$hdr_txt_1" "$right_sp" "$equal_chars"` | "$hdr_txt_1" "$right_sp" "$equal_chars"` | |||
# generate outfile | # generate outfile | |||
echo "$header" > $outfile | echo "$header" > $outfile | |||
echo "" >> $outfile | echo "" >> $outfile | |||
skipping to change at page 20, line 27 ¶ | skipping to change at page 20, line 36 ¶ | |||
return 0 | return 0 | |||
} | } | |||
fold_it_2() { | fold_it_2() { | |||
if [ "$temp_dir" == "" ]; then | if [ "$temp_dir" == "" ]; then | |||
temp_dir=`mktemp -d` | temp_dir=`mktemp -d` | |||
fi | fi | |||
# ensure input file doesn't contain the fold-sequence already | # ensure input file doesn't contain the fold-sequence already | |||
pcregrep -M "\\\\\n[\ ]*\\\\" $infile >> /dev/null 2>&1 | pcregrep -M "\\\\\n[\ ]*\\\\" $infile >> /dev/null 2>&1 | |||
if [ $? -eq 0 ]; then | if [[ $? -eq 0 ]]; then | |||
echo | if [[ $quiet -eq 0 ]]; then | |||
echo "Error: infile has a line ending with a '\\' character" | echo | |||
echo "followed by a '\\' character as the first non-space" | echo "Error: infile has a line ending with a '\\' character" | |||
echo "character on the next line. This file cannot be folded." | echo "followed by a '\\' character as the first non-space" | |||
echo | echo "character on the next line. This file cannot be folded" | |||
echo "using the '\\\\' strategy." | ||||
echo | ||||
fi | ||||
return 1 | return 1 | |||
fi | fi | |||
# center header text | # center header text | |||
length=`expr ${#hdr_txt_2} + 2` | length=`expr ${#hdr_txt_2} + 2` | |||
left_sp=`expr \( "$maxcol" - "$length" \) / 2` | left_sp=`expr \( "$maxcol" - "$length" \) / 2` | |||
right_sp=`expr "$maxcol" - "$length" - "$left_sp"` | right_sp=`expr "$maxcol" - "$length" - "$left_sp"` | |||
header=`printf "%.*s %s %.*s" "$left_sp" "$equal_chars"\ | header=`printf "%.*s %s %.*s" "$left_sp" "$equal_chars"\ | |||
"$hdr_txt_2" "$right_sp" "$equal_chars"` | "$hdr_txt_2" "$right_sp" "$equal_chars"` | |||
skipping to change at page 21, line 21 ¶ | skipping to change at page 21, line 32 ¶ | |||
echo "" >> $outfile | echo "" >> $outfile | |||
cat $temp_dir/wip2 >> $outfile | cat $temp_dir/wip2 >> $outfile | |||
rm -rf $temp_dir | rm -rf $temp_dir | |||
fi | fi | |||
return 0 | return 0 | |||
} | } | |||
fold_it() { | fold_it() { | |||
# ensure input file doesn't contain a TAB | # ensure input file doesn't contain a TAB | |||
grep $'\t' $infile >> /dev/null 2>&1 | grep $'\t' $infile >> /dev/null 2>&1 | |||
if [ $? -eq 0 ]; then | if [[ $? -eq 0 ]]; then | |||
echo | if [[ $quiet -eq 0 ]]; then | |||
echo "Error: infile contains a TAB character, which is not" | echo | |||
echo "allowed." | echo "Error: infile contains a TAB character, which is" | |||
echo | echo "not allowed." | |||
echo | ||||
fi | ||||
return 1 | return 1 | |||
fi | fi | |||
# check if file needs folding | # check if file needs folding | |||
testcol=`expr "$maxcol" + 1` | testcol=`expr "$maxcol" + 1` | |||
grep ".\{$testcol\}" $infile >> /dev/null 2>&1 | grep ".\{$testcol\}" $infile >> /dev/null 2>&1 | |||
if [ $? -ne 0 ]; then | if [ $? -ne 0 ]; then | |||
if [[ $debug -eq 1 ]]; then | if [[ $debug -eq 1 ]]; then | |||
echo "nothing to do" | echo "nothing to do" | |||
fi | fi | |||
skipping to change at page 21, line 39 ¶ | skipping to change at page 22, line 4 ¶ | |||
# check if file needs folding | # check if file needs folding | |||
testcol=`expr "$maxcol" + 1` | testcol=`expr "$maxcol" + 1` | |||
grep ".\{$testcol\}" $infile >> /dev/null 2>&1 | grep ".\{$testcol\}" $infile >> /dev/null 2>&1 | |||
if [ $? -ne 0 ]; then | if [ $? -ne 0 ]; then | |||
if [[ $debug -eq 1 ]]; then | if [[ $debug -eq 1 ]]; then | |||
echo "nothing to do" | echo "nothing to do" | |||
fi | fi | |||
cp $infile $outfile | cp $infile $outfile | |||
return -1 | return -1 | |||
fi | fi | |||
if [[ $strategy -eq 1 ]]; then | if [[ $strategy -eq 1 ]]; then | |||
fold_it_1 | fold_it_1 | |||
return $? | return $? | |||
fi | fi | |||
if [[ $strategy -eq 2 ]]; then | if [[ $strategy -eq 2 ]]; then | |||
fold_it_2 | fold_it_2 | |||
return $? | return $? | |||
fi | fi | |||
quiet_sav=$quite | ||||
quiet=1 | ||||
fold_it_1 | fold_it_1 | |||
if [ $? -ne 0 ]; then | result=$? | |||
quiet=$quiet_sav | ||||
if [[ $result -ne 0 ]]; then | ||||
if [[ $debug -eq 1 ]]; then | ||||
echo "Folding strategy 1 didn't succeed, trying strategy 2..." | ||||
fi | ||||
fold_it_2 | fold_it_2 | |||
return $? | return $? | |||
fi | fi | |||
return 0 | return 0 | |||
} | } | |||
unfold_it_1() { | unfold_it_1() { | |||
temp_dir=`mktemp -d` | temp_dir=`mktemp -d` | |||
# output all but the first two lines (the header) to wip file | # output all but the first two lines (the header) to wip file | |||
skipping to change at page 23, line 17 ¶ | skipping to change at page 23, line 37 ¶ | |||
process_input() { | process_input() { | |||
while [ "$1" != "" ]; do | while [ "$1" != "" ]; do | |||
if [ "$1" == "-h" -o "$1" == "--help" ]; then | if [ "$1" == "-h" -o "$1" == "--help" ]; then | |||
print_usage | print_usage | |||
exit 1 | exit 1 | |||
fi | fi | |||
if [ "$1" == "-d" ]; then | if [ "$1" == "-d" ]; then | |||
debug=1 | debug=1 | |||
fi | fi | |||
if [ "$1" == "-q" ]; then | ||||
quiet=1 | ||||
fi | ||||
if [ "$1" == "-s" ]; then | if [ "$1" == "-s" ]; then | |||
strategy="$2" | strategy="$2" | |||
shift | shift | |||
fi | fi | |||
if [ "$1" == "-c" ]; then | if [ "$1" == "-c" ]; then | |||
maxcol="$2" | maxcol="$2" | |||
shift | shift | |||
fi | fi | |||
if [ "$1" == "-r" ]; then | if [ "$1" == "-r" ]; then | |||
reversed=1 | reversed=1 | |||
skipping to change at page 23, line 39 ¶ | skipping to change at page 24, line 14 ¶ | |||
infile="$2" | infile="$2" | |||
shift | shift | |||
fi | fi | |||
if [ "$1" == "-o" ]; then | if [ "$1" == "-o" ]; then | |||
outfile="$2" | outfile="$2" | |||
shift | shift | |||
fi | fi | |||
shift | shift | |||
done | done | |||
if [ -z "$infile" ]; then | if [[ -z "$infile" ]]; then | |||
echo | if [[ $quiet -eq 0 ]]; then | |||
echo "Error: infile parameter missing (use -h for help)" | echo | |||
echo | echo "Error: infile parameter missing (use -h for help)" | |||
echo | ||||
fi | ||||
exit 1 | exit 1 | |||
fi | fi | |||
if [ -z "$outfile" ]; then | if [[ -z "$outfile" ]]; then | |||
echo | if [[ $quiet -eq 0 ]]; then | |||
echo "Error: outfile parameter missing (use -h for help)" | echo | |||
echo | echo "Error: outfile parameter missing (use -h for help)" | |||
exit 1 | echo | |||
exit 1 | ||||
fi | ||||
fi | fi | |||
if [ ! -f "$infile" ]; then | ||||
echo | if [[ ! -f "$infile" ]]; then | |||
echo "Error: specified file \"$infile\" is does not exist." | if [[ $quiet -eq 0 ]]; then | |||
echo | echo | |||
exit 1 | echo "Error: specified file \"$infile\" is does not exist." | |||
echo | ||||
exit 1 | ||||
fi | ||||
fi | fi | |||
if [[ $strategy -eq 2 ]]; then | if [[ $strategy -eq 2 ]]; then | |||
min_supported=`expr ${#hdr_txt_2} + 8` | min_supported=`expr ${#hdr_txt_2} + 8` | |||
else | else | |||
min_supported=`expr ${#hdr_txt_1} + 8` | min_supported=`expr ${#hdr_txt_1} + 8` | |||
fi | fi | |||
if [ $maxcol -lt $min_supported ]; then | if [[ $maxcol -lt $min_supported ]]; then | |||
echo | if [[ $quiet -eq 0 ]]; then | |||
echo "Error: the folding column cannot be less than" | echo | |||
echo "$min_supported." | echo "Error: the folding column cannot be less than" | |||
echo | echo "$min_supported." | |||
echo | ||||
fi | ||||
exit 1 | exit 1 | |||
fi | fi | |||
# this is only because the code otherwise runs out of equal_chars | # this is only because the code otherwise runs out of equal_chars | |||
max_supported=`expr ${#equal_chars} + 1 + ${#hdr_txt_1} + 1\ | max_supported=`expr ${#equal_chars} + 1 + ${#hdr_txt_1} + 1\ | |||
+ ${#equal_chars}` | + ${#equal_chars}` | |||
if [ $maxcol -gt $max_supported ]; then | if [[ $maxcol -gt $max_supported ]]; then | |||
echo | if [[ $quiet -eq 0 ]]; then | |||
echo "Error: the folding column cannot be more than" | echo | |||
echo "$max_supported." | echo "Error: the folding column cannot be more than" | |||
echo | echo "$max_supported." | |||
echo | ||||
fi | ||||
exit 1 | exit 1 | |||
fi | fi | |||
} | } | |||
main() { | main() { | |||
if [ "$#" == "0" ]; then | if [ "$#" == "0" ]; then | |||
print_usage | print_usage | |||
exit 1 | exit 1 | |||
fi | fi | |||
End of changes. 21 change blocks. | ||||
52 lines changed or deleted | 87 lines changed or added | |||
This html diff was produced by rfcdiff 1.47. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |