vis/unvis: pull in exact implementation from FreeBSD
Perhaps this is not completely ideal, because it brings in cgo. And with the flags, it can have tailored experience. I've added a basic test to ensure that the cases we're interested in are covered. This does not yet integrate the usage of Vis()/Unviz() into the manifest create and compare. Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
cc939615c7
commit
a63f83d94d
6 changed files with 649 additions and 0 deletions
14
vis.go
Normal file
14
vis.go
Normal file
|
@ -0,0 +1,14 @@
|
|||
package mtree
|
||||
|
||||
// #include "vis.h"
|
||||
import "C"
|
||||
import "fmt"
|
||||
|
||||
func Vis(str string) (string, error) {
|
||||
dst := new(C.char)
|
||||
ret := C.strvis(dst, C.CString(str), C.VIS_WHITE|C.VIS_OCTAL|C.VIS_GLOB)
|
||||
if ret == 0 {
|
||||
return "", fmt.Errorf("failed to encode string")
|
||||
}
|
||||
return C.GoString(dst), nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue