32 Commits
Author SHA1 Message Date
Rob Landley 167dfdf99c Always use 64 bit type for FLAG_ macros so &= ~FLAG_x doesn't
blank top 32 bits.
2022-12-02 01:53:36 -06:00
Rob Landley 401898110f Add ~ to collate bare longopts. 2022-05-17 09:22:20 -05:00
Rob Landley eee419c1d7 flags.h can #define its own CLEANUP_ macros for the next #include
so gearshifts between flag contexts require less setup.
2022-02-16 05:12:42 -06:00
Rob Landley ef363a8af2 Add LL to 0 to prevent gcc from warning that 0<<32 might produce 0. 2022-01-08 15:51:01 -06:00
Rob Landley 52bbc1e0a4 Allow 0 prefix to optstr to include argv[0] in optargs[0]. 2020-11-14 23:39:18 -06:00
Rob Landley 1934fddf3e Fix off by one error that treats bit 31 as negative (so ls --color sets
all the bits).

While we're at it, make LL be ULL so bit 63 doesn't have the same problem.
2020-02-25 11:49:49 -06:00
Elliott Hughes f428c2cc6f mkflags: fix a sscanf buffer off-by-one.
Sadly, the compilers don't even catch this common mistake if you use
sscanf_s(3). Luckily, ASan does.
2020-02-22 06:08:07 -06:00
Rob Landley 81207825c5 Fix various warnings building on FreeBSD. 2019-01-19 16:50:23 -06:00
Rob Landley 831266c068 Teach the argument plumbing how to do -@ for mkfs.vfat 2018-12-26 12:07:14 -06:00
Rob Landley 5a670c5883 Simplify the mkflags logic a bit.
We're not going to USE_BLAH("a")"(longopt)" or similarly crazy corner cases,
so don't try to support them.
2018-12-25 21:24:07 -06:00
Rob Landley 07a3b91920 Add % to lib/args.c (long time in milliseconds), add xmillitime(), redo
xparsetime() not to need floating point, adjust callers.
2018-10-21 21:36:51 -05:00
Rob Landley aa265ebff4 Ryan Prichard pointed out that du -d0 should act like du -s, but the plumbing
wouldn't let him assign a negative default value, so I fixed it.
2018-03-19 11:23:24 -05:00
Rob Landley c187be7b6c Thinko in recent longopt commit. 2016-12-07 23:05:33 -06:00
Rob Landley 0322afbc01 Bugfix: configuring out a longopt confused the option parsing.
(This made ls -l not work when LS_COLOR was off.)
2016-12-07 21:52:00 -06:00
Rob Landley 48ea559699 The recent option parsing changes broke the multiplexer, because the "toybox"
command was trying to parse their options and failing. (Commands
that aren't just disabled but have no option string even in the allyesconfig
case need an OPTSTR of 0.)

This is probably only a partial fix, there's some design work to think through
here.
2016-07-17 02:14:35 -05:00
Rob Landley adef5dcb18 Add optional openssl accelerated versions of hash functions, loosely based on
a patch from Elliott Hughes, who said:

[PATCH] Add support for libcrypto for MD5/SHA.

Orders of magnitude faster (for architectures where OpenSSL/BoringSSL
has optimized assembler).

Also adds sha224sum, sha256sum, sha384sum, and sha512sum for folks
building with libcrypto.

