Commit Graph

483 Commits

Author SHA1 Message Date
Jakob Kramer
7f7e7dcbb9 cols: simplify filling with spaces
Use printf("%*s", n, "") instead of allocating
a string filled with spaces.
2014-06-05 11:19:34 +01:00
Jakob Kramer
2e1580ed2d remove unnecessary calls to realloc from tee 2014-06-03 23:46:17 +01:00
Jakob Kramer
7d1fd2621e add -t flag to sort 2014-06-02 13:35:59 +01:00
Hiltjo Posthuma
2ab2d2ee3b remove afgets
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-06-01 18:03:20 +01:00
Hiltjo Posthuma
fab4b384e7 use agetline instead of agets
also use agetline where fgets with a static buffer was used previously.

Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-06-01 18:03:10 +01:00
Hiltjo Posthuma
eac0f658cf check snprintf error aswell, handle as truncation error
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-06-01 18:02:55 +01:00
Hiltjo Posthuma
953ebf3573 code style
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-06-01 18:02:30 +01:00
Hiltjo Posthuma
97ca7c8b6d cut: improvements
- use agetline().
- code style.
- free allocated list.
- don't close stdin if "-" is given.
2014-06-01 18:02:13 +01:00
Hiltjo Posthuma
97fb4a1f9c grep: improvements
improvements:
- improve statuscode behaviour
  - don't exit if a file in a series fails. exit 2 if an error occured
    in a file series. don't exit if there is a read error (like: grep
     input file is a directory).
- use agetline instead of agets().

with the simple test: time seq 1 100000000 | grep 'a'
its 12 seconds (from 24 seconds) on my machine.

Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-06-01 18:02:01 +01:00
Hiltjo Posthuma
d12e953f18 add agetline, separate estrtod to util
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-06-01 18:01:45 +01:00
Hiltjo Posthuma
daad071b31 cut, uudecode: free buf after use
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-06-01 18:01:31 +01:00
Hiltjo Posthuma
2dbb694932 strlcat, strlcpy style
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-06-01 18:01:19 +01:00
sin
07dd658f0d Use -std=c99 by default
Note, the code is largely c89 clean.  This is to avoid certain
warnings on some systems (OSX).
2014-05-31 17:56:34 +01:00
sin
69cde23703 Proper copyright header for strlcpy and strlcat 2014-05-28 11:15:59 +01:00
sin
4896bdf6de Revert "Make grep more memory-efficient"
This reverts commit d9a098ae6bc07188cbaefcd188e5911dec41815d.

Conflicts:
	grep.c

Hiltjo Posthuma <hiltjo@codemadness.org> said:

(Re)compiling the regex for each line doesn't make sense (imho) and
slows it down a lot.

A simple test:

time seq 1 100000000 | grep 'a'

sbase grep (before patch):
    0m22.21s real     0m0.00s user     0m0.00s system

sbase grep (after patch):
    2m16.28s real     0m0.00s user     0m0.00s system

coreutils grep:
    0m1.15s real     0m0.00s user     0m0.00s system

