draft-ietf-netmod-artwork-folding-08.txt | draft-ietf-netmod-artwork-folding-09.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: February 3, 2020 Old Dog Consulting | Expires: March 1, 2020 Old Dog Consulting | |||
Q. Wu | Q. Wu | |||
Huawei Technologies | Huawei Technologies | |||
August 2, 2019 | August 29, 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-08 | draft-ietf-netmod-artwork-folding-09 | |||
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 February 3, 2020. | This Internet-Draft will expire on March 1, 2020. | |||
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 2, line 31 ¶ | skipping to change at page 2, line 31 ¶ | |||
4.1. Automated Folding of Long Lines in Text Content . . . . . 4 | 4.1. Automated Folding of Long Lines in Text Content . . . . . 4 | |||
4.2. Automated Reconstitution of the Original Text Content . . 5 | 4.2. Automated Reconstitution of the Original Text Content . . 5 | |||
5. Limitations . . . . . . . . . . . . . . . . . . . . . . . . . 5 | 5. Limitations . . . . . . . . . . . . . . . . . . . . . . . . . 5 | |||
5.1. Not Recommended for Graphical Artwork . . . . . . . . . . 5 | 5.1. Not Recommended for Graphical Artwork . . . . . . . . . . 5 | |||
5.2. Doesn't Work as Well as Format-Specific Options . . . . . 5 | 5.2. Doesn't Work as Well as Format-Specific Options . . . . . 5 | |||
6. Two Folding Strategies . . . . . . . . . . . . . . . . . . . 6 | 6. Two Folding Strategies . . . . . . . . . . . . . . . . . . . 6 | |||
6.1. Comparison . . . . . . . . . . . . . . . . . . . . . . . 6 | 6.1. Comparison . . . . . . . . . . . . . . . . . . . . . . . 6 | |||
6.2. Recommendation . . . . . . . . . . . . . . . . . . . . . 6 | 6.2. Recommendation . . . . . . . . . . . . . . . . . . . . . 6 | |||
7. The Single Backslash Strategy ('\') . . . . . . . . . . . . . 6 | 7. The Single Backslash Strategy ('\') . . . . . . . . . . . . . 6 | |||
7.1. Folded Structure . . . . . . . . . . . . . . . . . . . . 6 | 7.1. Folded Structure . . . . . . . . . . . . . . . . . . . . 6 | |||
7.1.1. Header . . . . . . . . . . . . . . . . . . . . . . . 7 | 7.1.1. Header . . . . . . . . . . . . . . . . . . . . . . . 6 | |||
7.1.2. Body . . . . . . . . . . . . . . . . . . . . . . . . 7 | 7.1.2. Body . . . . . . . . . . . . . . . . . . . . . . . . 7 | |||
7.2. Algorithm . . . . . . . . . . . . . . . . . . . . . . . . 7 | 7.2. Algorithm . . . . . . . . . . . . . . . . . . . . . . . . 7 | |||
7.2.1. Folding . . . . . . . . . . . . . . . . . . . . . . . 7 | 7.2.1. Folding . . . . . . . . . . . . . . . . . . . . . . . 7 | |||
7.2.2. Unfolding . . . . . . . . . . . . . . . . . . . . . . 9 | 7.2.2. Unfolding . . . . . . . . . . . . . . . . . . . . . . 9 | |||
8. The Double Backslash Strategy ('\\') . . . . . . . . . . . . 9 | 8. The Double Backslash Strategy ('\\') . . . . . . . . . . . . 9 | |||
8.1. Folded Structure . . . . . . . . . . . . . . . . . . . . 9 | 8.1. Folded Structure . . . . . . . . . . . . . . . . . . . . 9 | |||
8.1.1. Header . . . . . . . . . . . . . . . . . . . . . . . 9 | 8.1.1. Header . . . . . . . . . . . . . . . . . . . . . . . 9 | |||
8.1.2. Body . . . . . . . . . . . . . . . . . . . . . . . . 10 | 8.1.2. Body . . . . . . . . . . . . . . . . . . . . . . . . 10 | |||
8.2. Algorithm . . . . . . . . . . . . . . . . . . . . . . . . 10 | 8.2. Algorithm . . . . . . . . . . . . . . . . . . . . . . . . 10 | |||
8.2.1. Folding . . . . . . . . . . . . . . . . . . . . . . . 10 | 8.2.1. Folding . . . . . . . . . . . . . . . . . . . . . . . 10 | |||
skipping to change at page 3, line 13 ¶ | skipping to change at page 3, line 13 ¶ | |||
9.3.2. Using '\\' . . . . . . . . . . . . . . . . . . . . . 15 | 9.3.2. Using '\\' . . . . . . . . . . . . . . . . . . . . . 15 | |||
9.4. Example Showing "Forced" Folding . . . . . . . . . . . . 16 | 9.4. Example Showing "Forced" Folding . . . . . . . . . . . . 16 | |||
9.4.1. Using '\' . . . . . . . . . . . . . . . . . . . . . . 17 | 9.4.1. Using '\' . . . . . . . . . . . . . . . . . . . . . . 17 | |||
9.4.2. Using '\\' . . . . . . . . . . . . . . . . . . . . . 17 | 9.4.2. Using '\\' . . . . . . . . . . . . . . . . . . . . . 17 | |||
10. Security Considerations . . . . . . . . . . . . . . . . . . . 17 | 10. Security Considerations . . . . . . . . . . . . . . . . . . . 17 | |||
11. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 18 | 11. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 18 | |||
12. References . . . . . . . . . . . . . . . . . . . . . . . . . 18 | 12. References . . . . . . . . . . . . . . . . . . . . . . . . . 18 | |||
12.1. Normative References . . . . . . . . . . . . . . . . . . 18 | 12.1. Normative References . . . . . . . . . . . . . . . . . . 18 | |||
12.2. Informative References . . . . . . . . . . . . . . . . . 18 | 12.2. Informative References . . . . . . . . . . . . . . . . . 18 | |||
Appendix A. POSIX Shell Script: rfcfold . . . . . . . . . . . . 19 | Appendix A. POSIX Shell Script: rfcfold . . . . . . . . . . . . 20 | |||
Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . 28 | Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . 29 | |||
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 28 | Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 29 | |||
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 4, line 48 ¶ | skipping to change at page 4, line 48 ¶ | |||
Generally, in order for tooling to be able to process input files, | Generally, in order for tooling to be able to process input files, | |||
the files must be in their original/natural state, which may entail | the files must be in their original/natural state, which may entail | |||
them having some long lines. Thus, these source files need to be | them having some long lines. Thus, these source files need to be | |||
modified before inclusion in the document in order to satisfy the | modified before inclusion in the document in order to satisfy the | |||
line length limits. This modification SHOULD be automated to reduce | line length limits. This modification SHOULD be automated to reduce | |||
effort and errors resulting from manual processing. | effort and errors resulting from manual processing. | |||
Similarly, dynamically generated output (e.g., tree diagrams) must | Similarly, dynamically generated output (e.g., tree diagrams) must | |||
also be modified, if necessary, in order for the resulting document | also be modified, if necessary, in order for the resulting document | |||
to satisfy the line length limits. When needed, this effort again | to satisfy the line length limits. This work should also be | |||
SHOULD be automated to reduce effort and errors resulting from manual | automated to reduce effort and errors resulting from manual | |||
processing. | processing. | |||
4.2. Automated Reconstitution of the Original Text Content | 4.2. Automated Reconstitution of the Original Text Content | |||
Automated reconstitution of the exact original text content is needed | Automated reconstitution of the exact original text content is needed | |||
to support validation of text-based content extracted from documents. | to support validation of text-based content extracted from documents. | |||
For instance, already YANG [RFC7950] modules are extracted from | For instance, already YANG [RFC7950] modules are extracted from | |||
Internet-Drafts and validated as part of the draft-submission | Internet-Drafts and validated as part of the draft-submission | |||
process. Additionally, the desire to validate instance examples | process. Additionally, the desire to validate instance examples | |||
skipping to change at page 5, line 40 ¶ | skipping to change at page 5, line 40 ¶ | |||
It is NOT RECOMMENDED to use the solution presented in this document | It is NOT RECOMMENDED to use the solution presented in this document | |||
on graphical artwork. | on graphical artwork. | |||
5.2. Doesn't Work as Well as Format-Specific Options | 5.2. Doesn't Work as Well as Format-Specific Options | |||
The solution presented in this document works generically for all | The solution presented in this document works generically for all | |||
text-based content, as it only views content as plain text. However, | text-based content, as it only views content as plain text. However, | |||
various formats sometimes have built-in mechanisms that are better | various formats sometimes have built-in mechanisms that are better | |||
suited to prevent long lines. | suited to prevent long lines. | |||
For instance, both the `pyang` and `yanglint` utilities have the | For instance, both the `pyang` [pyang] and `yanglint` [yanglint] | |||
command line option "--tree-line-length" that can be used to indicate | utilities have the command line option "--tree-line-length" that can | |||
a desired maximum line length for when generating tree diagrams | be used to indicate a desired maximum line length for when generating | |||
[RFC8340]. | tree diagrams [RFC8340]. | |||
In another example, some source formats (e.g., YANG [RFC7950]) allow | In another example, some source formats (e.g., YANG [RFC7950]) allow | |||
any quoted string to be broken up into substrings separated by a | any quoted string to be broken up into substrings separated by a | |||
concatenation character (e.g., '+'), any of which can be on a | concatenation character (e.g., '+'), any of which can be on a | |||
different line. | different line. | |||
It is RECOMMENDED that authors do as much as possible within the | It is RECOMMENDED that authors do as much as possible within the | |||
selected format to avoid long lines. | selected format to avoid long lines. | |||
6. Two Folding Strategies | 6. Two Folding Strategies | |||
This document defines two nearly identical strategies for folding | This document defines two nearly identical strategies for folding | |||
text-based content. | text-based content. | |||
The Single Backslash Strategy ('\'): Uses a backslash ('\') | The Single Backslash Strategy ('\'): Uses a backslash ('\') | |||
character at the end of the line where folding occurs, and | character at the end of the line where folding occurs, and | |||
assumes that the continuation begins at the character that is | assumes that the continuation begins at the first character | |||
not a space character (' ') on the following line. | that is not a space character (' ') on the following line. | |||
The Double Backslash Strategy ('\\'): Uses a backslash ('\') | The Double Backslash Strategy ('\\'): Uses a backslash ('\') | |||
character at the end of the line where folding occurs, and | character at the end of the line where folding occurs, and | |||
assumes that the continuation begins after a second backslash | assumes that the continuation begins after a second backslash | |||
('\') character on the following line. | ('\') character on the following line. | |||
6.1. Comparison | 6.1. Comparison | |||
The first strategy produces more readable output, however it is | The first strategy produces more readable output, however it is | |||
significantly more likely to encounter unfoldable input (e.g., there | significantly more likely to encounter unfoldable input (e.g., a long | |||
exists a line anywhere in the input ending with a backslash | line containing only space characters) and, for long lines that can | |||
character, or there exists a long line containing only space | be folded, automation implementations may encounter scenarios that | |||
characters) and, for long lines that can be folded, automation | will produce errors without special care. | |||
implementations may encounter scenarios that will produce errors | ||||
without special care. | ||||
The second strategy produces less readable output, but is unlikely to | The second strategy produces less readable output, but is unlikely to | |||
encounter unfoldable input, there are no long lines that cannot be | encounter unfoldable input, there are no long lines that cannot be | |||
folded, and no special care is required for when folding a long line. | folded, and no special care is required for when folding a long line. | |||
6.2. Recommendation | 6.2. Recommendation | |||
It is RECOMMENDED for implementations to first attempt to fold | It is RECOMMENDED for implementations to first attempt to fold | |||
content using the single backslash strategy and, only in the unlikely | content using the single backslash strategy and, only in the unlikely | |||
event that it cannot fold the input or the folding logic is unable to | event that it cannot fold the input or the folding logic is unable to | |||
skipping to change at page 7, line 9 ¶ | skipping to change at page 7, line 5 ¶ | |||
7.1. Folded Structure | 7.1. Folded Structure | |||
Text content that has been folded as specified by this strategy MUST | Text content that has been folded as specified by this strategy MUST | |||
adhere to the following structure. | adhere to the following structure. | |||
7.1.1. Header | 7.1.1. Header | |||
The header is two lines long. | The header is two lines long. | |||
The first line is the following 45-character string that MAY be | The first line is the following 46-character string that MAY be | |||
surrounded by any number of printable characters. This first line | surrounded by any number of printable characters. This first line | |||
cannot itself be folded. | cannot itself be folded. | |||
NOTE: '\' line wrapping per BCP XX (RFC XXXX) | NOTE: '\' line wrapping per BCP XXX (RFC XXXX) | |||
[Note to RFC Editor: Please replace XX and XXXX with the numbers | [Note to RFC Editor: Please replace XXX and XXXX with the numbers | |||
assigned to this document and delete this note. Please make this | assigned to this document and delete this note. Please make this | |||
change in multiple places in this document.] | change in multiple places in this document.] | |||
The second line is a blank line. This line provides visual | The second line is a empty line, containing only the end-of-line | |||
separation for readability. | character sequence. This line provides visual separation for | |||
readability. | ||||
7.1.2. Body | 7.1.2. Body | |||
The character encoding is the same as described in Section 2 of | The character encoding is the same as described in Section 2 of | |||
[RFC7994], except that, per [RFC7991], tab characters are prohibited. | [RFC7994], except that, per [RFC7991], tab characters are prohibited. | |||
Lines that have a backslash ('\') occurring as the last character in | Lines that have a backslash ('\') occurring as the last character in | |||
a line are considered "folded". | a line are considered "folded". | |||
Really long lines may be folded multiple times. | Really long lines may be folded multiple times. | |||
skipping to change at page 8, line 6 ¶ | skipping to change at page 7, line 50 ¶ | |||
document prior to utilizing the algorithms described in this section. | document prior to utilizing the algorithms described in this section. | |||
For example, the `xiax` utility [xiax] does this. | For example, the `xiax` utility [xiax] does this. | |||
7.2.1. Folding | 7.2.1. Folding | |||
Determine the desired maximum line length from input to the line- | Determine the desired maximum line length from input to the line- | |||
wrapping process, such as from a command line parameter. If no value | wrapping process, such as from a command line parameter. If no value | |||
is explicitly specified, the value "69" SHOULD be used. | is explicitly specified, the value "69" SHOULD be used. | |||
Ensure that the desired maximum line length is not less than the | Ensure that the desired maximum line length is not less than the | |||
minimum header, which is 45 characters. If the desired maximum line | minimum header, which is 46 characters. If the desired maximum line | |||
length is less than this minimum, exit (this text-based content | length is less than this minimum, exit (this text-based content | |||
cannot be folded). | cannot be folded). | |||
Scan the text content for horizontal tab characters. If any | Scan the text content for horizontal tab characters. If any | |||
horizontal tab characters appear, either resolve them to space | horizontal tab characters appear, either resolve them to space | |||
characters or exit, forcing the input provider to convert them to | characters or exit, forcing the input provider to convert them to | |||
space characters themselves first. | space characters themselves first. | |||
Scan the text content to ensure at least one line exceeds the desired | Scan the text content to ensure at least one line exceeds the desired | |||
maximum. If no line exceeds the desired maximum, exit (this text | maximum. If no line exceeds the desired maximum, exit (this text | |||
content does not need to be folded). | content does not need to be folded). | |||
Scan the text content to ensure no existing lines already end with a | Scan the text content to ensure no existing lines already end with a | |||
backslash ('\') character, as this would lead to an ambiguous result. | backslash ('\') character, as this could lead to an ambiguous result. | |||
If such a line is found, and its width is less than the desired | If such a line is found, and its width is less than the desired | |||
maximum, then it SHOULD be flagged for forced folding (folding even | maximum, then it SHOULD be flagged for forced folding (folding even | |||
though unnecessary). If the folding implementation doesn't support | though unnecessary). If the folding implementation doesn't support | |||
forced foldings, it MUST exit. | forced foldings, it MUST exit. | |||
If this text content needs to and can be folded, insert the header | If this text content needs to and can be folded, insert the header | |||
described in Section 7.1.1, ensuring that any additional printable | described in Section 7.1.1, ensuring that any additional printable | |||
characters surrounding the header does not result in a line exceeding | characters surrounding the header do not result in a line exceeding | |||
the desired maximum. | the desired maximum. | |||
For each line in the text content, from top-to-bottom, if the line | For each line in the text content, from top-to-bottom, if the line | |||
exceeds the desired maximum, or requires a forced folding, then fold | exceeds the desired maximum, or requires a forced folding, then fold | |||
the line by: | the line by: | |||
1. Determine where the fold will occur. This location MUST be | 1. Determine where the fold will occur. This location MUST be | |||
before or at the desired maximum column, and MUST NOT be chosen | before or at the desired maximum column, and MUST NOT be chosen | |||
such that the character immediately after the fold is a space (' | such that the character immediately after the fold is a space (' | |||
') character. If no such location can be found, then exit (this | ') character. For forced foldings, the location is between the | |||
text content cannot be folded). | '\' and the end of line sequence. If no such location can be | |||
found, then exit (this text content cannot be folded). | ||||
2. At the location where the fold is to occur, insert a backslash | 2. At the location where the fold is to occur, insert a backslash | |||
('\') character followed by the end of line character sequence. | ('\') character followed by the end of line character sequence. | |||
3. On the following line, insert any number of space (' ') | 3. On the following line, insert any number of space (' ') | |||
characters. | characters. | |||
The result of the previous operation is that the next line starts | The result of the previous operation is that the next line starts | |||
with an arbitrary number of space (' ') characters, followed by the | with an arbitrary number of space (' ') characters, followed by the | |||
character that was previously occupying the position where the fold | character that was previously occupying the position where the fold | |||
skipping to change at page 9, line 46 ¶ | skipping to change at page 9, line 41 ¶ | |||
8.1. Folded Structure | 8.1. Folded Structure | |||
Text content that has been folded as specified by this strategy MUST | Text content that has been folded as specified by this strategy MUST | |||
adhere to the following structure. | adhere to the following structure. | |||
8.1.1. Header | 8.1.1. Header | |||
The header is two lines long. | The header is two lines long. | |||
The first line is the following 46-character string that MAY be | The first line is the following 47-character string that MAY be | |||
surrounded by any number of printable characters. This first line | surrounded by any number of printable characters. This first line | |||
cannot itself be folded. | cannot itself be folded. | |||
NOTE: '\\' line wrapping per BCP XX (RFC XXXX) | NOTE: '\\' line wrapping per BCP XXX (RFC XXXX) | |||
[Note to RFC Editor: Please replace XX and XXXX with the numbers | [Note to RFC Editor: Please replace XXX and XXXX with the numbers | |||
assigned to this document and delete this note. Please make this | assigned to this document and delete this note. Please make this | |||
change in multiple places in this document.] | change in multiple places in this document.] | |||
The second line is a empty line, containing only the end-of-line | ||||
The second line is a blank line. This line provides visual | character sequence. This line provides visual separation for | |||
separation for readability. | readability. | |||
8.1.2. Body | 8.1.2. Body | |||
The character encoding is the same as described in Section 2 of | The character encoding is the same as described in Section 2 of | |||
[RFC7994], except that, per [RFC7991], tab characters are prohibited. | [RFC7994], except that, per [RFC7991], tab characters are prohibited. | |||
Lines that have a backslash ('\') occurring as the last character in | Lines that have a backslash ('\') occurring as the last character in | |||
a line immediately followed by the end of line character sequence, | a line immediately followed by the end of line character sequence, | |||
when the subsequent line starts with a backslash ('\') as the first | when the subsequent line starts with a backslash ('\') as the first | |||
non-space (' ') character, are considered "folded". | non-space (' ') character, are considered "folded". | |||
skipping to change at page 10, line 47 ¶ | skipping to change at page 10, line 41 ¶ | |||
document prior to utilizing the algorithms described in this section. | document prior to utilizing the algorithms described in this section. | |||
For example, the `xiax` utility [xiax] does this. | For example, the `xiax` utility [xiax] does this. | |||
8.2.1. Folding | 8.2.1. Folding | |||
Determine the desired maximum line length from input to the line- | Determine the desired maximum line length from input to the line- | |||
wrapping process, such as from a command line parameter. If no value | wrapping process, such as from a command line parameter. If no value | |||
is explicitly specified, the value "69" SHOULD be used. | is explicitly specified, the value "69" SHOULD be used. | |||
Ensure that the desired maximum line length is not less than the | Ensure that the desired maximum line length is not less than the | |||
minimum header, which is 46 characters. If the desired maximum line | minimum header, which is 47 characters. If the desired maximum line | |||
length is less than this minimum, exit (this text-based content | length is less than this minimum, exit (this text-based content | |||
cannot be folded). | cannot be folded). | |||
Scan the text content for horizontal tab characters. If any | Scan the text content for horizontal tab characters. If any | |||
horizontal tab characters appear, either resolve them to space | horizontal tab characters appear, either resolve them to space | |||
characters or exit, forcing the input provider to convert them to | characters or exit, forcing the input provider to convert them to | |||
space characters themselves first. | space characters themselves first. | |||
Scan the text content to see if any line exceeds the desired maximum. | Scan the text content to see if any line exceeds the desired maximum. | |||
If no line exceeds the desired maximum, exit (this text content does | If no line exceeds the desired maximum, exit (this text content does | |||
skipping to change at page 11, line 21 ¶ | skipping to change at page 11, line 19 ¶ | |||
Scan the text content to ensure no existing lines already end with a | Scan the text content to ensure no existing lines already end with a | |||
backslash ('\') character while the subsequent line starts with a | backslash ('\') character while the subsequent line starts with a | |||
backslash ('\') character as the first non-space (' ') character, as | backslash ('\') character as the first non-space (' ') character, as | |||
this could lead to an ambiguous result. If such a line is found, and | this could lead to an ambiguous result. If such a line is found, and | |||
its width is less than the desired maximum, then it SHOULD be flagged | its width is less than the desired maximum, then it SHOULD be flagged | |||
for forced folding (folding even though unnecessary). If the folding | for forced folding (folding even though unnecessary). If the folding | |||
implementation doesn't support forced foldings, it MUST exit. | implementation doesn't support forced foldings, it MUST exit. | |||
If this text content needs to and can be folded, insert the header | If this text content needs to and can be folded, insert the header | |||
described in Section 8.1.1, ensuring that any additional printable | described in Section 8.1.1, ensuring that any additional printable | |||
characters surrounding the header does not result in a line exceeding | characters surrounding the header do not result in a line exceeding | |||
the desired maximum. | the desired maximum. | |||
For each line in the text content, from top-to-bottom, if the line | For each line in the text content, from top-to-bottom, if the line | |||
exceeds the desired maximum, or requires a forced folding, then fold | exceeds the desired maximum, or requires a forced folding, then fold | |||
the line by: | the line by: | |||
1. Determine where the fold will occur. This location MUST be | 1. Determine where the fold will occur. This location MUST be | |||
before or at the desired maximum column. | before or at the desired maximum column. For forced foldings, | |||
the location is between the '\' and the end of line sequence on | ||||
the first line. | ||||
2. At the location where the fold is to occur, insert a first | 2. At the location where the fold is to occur, insert a first | |||
backslash ('\') character followed by the end of line character | backslash ('\') character followed by the end of line character | |||
sequence. | sequence. | |||
3. On the following line, insert any number of space (' ') | 3. On the following line, insert any number of space (' ') | |||
characters followed by a second backslash ('\') character. | characters followed by a second backslash ('\') character. | |||
The result of the previous operation is that the next line starts | The result of the previous operation is that the next line starts | |||
with an arbitrary number of space (' ') characters, followed by a | with an arbitrary number of space (' ') characters, followed by a | |||
skipping to change at page 13, line 4 ¶ | skipping to change at page 13, line 4 ¶ | |||
be folded. Alas, only the results can be provided. | be folded. Alas, only the results can be provided. | |||
9.1. Example Showing Boundary Conditions | 9.1. Example Showing Boundary Conditions | |||
This example illustrates boundary condition. The input contains | This example illustrates boundary condition. The input contains | |||
seven lines, each line one character longer than the previous line. | seven lines, each line one character longer than the previous line. | |||
Numbers for counting purposes. The default desired maximum column | Numbers for counting purposes. The default desired maximum column | |||
value "69" is used. | value "69" is used. | |||
9.1.1. Using '\' | 9.1.1. Using '\' | |||
=========== NOTE: '\' line wrapping per BCP XX (RFC XXXX) =========== | ========== NOTE: '\' line wrapping per BCP XXX (RFC XXXX) =========== | |||
123456789012345678901234567890123456789012345678901234567890123456 | 123456789012345678901234567890123456789012345678901234567890123456 | |||
1234567890123456789012345678901234567890123456789012345678901234567 | 1234567890123456789012345678901234567890123456789012345678901234567 | |||
12345678901234567890123456789012345678901234567890123456789012345678 | 12345678901234567890123456789012345678901234567890123456789012345678 | |||
123456789012345678901234567890123456789012345678901234567890123456789 | 123456789012345678901234567890123456789012345678901234567890123456789 | |||
12345678901234567890123456789012345678901234567890123456789012345678\ | 12345678901234567890123456789012345678901234567890123456789012345678\ | |||
90 | 90 | |||
12345678901234567890123456789012345678901234567890123456789012345678\ | 12345678901234567890123456789012345678901234567890123456789012345678\ | |||
901 | 901 | |||
12345678901234567890123456789012345678901234567890123456789012345678\ | 12345678901234567890123456789012345678901234567890123456789012345678\ | |||
9012 | 9012 | |||
9.1.2. Using '\\' | 9.1.2. Using '\\' | |||
========== NOTE: '\\' line wrapping per BCP XX (RFC XXXX) =========== | ========== NOTE: '\\' line wrapping per BCP XXX (RFC XXXX) ========== | |||
123456789012345678901234567890123456789012345678901234567890123456 | 123456789012345678901234567890123456789012345678901234567890123456 | |||
1234567890123456789012345678901234567890123456789012345678901234567 | 1234567890123456789012345678901234567890123456789012345678901234567 | |||
12345678901234567890123456789012345678901234567890123456789012345678 | 12345678901234567890123456789012345678901234567890123456789012345678 | |||
123456789012345678901234567890123456789012345678901234567890123456789 | 123456789012345678901234567890123456789012345678901234567890123456789 | |||
12345678901234567890123456789012345678901234567890123456789012345678\ | 12345678901234567890123456789012345678901234567890123456789012345678\ | |||
\90 | \90 | |||
12345678901234567890123456789012345678901234567890123456789012345678\ | 12345678901234567890123456789012345678901234567890123456789012345678\ | |||
\901 | \901 | |||
12345678901234567890123456789012345678901234567890123456789012345678\ | 12345678901234567890123456789012345678901234567890123456789012345678\ | |||
skipping to change at page 13, line 41 ¶ | skipping to change at page 13, line 41 ¶ | |||
9.2. Example Showing Multiple Wraps of a Single Line | 9.2. Example Showing Multiple Wraps of a Single Line | |||
This example illustrates what happens when very long line needs to be | This example illustrates what happens when very long line needs to be | |||
folded multiple times. The input contains one line containing 280 | folded multiple times. The input contains one line containing 280 | |||
characters. Numbers for counting purposes. The default desired | characters. Numbers for counting purposes. The default desired | |||
maximum column value "69" is used. | maximum column value "69" is used. | |||
9.2.1. Using '\' | 9.2.1. Using '\' | |||
=========== NOTE: '\' line wrapping per BCP XX (RFC XXXX) =========== | ========== NOTE: '\' line wrapping per BCP XXX (RFC XXXX) =========== | |||
12345678901234567890123456789012345678901234567890123456789012345678\ | 12345678901234567890123456789012345678901234567890123456789012345678\ | |||
90123456789012345678901234567890123456789012345678901234567890123456\ | 90123456789012345678901234567890123456789012345678901234567890123456\ | |||
78901234567890123456789012345678901234567890123456789012345678901234\ | 78901234567890123456789012345678901234567890123456789012345678901234\ | |||
56789012345678901234567890123456789012345678901234567890123456789012\ | 56789012345678901234567890123456789012345678901234567890123456789012\ | |||
34567890 | 34567890 | |||
9.2.2. Using '\\' | 9.2.2. Using '\\' | |||
========== NOTE: '\\' line wrapping per BCP XX (RFC XXXX) =========== | ========== NOTE: '\\' line wrapping per BCP XXX (RFC XXXX) ========== | |||
12345678901234567890123456789012345678901234567890123456789012345678\ | 12345678901234567890123456789012345678901234567890123456789012345678\ | |||
\9012345678901234567890123456789012345678901234567890123456789012345\ | \9012345678901234567890123456789012345678901234567890123456789012345\ | |||
\6789012345678901234567890123456789012345678901234567890123456789012\ | \6789012345678901234567890123456789012345678901234567890123456789012\ | |||
\3456789012345678901234567890123456789012345678901234567890123456789\ | \3456789012345678901234567890123456789012345678901234567890123456789\ | |||
\01234567890 | \01234567890 | |||
9.3. Example Showing "Smart" Folding | 9.3. Example Showing "Smart" Folding | |||
This example illustrates how readability can be improved via "smart" | This example illustrates how readability can be improved via "smart" | |||
skipping to change at page 14, line 29 ¶ | skipping to change at page 14, line 29 ¶ | |||
format-specific indentations are used. | format-specific indentations are used. | |||
The text content was manually folded, since the script in the | The text content was manually folded, since the script in the | |||
appendix does not implement smart folding. | appendix does not implement smart folding. | |||
Note that the headers are surrounded by different printable | Note that the headers are surrounded by different printable | |||
characters than shown in the script-generated examples. | characters than shown in the script-generated examples. | |||
9.3.1. Using '\' | 9.3.1. Using '\' | |||
[NOTE: '\' line wrapping per BCP XX (RFC XXXX)] | [NOTE: '\' line wrapping per BCP XXX (RFC XXXX)] | |||
<yang-library | <yang-library | |||
xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-library" | xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-library" | |||
xmlns:ds="urn:ietf:params:xml:ns:yang:ietf-datastores"> | xmlns:ds="urn:ietf:params:xml:ns:yang:ietf-datastores"> | |||
<module-set> | <module-set> | |||
<name>config-modules</name> | <name>config-modules</name> | |||
<module> | <module> | |||
<name>ietf-interfaces</name> | <name>ietf-interfaces</name> | |||
<revision>2018-02-20</revision> | <revision>2018-02-20</revision> | |||
skipping to change at page 15, line 5 ¶ | skipping to change at page 15, line 5 ¶ | |||
</namespace> | </namespace> | |||
</module> | </module> | |||
... | ... | |||
</module-set> | </module-set> | |||
... | ... | |||
</yang-library> | </yang-library> | |||
Below is the equivalent to the above, but it was folded using the | Below is the equivalent to the above, but it was folded using the | |||
script in the appendix. | script in the appendix. | |||
=========== NOTE: '\' line wrapping per BCP XX (RFC XXXX) =========== | ========== NOTE: '\' line wrapping per BCP XXX (RFC XXXX) =========== | |||
<yang-library | <yang-library | |||
xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-library" | xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-library" | |||
xmlns:ds="urn:ietf:params:xml:ns:yang:ietf-datastores"> | xmlns:ds="urn:ietf:params:xml:ns:yang:ietf-datastores"> | |||
<module-set> | <module-set> | |||
<name>config-modules</name> | <name>config-modules</name> | |||
<module> | <module> | |||
<name>ietf-interfaces</name> | <name>ietf-interfaces</name> | |||
<revision>2018-02-20</revision> | <revision>2018-02-20</revision> | |||
<namespace>urn:ietf:params:xml:ns:yang:ietf-interfaces</namesp\ | <namespace>urn:ietf:params:xml:ns:yang:ietf-interfaces</namesp\ | |||
ace> | ace> | |||
</module> | </module> | |||
... | ... | |||
</module-set> | </module-set> | |||
... | ... | |||
</yang-library> | </yang-library> | |||
9.3.2. Using '\\' | 9.3.2. Using '\\' | |||
[NOTE: '\\' line wrapping per BCP XX (RFC XXXX)] | [NOTE: '\\' line wrapping per BCP XXX (RFC XXXX)] | |||
<yang-library | <yang-library | |||
xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-library" | xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-library" | |||
xmlns:ds="urn:ietf:params:xml:ns:yang:ietf-datastores"> | xmlns:ds="urn:ietf:params:xml:ns:yang:ietf-datastores"> | |||
<module-set> | <module-set> | |||
<name>config-modules</name> | <name>config-modules</name> | |||
<module> | <module> | |||
<name>ietf-interfaces</name> | <name>ietf-interfaces</name> | |||
<revision>2018-02-20</revision> | <revision>2018-02-20</revision> | |||
skipping to change at page 16, line 5 ¶ | skipping to change at page 16, line 5 ¶ | |||
\</namespace> | \</namespace> | |||
</module> | </module> | |||
... | ... | |||
</module-set> | </module-set> | |||
... | ... | |||
</yang-library> | </yang-library> | |||
Below is the equivalent to the above, but it was folded using the | Below is the equivalent to the above, but it was folded using the | |||
script in the appendix. | script in the appendix. | |||
========== NOTE: '\\' line wrapping per BCP XX (RFC XXXX) =========== | ========== NOTE: '\\' line wrapping per BCP XXX (RFC XXXX) ========== | |||
<yang-library | <yang-library | |||
xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-library" | xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-library" | |||
xmlns:ds="urn:ietf:params:xml:ns:yang:ietf-datastores"> | xmlns:ds="urn:ietf:params:xml:ns:yang:ietf-datastores"> | |||
<module-set> | <module-set> | |||
<name>config-modules</name> | <name>config-modules</name> | |||
<module> | <module> | |||
<name>ietf-interfaces</name> | <name>ietf-interfaces</name> | |||
<revision>2018-02-20</revision> | <revision>2018-02-20</revision> | |||
skipping to change at page 17, line 7 ¶ | skipping to change at page 17, line 7 ¶ | |||
The samples below were manually folded, since the script in the | The samples below were manually folded, since the script in the | |||
appendix does not implement forced folding. | appendix does not implement forced folding. | |||
Note that the headers are prefixed by a pound ('#') character, rather | Note that the headers are prefixed by a pound ('#') character, rather | |||
than surrounded by equal ('=') characters as shown in the script- | than surrounded by equal ('=') characters as shown in the script- | |||
generated examples. | generated examples. | |||
9.4.1. Using '\' | 9.4.1. Using '\' | |||
# NOTE: '\' line wrapping per BCP XX (RFC XXXX) | # NOTE: '\' line wrapping per BCP XXX (RFC XXXX) | |||
The following line exceeds a 68-char max, thus demands folding | The following line exceeds a 68-char max, thus demands folding | |||
1234567890123456789012345678901234567890123456789012345678901234567\ | 1234567890123456789012345678901234567890123456789012345678901234567\ | |||
89 | 89 | |||
This line ends with a backslash \\ | This line ends with a backslash \\ | |||
This line ends with a backslash \\ | This line ends with a backslash \\ | |||
\ This line begins with a backslash | \ This line begins with a backslash | |||
Following is an indented 3x3 block of backslashes: | Following is an indented 3x3 block of backslashes: | |||
\\\\ | \\\\ | |||
\\\\ | \\\\ | |||
\\\ | \\\ | |||
9.4.2. Using '\\' | 9.4.2. Using '\\' | |||
# NOTE: '\\' line wrapping per BCP XX (RFC XXXX) | # NOTE: '\\' line wrapping per BCP XXX (RFC XXXX) | |||
The following line exceeds a 68-char max, thus demands folding | The following line exceeds a 68-char max, thus demands folding | |||
1234567890123456789012345678901234567890123456789012345678901234567\ | 1234567890123456789012345678901234567890123456789012345678901234567\ | |||
\89 | \89 | |||
This line ends with a backslash \ | This line ends with a backslash \ | |||
This line ends with a backslash \\ | This line ends with a backslash \\ | |||
\ | \ | |||
\ This line begins with a backslash | \ This line begins with a backslash | |||
skipping to change at page 18, line 24 ¶ | skipping to change at page 18, line 24 ¶ | |||
Requirement Levels", BCP 14, RFC 2119, | Requirement Levels", BCP 14, RFC 2119, | |||
DOI 10.17487/RFC2119, March 1997, | DOI 10.17487/RFC2119, March 1997, | |||
<https://www.rfc-editor.org/info/rfc2119>. | <https://www.rfc-editor.org/info/rfc2119>. | |||
[RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC | [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC | |||
2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, | 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, | |||
May 2017, <https://www.rfc-editor.org/info/rfc8174>. | May 2017, <https://www.rfc-editor.org/info/rfc8174>. | |||
12.2. Informative References | 12.2. Informative References | |||
[pyang] "An extensible YANG (RFC 6020/7950) validator.", | ||||
<https://pypi.org/project/pyang/>. | ||||
[RFC7749] Reschke, J., "The "xml2rfc" Version 2 Vocabulary", | [RFC7749] Reschke, J., "The "xml2rfc" Version 2 Vocabulary", | |||
RFC 7749, DOI 10.17487/RFC7749, February 2016, | RFC 7749, DOI 10.17487/RFC7749, February 2016, | |||
<https://www.rfc-editor.org/info/rfc7749>. | <https://www.rfc-editor.org/info/rfc7749>. | |||
[RFC7950] Bjorklund, M., Ed., "The YANG 1.1 Data Modeling Language", | [RFC7950] Bjorklund, M., Ed., "The YANG 1.1 Data Modeling Language", | |||
RFC 7950, DOI 10.17487/RFC7950, August 2016, | RFC 7950, DOI 10.17487/RFC7950, August 2016, | |||
<https://www.rfc-editor.org/info/rfc7950>. | <https://www.rfc-editor.org/info/rfc7950>. | |||
[RFC7991] Hoffman, P., "The "xml2rfc" Version 3 Vocabulary", | [RFC7991] Hoffman, P., "The "xml2rfc" Version 3 Vocabulary", | |||
RFC 7991, DOI 10.17487/RFC7991, December 2016, | RFC 7991, DOI 10.17487/RFC7991, December 2016, | |||
skipping to change at page 19, line 5 ¶ | skipping to change at page 19, line 10 ¶ | |||
<https://www.rfc-editor.org/info/rfc8340>. | <https://www.rfc-editor.org/info/rfc8340>. | |||
[xiax] "The `xiax` Python Package", | [xiax] "The `xiax` Python Package", | |||
<https://pypi.org/project/xiax/>. | <https://pypi.org/project/xiax/>. | |||
[yang-doctors-thread] | [yang-doctors-thread] | |||
"[yang-doctors] automating yang doctor reviews", | "[yang-doctors] automating yang doctor reviews", | |||
<https://mailarchive.ietf.org/arch/msg/yang-doctors/ | <https://mailarchive.ietf.org/arch/msg/yang-doctors/ | |||
DCfBqgfZPAD7afzeDFlQ1Xm2X3g>. | DCfBqgfZPAD7afzeDFlQ1Xm2X3g>. | |||
[yanglint] | ||||
"A feature-rich tool for validation and conversion of the | ||||
schemas and YANG modeled data.", | ||||
<https://github.com/CESNET/libyang#yanglint>. | ||||
Appendix A. POSIX Shell Script: rfcfold | Appendix A. POSIX Shell Script: rfcfold | |||
This non-normative appendix section includes a shell script that can | This non-normative appendix section includes a shell script that can | |||
both fold and unfold text content using both the single and double | both fold and unfold text content using both the single and double | |||
backslash strategies described in Section 7 and Section 8 | backslash strategies described in Section 7 and Section 8 | |||
respectively. | respectively. | |||
This script is intended to be applied to a single text content | This script is intended to be applied to a single text content | |||
instance. If it is desired to fold or unfold text content instances | instance. If it is desired to fold or unfold text content instances | |||
within a larger document (e.g., an Internet draft or RFC), then | within a larger document (e.g., an Internet draft or RFC), then | |||
skipping to change at page 19, line 32 ¶ | skipping to change at page 20, line 32 ¶ | |||
('=') characters on each side of the raw header text. | ('=') characters on each side of the raw header text. | |||
This script does not implement the whitespace-avoidance logic | This script does not implement the whitespace-avoidance logic | |||
described in Section 7.2.1. In such case, the script will exit with | described in Section 7.2.1. In such case, the script will exit with | |||
one of the following message: | one of the following message: | |||
Error: infile has a space character occuring on the | Error: infile has a space character occuring on the | |||
folding column. This file cannot be folded using the | folding column. This file cannot be folded using the | |||
'\' strategy. | '\' strategy. | |||
This script does not implement the "forced folding" logic described | While this script can unfold input that contains forced foldings, it | |||
in Section 7.2.1 or Section 8.2.1. In such cases the script will | unable to fold files that would require forced foldings. Forced | |||
exit with one of the following message: | folding is described in Section 7.2.1 and Section 8.2.1. When being | |||
asked to fold a file that would require forced folding, the script | ||||
will instead exit with one of the following messages: | ||||
Error: infile has a line ending with a '\' character | Error: infile has a line ending with a '\' character. | |||
This file cannot be folded using the '\' strategy. | This file cannot be folded using the '\' strategy without | |||
there being false positives produced in the unfolding | ||||
(i.e., this script does not attempt to proactively | ||||
force-fold such lines, as described in RFC XXXX). | ||||
Error: infile has a line ending with a '\' character | Error: infile has a line ending with a '\' character | |||
followed by a '\' character as the first non-space | followed by a '\' character as the first non-space | |||
character on the next line. This script cannot fold | character on the next line. This script cannot fold | |||
this file using '\\' strategy without there being | this file using '\\' strategy without there being | |||
false positives produced in the unfolding (i.e., this | false positives produced in the unfolding (i.e., this | |||
script does not attempt to proactively force-fold such | script does not attempt to proactively force-fold such | |||
lines, as described in RFC XXXX). | lines, as described in RFC XXXX). | |||
Shell-level end-of-line backslash ('\') characters have been | Shell-level end-of-line backslash ('\') characters have been | |||
skipping to change at page 20, line 51 ¶ | skipping to change at page 22, line 8 ¶ | |||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |||
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |||
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | |||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
print_usage() { | print_usage() { | |||
printf "\n" | printf "\n" | |||
printf "Folds or unfolds the input text file according to BCP XX" | printf "Folds or unfolds the input text file according to BCP XXX" | |||
printf " (RFC XXXX).\n" | printf " (RFC XXXX).\n" | |||
printf "\n" | printf "\n" | |||
printf "Usage: rfcfold [-s <strategy>] [-c <col>] [-r] -i <infile>" | printf "Usage: rfcfold [-s <strategy>] [-c <col>] [-r] -i <infile>" | |||
printf " -o <outfile>\n" | printf " -o <outfile>\n" | |||
printf "\n" | printf "\n" | |||
printf " -s: strategy to use, '1' or '2' (default: try 1," | printf " -s: strategy to use, '1' or '2' (default: try 1," | |||
printf " else 2)\n" | printf " else 2)\n" | |||
printf " -c: column to fold on (default: 69)\n" | printf " -c: column to fold on (default: 69)\n" | |||
printf " -r: reverses the operation\n" | printf " -r: reverses the operation\n" | |||
printf " -i: the input filename\n" | printf " -i: the input filename\n" | |||
skipping to change at page 21, line 31 ¶ | skipping to change at page 22, line 36 ¶ | |||
} | } | |||
# global vars, do not edit | # global vars, do not edit | |||
strategy=0 # auto | strategy=0 # auto | |||
debug=0 | debug=0 | |||
quiet=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 XXX (RFC XXXX)" | |||
hdr_txt_2="NOTE: '\\\\' line wrapping per BCP XX (RFC XXXX)" | hdr_txt_2="NOTE: '\\\\' line wrapping per BCP XXX (RFC XXXX)" | |||
equal_chars="=======================================================" | equal_chars="=======================================================" | |||
space_chars=" " | space_chars=" " | |||
temp_dir="" | temp_dir="" | |||
# determine name of [g]sed binary | # determine name of [g]sed binary | |||
type gsed > /dev/null 2>&1 && SED=gsed || SED=sed | type gsed > /dev/null 2>&1 && SED=gsed || SED=sed | |||
# warn if a non-GNU sed utility is used | # warn if a non-GNU sed utility is used | |||
"$SED" --version < /dev/null 2> /dev/null \ | "$SED" --version < /dev/null 2> /dev/null \ | |||
| grep GNU >/dev/null 2>&1 || echo 'Warning: not using GNU `sed`.' | | grep GNU >/dev/null 2>&1 || \ | |||
echo 'Warning: not using GNU `sed` (likely cause if an error occurs)' | ||||
# verify the availability of pcregrep | # verify the availability of pcregrep | |||
type pcregrep > /dev/null 2>&1 || { | type pcregrep > /dev/null 2>&1 || { | |||
echo 'Error: missing utility `pcregrep`' | printf '\nError: missing utility `pcregrep`\n' | |||
exit 1 | exit 1 | |||
} | } | |||
cleanup() { | cleanup() { | |||
rm -rf "$temp_dir" | rm -rf "$temp_dir" | |||
} | } | |||
trap 'cleanup' EXIT | trap 'cleanup' EXIT | |||
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 | |||
if [[ $quiet -eq 0 ]]; then | if [[ $quiet -eq 0 ]]; then | |||
echo | echo | |||
echo "Error: infile $infile has a line ending with a '\\'" | echo "Error: infile $infile has a line ending with a '\\'" | |||
skipping to change at page 22, line 16 ¶ | skipping to change at page 23, line 21 ¶ | |||
trap 'cleanup' EXIT | trap 'cleanup' EXIT | |||
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 | |||
if [[ $quiet -eq 0 ]]; then | if [[ $quiet -eq 0 ]]; then | |||
echo | echo | |||
echo "Error: infile $infile has a line ending with a '\\'" | echo "Error: infile $infile has a line ending with a '\\'" | |||
echo "character. This file cannot be folded using the '\\'" | echo "character. This file cannot be folded using the '\\'" | |||
echo "strategy." | echo "strategy without there being false positives produced" | |||
echo "in the unfolding (i.e., this script does not attempt" | ||||
echo "to proactively force-fold such lines, as described" | ||||
echo "in RFC XXXX)." | ||||
echo | echo | |||
fi | fi | |||
return 1 | return 1 | |||
fi | fi | |||
# where to fold | # where to fold | |||
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 | |||
skipping to change at page 25, line 24 ¶ | skipping to change at page 26, line 31 ¶ | |||
# unfold wip file | # unfold wip file | |||
"$SED" '{H;$!d};x;s/^\n//;s/\\\n *\\//g' $temp_dir/wip > $outfile | "$SED" '{H;$!d};x;s/^\n//;s/\\\n *\\//g' $temp_dir/wip > $outfile | |||
return 0 | return 0 | |||
} | } | |||
unfold_it() { | unfold_it() { | |||
# check if file needs unfolding | # check if file needs unfolding | |||
line=`head -n 1 $infile` | line=`head -n 1 $infile` | |||
line2=`$SED -n '2p' $infile` | ||||
result=`echo $line | fgrep "$hdr_txt_1"` | result=`echo $line | fgrep "$hdr_txt_1"` | |||
if [ $? -eq 0 ]; then | if [ $? -eq 0 ]; then | |||
if [ -n "$line2" ]; then | ||||
if [[ $quiet -eq 0 ]]; then | ||||
echo "Error: the second line is not empty." | ||||
fi | ||||
return 1 | ||||
fi | ||||
unfold_it_1 | unfold_it_1 | |||
return $? | return $? | |||
fi | fi | |||
result=`echo $line | fgrep "$hdr_txt_2"` | result=`echo $line | fgrep "$hdr_txt_2"` | |||
if [ $? -eq 0 ]; then | if [ $? -eq 0 ]; then | |||
if [ -n "$line2" ]; then | ||||
if [[ $quiet -eq 0 ]]; then | ||||
echo "Error: the second line is not empty." | ||||
fi | ||||
return 1 | ||||
fi | ||||
unfold_it_2 | unfold_it_2 | |||
return $? | return $? | |||
fi | fi | |||
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 | |||
} | } | |||
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 0 | |||
fi | fi | |||
if [ "$1" == "-d" ]; then | if [ "$1" == "-d" ]; then | |||
debug=1 | debug=1 | |||
fi | fi | |||
if [ "$1" == "-q" ]; then | if [ "$1" == "-q" ]; then | |||
quiet=1 | quiet=1 | |||
fi | 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 | |||
End of changes. 50 change blocks. | ||||
65 lines changed or deleted | 95 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/ |