The fallback portable C implementations could easily be refactored
to be API-compatible, but I don't know whether they'd stay here or
move to lib/ so I've left that part alone for now.
2016-07-15 04:45:08 -05:00
Rob Landley ec0b482e9f Fix option parsing infrastructure bug.
In main.c: used adjusted string with placeholers for removed options (so flag
values don't move based on config, allowing FORCE_FLAGS to work).

In scripts/mkflags.c: test was wrong, a bare longopt never matches a single
letter command, but it was treated as always matching when comparing
allyesconfig vs current config to determine which options were disabled, so
there was a corner case that got the flag values wrong.
2016-06-30 20:41:07 -05:00
Rob Landley 36b7cb7c3b Implement basic pkill plumbing, and fix FORCE_FLAGS on flag context switch. 2016-01-18 15:45:56 -06:00
Rob Landley aaecbbac2f Expand toys.optargs to 64 bits so people adding more options to ls don't run out.
Keep the low 32 bits of FLAG_x constants as 32 bit numbers so that at least
on little endian platforms it's still normal 32 bit math outside of lib/args.c.
2015-12-10 15:57:08 -06:00
Rob Landley 6fde0f9be2 Build updates: make change should use top level .config for global settings,
add NOSTRIP variable to force skipping strip, and save intermediate flag
data in generated/flags.raw and have mkflags.c error message point to that.
2015-08-30 04:42:49 -05:00
Isaac Dunham 79191b6c48 scripts/mkflags.c: add missing unistd.h, ctype.h 2015-08-08 17:03:38 -05:00
Rob Landley 5640acb50d If a shortopt is configured out right before a bare longopt, the option parsing infrastructure segfaults because there's no next shortopt but the list isn't empty. (There was a test for this, but we're simultaneously traversing two lists and it was testing the wrong one.) 2015-05-03 12:43:58 -05:00
Hyejin Kim 3b741474b7 scripts/mkflags.c : main function need return 0 if normal exit 2015-03-04 07:29:57 -06:00
Rob Landley f3e56f4e4f Redo option parsing infrastructure so #define FORCE_FLAGS can unzero flag macros for a disabled command (needed when multiple commands share infrastructure with a common set of flags).
This means the flag space is no longer packed, but leaves gaps where the zeroes
go. (Actual flag bit positions are the same for all configs.) Since the
option parsing needs to know where the holes are, the OPTSTR values are
now generated as part of flags.h with ascii 1 values for the disabled values.
(So generated/oldflags.h went away.)

This also means that the option string argument for OLDTOY() went away, it now
uses the same arguments as the NEWTOY() it references.
2014-12-31 21:30:59 -06:00
Rob Landley 3a41541347 Catch duplicate command name (which breaks the build already, but doesn't identify the culprit). 2014-05-10 13:06:31 -05:00
Ashwini Sharma 882ca8bf5b _mkflags_ had an issue for generating FLAG_xxxx macros for long options.
Only the first __long__ option, without any __short__ option had a proper
flag value, rest all were defined to ZERO. Becaus the _flist_ was not moved
to the next in this case.
2014-04-09 07:40:02 -05:00
Ashwini Sharma 64f6164088 There are cases when the long options are of the format abc-def. In current implementation FLAG_xxx macros are generated for long options too. with __-__ sign in the macro, it will generate errors.
I am of the opinion that __-__ be converted to '_' for generating the FLAG_xxx macros and be used in the command.

This will enable the user to 'abc-def', but be handled like 'abc_def' in code.
2014-03-19 13:57:06 -05:00
Rob Landley 6ebe03d616 Put all FOR_xxx blocks after all CLEANUP_xxx in generated/flags.h so the usages don't have to be in alphabetical order. 2014-02-24 23:34:43 -06:00
Rob Landley a2359011a8 Make CLEANUP transitions work, so multiple NEWTOY() can exist in the same file.
Don't #undefine TT in the CLEANUP blocks of generated/flags.h, and #ifdef
around the other TT definition. That way you can put a union at the start
of your GLOBALS() with the arguments filled out by option parsing, and then
have multiple main() functions with different argumetns and different
FLAG_x macros, while sharing infrastructure that's not under lib.
2014-02-16 17:31:33 -06:00
Rob Landley 1fb3ae7075 Various cleanups found by Tom Sparrow's static analysis. 2014-02-16 11:09:23 -06:00
Rob Landley 5a2583ac4f Fix segfault with single build of a command with bare longopts. 2014-02-08 10:53:26 -06:00
Rob Landley 207cadacd3 Switch flag generation from shell to C.
This should actually generate FLAG_longopt 0 #defines for disabled bare
longopts (ala ls without --color). Put temporary executables under "generated"
(including instlist for install).
2013-10-03 03:18:00 -05:00