So the patch should be reverted I think.
2014-05-12 12:06:40 +01:00
Hiltjo Posthuma
5b3a0a9382 build warnings: initialise values...
... to make fix gcc warnings with -Wall.

Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-05-12 12:06:14 +01:00
sin
11eef783fe Declare error buffer at start of block 2014-05-12 00:40:29 +01:00
FRIGN
fb1bfe24bb Make grep more memory-efficient 2014-05-12 00:32:50 +01:00
FRIGN
8ea17b2a7d Switching to real name 2014-05-11 11:04:26 +01:00
Jakob Kramer
9366f48b1f sort: simplify linecmp, rename curr => tail 2014-05-06 18:01:44 +01:00
Jakob Kramer
8a44c352ee renice(1): renice is not PASTE 2014-05-06 16:21:56 +01:00
Jakob Kramer
6f7e9a5078 sort: add support for "per-keydef" flags 2014-05-06 16:21:50 +01:00
Jakob Kramer
109e8963f5 sort: ignore trailing newline while sorting 2014-05-06 16:21:45 +01:00
Jakob Kramer
0723c8d32e sort: work with signed integers as well 2014-05-06 16:21:39 +01:00
sin
9694305e05 Chop one level of indentation
eprintf() will exit the program, no need to use the else construct.
2014-05-05 15:12:20 +01:00
sin
b257f7a05f cp: Don't try to open the file twice in case we did not provide -f 2014-05-05 15:06:23 +01:00
sin
02918a46e8 Implement cp -f 2014-05-05 15:02:03 +01:00
Daniel Bainton
c323f6f233 Support reading checksums from stdin 2014-05-05 10:05:48 +01:00
Daniel Bainton
9ad5ca5a15 Add breaks to the sha*sum arg cases 2014-05-05 10:05:43 +01:00
Jakob Kramer
814b04e710 sort: document -b 2014-05-04 00:16:24 +01:00
Jakob Kramer
a2da9edb99 sort: simplify skip_columns 2014-05-04 00:15:57 +01:00
Jakob Kramer
d965985a52 sort: add -b flag; don't use it as default 2014-05-04 00:15:46 +01:00
Jakob Kramer
a62a2197a8 sort: don't evaluate if clause
this fixes that you could specify a key
definition like "-k 1.2.3", which is incorrect.
2014-05-04 00:15:33 +01:00
Jakob Kramer
e535e8d88a sort: replace loop with MIN() 2014-05-04 00:15:23 +01:00
Jakob Kramer
56e1616486 sort: remove 'rest' variable 2014-05-04 00:15:10 +01:00
Jakob Kramer
56b9a26de9 sort: don't repeat skipping columns logic 2014-05-04 00:14:58 +01:00
Jakob Kramer
c4e5354a32 sort: linebuf is no global 2014-05-04 00:14:19 +01:00
sin
f23409f65a Break long line in mktemp(1) 2014-05-02 21:38:40 +01:00
Jakob Kramer
0bc6b1377b sort: readability; check strndup return value 2014-04-30 15:17:01 +01:00
sin
f8a216a18c Add -D_GNU_SOURCE to config.mk for tcc 2014-04-29 22:31:16 +01:00
Silvan Jegen
60e972c229 Update tr.1 man page
Document the -d option and slightly change the wording of the page.

Signed-off-by: Silvan Jegen <s.jegen@gmail.com>
2014-04-27 11:42:10 +01:00
Hiltjo Posthuma
997f4f006c chown: return EXIT_FAILURE if one file failed.
NOTE: coreutils chown wont process file series further on error, but busybox does. For consistency among the other tools follow busybox behaviour.

Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-04-24 11:51:54 +01:00
Hiltjo Posthuma
90861840b7 chmod: process file series behaviour
continue processing files if a chmod on a file in a series failed, but return with an error status code.

Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-04-24 11:51:43 +01:00
Hiltjo Posthuma
bd99b92e91 parsemode: rework
- for octal input: reset mode to 0.
- take umask into account.
- make '=rwx' etc work.
- we wont support crazy but valid modes like "a+rw,g=x,o=g"
- uudecode: use parsemode, mask is 0.

Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-04-24 11:51:33 +01:00
Hiltjo Posthuma
a1b62b2282 sort: style, explicitly state type
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-04-23 15:25:21 +01:00
dwts
459161481a use always static for usage and keep usage definition above main 2014-04-22 14:49:23 +01:00
dwts
575b38391c keep usage definition above main 2014-04-22 13:46:33 +01:00
sin
f488547779 Don't bail out if chmod(2) or chown(2) fails
Keep processing all the files specified.
2014-04-22 13:46:28 +01:00
dwts
b700d5a8ed minor style changes 2014-04-22 13:46:19 +01:00
Hiltjo Posthuma
59d0b5cd97 chown: add -R for compatability
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-04-18 20:31:39 +01:00