mirror of
https://github.com/vbatts/go-mtree.git
synced 2025-07-03 14:28:28 +00:00
vis: rewrite to use byte slices
This results in all multi-byte characters to be encoded in a way that naive unvis(3) implementations will not bork up the encoding. In addition, it also ensures that the output of Vis will always be ASCII *only*. Also test far more cases in *_test.go when it comes to different flags, and do far more tests to ensure that the output of Vis() makes sense. These outputs come directly from vis(3) and so are useful regression tests to ensure that the handling of Vis() is identical to the original. Signed-off-by: Aleksa Sarai <asarai@suse.de>
This commit is contained in:
parent
c2a9f1a56d
commit
4045484afb
3 changed files with 171 additions and 82 deletions
19
govis.go
19
govis.go
|
@ -23,15 +23,16 @@ type VisFlag uint
|
|||
// mtree only uses one set of flags, implementing them all is necessary in
|
||||
// order to have compatibility with BSD's vis() and unvis() commands.
|
||||
const (
|
||||
VisOctal VisFlag = (1 << iota) // VIS_OCTAL: Use octal \ddd format.
|
||||
VisCStyle // VIS_CSTYLE: Use \[nrft0..] where appropriate.
|
||||
VisSpace // VIS_SP: Also encode space.
|
||||
VisTab // VIS_TAB: Also encode tab.
|
||||
VisNewline // VIS_NL: Also encode newline.
|
||||
VisSafe // VIS_SAFE: Encode unsafe characters.
|
||||
VisNoSlash // VIS_NOSLASH: Inhibit printing '\'.
|
||||
VisHTTPStyle // VIS_HTTPSTYLE: HTTP-style escape %xx.
|
||||
VisGlob // VIS_GLOB: Encode glob(3) magics.
|
||||
VisOctal VisFlag = (1 << iota) // VIS_OCTAL: Use octal \ddd format.
|
||||
VisCStyle // VIS_CSTYLE: Use \[nrft0..] where appropriate.
|
||||
VisSpace // VIS_SP: Also encode space.
|
||||
VisTab // VIS_TAB: Also encode tab.
|
||||
VisNewline // VIS_NL: Also encode newline.
|
||||
VisSafe // VIS_SAFE: Encode unsafe characters.
|
||||
VisNoSlash // VIS_NOSLASH: Inhibit printing '\'.
|
||||
VisHTTPStyle // VIS_HTTPSTYLE: HTTP-style escape %xx.
|
||||
VisGlob // VIS_GLOB: Encode glob(3) magics.
|
||||
visMask VisFlag = (1 << iota) - 1 // Mask of all flags.
|
||||
|
||||
VisWhite VisFlag = (VisSpace | VisTab | VisNewline)
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue