Commit Graph

346 Commits

Author SHA1 Message Date
Michael Bryant
ee7ad17086 avoid panic when counting zero-sized outputs in count() (#1618)
* avoid panic when counting zero-sized outputs in count()

* run cargo fmt
2023-01-15 21:59:46 +01:00
John Kugelman
3645656644 Clamp Vec::with_capacity to 64KiB to avoid OOM 2022-09-12 21:36:46 +02:00
Geoffroy Couprie
8285735f93 as_slice is not available on array in 1.48 2022-03-14 23:30:39 +01:00
Fredrick Brennan
bb8ef79733 impl<'a> FindToken<char> for &'a [char]
Close Geal/nom#1282.
2022-03-14 22:54:19 +01:00
homersimpsons
00f4085402 Remove dead code (tests/blockbuf-arithmetic.rs) 2021-10-23 22:28:41 +02:00
Guillaume
b4d50017e2 Use [] for vec! macro 2021-10-21 23:16:49 +02:00
cenodis
18cc1d18b9 Remove Clone trait bound from fold parsers
Update documentation
2021-08-09 17:35:40 +02:00
Constantin Nickel
5a65658a95 fix edition idioms 2021-08-09 17:30:00 +02:00
Geoffroy Couprie
d3323ae948 fmt 2021-08-05 18:33:49 +02:00
Constantin Nickel
02ff562092 remove macros from issue tests 2021-08-05 16:18:39 +02:00
Constantin Nickel
71b98465fe remove macros from custom error tests 2021-08-05 16:18:39 +02:00
Constantin Nickel
9601840a2b remove named_args macro and its tests 2021-08-05 16:18:39 +02:00
Constantin Nickel
f54616848f remove macro related tests for previous issues
The type-inference tests for macros are no longer needed.
2021-08-05 16:18:39 +02:00
Constantin Nickel
f8661f3330 replace macros in tests with functions
The deleted tests/test1.rs didn't contain any additional tests and was
depending on an old `stream` feature. It should be covered by the
doctests of the used functions.
2021-08-03 16:15:12 +02:00
Geoffroy Couprie
a59ff75e23 remove the bitvec input type
bitvec integration has caused some dependency issues, that were solved,
but still raises the minimum rust version significantly, which will be
problematic for some distributions like Debian.

The input traits implementations for bitvec types have been moved to the
nom-bitvec crate, so we can keep the functionality without affecting
basic nom usage
2021-07-25 17:57:23 +02:00
Geoffroy Couprie
bd1adeb8ce fmt 2020-11-24 11:29:17 +01:00
Pierre Chifflier
76c52af52f Fix bits and bytes functions, expecting Fn instead of FnMut (Closes #1231) 2020-11-24 10:28:23 +01:00
W. Brian Gourlie
1ddc3959f8 Fix BitVec take_split impl 2020-10-31 15:31:59 +01:00
Geoffroy Couprie
6168f7b7e1 use fold_many0c in the fold_many0 macro 2020-10-25 16:52:40 +01:00
Geoffroy Couprie
b52d460276 fmt 2020-10-24 15:19:14 +02:00
Geoffroy Couprie
8a4efe51e3 the regexp_macros is not used anymore
fix the issues related unit tests that were not compiled anymore
2020-10-11 16:12:42 +02:00
FallenWarrior2k
fcc169195c Make JSON test/bench handle surrogates
This correctly decodes Unicode escapes which resolve to surrogates into
the corresponding character instead of just failing when hitting a
surrogate.
2020-10-11 16:06:08 +02:00
FallenWarrior2k
075cba80d3 Fix UB in JSON test/bench
Use safe version of turning u32 into char because the input might
contain surrogates.
This only fixes a symptom and not the underlying issue that surrogates
are not handled at the moment.
2020-10-11 16:06:08 +02:00
Jamey Sharp
6c643a3932 Correct Incomplete errors from length_data/value
If they didn't have enough input data, these two functions were
returning a `Needed` value reflecting the entire expected length, not
the length remaining after the available input.

As a result, a caller that blocks until the specified number of bytes
are available could get stuck waiting forever.

I've fixed the affected tests at the same time as fixing this bug. For
most of them I made sure the tests would detect this error. But for
`tests/overflow.rs`, I deleted the partial input after the length
instead (meaning the tests pass either way), because I don't think it
matters for the purposes of checking if the parsers have an unsigned
overflow.
2020-10-11 12:01:43 +02:00
myrrlyn
5b427b2268 Add bitvec and implement support for it
The trait implementations permit `bitvec` types to be used directly
within the `bytes` parsers, as demonstrated by the `tests/bitstream`
module using `bytes::tag` to process a bitstream.

This unification allows the removal of the `bits` module in favor of
ordinary combinators written to be generic over a consumable input
type.
2020-09-26 14:51:00 +02:00
Geoffroy Couprie
981d036ca8 replace the basic error tuple with a struct
this will allow implementing traits on the error type
2020-08-24 11:35:14 +02:00
Caleb Sander
13e047e085 Make benchmarks compile again
Also implemented the full JSON specification
2020-08-22 12:32:13 +02:00
Geoffroy Couprie
20a3bb9e1c remove warnings 2020-04-10 16:35:03 +02:00
Geoffroy Couprie
dfc69e59b2 remove the deprecated whitespace module 2020-04-10 16:31:05 +02:00
Geoffroy Couprie
432559c917 add a test for FnMut 2020-04-10 16:17:54 +02:00
Geoffroy Couprie
5475677823 test FnMut usage 2020-04-10 16:01:53 +02:00
Geoffroy Couprie
afad7bf93e formatting 2020-04-10 11:08:18 +02:00
Geoffroy Couprie
e6ebcd7193 rename separated_list to separated_list0
and separated_nonempty_list to separated_list1
2020-04-09 17:27:05 +02:00
Geoffroy Couprie
84d1ac025b move parser implementation to use a Parser trait
this parser trait reproduces the behaviour of previous nom functions,
and uses &mut self instead of &self to allow FnMut closures to be used
as parsers
2020-04-09 16:10:26 +02:00
Geoffroy Couprie
d2d8d7b8c1 remove 8 bytes from Needed and Err
not much improvement on most benchmarks, but error storage will be
cheaper
2020-04-08 15:28:05 +02:00
Geoffroy Couprie
517bc7759c fix panic in convert_error 2020-01-07 19:11:19 +01:00
Aleksander Heintz
6d235a705c
Move test and revert old test 2019-09-13 22:46:29 +02:00
Mathieu Poumeyrol
8829a2a38c fix many_m_n for n=0 2019-07-28 10:42:58 +02:00
Geoffroy Couprie
0efdfac0cc fix MP4 test compilation 2019-06-28 16:35:55 +02:00
Geoffroy Couprie
b16bbf3ff4 only build overflow tests on 64 bits arch 2019-06-24 11:52:09 +02:00
Geoffroy Couprie
5ce22d8d4c fix unit tests 2019-06-17 16:12:06 +02:00
Geoffroy Couprie
f8e32ba4af remove warnings 2019-06-16 12:17:55 +02:00
Geoffroy Couprie
6af969294c fix unit tests 2019-06-16 12:03:34 +02:00
Ankit
fa5b79b613 Fix escaped not returning err on failure 2019-06-13 21:42:10 +02:00
Geoffroy Couprie
f6dd765e6c crate level docs and README update 2019-05-13 17:04:28 +02:00
Geoffroy Couprie
fa743698f7 fix failing test 2019-05-08 19:28:13 +02:00
YOSHIOKA Takuma
01d079e3e9 Stop converting Err::Error to Err::Failure in error::context()
Closes #942.
2019-05-08 10:11:28 +02:00
Geoffroy Couprie
a1390dd56c missing length_bytes 2019-05-06 15:48:56 +02:00
Geoffroy Couprie
58cddb8f2b remove sized_buffer and length_bytes!, add length_data function
also, use the ToUsize trait instead of Into<usize> for safer conversions
2019-05-06 11:38:05 +02:00
Geoffroy Couprie
584cf73529 remove warnings 2019-05-05 10:31:19 +02:00