aboutsummaryrefslogtreecommitdiff
path: root/coreutils/expr.c (unfollow)
Commit message (Collapse)AuthorFilesLines
2018-03-06winansi: changes to puts, fputs and fwriteRon Yorston1-18/+3
Rewrite winansi_puts using winansi_fputs and putchar. There's no need to use winansi_putchar. Improve error return values from winansi_fputs and winansi_fwrite.
2018-03-06winansi: improve error return values in ANSI emulationRon Yorston1-20/+23
Also tighten up the code slightly.
2018-03-06winansi: create and use functions to test for consoleRon Yorston1-51/+20
2018-03-05win32: squeeze a few bytes out of strftimeRon Yorston1-4/+6
2018-03-05win32: use strchrnul from BusyBox in fnmatchRon Yorston1-1/+5
BusyBox ensures that strchrnul is always available, either from the target platform or by including its own version. Therefore it isn't necessary for fnmatch to use its equivalent.
2018-03-04win32: reduce amount of static dataRon Yorston4-101/+127
It appears that uninitialised static variables are placed in the data section rather than bss, increasing the size of the binary. Rewrite some code to reduce the amount of static data.
2018-03-03ar: conditional compilation for variable only needed on WIN32Ron Yorston1-0/+2
2018-03-02Minor improvements to buildRon Yorston5-23/+22
Exclude source files in libbb that aren't used by busybox-w32. This speeds up the build marginally. They can always be reinstated if necessary. Provide fake routines for everything in inode_hash.c so that it can be excluded. inode_hash.c is now unchanged from upstream. Use last_char_is in has_exe_suffix_or_dot. It doesn't save any bytes but it makes the code neater.
2018-03-01Remove fake signal-handling codeRon Yorston8-32/+39
Microsoft Windows has only limited support for signals. busybox-w32 initially papered over this fact by adding definitions for unsupported signals and signal-handling functions. Remove this fake code and deal with the consequences by excluding anything that fails to compile as a result.
2018-03-01lineedit: disable window size tracking in default configurationRon Yorston4-4/+23
SIGWINCH isn't available on Microsoft Windows. Make the use of SIGWINCH configurable and disable it by default.
2018-03-01win32: make has_exec_format staticRon Yorston2-56/+55
The only other caller (in spawnveq) has been removed.
2018-02-28win32: additional improvements to handling of executablesRon Yorston3-21/+36
Consistent processing of file extensions, as described in the previous commit, has been applied to the 'which' applet and the functions find_executable and mingw_spawn_interpreter. In spawnveq check that the file to be executed exists and is executable, and ensure that it won't have any extensions added by spawnve. It's intended that all files passed to spawnve should have their names fully specified. If this isn't the case the tests here will cause errors which will need to be fixed.
2018-02-28ash: changes to command resolution, execution and displayRon Yorston1-23/+55
ash separates searching for commands from running them. Searching is performed in find_command(). The result of the search is stored in a hash table but not as the full path: the path is reconstructed in shellexec() by combining the directory and command name. In Windows the command name is insufficient, as the executable name may also include an extension. To resolve this we must ensure that extensions are processed in the same order in find_command, shellexec and any other places where command names are resolved into file names. The order used matches that of spawnve: .com, .exe, .bat, .cmd. Finally the bare filename with no additional extension The order has been made consistent: - in find_command for absolute paths and the Windows-specific path search; - in tryexec (which is called by shellexec) where an additional test that the file is executable has been added; - in the type and hash built-ins where the output has been modified to include the extension. Additionally, the code in tryexec to handle ENOEXEC errors from execve has been excluded. The rationale for the exec functions in POSIX [1] suggests the requirement to retry is a workaround for the lack of '#!' support on some platforms. [1] http://pubs.opengroup.org/onlinepubs/009695399/functions/exec.html
2018-02-28win32: don't add extensions to filenames ending with a dotRon Yorston2-2/+9
A filename ending with a dot is a signal to spawnve not to try adding extensions but to use the name unmodified. The add_win32_extension function should follow the same rule.
2018-02-27win32: fix code to check for file extensionsRon Yorston1-1/+1
The has_win_suffix function didn't check that the extension started with a '.'. As a result the shell was unable to execute cmd.exe.
2018-02-27libbb: Use return value from is_prefixed_with()Andy Shevchenko1-3/+2
add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-5 (-5) Function old new delta skip_dev_pfx 30 25 -5 Total: Before=779966, After=779961, chg -0.00% Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-27tcpudp: shrink per-host rate-limiting codeDenys Vlasenko3-20/+17
function old new delta tcpudpsvd_main 1775 1780 +5 ipsvd_perhost_add 108 107 -1 cclen 4 - -4 cc 4 - -4 ipsvd_perhost_init 30 25 -5 ipsvd_perhost_remove 80 44 -36 ------------------------------------------------------------------------------ (add/remove: 0/2 grow/shrink: 1/3 up/down: 5/-50) Total: -45 bytes text data bss dec hex filename 933358 473 6852 940683 e5a8b busybox_old 933326 473 6844 940643 e5a63 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-27less: accept -R option. Closes 10816Denys Vlasenko1-1/+5
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-26libbb: ensure build details are only stored onceRon Yorston1-1/+1
Determine the size of the MINGW_VER string at compile time so it's only stored once.
2018-02-26win32: move detection of file formats to stat(2)Ron Yorston7-77/+82
Move the code to detect shell scripts and binary executables from mingw_access to a separate function, has_exec_format. Call this function in do_lstat to decide whether to set the executable bits in the file mode. This will slow down stat but has a couple of advantages: - shell scripts are highlighted in ls output - the test applet can use stat(2) to detect executable files The new function is used to handle another corner case in spawnveq: binary executables without the usual .exe extension are only run by spawnve if the file name ends with '.'. Two minor changes: - file_is_win32_executable has been renamed add_win32_extension to clarify what it does - a call to file_is_executable has been removed from find_command in ash as it resulted in unhelpful error messages.
2018-02-26win32: improvements to stat(2) emulationRon Yorston1-25/+18
Set all mode bits rather than just setting user modes and then extending them to group and other. Combine common code in mingw_fstat.
2018-02-26tar: don't save file statusRon Yorston1-0/+4
Since we're unable to track the file using its device/inode there's no need to obtain the file's status.
2018-02-26win32: add support for batch filesRon Yorston4-30/+82
Support batch files with .bat and .cmd extensions, similar to what's done for .exe and .com. Check extensions in the same order as Windows' spawn function: .com, .exe, .bat, .cmd.
2018-02-25lineedit: allow window size tracking to be disabledRon Yorston2-4/+19
function old new delta lineedit_read_key 269 261 -8 win_changed 47 - -47 read_line_input 3884 3821 -63 cmdedit_setwidth 63 - -63 ------------------------------------------------------------------------------ (add/remove: 0/2 grow/shrink: 0/2 up/down: 0/-181) Total: -181 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-23df: do "rootfs" check soonerDenys Vlasenko1-4/+5
function old new delta df_main 1065 1064 -1 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-23df: 4TB+ support on 32 bits archDenys Vlasenko1-8/+15
Reported for Pascal Bellard. function old new delta df_main 1054 1065 +11 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-23Fix install with hardlinks and a custom PREFIX. Closes 10801Denys Vlasenko1-9/+9
Trying to install busybox with hardlinks and a custom PREFIX will fail for applets not in the /bin directory, because relative pathnames are used. applets/install.sh is *supposed to* use the absolute pathname for hardlinks but it fails to do so because the wrong check is used in the if statement. While fixing it, shore up other sloppy coding in applets/install.sh Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-23win32: make /dev/urandom more randomRon Yorston4-2/+244
2018-02-22ash: tidy up /dev/null redirectionRon Yorston1-11/+6
Remove some duplicated code and raise an error for unsupported devices.
2018-02-22shred: fix up for WIN32 and enable by defaultRon Yorston3-2/+8
Use the new low-level support for /dev/zero and /dev/urandom to allow shred to work in busybox-w32. The only change required is to close the file before unlinking it, as Microsoft Windows won't delete an open file.
2018-02-22dd: use new device handling to implement /dev/zero and /dev/urandomRon Yorston1-13/+10
Replace internal support for /dev/zero with the newly introduced device handling in open/read. This reduces the differences between busybox-w32 and upstream.
2018-02-22win32: handle /dev/zero and /dev/urandom in open and read functionsRon Yorston3-3/+65
Currently /dev/zero is handled as a special case in dd. Add hacks to the open and read functions in mingw.c to handle the zero and urandom devices. - Opening /dev/zero or /dev/urandom actually opens the special Windows file 'nul' which behaves like /dev/null. This allows manipulation of the file descriptor with things like seek and close - When /dev/zero or /dev/urandom is opened the resulting file descriptor is stored and used to override the behaviour of read. - No attempt is made to track duplicated file descriptors, so using these devices for redirections in the shell isn't going to work and won't be permitted. (Could be, but won't.) - Limited control of the special file descriptors is provided by allowing the internal variables to be changed. - The numbers from /dev/urandom aren't very random.
2018-02-22od: move address_fmt[] from data to globals. 8 less bytes in data sectionDenys Vlasenko1-8/+10
function old new delta od_main 2164 2179 +15 address_fmt 8 - -8 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 1/0 up/down: 15/-8) Total: 7 bytes text data bss dec hex filename 930954 481 6852 938287 e512f busybox_old 930977 473 6852 938302 e513e busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-22sort: fix potentially buggy use of OPT_STRDenys Vlasenko1-12/+15
This also makes OPT_STR reused: text data bss dec hex filename 930979 481 6852 938312 e5148 busybox_old 930954 481 6852 938287 e512f busybox_unstripped ^^^^^^ Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-22sort: in -s handling, return 1/-1, not 1/0 compare resultDenys Vlasenko1-2/+3
function old new delta compare_keys 794 795 +1 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-22fsync: enable in default configurationRon Yorston3-2/+5
2018-02-22win32: tailor inet_pton.c for use in busybox-w32Ron Yorston1-11/+8
2018-02-22win32: import inet_pton.c from ISC BINDRon Yorston1-231/+182
The copy of inet_pton.c imported from gnulib was licensed under GPL3 which is incompatible with the GPL2-only licence of BusyBox. Import an MPL2-licensed version of this file from ISC BIND git master as of this date.
2018-02-21libbb: compile capability code only if FEATURE_SETPRIV_CAPABILITIES or RUN_INITDenys Vlasenko3-4/+10
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-21sort: fix -s. Closes 10671Denys Vlasenko1-12/+57
function old new delta sort_main 786 862 +76 compare_keys 720 794 +74 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 150/0) Total: 150 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-21win32: import fsync(2) implementation from gnulibRon Yorston4-1/+78
2018-02-20iplink: implement support for selecting a master interfaceJan Luebbe3-2/+41
Attaching an interface to a VRF is done by setting the interface's master. Besides VRF, this can also be used for bridges. function old new delta set_master - 142 +142 do_iplink 1262 1357 +95 packed_usage 32546 32539 -7 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/1 up/down: 237/-7) Total: 230 bytes Signed-off-by: Jan Luebbe <jluebbe@debian.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-20ip link: support "add TYPE vrf", improve --helpJan Luebbe2-5/+76
VRF interfaces have a mandatory table parameter, which needs to be specified using a RTNL attribute. function old new delta do_add_or_delete 1150 1254 +104 packed_usage 32444 32546 +102 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 206/0) Total: 206 bytes Signed-off-by: Jan Luebbe <jluebbe@debian.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-20umount: fix "umount -t FSTYPE MNTPOINT" acting as if -a is specifiedDenys Vlasenko1-3/+5
While at it, add -t to --help, and fix comments which say that -t is ignored function old new delta packed_usage 32427 32444 +17 umount_main 558 552 -6 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 17/-6) Total: 11 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-20tar,unzip: postpone creation of symlinks with "suspicious" targetsDenys Vlasenko6-79/+68
This mostly reverts commit bc9bbeb2b81001e8731cd2ae501c8fccc8d87cc7 "libarchive: do not extract unsafe symlinks unless $EXTRACT_UNSAFE_SYMLINKS=1" Users report that it is somewhat too restrictive. See https://bugs.busybox.net/show_bug.cgi?id=8411 In particular, this interferes with unpacking of busybox-based filesystems with links like "sbin/applet" -> "../bin/busybox". The change is made smaller by deleting ARCHIVE_EXTRACT_QUIET flag - it is unused since 2010, and removing conditionals on it allows commonalizing some error message codes. function old new delta create_or_remember_symlink - 94 +94 create_symlinks_from_list - 64 +64 tar_main 1002 1006 +4 unzip_main 2732 2724 -8 data_extract_all 984 891 -93 unsafe_symlink_target 147 - -147 ------------------------------------------------------------------------------ (add/remove: 2/1 grow/shrink: 1/2 up/down: 162/-248) Total: -86 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-19ash: use correct size for tblentryRon Yorston1-2/+2
As noted in cmdlookup the size of a tblentry instance, *t, is sizeof(struct tblentry) + strlen(t->cmdname) because the structure includes one byte for the cmdname array. Apply the same logic in tblentry_size and tblentry_copy.
2018-02-19poweroff: add a config option for people needing VERY early poweroffDenys Vlasenko1-0/+54
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-18win32: use built-in shell for popen, if possibleRon Yorston1-2/+12
popen uses the shell to run the command provided. If BusyBox has been configured appropriately use the built-in shell for this. - Currently the only user of popen in busybox-w32 is awk, which uses it when piping to or from commands. - If the command is available as an applet the shell will use it. If a different version of the program is required the command will need to specify the full path. - This change means that popen will work even if no shell is present on the path. - Since the binary may have been run as sh.exe or awk.exe it's necessary to use the magic --busybox option.
2018-02-17ash: allow waitpid_child to blockRon Yorston1-1/+1
The wrong sort of boolean operator resulted in waitpid_child always being nonblocking.
2018-02-15mkfs_ext2, mkfs_vfat: fix warnings in STORE_LE on big-endian platformsDenys Vlasenko2-6/+6
"warning: large integer implicitly truncated to unsigned type [-Woverflow]" Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>