Commit graph

56 commits

Author SHA1 Message Date
Erik Vesteraas
21d9152cfe cat: Collect output state into a struct 2017-01-23 11:07:47 +01:00
Erik Vesteraas
81996915df cat: fix for numbered lines w/ no trailing newline
Make at_line_start persist between printing each file. This fixes an
issue when numbering lines in the output and one of the input files
does not have a trailing newline.
2017-01-23 03:34:47 +01:00
Joshua Miller
133934f7cf add cat support for unix domain sockets
- adds conditional supports for unix domain sockets
   - adds unix domain socket test
   - adds Results to functions, removing unwraps
   - uutils `cat` used to panic on broken stdout pipes (e.g. `cat
     /dev/zero | head -c1`).  this is fixed in this PR
   - updated to exit 0 on success, and 1 if an error occurs.
   - adds docstrings
   - adds an error log on printing a directory
   - adds categorization of other filetypes for extensible
     differentiation of behaviors
   - adds OutputOptions struct to replace params for extensibility
   - adds correct status code on exit
2017-01-08 19:56:35 -06:00
kevgeniy
6d13bcf2da cat: fixed indentation 2016-11-18 22:30:12 +03:00
kevgeniy
0d56009c3a cat: remove recursion 2016-10-24 20:18:44 +03:00
kevgeniy
6228b06e29 cat: remove libc dependency 2016-10-24 05:23:54 +03:00
kevgeniy
72490ef956 cat: rewrote most part of the code
Rewrote cat to eliminate code duplication and make it safe

  - UnsafeWriter is replaced by BufWriter
  - write_lines (any option except -T and -v) and write_bytes (-T and -v
    options) are replaced by single write_lines method. A new method use
    ``write_to_end``, ``write_tab_to_end`` or ``write_nonprint_to_end``
    method to write all symbols untill the end of line in the right way.
  - Benchmarking (-n, -T and -v options respectively):
    | old (ns/iter)              | new (ns/iter)              |
    | -------------------------- | -------------------------- |
    | 6,501,496 (+/- 1,173,481)  | 6,683,158 (+/- 373,539)    |
    | 8,634,023 (+/- 547,595)    | 5,408,676 (+/- 715,458)    |
    | 24,056,507 (+/- 1,177,445) | 30,879,788 (+/- 1,180,598) |
2016-10-24 04:51:40 +03:00
evgeniy
4a2b8e3c52 cat: conditional compilation added 2016-10-18 19:09:36 +02:00
kevgeniy
2060048c79 Fixed and made the comments clearer 2016-10-16 17:13:02 +02:00
evgeniy
dd16c58ab4 cat utility refactoring:
- Less if branches
 - Unnecessary range variable deleted
 - Optional fail-assertion commented
2016-10-16 12:43:23 +02:00
Nathan Ross
36503a77c7 impl: use coreopts for brevity and consistent UX 2016-08-20 10:07:24 -04:00
Nathan Ross
a4e1372451 cat: squeeze blank keeps up to one blank line 2016-02-16 18:52:51 -05:00
Michael Gehring
a2944e06db Fix clippy warnings 2016-01-06 09:36:20 +01:00
Joseph Crail
b90d253584 Refactor and simplify build for utilities.
For coreutils, there are two build artifacts:

  1. multicall executable (each utility is a separate static library)
  2. individual utilities (still separate library with main wrapper)

To avoid namespace collision, each utility crate is defined as
"uu_{CMD}". The end user only sees the original utility name. This
simplifies build.rs.

Also, the thin wrapper for the main() function is no longer contained in
the crate. It has been separated into a dedicated file. This was
necessary to work around Cargo's need for the crate name attribute to
match the name in the respective Cargo.toml.
2015-12-07 21:56:45 -05:00
Joseph Crail
9a4c1aa7fa Refactor check for standard stream interactivity.
Since several utilities check if the standard streams are interactive, I
moved this into the uucore::fs library as is_std*_interactive(). I also
added Windows support for these methods, which only return false (or at
least until someone finds a way to support this).
2015-11-29 21:03:53 -05:00
Michael Gehring
ca16e66a55 switch to cargo version numbers 2015-11-25 10:58:49 +01:00
Joseph Crail
ca1074201f Split utility files into separate library.
Everything in src/common has been moved to src/uucore. This is defined
as a Cargo library, instead of directly included. This gives us
flexibility to make the library an external crate in the future.

