--- 1/draft-ietf-netmod-artwork-folding-03.txt 2019-06-17 11:13:10.709767546 -0700 +++ 2/draft-ietf-netmod-artwork-folding-04.txt 2019-06-17 11:13:10.805769964 -0700 @@ -1,21 +1,21 @@ NETMOD Working Group K. Watsen Internet-Draft Watsen Networks Intended status: Best Current Practice A. Farrel -Expires: December 1, 2019 Old Dog Consulting +Expires: December 19, 2019 Old Dog Consulting Q. Wu Huawei Technologies - May 30, 2019 + June 17, 2019 Handling Long Lines in Inclusions in Internet-Drafts and RFCs - draft-ietf-netmod-artwork-folding-03 + draft-ietf-netmod-artwork-folding-04 Abstract This document defines two strategies for handling long lines in width-bounded text content. One strategy is based on the historic use of a single backslash ('\') character to indicate where line- folding has occurred, with the continuation occurring with the first non-space (' ') character on the next line. The second strategy extends the first strategy by adding a second backslash character to identify where the continuation begins and thereby able to handle @@ -31,21 +31,21 @@ 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 https://datatracker.ietf.org/drafts/current/. 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." - This Internet-Draft will expire on December 1, 2019. + This Internet-Draft will expire on December 19, 2019. Copyright Notice Copyright (c) 2019 IETF Trust and the persons identified as the document authors. All rights reserved. This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents @@ -94,21 +94,21 @@ 9.3.1. Using '\' . . . . . . . . . . . . . . . . . . . . . . 14 9.3.2. Using '\\' . . . . . . . . . . . . . . . . . . . . . 15 10. Security Considerations . . . . . . . . . . . . . . . . . . . 16 11. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 16 12. References . . . . . . . . . . . . . . . . . . . . . . . . . 16 12.1. Normative References . . . . . . . . . . . . . . . . . . 16 12.2. Informative References . . . . . . . . . . . . . . . . . 16 Appendix A. POSIX Shell Script . . . . . . . . . . . . . . . . . 18 Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . 25 - Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 25 + Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 26 1. Introduction [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 limited to 72 characters followed by the character sequence that denotes an end-of-line (EOL). Internet-Drafts and RFCs often include example text or code fragments. Many times the example text or code exceeds the 72 @@ -801,63 +801,72 @@ echo echo "Usage: $0 [-s ] [-c ] [-r] -i " echo " -o " echo echo " -s: strategy to use, '1' or '2' (default: try 1, else 2)" echo " -c: column to fold on (default: 69)" echo " -r: reverses the operation" echo " -i: the input filename" echo " -o: the output filename" echo " -d: show debug messages" + echo " -q: quiet (suppress error messages)" echo " -h: show this message" echo echo "Exit status code: zero on success, non-zero otherwise." echo } # global vars, do not edit strategy=0 # auto debug=0 + quiet=0 reversed=0 infile="" outfile="" maxcol=69 # default, may be overridden by param hdr_txt_1="NOTE: '\\' line wrapping per BCP XX (RFC XXXX)" hdr_txt_2="NOTE: '\\\\' line wrapping per BCP XX (RFC XXXX)" equal_chars="==============================================" space_chars=" " temp_dir="" fold_it_1() { # ensure input file doesn't contain the fold-sequence already pcregrep -M "\\\\\n" $infile >> /dev/null 2>&1 - if [ $? -eq 0 ]; then + if [[ $? -eq 0 ]]; then + if [[ $quiet -eq 0 ]]; then echo echo "Error: infile $infile has a line ending with a '\\'" - echo "character. This file cannot be folded." + echo "character. This file cannot be folded using the '\\'" + echo "strategy." echo + fi return 1 fi # stash some vars testcol=`expr "$maxcol" + 1` foldcol=`expr "$maxcol" - 1` # for the inserted '\' char # ensure input file doesn't contain whitespace on the fold column grep "^.\{$foldcol\} " $infile >> /dev/null 2>&1 - if [ $? -eq 0 ]; then + if [[ $? -eq 0 ]]; then + if [[ $quiet -eq 0 ]]; then echo echo "Error: infile has a space character occuring on the" - echo "folding column. This file cannot be folded." + echo "folding column. This file cannot be folded using the" + echo "'\\' strategy." echo + fi return 1 fi + # center header text length=`expr ${#hdr_txt_1} + 2` left_sp=`expr \( "$maxcol" - "$length" \) / 2` right_sp=`expr "$maxcol" - "$length" - "$left_sp"` header=`printf "%.*s %s %.*s" "$left_sp" "$equal_chars"\ "$hdr_txt_1" "$right_sp" "$equal_chars"` # generate outfile echo "$header" > $outfile echo "" >> $outfile @@ -867,26 +876,29 @@ return 0 } fold_it_2() { if [ "$temp_dir" == "" ]; then temp_dir=`mktemp -d` fi # ensure input file doesn't contain the fold-sequence already pcregrep -M "\\\\\n[\ ]*\\\\" $infile >> /dev/null 2>&1 - if [ $? -eq 0 ]; then + if [[ $? -eq 0 ]]; then + if [[ $quiet -eq 0 ]]; then echo echo "Error: infile has a line ending with a '\\' character" echo "followed by a '\\' character as the first non-space" - echo "character on the next line. This file cannot be folded." + echo "character on the next line. This file cannot be folded" + echo "using the '\\\\' strategy." echo + fi return 1 fi # center header text length=`expr ${#hdr_txt_2} + 2` left_sp=`expr \( "$maxcol" - "$length" \) / 2` right_sp=`expr "$maxcol" - "$length" - "$left_sp"` header=`printf "%.*s %s %.*s" "$left_sp" "$equal_chars"\ "$hdr_txt_2" "$right_sp" "$equal_chars"` @@ -909,25 +920,27 @@ echo "" >> $outfile cat $temp_dir/wip2 >> $outfile rm -rf $temp_dir fi return 0 } fold_it() { # ensure input file doesn't contain a TAB grep $'\t' $infile >> /dev/null 2>&1 - if [ $? -eq 0 ]; then + if [[ $? -eq 0 ]]; then + if [[ $quiet -eq 0 ]]; then echo - echo "Error: infile contains a TAB character, which is not" - echo "allowed." + echo "Error: infile contains a TAB character, which is" + echo "not allowed." echo + fi return 1 fi # check if file needs folding testcol=`expr "$maxcol" + 1` grep ".\{$testcol\}" $infile >> /dev/null 2>&1 if [ $? -ne 0 ]; then if [[ $debug -eq 1 ]]; then echo "nothing to do" fi @@ -927,31 +940,37 @@ # check if file needs folding testcol=`expr "$maxcol" + 1` grep ".\{$testcol\}" $infile >> /dev/null 2>&1 if [ $? -ne 0 ]; then if [[ $debug -eq 1 ]]; then echo "nothing to do" fi cp $infile $outfile return -1 fi - if [[ $strategy -eq 1 ]]; then fold_it_1 return $? fi if [[ $strategy -eq 2 ]]; then fold_it_2 return $? fi + quiet_sav=$quite + quiet=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 return $? fi return 0 } unfold_it_1() { temp_dir=`mktemp -d` # output all but the first two lines (the header) to wip file @@ -1002,20 +1021,23 @@ process_input() { while [ "$1" != "" ]; do if [ "$1" == "-h" -o "$1" == "--help" ]; then print_usage exit 1 fi if [ "$1" == "-d" ]; then debug=1 fi + if [ "$1" == "-q" ]; then + quiet=1 + fi if [ "$1" == "-s" ]; then strategy="$2" shift fi if [ "$1" == "-c" ]; then maxcol="$2" shift fi if [ "$1" == "-r" ]; then reversed=1 @@ -1024,61 +1046,73 @@ infile="$2" shift fi if [ "$1" == "-o" ]; then outfile="$2" shift fi shift done - if [ -z "$infile" ]; then + if [[ -z "$infile" ]]; then + if [[ $quiet -eq 0 ]]; then echo echo "Error: infile parameter missing (use -h for help)" echo + fi exit 1 fi - if [ -z "$outfile" ]; then + if [[ -z "$outfile" ]]; then + if [[ $quiet -eq 0 ]]; then echo echo "Error: outfile parameter missing (use -h for help)" echo exit 1 fi - if [ ! -f "$infile" ]; then + fi + + if [[ ! -f "$infile" ]]; then + if [[ $quiet -eq 0 ]]; then echo echo "Error: specified file \"$infile\" is does not exist." echo exit 1 fi + fi if [[ $strategy -eq 2 ]]; then min_supported=`expr ${#hdr_txt_2} + 8` else min_supported=`expr ${#hdr_txt_1} + 8` fi - if [ $maxcol -lt $min_supported ]; then + if [[ $maxcol -lt $min_supported ]]; then + if [[ $quiet -eq 0 ]]; then echo echo "Error: the folding column cannot be less than" echo "$min_supported." echo + + fi exit 1 fi # this is only because the code otherwise runs out of equal_chars max_supported=`expr ${#equal_chars} + 1 + ${#hdr_txt_1} + 1\ + ${#equal_chars}` - if [ $maxcol -gt $max_supported ]; then + if [[ $maxcol -gt $max_supported ]]; then + if [[ $quiet -eq 0 ]]; then echo echo "Error: the folding column cannot be more than" echo "$max_supported." echo + fi exit 1 fi } main() { if [ "$#" == "0" ]; then print_usage exit 1 fi