Skip to content

Commit

Permalink
doc: Correct bencode spec URL
Browse files Browse the repository at this point in the history
Also rename _tojq value_sep to object_sep and fix formats_diagram.jq to use tomd5
  • Loading branch information
wader committed Jun 13, 2022
1 parent f46e7df commit 0863374
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
16 changes: 8 additions & 8 deletions doc/formats.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ $ fq -d aac_frame -o object_type=1 . file

Decode value as aac_frame
```
... | aac_frame({object_type: 1})
... | aac_frame({object_type:1})
```

### asn1_ber
Expand Down Expand Up @@ -198,7 +198,7 @@ $ fq -d avc_au -o length_size=4 . file

Decode value as avc_au
```
... | avc_au({length_size: 4})
... | avc_au({length_size:4})
```

### avro_ocf
Expand Down Expand Up @@ -231,7 +231,7 @@ Supports `torepr`

#### References and links

- https://bsonspec.org/spec.html
- https://wiki.theory.org/BitTorrentSpecification#Bencoding

### bson

Expand Down Expand Up @@ -292,7 +292,7 @@ $ fq -d flac_frame -o bits_per_sample=16 . file

Decode value as flac_frame
```
... | flac_frame({bits_per_sample: 16})
... | flac_frame({bits_per_sample:16})
```

### hevc_au
Expand All @@ -312,7 +312,7 @@ $ fq -d hevc_au -o length_size=4 . file

Decode value as hevc_au
```
... | hevc_au({length_size: 4})
... | hevc_au({length_size:4})
```

### macho
Expand Down Expand Up @@ -370,7 +370,7 @@ $ fq -d mp3 -o max_sync_seek=32768 -o max_unique_header_configs=5 . file

Decode value as mp3
```
... | mp3({max_sync_seek: 32768, max_unique_header_configs: 5})
... | mp3({max_sync_seek:32768,max_unique_header_configs:5})
```

### mp4
Expand Down Expand Up @@ -403,7 +403,7 @@ $ fq -d mp4 -o allow_truncated=false -o decode_samples=true . file

Decode value as mp4
```
... | mp4({allow_truncated: false, decode_samples: true})
... | mp4({allow_truncated:false,decode_samples:true})
```

#### References and links
Expand Down Expand Up @@ -470,7 +470,7 @@ $ fq -d zip -o uncompress=true . file

Decode value as zip
```
... | zip({uncompress: true})
... | zip({uncompress:true})
```

#### References and links
Expand Down
2 changes: 1 addition & 1 deletion doc/formats_diagram.jq
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env fq -rnf

def color:
md5 | [.[range(3)]] | map(band(.; 0x7f)+60 | toradix(16) | "0"[length:]+.) | join("");
tomd5 | [.[range(3)]] | map(band(.; 0x7f)+60 | toradix(16) | "0"[length:]+.) | join("");

def _formats_dot:
def _record($title; $fields):
Expand Down
2 changes: 1 addition & 1 deletion format/all/help.fqtest
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ out $ fq -d bencode torepr file
out # Supports torepr
out ... | bencode | torepr
out References and links
out https://bsonspec.org/spec.html
out https://wiki.theory.org/BitTorrentSpecification#Bencoding
"help(bsd_loopback_frame)"
out bsd_loopback_frame: BSD loopback frame decoder
out Examples:
Expand Down
2 changes: 1 addition & 1 deletion format/bencode/bencode.jq
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ def _bencode_torepr:

def _bencode__help:
{ links: [
{url: "https://bsonspec.org/spec.html"}
{url: "https://wiki.theory.org/BitTorrentSpecification#Bencoding"}
]
};
6 changes: 3 additions & 3 deletions pkg/interp/encoding.jq
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def _tojq($opts):
, ( [ to_entries[]
| $prefix, $indent
, (.key | _key), $opts.key_sep
, (.value | _r($prefix+$indent)), $opts.value_sep
, (.value | _r($prefix+$indent)), $opts.object_sep
]
| .[0:-1]
)
Expand All @@ -189,13 +189,13 @@ def tojq($opts):
_tojq(
( { indent: 0,
key_sep: ":",
value_sep: ",",
object_sep: ",",
array_sep: ",",
compound_newline: "",
} + $opts
| if .indent > 0 then
( .key_sep = ": "
| .value_sep = ",\n"
| .object_sep = ",\n"
| .array_sep = ",\n"
| .compound_newline = "\n"
)
Expand Down

0 comments on commit 0863374

Please sign in to comment.