This commit adds `cargo update` to the distclean target in the
makefile. This updates the Cargo.lock file when clearing the
deps directory.
In addition, it adds a faster implementation of the Sieve of
Eratosthenes for use by `src/factor/gen_table.rs` and `test/factor.rs`.
I created random data to test several cases. I verified that the data is
split into the correct number of files and can also be reassembled into
the original file.
This change does the following:
1. Updates the arithmetic functions in `src/factor/numeric.rs` to
correctly handle all cases up to 2^64. When numbers are larger
than 2^63, we fall back to slightly slower routines that check
for and handle overflow.
2. Since the arithmetic functions will now not overflow, we no longer
need the safety net trial division implementation. We now always
use Pollard's rho after eliminating small (<=13 bit) primes.
3. Slight tweak in `src/factor/gen_table.rs` to generate the first
1027 primes, which means we test every prime of 13 or fewer bits
before going into Pollard's rho. Includes corresponding update in
`src/factor/prime_table.rs` and the Makefile to reflect this.
4. Add a new test that generates random numbers with exclusively
large (14 to 50 bit) prime factors. This exercises the possible
overflow paths.
5. Add another new test that checks the `is_prime()` function against
a few dozen 64-bit primes. Again this is to exercise possible
overflow paths.
Add a test for `factor`.
This commit also pulls factor's Sieve implementation into its own module
so that the factor test can use it.
Finally, slight refactoring for clarity in gen_table.rs.
This commit builds upon @wikol's Pollard rho implementation.
It adds the following:
1. A generator for prime inverse tables. With these, we can do
very fast divisibility tests (a single multiply and comparison)
for small primes (presently, the first 1000 primes are in the
table, which means all numbers of ~26 bits or less can be
factored very quickly.
2. Always try prime inverse tables before jumping into Pollard's
rho method or using trial division.
3. Since we have eliminated all small factors by the time we're
done with the table division, only use slow trial division when
the number is big enough to cause overflow issues in Pollard's
rho, and jump out of trial division and into Pollard's rho as
soon as the number is small enough.
4. Updates the Makefile to regenerate the prime table if it's not
up-to-date.
This rule will test each program, ignore all output, and return pass or
fail depending on whether the test has errors. This is the equivalent of
"make build-check", but for tests.
This rule will build each program, ignore all output, and return pass or
fail depending on whether the build has errors. This is helpful for
finding out which programs need to be fixed when a new Rust nightly
build inevitably breaks everything.
In the normal case, one does, e.g.,
make TEST="cat" test
This means that the value of EXES in the Makefile contains all
possible targets, which means many prerequisites that aren't
required get built.
With this change, when the `test` target is in effect (and,
in particular, *only* the test target), then the value of
EXES is ignored when calculating dependencies. Otherwise,
the values of EXES and TESTS are both considered.
With this change, individual submodules can specify their dependencies with
an additional file called "deps.mk" in the subdir. When building, only
the dependencies that are necessary are built, using cargo, and then linked.
This greatly simplifies adding new dependencies: add the package in
deps/Cargo.toml, and add the appropriate line in "deps.mk" in the
src/utilname/ directory, and the dependency will be built automatically
as needed.
This also removes the need to use git submodules.
After building the serialize crate, the rlib was copied to the build
directory using a hyphen in the library name ('librustc-serialize').
It seems that Rust expects an underscore instead.
This patch begins the work of modernizing uutils to work with 1.0-ish
Rust. In particular, it
1. Updates to the latest submodules.
2. Convert mkmain.rs, mkuutils.rs, and src/uutils/uutils.rs
to new slice syntax and use of new io, fs, and path APIs.
3. Convert src/common/util.rs to new io, fs, and path APIs.
4. Convert fmt to use new APIs.
This implementation uses rust's concept of characters and fails if the
input isn't valid utf-8. GNU cut implements '--characters' as an alias
for '--bytes' and thus has different semantics, for this option, from
this implemtation.
It requires the BUSYBOX_SRC environment variable to be set,
and optionally passes arguments to the busybox test runner with
the RUNTEST_ARGS environment variable.
Example:
```
make busytest MULTICALL=1 BUSYBOX_SRC=~/dev/busybox RUNTEST_ARGS=tr
```
Squashed commit of the following:
commit 7b7981d315dd7748287bedc8f6417bbc2f9cb1ee
Author: Nick Platt <platt.nicholas@gmail.com>
Date: Sat May 24 00:33:49 2014 -0400
Last minute touchups
commit dae70f52e2b485695e8c7e2ce8d2997f571afcab
Author: Nick Platt <platt.nicholas@gmail.com>
Date: Fri May 23 23:43:24 2014 -0400
Minor indentation fixes
commit 782a02fe2768cf9e457bb6db9e8a63615c3a4bd1
Author: Nick Platt <platt.nicholas@gmail.com>
Date: Fri May 23 23:40:57 2014 -0400
Fixes for latest rust
commit 51b0e59f75352bf65c89d2ab8cf0948da8404753
Author: Nick Platt <platt.nicholas@gmail.com>
Date: Sun Apr 27 15:15:29 2014 -0400
Fixups
commit 9efd1f4c07f4610e3067a5b2bd047eb117344cdf
Author: Nick Platt <platt.nicholas@gmail.com>
Date: Sun Apr 27 14:20:11 2014 -0400
Basic date and timestamp support
commit a354bc9c07a6ed2cd2748f1734a1ce0f6683e58c
Author: Nick Platt <platt.nicholas@gmail.com>
Date: Sun Apr 27 01:37:37 2014 -0400
Primary functionality in place
commit 8bbaa0caa34fbca129db0c86f32d376d6eafbe18
Author: Nick Platt <platt.nicholas@gmail.com>
Date: Sat Apr 26 22:23:16 2014 -0400
Support creating files
commit 5bf47c3c790b556b596d25a05cd74ca4c06b6d67
Author: Nick Platt <platt.nicholas@gmail.com>
Date: Mon Apr 21 00:24:49 2014 -0400
Add touch with basic usage text