Skip to content

Commit

Permalink
tar: Fix 0 trim regression
Browse files Browse the repository at this point in the history
  • Loading branch information
wader committed Nov 21, 2021
1 parent df5bd19 commit 5ad048d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions format/tar/tar.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ func tarDecode(d *decode.D, in interface{}) interface{} {
// TODO: some kind of FieldUScalarFn func that returns sym value?
var n uint64
d.FieldScalar(name, func(_ decode.Scalar) (decode.Scalar, error) {
a := d.UTF8(nBytes)
ts := strings.Trim(a, "0 \x00")
a := d.UTF8NullFixedLen(nBytes)
ts := strings.Trim(a, " ")
n = uint64(0)
if ts != "" {
var err error
Expand Down
12 changes: 6 additions & 6 deletions format/tar/testdata/tar.fqtest
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ $ fq -d tar v /test.tar
| | | [0]: file {} 0x0-0x3ff.7 (1024)
0x0000|74 65 73 74 00 00 00 00 00 00 00 00 00 00 00 00|test............| name: "test" 0x0-0x63.7 (100)
* |until 0x63.7 (100) | |
0x0060| 30 30 30 36 34 34 20 00 | 000644 . | mode: 420 ("000644 \x00") 0x64-0x6b.7 (8)
0x0060| 30 30 30 37| 0007| uid: 501 ("000765 \x00") 0x6c-0x73.7 (8)
0x0060| 30 30 30 36 34 34 20 00 | 000644 . | mode: 420 ("000644 ") 0x64-0x6b.7 (8)
0x0060| 30 30 30 37| 0007| uid: 501 ("000765 ") 0x6c-0x73.7 (8)
0x0070|36 35 20 00 |65 . |
0x0070| 30 30 30 30 32 34 20 00 | 000024 . | gid: 20 ("000024 \x00") 0x74-0x7b.7 (8)
0x0070| 30 30 30 30 32 34 20 00 | 000024 . | gid: 20 ("000024 ") 0x74-0x7b.7 (8)
0x0070| 30 30 30 30| 0000| size: 6 ("00000000006 ") 0x7c-0x87.7 (12)
0x0080|30 30 30 30 30 30 36 20 |0000006 |
0x0080| 31 34 31 33 33 36 32 35| 14133625| mtime: 1634675538 ("14133625522 ") 0x88-0x93.7 (12)
0x0090|35 32 32 20 |522 |
0x0090| 30 31 32 32 32 34 00 20 | 012224. | chksum: 5268 ("012224\x00 ") 0x94-0x9b.7 (8)
0x0090| 30 31 32 32 32 34 00 20 | 012224. | chksum: 5268 ("012224") 0x94-0x9b.7 (8)
0x0090| 30 | 0 | typeflag: "0" 0x9c-0x9c.7 (1)
0x0090| 00 00 00| ...| linkname: "" 0x9d-0x100.7 (100)
0x00a0|00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00|................|
Expand All @@ -27,9 +27,9 @@ $ fq -d tar v /test.tar
0x0120| 73 74 61 66 66 00 00| staff..| gname: "staff" 0x129-0x148.7 (32)
0x0130|00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00|................|
0x0140|00 00 00 00 00 00 00 00 00 |......... |
0x0140| 30 30 30 30 30 30 20| 000000 | devmajor: 0 ("000000 \x00") 0x149-0x150.7 (8)
0x0140| 30 30 30 30 30 30 20| 000000 | devmajor: 0 ("000000 ") 0x149-0x150.7 (8)
0x0150|00 |. |
0x0150| 30 30 30 30 30 30 20 00 | 000000 . | devminor: 0 ("000000 \x00") 0x151-0x158.7 (8)
0x0150| 30 30 30 30 30 30 20 00 | 000000 . | devminor: 0 ("000000 ") 0x151-0x158.7 (8)
0x0150| 00 00 00 00 00 00 00| .......| prefix: "" 0x159-0x1f3.7 (155)
0x0160|00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00|................|
* |until 0x1f3.7 (155) | |
Expand Down

0 comments on commit 5ad048d

Please sign in to comment.