applets
applets_sh
arch
archival
configs
console-tools
coreutils
debianutils
docs
e2fsprogs
editors
examples
findutils
include
init
libbb
Config.src
Kbuild.src
README
appletlib.c
ask_confirmation.c
auto_string.c
bb_askpass.c
bb_bswap_64.c
bb_cat.c
bb_do_delay.c
bb_pwd.c
bb_qsort.c
bb_strtod.c
bb_strtonum.c
bbunit.c
change_identity.c
chomp.c
common_bufsiz.c
compare_string_array.c
concat_path_file.c
concat_subpath_file.c
copy_file.c
copyfd.c
correct_password.c
crc32.c
default_error_retval.c
device_open.c
die_if_bad_username.c
dump.c
endofname.c
executable.c
fclose_nonstdin.c
fflush_stdout_and_exit.c
fgets_str.c
find_mount_point.c
find_pid_by_name.c
find_root_device.c
full_write.c
get_console.c
get_cpu_count.c
get_last_path_component.c
get_line_from_file.c
get_shell_name.c
get_volsize.c
getopt32.c
getpty.c
hash_md5_sha.c
hash_md5prime.c
herror_msg.c
human_readable.c
in_ether.c
inet_cksum.c
inet_common.c
inode_hash.c
isdirectory.c
isqrt.c
kernel_version.c
last_char_is.c
lineedit.c
lineedit_ptr_hack.c
llist.c
logenv.c
login.c
loop.c
make_directory.c
makedev.c
match_fstype.c
messages.c
missing_syscalls.c
mode_string.c
mtab.c
nuke_str.c
obscure.c
parse_config.c
parse_mode.c
percent_decode.c
perror_msg.c
perror_nomsg.c
perror_nomsg_and_die.c
pidfile.c
platform.c
print_flags.c
print_numbered_lines.c
printable.c
printable_string.c
process_escape_sequence.c
procps.c
progress.c
ptr_to_globals.c
pw_encrypt.c
pw_encrypt_des.c
pw_encrypt_md5.c
pw_encrypt_sha.c
read.c
read_key.c
read_printf.c
recursive_action.c
remove_file.c
replace.c
rtc.c
run_shell.c
safe_gethostname.c
safe_poll.c
safe_strncpy.c
safe_write.c
securetty.c
selinux_common.c
setup_environment.c
signals.c
simplify_path.c
single_argv.c
skip_whitespace.c
speed_table.c
str_tolower.c
strrstr.c
sysconf.c
time.c
trim.c
u_signal_names.c
ubi.c
udp_io.c
unicode.c
update_passwd.c
utmp.c
uuencode.c
vdprintf.c
verror_msg.c
vfork_daemon_rexec.c
warn_ignoring_args.c
wfopen.c
wfopen_input.c
write.c
xatonum.c
xatonum_template.c
xconnect.c
xfunc_die.c
xfuncs.c
xfuncs_printf.c
xgetcwd.c
xgethostbyname.c
xreadlink.c
xrealloc_vector.c
xregcomp.c
libpwdgrp
loginutils
mailutils
miscutils
modutils
networking
printutils
procps
qemu_multiarch_testing
runit
scripts
selinux
shell
sysklogd
testsuite
util-linux
.gitignore
.indent.pro
AUTHORS
Config.in
INSTALL
LICENSE
Makefile
Makefile.custom
Makefile.flags
Makefile.help
README
TODO
TODO_unicode
make_single_applets.sh
This change retains "or later" state! No licensing _changes_ here, only form is adjusted (article, space between "GPL" and "v2" and so on). Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
31 lines
549 B
C
31 lines
549 B
C
/* vi: set sw=4 ts=4: */
|
|
/*
|
|
* Utility routines.
|
|
*
|
|
* Copyright (C) many different people.
|
|
* If you wrote this, please acknowledge your work.
|
|
*
|
|
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
|
*/
|
|
|
|
#include "libbb.h"
|
|
|
|
void FAST_FUNC trim(char *s)
|
|
{
|
|
size_t len = strlen(s);
|
|
|
|
/* trim trailing whitespace */
|
|
while (len && isspace(s[len-1]))
|
|
--len;
|
|
|
|
/* trim leading whitespace */
|
|
if (len) {
|
|
char *nws = skip_whitespace(s);
|
|
if ((nws - s) != 0) {
|
|
len -= (nws - s);
|
|
memmove(s, nws, len);
|
|
}
|
|
}
|
|
s[len] = '\0';
|
|
}
|