├── .github
└── workflows
│ ├── oss-fuzz.yml
│ └── rust.yml
├── .gitignore
├── CONTRIBUTING.md
├── Cargo.lock
├── Cargo.toml
├── LICENSE
├── README.md
├── code-of-conduct.md
├── examples
└── formatjson5.rs
├── fuzz
├── .gitignore
├── Cargo.toml
└── fuzz_targets
│ └── fuzz_parse.rs
├── rustfmt.toml
├── samples
└── fuzz_fails_fixed
│ ├── clusterfuzz-testcase-minimized-fuzz_parse-4641835596251136
│ ├── clusterfuzz-testcase-minimized-fuzz_parse-4802677486780416
│ ├── clusterfuzz-testcase-minimized-fuzz_parse-4993106563956736
│ ├── clusterfuzz-testcase-minimized-fuzz_parse-5734884822351872
│ ├── clusterfuzz-testcase-minimized-fuzz_parse-6069233958649856
│ ├── clusterfuzz-testcase-minimized-fuzz_parse-6238978431385600
│ ├── clusterfuzz-testcase-minimized-fuzz_parse-6541106597199872
│ ├── clusterfuzz-testcase-minimized-fuzz_parse-6612345919504384
│ └── clusterfuzz-testcase-minimized-fuzz_parse-6642606161920000
├── src
├── content.rs
├── error.rs
├── formatter.rs
├── lib.rs
├── options.rs
└── parser.rs
└── tests
└── lib.rs
/.github/workflows/oss-fuzz.yml:
--------------------------------------------------------------------------------
1 | name: CIFuzz
2 | on: [pull_request]
3 | jobs:
4 | Fuzzing:
5 | runs-on: ubuntu-latest
6 | strategy:
7 | fail-fast: false
8 | matrix:
9 | sanitizer: [address]
10 | # options include 1 or more of sanitizer: [address, undefined, memory]
11 | steps:
12 | - name: Build Fuzzers (${{ matrix.sanitizer }})
13 | id: build
14 | uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
15 | with:
16 | oss-fuzz-project-name: 'json5format'
17 | language: rust
18 | dry-run: false
19 | sanitizer: ${{ matrix.sanitizer }}
20 | - name: Run Fuzzers (${{ matrix.sanitizer }})
21 | uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
22 | with:
23 | oss-fuzz-project-name: 'json5format'
24 | language: rust
25 | fuzz-seconds: 600
26 | dry-run: false
27 | sanitizer: ${{ matrix.sanitizer }}
28 | - name: Upload Crash
29 | uses: actions/upload-artifact@v1
30 | if: failure() && steps.build.outcome == 'success'
31 | with:
32 | name: ${{ matrix.sanitizer }}-artifacts
33 | path: ./out/artifacts
34 |
--------------------------------------------------------------------------------
/.github/workflows/rust.yml:
--------------------------------------------------------------------------------
1 | name: json5format
2 |
3 | on:
4 | push:
5 | branches:
6 | - master
7 | pull_request:
8 | branches:
9 | - master
10 |
11 | jobs:
12 | build:
13 |
14 | runs-on: ubuntu-latest
15 |
16 | steps:
17 | - name: Cancel previous
18 | uses: styfle/cancel-workflow-action@0.8.0
19 | with:
20 | access_token: ${{ github.token }}
21 | - uses: actions/checkout@v2
22 | - name: Run Rustfmt
23 | run: cargo fmt -- --check
24 | - name: Build
25 | run: cargo build --verbose
26 | - name: Clippy
27 | run: cargo clippy --all-targets -- -D warnings
28 | - name: Run tests
29 | run: cargo test --verbose
30 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 | rls*.log
3 | *.swp
4 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # How to Contribute
2 |
3 | We'd love to accept your patches and contributions to this project. There are
4 | just a few small guidelines you need to follow.
5 |
6 | ## Contributor License Agreement
7 |
8 | Contributions to this project must be accompanied by a Contributor License
9 | Agreement. You (or your employer) retain the copyright to your contribution;
10 | this simply gives us permission to use and redistribute your contributions as
11 | part of the project. Head over to to see
12 | your current agreements on file or to sign a new one.
13 |
14 | You generally only need to submit a CLA once, so if you've already submitted one
15 | (even if it was for a different project), you probably don't need to do it
16 | again.
17 |
18 | ## Code reviews
19 |
20 | All submissions, including submissions by project members, require review. We
21 | use GitHub pull requests for this purpose. Consult
22 | [GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
23 | information on using pull requests.
24 |
25 | ## Community Guidelines
26 |
27 | This project follows [Google's Open Source Community
28 | Guidelines](https://opensource.google/conduct/).
29 |
--------------------------------------------------------------------------------
/Cargo.lock:
--------------------------------------------------------------------------------
1 | # This file is automatically @generated by Cargo.
2 | # It is not intended for manual editing.
3 | version = 3
4 |
5 | [[package]]
6 | name = "aho-corasick"
7 | version = "0.7.18"
8 | source = "registry+https://github.com/rust-lang/crates.io-index"
9 | checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f"
10 | dependencies = [
11 | "memchr",
12 | ]
13 |
14 | [[package]]
15 | name = "ansi_term"
16 | version = "0.11.0"
17 | source = "registry+https://github.com/rust-lang/crates.io-index"
18 | checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
19 | dependencies = [
20 | "winapi",
21 | ]
22 |
23 | [[package]]
24 | name = "anyhow"
25 | version = "1.0.28"
26 | source = "registry+https://github.com/rust-lang/crates.io-index"
27 | checksum = "d9a60d744a80c30fcb657dfe2c1b22bcb3e814c1a1e3674f32bf5820b570fbff"
28 |
29 | [[package]]
30 | name = "atty"
31 | version = "0.2.14"
32 | source = "registry+https://github.com/rust-lang/crates.io-index"
33 | checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
34 | dependencies = [
35 | "hermit-abi",
36 | "libc",
37 | "winapi",
38 | ]
39 |
40 | [[package]]
41 | name = "autocfg"
42 | version = "0.1.7"
43 | source = "registry+https://github.com/rust-lang/crates.io-index"
44 | checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2"
45 |
46 | [[package]]
47 | name = "autocfg"
48 | version = "1.0.0"
49 | source = "registry+https://github.com/rust-lang/crates.io-index"
50 | checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d"
51 |
52 | [[package]]
53 | name = "bit-set"
54 | version = "0.5.1"
55 | source = "registry+https://github.com/rust-lang/crates.io-index"
56 | checksum = "e84c238982c4b1e1ee668d136c510c67a13465279c0cb367ea6baf6310620a80"
57 | dependencies = [
58 | "bit-vec",
59 | ]
60 |
61 | [[package]]
62 | name = "bit-vec"
63 | version = "0.5.1"
64 | source = "registry+https://github.com/rust-lang/crates.io-index"
65 | checksum = "f59bbe95d4e52a6398ec21238d31577f2b28a9d86807f06ca59d191d8440d0bb"
66 |
67 | [[package]]
68 | name = "bitflags"
69 | version = "1.2.1"
70 | source = "registry+https://github.com/rust-lang/crates.io-index"
71 | checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
72 |
73 | [[package]]
74 | name = "byteorder"
75 | version = "1.3.4"
76 | source = "registry+https://github.com/rust-lang/crates.io-index"
77 | checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
78 |
79 | [[package]]
80 | name = "cfg-if"
81 | version = "0.1.10"
82 | source = "registry+https://github.com/rust-lang/crates.io-index"
83 | checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
84 |
85 | [[package]]
86 | name = "clap"
87 | version = "2.33.0"
88 | source = "registry+https://github.com/rust-lang/crates.io-index"
89 | checksum = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9"
90 | dependencies = [
91 | "ansi_term",
92 | "atty",
93 | "bitflags",
94 | "strsim",
95 | "textwrap",
96 | "unicode-width",
97 | "vec_map",
98 | ]
99 |
100 | [[package]]
101 | name = "cloudabi"
102 | version = "0.0.3"
103 | source = "registry+https://github.com/rust-lang/crates.io-index"
104 | checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
105 | dependencies = [
106 | "bitflags",
107 | ]
108 |
109 | [[package]]
110 | name = "fnv"
111 | version = "1.0.6"
112 | source = "registry+https://github.com/rust-lang/crates.io-index"
113 | checksum = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3"
114 |
115 | [[package]]
116 | name = "fuchsia-cprng"
117 | version = "0.1.1"
118 | source = "registry+https://github.com/rust-lang/crates.io-index"
119 | checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
120 |
121 | [[package]]
122 | name = "getrandom"
123 | version = "0.1.14"
124 | source = "registry+https://github.com/rust-lang/crates.io-index"
125 | checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb"
126 | dependencies = [
127 | "cfg-if",
128 | "libc",
129 | "wasi",
130 | ]
131 |
132 | [[package]]
133 | name = "heck"
134 | version = "0.3.1"
135 | source = "registry+https://github.com/rust-lang/crates.io-index"
136 | checksum = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205"
137 | dependencies = [
138 | "unicode-segmentation",
139 | ]
140 |
141 | [[package]]
142 | name = "hermit-abi"
143 | version = "0.1.11"
144 | source = "registry+https://github.com/rust-lang/crates.io-index"
145 | checksum = "8a0d737e0f947a1864e93d33fdef4af8445a00d1ed8dc0c8ddb73139ea6abf15"
146 | dependencies = [
147 | "libc",
148 | ]
149 |
150 | [[package]]
151 | name = "json5format"
152 | version = "0.2.6"
153 | dependencies = [
154 | "anyhow",
155 | "lazy_static",
156 | "maplit",
157 | "proptest",
158 | "regex",
159 | "structopt",
160 | ]
161 |
162 | [[package]]
163 | name = "lazy_static"
164 | version = "1.4.0"
165 | source = "registry+https://github.com/rust-lang/crates.io-index"
166 | checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
167 |
168 | [[package]]
169 | name = "libc"
170 | version = "0.2.69"
171 | source = "registry+https://github.com/rust-lang/crates.io-index"
172 | checksum = "99e85c08494b21a9054e7fe1374a732aeadaff3980b6990b94bfd3a70f690005"
173 |
174 | [[package]]
175 | name = "maplit"
176 | version = "1.0.2"
177 | source = "registry+https://github.com/rust-lang/crates.io-index"
178 | checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d"
179 |
180 | [[package]]
181 | name = "memchr"
182 | version = "2.5.0"
183 | source = "registry+https://github.com/rust-lang/crates.io-index"
184 | checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
185 |
186 | [[package]]
187 | name = "num-traits"
188 | version = "0.2.11"
189 | source = "registry+https://github.com/rust-lang/crates.io-index"
190 | checksum = "c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096"
191 | dependencies = [
192 | "autocfg 1.0.0",
193 | ]
194 |
195 | [[package]]
196 | name = "ppv-lite86"
197 | version = "0.2.6"
198 | source = "registry+https://github.com/rust-lang/crates.io-index"
199 | checksum = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b"
200 |
201 | [[package]]
202 | name = "proc-macro2"
203 | version = "0.4.30"
204 | source = "registry+https://github.com/rust-lang/crates.io-index"
205 | checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
206 | dependencies = [
207 | "unicode-xid",
208 | ]
209 |
210 | [[package]]
211 | name = "proptest"
212 | version = "0.9.6"
213 | source = "registry+https://github.com/rust-lang/crates.io-index"
214 | checksum = "01c477819b845fe023d33583ebf10c9f62518c8d79a0960ba5c36d6ac8a55a5b"
215 | dependencies = [
216 | "bit-set",
217 | "bitflags",
218 | "byteorder",
219 | "lazy_static",
220 | "num-traits",
221 | "quick-error",
222 | "rand 0.6.5",
223 | "rand_chacha 0.1.1",
224 | "rand_xorshift",
225 | "regex-syntax",
226 | "rusty-fork",
227 | "tempfile",
228 | ]
229 |
230 | [[package]]
231 | name = "quick-error"
232 | version = "1.2.3"
233 | source = "registry+https://github.com/rust-lang/crates.io-index"
234 | checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
235 |
236 | [[package]]
237 | name = "quote"
238 | version = "0.6.13"
239 | source = "registry+https://github.com/rust-lang/crates.io-index"
240 | checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1"
241 | dependencies = [
242 | "proc-macro2",
243 | ]
244 |
245 | [[package]]
246 | name = "rand"
247 | version = "0.6.5"
248 | source = "registry+https://github.com/rust-lang/crates.io-index"
249 | checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca"
250 | dependencies = [
251 | "autocfg 0.1.7",
252 | "libc",
253 | "rand_chacha 0.1.1",
254 | "rand_core 0.4.2",
255 | "rand_hc 0.1.0",
256 | "rand_isaac",
257 | "rand_jitter",
258 | "rand_os",
259 | "rand_pcg",
260 | "rand_xorshift",
261 | "winapi",
262 | ]
263 |
264 | [[package]]
265 | name = "rand"
266 | version = "0.7.3"
267 | source = "registry+https://github.com/rust-lang/crates.io-index"
268 | checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
269 | dependencies = [
270 | "getrandom",
271 | "libc",
272 | "rand_chacha 0.2.2",
273 | "rand_core 0.5.1",
274 | "rand_hc 0.2.0",
275 | ]
276 |
277 | [[package]]
278 | name = "rand_chacha"
279 | version = "0.1.1"
280 | source = "registry+https://github.com/rust-lang/crates.io-index"
281 | checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef"
282 | dependencies = [
283 | "autocfg 0.1.7",
284 | "rand_core 0.3.1",
285 | ]
286 |
287 | [[package]]
288 | name = "rand_chacha"
289 | version = "0.2.2"
290 | source = "registry+https://github.com/rust-lang/crates.io-index"
291 | checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402"
292 | dependencies = [
293 | "ppv-lite86",
294 | "rand_core 0.5.1",
295 | ]
296 |
297 | [[package]]
298 | name = "rand_core"
299 | version = "0.3.1"
300 | source = "registry+https://github.com/rust-lang/crates.io-index"
301 | checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
302 | dependencies = [
303 | "rand_core 0.4.2",
304 | ]
305 |
306 | [[package]]
307 | name = "rand_core"
308 | version = "0.4.2"
309 | source = "registry+https://github.com/rust-lang/crates.io-index"
310 | checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc"
311 |
312 | [[package]]
313 | name = "rand_core"
314 | version = "0.5.1"
315 | source = "registry+https://github.com/rust-lang/crates.io-index"
316 | checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
317 | dependencies = [
318 | "getrandom",
319 | ]
320 |
321 | [[package]]
322 | name = "rand_hc"
323 | version = "0.1.0"
324 | source = "registry+https://github.com/rust-lang/crates.io-index"
325 | checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4"
326 | dependencies = [
327 | "rand_core 0.3.1",
328 | ]
329 |
330 | [[package]]
331 | name = "rand_hc"
332 | version = "0.2.0"
333 | source = "registry+https://github.com/rust-lang/crates.io-index"
334 | checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"
335 | dependencies = [
336 | "rand_core 0.5.1",
337 | ]
338 |
339 | [[package]]
340 | name = "rand_isaac"
341 | version = "0.1.1"
342 | source = "registry+https://github.com/rust-lang/crates.io-index"
343 | checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08"
344 | dependencies = [
345 | "rand_core 0.3.1",
346 | ]
347 |
348 | [[package]]
349 | name = "rand_jitter"
350 | version = "0.1.4"
351 | source = "registry+https://github.com/rust-lang/crates.io-index"
352 | checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b"
353 | dependencies = [
354 | "libc",
355 | "rand_core 0.4.2",
356 | "winapi",
357 | ]
358 |
359 | [[package]]
360 | name = "rand_os"
361 | version = "0.1.3"
362 | source = "registry+https://github.com/rust-lang/crates.io-index"
363 | checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071"
364 | dependencies = [
365 | "cloudabi",
366 | "fuchsia-cprng",
367 | "libc",
368 | "rand_core 0.4.2",
369 | "rdrand",
370 | "winapi",
371 | ]
372 |
373 | [[package]]
374 | name = "rand_pcg"
375 | version = "0.1.2"
376 | source = "registry+https://github.com/rust-lang/crates.io-index"
377 | checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44"
378 | dependencies = [
379 | "autocfg 0.1.7",
380 | "rand_core 0.4.2",
381 | ]
382 |
383 | [[package]]
384 | name = "rand_xorshift"
385 | version = "0.1.1"
386 | source = "registry+https://github.com/rust-lang/crates.io-index"
387 | checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c"
388 | dependencies = [
389 | "rand_core 0.3.1",
390 | ]
391 |
392 | [[package]]
393 | name = "rdrand"
394 | version = "0.4.0"
395 | source = "registry+https://github.com/rust-lang/crates.io-index"
396 | checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
397 | dependencies = [
398 | "rand_core 0.3.1",
399 | ]
400 |
401 | [[package]]
402 | name = "redox_syscall"
403 | version = "0.1.56"
404 | source = "registry+https://github.com/rust-lang/crates.io-index"
405 | checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84"
406 |
407 | [[package]]
408 | name = "regex"
409 | version = "1.5.6"
410 | source = "registry+https://github.com/rust-lang/crates.io-index"
411 | checksum = "d83f127d94bdbcda4c8cc2e50f6f84f4b611f69c902699ca385a39c3a75f9ff1"
412 | dependencies = [
413 | "aho-corasick",
414 | "memchr",
415 | "regex-syntax",
416 | ]
417 |
418 | [[package]]
419 | name = "regex-syntax"
420 | version = "0.6.26"
421 | source = "registry+https://github.com/rust-lang/crates.io-index"
422 | checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64"
423 |
424 | [[package]]
425 | name = "remove_dir_all"
426 | version = "0.5.2"
427 | source = "registry+https://github.com/rust-lang/crates.io-index"
428 | checksum = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e"
429 | dependencies = [
430 | "winapi",
431 | ]
432 |
433 | [[package]]
434 | name = "rusty-fork"
435 | version = "0.2.2"
436 | source = "registry+https://github.com/rust-lang/crates.io-index"
437 | checksum = "3dd93264e10c577503e926bd1430193eeb5d21b059148910082245309b424fae"
438 | dependencies = [
439 | "fnv",
440 | "quick-error",
441 | "tempfile",
442 | "wait-timeout",
443 | ]
444 |
445 | [[package]]
446 | name = "strsim"
447 | version = "0.8.0"
448 | source = "registry+https://github.com/rust-lang/crates.io-index"
449 | checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
450 |
451 | [[package]]
452 | name = "structopt"
453 | version = "0.2.18"
454 | source = "registry+https://github.com/rust-lang/crates.io-index"
455 | checksum = "16c2cdbf9cc375f15d1b4141bc48aeef444806655cd0e904207edc8d68d86ed7"
456 | dependencies = [
457 | "clap",
458 | "structopt-derive",
459 | ]
460 |
461 | [[package]]
462 | name = "structopt-derive"
463 | version = "0.2.18"
464 | source = "registry+https://github.com/rust-lang/crates.io-index"
465 | checksum = "53010261a84b37689f9ed7d395165029f9cc7abb9f56bbfe86bee2597ed25107"
466 | dependencies = [
467 | "heck",
468 | "proc-macro2",
469 | "quote",
470 | "syn",
471 | ]
472 |
473 | [[package]]
474 | name = "syn"
475 | version = "0.15.44"
476 | source = "registry+https://github.com/rust-lang/crates.io-index"
477 | checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5"
478 | dependencies = [
479 | "proc-macro2",
480 | "quote",
481 | "unicode-xid",
482 | ]
483 |
484 | [[package]]
485 | name = "tempfile"
486 | version = "3.1.0"
487 | source = "registry+https://github.com/rust-lang/crates.io-index"
488 | checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9"
489 | dependencies = [
490 | "cfg-if",
491 | "libc",
492 | "rand 0.7.3",
493 | "redox_syscall",
494 | "remove_dir_all",
495 | "winapi",
496 | ]
497 |
498 | [[package]]
499 | name = "textwrap"
500 | version = "0.11.0"
501 | source = "registry+https://github.com/rust-lang/crates.io-index"
502 | checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
503 | dependencies = [
504 | "unicode-width",
505 | ]
506 |
507 | [[package]]
508 | name = "unicode-segmentation"
509 | version = "1.6.0"
510 | source = "registry+https://github.com/rust-lang/crates.io-index"
511 | checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0"
512 |
513 | [[package]]
514 | name = "unicode-width"
515 | version = "0.1.7"
516 | source = "registry+https://github.com/rust-lang/crates.io-index"
517 | checksum = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479"
518 |
519 | [[package]]
520 | name = "unicode-xid"
521 | version = "0.1.0"
522 | source = "registry+https://github.com/rust-lang/crates.io-index"
523 | checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
524 |
525 | [[package]]
526 | name = "vec_map"
527 | version = "0.8.1"
528 | source = "registry+https://github.com/rust-lang/crates.io-index"
529 | checksum = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a"
530 |
531 | [[package]]
532 | name = "wait-timeout"
533 | version = "0.2.0"
534 | source = "registry+https://github.com/rust-lang/crates.io-index"
535 | checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6"
536 | dependencies = [
537 | "libc",
538 | ]
539 |
540 | [[package]]
541 | name = "wasi"
542 | version = "0.9.0+wasi-snapshot-preview1"
543 | source = "registry+https://github.com/rust-lang/crates.io-index"
544 | checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
545 |
546 | [[package]]
547 | name = "winapi"
548 | version = "0.3.8"
549 | source = "registry+https://github.com/rust-lang/crates.io-index"
550 | checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6"
551 | dependencies = [
552 | "winapi-i686-pc-windows-gnu",
553 | "winapi-x86_64-pc-windows-gnu",
554 | ]
555 |
556 | [[package]]
557 | name = "winapi-i686-pc-windows-gnu"
558 | version = "0.4.0"
559 | source = "registry+https://github.com/rust-lang/crates.io-index"
560 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
561 |
562 | [[package]]
563 | name = "winapi-x86_64-pc-windows-gnu"
564 | version = "0.4.0"
565 | source = "registry+https://github.com/rust-lang/crates.io-index"
566 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
567 |
--------------------------------------------------------------------------------
/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "json5format"
3 | version = "0.2.6"
4 | authors = [
5 | "Rich Kadel ",
6 | "David Tamas-Parris ",
7 | ]
8 | edition = "2018"
9 | keywords = ["json", "json5", "style", "formatter", "comments"]
10 | license = "BSD-3-Clause"
11 | description = "Customizable JSON5 document formatter that preserves comments"
12 | repository = "https://github.com/google/json5format"
13 |
14 | [dependencies]
15 | lazy_static = "1.4"
16 | regex = "1.5.6"
17 |
18 | [dev-dependencies]
19 | anyhow = "1.0.25"
20 | maplit = "1.0.1"
21 | proptest = "0.9.3"
22 | structopt = "0.2.14"
23 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2020 The Fuchsia Authors. All rights reserved.
2 |
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions are
5 | met:
6 |
7 | * Redistributions of source code must retain the above copyright
8 | notice, this list of conditions and the following disclaimer.
9 | * Redistributions in binary form must reproduce the above
10 | copyright notice, this list of conditions and the following disclaimer
11 | in the documentation and/or other materials provided with the
12 | distribution.
13 | * Neither the name of Google LLC nor the names of its
14 | contributors may be used to endorse or promote products derived from
15 | this software without specific prior written permission.
16 |
17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # json5format
2 |
3 | **`json5format` is a general purpose Rust library that formats [JSON5](https://json5.org) (a.k.a., "JSON for Humans"), preserving contextual line and block comments.**
4 |
5 | [](https://crates.io/crates/json5format)
6 | [](https://github.com/google/json5format/LICENSE)
7 | [](https://docs.rs/crate/json5format/)
8 | 
9 |
10 | ## `json5format` Rust library
11 |
12 | The [`json5format` library](https://crates.io/crates/json5format) includes APIs to customize the document format, with style options configurable both globally (affecting the entire document) as well as tailoring specific subsets of a target JSON5 schema. (See the [Rust package documentation](https://docs.rs/json5format/0.1.0/json5format) for more details and examples.) As of version 0.2.0, public APIs allow limited support for accessing the information inside a parsed document, and for injecting or modifying comments.
13 | ## `formatjson5` command line tool
14 |
15 | The `json5format` package also bundles an [example command line tool, `formatjson5`,](https://github.com/google/json5format/blob/master/examples/formatjson5.rs) that formats JSON5 documents using a basic style with some customizations available through command line options:
16 |
17 | ```
18 | $ cargo build --example formatjson5
19 | $ ./target/debug/examples/formatjson5 --help
20 |
21 | formatjson5 [FLAGS] [OPTIONS] [files]...
22 |
23 | FLAGS:
24 | -h, --help Prints help information
25 | -n, --no_trailing_commas Suppress trailing commas (otherwise added by default)
26 | -o, --one_element_lines Objects or arrays with a single child should collapse to a
27 | single line; no trailing comma
28 | -r, --replace Replace (overwrite) the input file with the formatted result
29 | -s, --sort_arrays Sort arrays of primitive values (string, number, boolean, or
30 | null) lexicographically
31 | -V, --version Prints version information
32 |
33 | OPTIONS:
34 | -i, --indent Indent by the given number of spaces [default: 4]
35 |
36 | ARGS:
37 | ... Files to format (use "-" for stdin)
38 | ```
39 |
40 | NOTE: This is not an officially supported Google product.
41 |
--------------------------------------------------------------------------------
/code-of-conduct.md:
--------------------------------------------------------------------------------
1 | # Google Open Source Community Guidelines
2 |
3 | At Google, we recognize and celebrate the creativity and collaboration of open
4 | source contributors and the diversity of skills, experiences, cultures, and
5 | opinions they bring to the projects and communities they participate in.
6 |
7 | Every one of Google's open source projects and communities are inclusive
8 | environments, based on treating all individuals respectfully, regardless of
9 | gender identity and expression, sexual orientation, disabilities,
10 | neurodiversity, physical appearance, body size, ethnicity, nationality, race,
11 | age, religion, or similar personal characteristic.
12 |
13 | We value diverse opinions, but we value respectful behavior more.
14 |
15 | Respectful behavior includes:
16 |
17 | * Being considerate, kind, constructive, and helpful.
18 | * Not engaging in demeaning, discriminatory, harassing, hateful, sexualized, or
19 | physically threatening behavior, speech, and imagery.
20 | * Not engaging in unwanted physical contact.
21 |
22 | Some Google open source projects [may adopt][] an explicit project code of
23 | conduct, which may have additional detailed expectations for participants. Most
24 | of those projects will use our [modified Contributor Covenant][].
25 |
26 | [may adopt]: https://opensource.google/docs/releasing/preparing/#conduct
27 | [modified Contributor Covenant]: https://opensource.google/docs/releasing/template/CODE_OF_CONDUCT/
28 |
29 | ## Resolve peacefully
30 |
31 | We do not believe that all conflict is necessarily bad; healthy debate and
32 | disagreement often yields positive results. However, it is never okay to be
33 | disrespectful.
34 |
35 | If you see someone behaving disrespectfully, you are encouraged to address the
36 | behavior directly with those involved. Many issues can be resolved quickly and
37 | easily, and this gives people more control over the outcome of their dispute.
38 | If you are unable to resolve the matter for any reason, or if the behavior is
39 | threatening or harassing, report it. We are dedicated to providing an
40 | environment where participants feel welcome and safe.
41 |
42 | ## Reporting problems
43 |
44 | Some Google open source projects may adopt a project-specific code of conduct.
45 | In those cases, a Google employee will be identified as the Project Steward,
46 | who will receive and handle reports of code of conduct violations. In the event
47 | that a project hasn’t identified a Project Steward, you can report problems by
48 | emailing opensource@google.com.
49 |
50 | We will investigate every complaint, but you may not receive a direct response.
51 | We will use our discretion in determining when and how to follow up on reported
52 | incidents, which may range from not taking action to permanent expulsion from
53 | the project and project-sponsored spaces. We will notify the accused of the
54 | report and provide them an opportunity to discuss it before any action is
55 | taken. The identity of the reporter will be omitted from the details of the
56 | report supplied to the accused. In potentially harmful situations, such as
57 | ongoing harassment or threats to anyone's safety, we may take action without
58 | notice.
59 |
60 | *This document was adapted from the [IndieWeb Code of Conduct][] and can also
61 | be found at .*
62 |
63 | [IndieWeb Code of Conduct]: https://indieweb.org/code-of-conduct
64 |
--------------------------------------------------------------------------------
/examples/formatjson5.rs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2020 Google LLC All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | //! A command line interface (CLI) tool to format [JSON5](https://json5.org) ("JSON for
6 | //! Humans") documents to a consistent style, preserving comments.
7 | //!
8 | //! See [json5format](../json5format/index.html) for more details.
9 | //!
10 | //! # Usage
11 | //!
12 | //! formatjson5 [FLAGS] [OPTIONS] [files]...
13 | //!
14 | //! FLAGS:
15 | //! -h, --help Prints help information
16 | //! -n, --no_trailing_commas Suppress trailing commas (otherwise added by default)
17 | //! -o, --one_element_lines Objects or arrays with a single child should collapse to a
18 | //! single line; no trailing comma
19 | //! -r, --replace Replace (overwrite) the input file with the formatted result
20 | //! -s, --sort_arrays Sort arrays of primitive values (string, number, boolean, or
21 | //! null) lexicographically
22 | //! -V, --version Prints version information
23 | //!
24 | //! OPTIONS:
25 | //! -i, --indent Indent by the given number of spaces [default: 4]
26 | //!
27 | //! ARGS:
28 | //! ... Files to format (use "-" for stdin)
29 |
30 | #![warn(missing_docs)]
31 |
32 | use anyhow::Result;
33 | use json5format::*;
34 | use std::fs;
35 | use std::io;
36 | use std::io::{Read, Write};
37 | use std::path::PathBuf;
38 | use structopt::StructOpt;
39 |
40 | /// Parses each file in the given `files` vector and returns a parsed object for each JSON5
41 | /// document. If the parser encounters an error in any input file, the command aborts without
42 | /// formatting any of the documents.
43 | fn parse_documents(files: Vec) -> Result, anyhow::Error> {
44 | let mut parsed_documents = Vec::with_capacity(files.len());
45 | for file in files {
46 | let filename = file.clone().into_os_string().to_string_lossy().to_string();
47 | let mut buffer = String::new();
48 | if filename == "-" {
49 | Opt::from_stdin(&mut buffer)?;
50 | } else {
51 | fs::File::open(&file)?.read_to_string(&mut buffer)?;
52 | }
53 |
54 | parsed_documents.push(ParsedDocument::from_string(buffer, Some(filename))?);
55 | }
56 | Ok(parsed_documents)
57 | }
58 |
59 | /// Formats the given parsed documents, applying the given format `options`. If `replace` is true,
60 | /// each input file is overwritten by its formatted version.
61 | fn format_documents(
62 | parsed_documents: Vec,
63 | options: FormatOptions,
64 | replace: bool,
65 | ) -> Result<(), anyhow::Error> {
66 | let format = Json5Format::with_options(options)?;
67 | for (index, parsed_document) in parsed_documents.iter().enumerate() {
68 | let filename = parsed_document.filename().as_ref().unwrap();
69 | let bytes = format.to_utf8(parsed_document)?;
70 | if replace {
71 | Opt::write_to_file(filename, &bytes)?;
72 | } else {
73 | if index > 0 {
74 | println!();
75 | }
76 | if parsed_documents.len() > 1 {
77 | println!("{}:", filename);
78 | println!("{}", "=".repeat(filename.len()));
79 | }
80 | print!("{}", std::str::from_utf8(&bytes)?);
81 | }
82 | }
83 | Ok(())
84 | }
85 |
86 | /// The entry point for the [formatjson5](index.html) command line interface.
87 | fn main() -> Result<()> {
88 | let args = Opt::args();
89 |
90 | if args.files.is_empty() {
91 | return Err(anyhow::anyhow!("No files to format"));
92 | }
93 |
94 | let parsed_documents = parse_documents(args.files)?;
95 |
96 | let options = FormatOptions {
97 | indent_by: args.indent,
98 | trailing_commas: !args.no_trailing_commas,
99 | collapse_containers_of_one: args.one_element_lines,
100 | sort_array_items: args.sort_arrays,
101 | ..Default::default()
102 | };
103 |
104 | format_documents(parsed_documents, options, args.replace)
105 | }
106 |
107 | /// Command line options defined via the structopt! macrorule. These definitions generate the
108 | /// option parsing, validation, and [usage documentation](index.html).
109 | #[derive(Debug, StructOpt)]
110 | #[structopt(
111 | name = "json5format",
112 | about = "Format JSON5 documents to a consistent style, preserving comments."
113 | )]
114 | struct Opt {
115 | /// Files to format (use "-" for stdin)
116 | #[structopt(parse(from_os_str))]
117 | files: Vec,
118 |
119 | /// Replace (overwrite) the input file with the formatted result
120 | #[structopt(short, long)]
121 | replace: bool,
122 |
123 | /// Suppress trailing commas (otherwise added by default)
124 | #[structopt(short, long)]
125 | no_trailing_commas: bool,
126 |
127 | /// Objects or arrays with a single child should collapse to a single line; no trailing comma
128 | #[structopt(short, long)]
129 | one_element_lines: bool,
130 |
131 | /// Sort arrays of primitive values (string, number, boolean, or null) lexicographically
132 | #[structopt(short, long)]
133 | sort_arrays: bool,
134 |
135 | /// Indent by the given number of spaces
136 | #[structopt(short, long, default_value = "4")]
137 | indent: usize,
138 | }
139 |
140 | #[cfg(not(test))]
141 | impl Opt {
142 | fn args() -> Self {
143 | Self::from_args()
144 | }
145 |
146 | fn from_stdin(buf: &mut String) -> Result {
147 | io::stdin().read_to_string(buf)
148 | }
149 |
150 | fn write_to_file(filename: &str, bytes: &[u8]) -> Result<(), io::Error> {
151 | fs::OpenOptions::new()
152 | .create(true)
153 | .truncate(true)
154 | .write(true)
155 | .open(filename)?
156 | .write_all(bytes)
157 | }
158 | }
159 |
160 | #[cfg(test)]
161 | impl Opt {
162 | fn args() -> Self {
163 | if let Some(test_args) = unsafe { &self::tests::TEST_ARGS } {
164 | Self::from_clap(
165 | &Self::clap()
166 | .get_matches_from_safe(test_args)
167 | .expect("failed to parse TEST_ARGS command line arguments"),
168 | )
169 | } else {
170 | Self::from_args()
171 | }
172 | }
173 |
174 | fn from_stdin(mut buf: &mut String) -> Result {
175 | if let Some(test_buffer) = unsafe { &mut self::tests::TEST_BUFFER } {
176 | *buf = test_buffer.clone();
177 | Ok(buf.as_bytes().len())
178 | } else {
179 | io::stdin().read_to_string(&mut buf)
180 | }
181 | }
182 |
183 | fn write_to_file(filename: &str, bytes: &[u8]) -> Result<(), io::Error> {
184 | if filename == "-" {
185 | let buf = std::str::from_utf8(&bytes)
186 | .map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?;
187 | if let Some(test_buffer) = unsafe { &mut self::tests::TEST_BUFFER } {
188 | *test_buffer = buf.to_string();
189 | } else {
190 | print!("{}", buf);
191 | }
192 | Ok(())
193 | } else {
194 | fs::OpenOptions::new()
195 | .create(true)
196 | .truncate(true)
197 | .write(true)
198 | .open(filename)?
199 | .write_all(&bytes)
200 | }
201 | }
202 | }
203 |
204 | #[cfg(test)]
205 | mod tests {
206 |
207 | use super::*;
208 |
209 | pub(crate) static mut TEST_ARGS: Option> = None;
210 | pub(crate) static mut TEST_BUFFER: Option = None;
211 |
212 | #[test]
213 | fn test_main() {
214 | let example_json5 = r##"{
215 | offer: [
216 | {
217 | runner: "elf",
218 | },
219 | {
220 | from: "framework",
221 | to: "#elements",
222 | protocol: "/svc/fuchsia.sys2.Realm",
223 | },
224 | {
225 | to: "#elements",
226 | protocol: [
227 | "/svc/fuchsia.logger.LogSink",
228 | "/svc/fuchsia.cobalt.LoggerFactory",
229 | ],
230 | from: "realm",
231 | },
232 | ],
233 | collections: [
234 | {
235 | name: "elements",
236 | durability: "transient",
237 | }
238 | ],
239 | use: [
240 | {
241 | runner: "elf",
242 | },
243 | {
244 | protocol: "/svc/fuchsia.sys2.Realm",
245 | from: "framework",
246 | },
247 | {
248 | from: "realm",
249 | to: "#elements",
250 | protocol: [
251 | "/svc/fuchsia.logger.LogSink",
252 | "/svc/fuchsia.cobalt.LoggerFactory",
253 | ],
254 | },
255 | ],
256 | children: [
257 | ],
258 | program: {
259 | args: [ "--zarg_first", "zoo_opt", "--arg3", "and_arg3_value" ],
260 | binary: "bin/session_manager",
261 | },
262 | }"##;
263 | let expected = r##"{
264 | offer: [
265 | { runner: "elf" },
266 | {
267 | from: "framework",
268 | to: "#elements",
269 | protocol: "/svc/fuchsia.sys2.Realm"
270 | },
271 | {
272 | to: "#elements",
273 | protocol: [
274 | "/svc/fuchsia.cobalt.LoggerFactory",
275 | "/svc/fuchsia.logger.LogSink"
276 | ],
277 | from: "realm"
278 | }
279 | ],
280 | collections: [
281 | {
282 | name: "elements",
283 | durability: "transient"
284 | }
285 | ],
286 | use: [
287 | { runner: "elf" },
288 | {
289 | protocol: "/svc/fuchsia.sys2.Realm",
290 | from: "framework"
291 | },
292 | {
293 | from: "realm",
294 | to: "#elements",
295 | protocol: [
296 | "/svc/fuchsia.cobalt.LoggerFactory",
297 | "/svc/fuchsia.logger.LogSink"
298 | ]
299 | }
300 | ],
301 | children: [],
302 | program: {
303 | args: [
304 | "--arg3",
305 | "--zarg_first",
306 | "and_arg3_value",
307 | "zoo_opt"
308 | ],
309 | binary: "bin/session_manager"
310 | }
311 | }
312 | "##;
313 | unsafe {
314 | TEST_ARGS = Some(vec![
315 | "formatjson5",
316 | "--replace",
317 | "--no_trailing_commas",
318 | "--one_element_lines",
319 | "--sort_arrays",
320 | "--indent",
321 | "2",
322 | "-",
323 | ]);
324 | TEST_BUFFER = Some(example_json5.to_string());
325 | }
326 | main().expect("test failed");
327 | assert!(unsafe { &TEST_BUFFER }.is_some());
328 | assert_eq!(unsafe { TEST_BUFFER.as_ref().unwrap() }, expected);
329 | }
330 |
331 | #[test]
332 | fn test_args() {
333 | let args = Opt::from_iter(vec![""].iter());
334 | assert_eq!(args.files.len(), 0);
335 | assert_eq!(args.replace, false);
336 | assert_eq!(args.no_trailing_commas, false);
337 | assert_eq!(args.one_element_lines, false);
338 | assert_eq!(args.sort_arrays, false);
339 | assert_eq!(args.indent, 4);
340 |
341 | let some_filename = "some_file.json5";
342 | let args = Opt::from_iter(
343 | vec!["formatjson5", "-r", "-n", "-o", "-s", "-i", "2", some_filename].iter(),
344 | );
345 | assert_eq!(args.files.len(), 1);
346 | assert_eq!(args.replace, true);
347 | assert_eq!(args.no_trailing_commas, true);
348 | assert_eq!(args.one_element_lines, true);
349 | assert_eq!(args.sort_arrays, true);
350 | assert_eq!(args.indent, 2);
351 |
352 | let filename = args.files[0].clone().into_os_string().to_string_lossy().to_string();
353 | assert_eq!(filename, some_filename);
354 | }
355 | }
356 |
--------------------------------------------------------------------------------
/fuzz/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | target
3 | corpus
4 | artifacts
5 |
--------------------------------------------------------------------------------
/fuzz/Cargo.toml:
--------------------------------------------------------------------------------
1 |
2 | [package]
3 | name = "json5format-fuzz"
4 | version = "0.0.0"
5 | authors = ["David Korczynski "]
6 | publish = false
7 | edition = "2018"
8 |
9 | [package.metadata]
10 | cargo-fuzz = true
11 |
12 | [dependencies]
13 | libfuzzer-sys = "0.4.0"
14 |
15 | [dependencies.json5format]
16 | path = ".."
17 |
18 | # Prevent this from interfering with workspaces
19 | [workspace]
20 | members = ["."]
21 |
22 | [[bin]]
23 | name = "fuzz_parse"
24 | path = "fuzz_targets/fuzz_parse.rs"
25 |
--------------------------------------------------------------------------------
/fuzz/fuzz_targets/fuzz_parse.rs:
--------------------------------------------------------------------------------
1 | #![no_main]
2 | use libfuzzer_sys::fuzz_target;
3 | use json5format::*;
4 | use std::str;
5 |
6 | fuzz_target!(|data: &[u8]| {
7 | if let Ok(utf8) = str::from_utf8(data) {
8 | ParsedDocument::from_str(utf8, None);
9 | }
10 | });
11 |
--------------------------------------------------------------------------------
/rustfmt.toml:
--------------------------------------------------------------------------------
1 | # Fuchsia Format Style
2 | # last reviewed: Jan 29, 2019
3 |
4 | # Fuchsia uses 2018 edition only
5 | edition = "2018"
6 |
7 | # The "Default" setting has a heuristic which splits lines too aggresively.
8 | # We are willing to revisit this setting in future versions of rustfmt.
9 | # Bugs:
10 | # * https://github.com/rust-lang/rustfmt/issues/3119
11 | # * https://github.com/rust-lang/rustfmt/issues/3120
12 | use_small_heuristics = "Max"
13 |
14 | # Prevent carriage returns
15 | newline_style = "Unix"
16 |
--------------------------------------------------------------------------------
/samples/fuzz_fails_fixed/clusterfuzz-testcase-minimized-fuzz_parse-4802677486780416:
--------------------------------------------------------------------------------
1 | ]}
--------------------------------------------------------------------------------
/samples/fuzz_fails_fixed/clusterfuzz-testcase-minimized-fuzz_parse-4993106563956736:
--------------------------------------------------------------------------------
1 | {
2 | /*//*//*//*//*//*//*//*//*//@//*174105729,170141183460469231731687303715884105729,170141183460469231731687303715884//*//*//*//*//*//*
3 |
4 | //*//*
5 |
6 |
7 |
8 | //*14118346046923173168730//*/
--------------------------------------------------------------------------------
/samples/fuzz_fails_fixed/clusterfuzz-testcase-minimized-fuzz_parse-5734884822351872:
--------------------------------------------------------------------------------
1 | {//* }
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | //{ //*
11 |
12 |
13 | //**
14 |
15 | //*
16 |
17 | //**
18 |
19 | //*
20 |
21 |
22 | //**
23 |
24 | //*
25 |
26 | //**
27 |
28 | //*
29 |
30 |
31 | //**
32 |
33 | //*
34 |
35 | //**
36 |
37 | //*
38 |
39 |
40 | //**Ozƌ
41 |
42 | //
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | // + [**
51 |
52 | //*
53 |
54 | //**
55 |
56 | //* //*
57 |
58 |
59 | //**
60 |
61 | //*
62 |
63 | //**
64 |
65 | //*
66 |
67 |
68 | //**
69 |
70 | //*
71 |
72 | //**
73 |
74 | //*
75 |
76 |
77 | //**
78 |
79 | //
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 | // + . zzz ':{'ƍIzzzzzzzz zz ':{'ƍIz! zzzzz; zzz ':{'ƍIz z R zzz ':{'ƍ zzz ':{'ƍIzzz ?,! ':{'ƍ zzz ':{'ƍIz zzz ':{'ƍ zzz ':{'ƍ zzz ':{'ƍIz zzzzz ':{'ƍIzzzzzzzz ':{'ƍIzzzzzzzz ?