Fixes #717.
2015-11-24 22:20:27 -05:00
Nathan Ross
502957dc3e use cargo idioms to manage dependency resolution and compilation 2015-11-23 02:04:15 -05:00
Nathan Ross
b20b2cca19 update uses of libc 0.1.x and deprecated stdlib uses 2015-11-23 02:04:15 -05:00
Carlos Liam
87d14978e9 Clean whitespace
Remove leading newlines and replace lines containing only whitespace
with empty lines
2015-10-06 12:04:46 -04:00
Michael Gehring
9d8abbcb06 Basic Cargo build
Builds the uutils multicall binary containing all utils (except stdbuf)
by default. To only build a subset
    `cargo --no-default-features --features <utils>`
can be used.

Whats missing is building the standalone binaries and a mechanism to
automatically disable the build of unix only utils on windows.
2015-08-28 21:12:30 +02:00
Joseph Crail
17e732f0fd Flush pending stdout writes. 2015-05-29 13:51:11 -04:00
Vinícius dos Santos Oliveira
c17f925b11 cat.rs: removing need for mut variable 2015-05-22 13:53:13 -03:00
Joseph Crail
b4b08de42c Switch to external getopts cargo (part 1).
I switched over to the getopts crate on crates.io, instead of Rust's
private implementation. This will allow coreutils to build for Rust 1.0.

I'm splitting the updates into several commits for better reviewing.
2015-05-20 22:47:30 -04:00
Joseph Crail
dfaee63cd3 Remove unused feature from cat. 2015-05-07 23:02:47 -04:00
kwantam
d1f594eb68 remove box_syntax feature from fmt, base64, cat 2015-04-29 01:09:26 -04:00
kwantam
05520e69cb clean up #![features]
For the most part, this commit removes the `collections` feature.
In some places I've removed other features where the effort to do
so was pretty low.
2015-04-27 15:27:15 -04:00
kwantam
cc48e83e98 update cat, cat tests to new API
This commit updates the `cat` utility as well as its testbench
to work with the latest APIs.
2015-04-25 03:28:06 -04:00
Michael Gehring
26568d2021 Update to the new integer suffixes 2015-02-22 13:59:57 +01:00
Michael Gehring
8098d172d7 Update slicing syntax ([] -> [..]) 2015-02-22 13:59:12 +01:00
Michael Gehring
9ae9a48387 feature io -> old_io, path -> old_path 2015-02-22 13:59:12 +01:00
Michael Gehring
e7b647171f os::set_exit_status(isize) -> env::set_exit_status(i32) 2015-02-22 13:59:12 +01:00
Michael Gehring
5e70473a2b std::path -> std::old_path 2015-02-06 13:45:45 +01:00
Michael Gehring
3eb5a814a3 Fix most unstable feature warnings 2015-02-03 23:54:37 +01:00
Michael Gehring
906d3e4ec5 write -> write_all 2015-01-29 08:47:43 +01:00
Michael Gehring
d187dc574b std::io -> std::old_io 2015-01-29 08:45:37 +01:00
Steven Allen
7647a37bf8 Cleanup cat: use slicing syntax. 2015-01-25 01:21:31 -05:00
Steven Allen
8a101b2203 Cleanup cat: use while let instead of loop then match. 2015-01-24 22:53:27 -05:00
Steven Allen
9326dbc3de Cleanup cat: open files in for loop header. 2015-01-24 22:52:40 -05:00
Michael Gehring
fbdf04c072 Replace deprecated slice_{to,from} with slicing syntax 2015-01-24 10:46:28 +01:00
Michael Gehring
4d6cbfa393 Disable unstable warnings for now 2015-01-10 20:44:56 +01:00
Michael Gehring
782fad4667 int/uint -> isize/usize 2015-01-10 20:40:37 +01:00
Michael Gehring
f2d49f4bb6 Make uumain return isize everywhere 2015-01-10 14:07:39 +01:00
Arcterus
4e0360c495 base64, cat: fix build for Rust alpha 2015-01-09 16:16:05 -08:00
Michael Gehring
7d8053561e Use new array syntax 2015-01-08 14:50:03 +01:00
Michael Gehring
074a58eafd deriving is now called derive 2015-01-08 14:50:03 +01:00
Michael Gehring
2027a7a981 fix *write*! macro args 2014-11-22 07:30:18 +01:00
Michael Gehring
cb4b5bce29 Remove now invalid format specifiers 2014-11-22 07:30:18 +01:00
Michael Gehring
09f223fdb1 Update for new coercion rules 2014-11-19 21:58:16 +01:00
Michael Gehring
cd409c6d3f Update for namespaced enums 2014-11-19 21:58:16 +01:00