e28deeb8e9
getline(3) is much more readable than manually looping. It has some overhead due to the allocation of a buffer, but that shouldn't be a problem here. If that was a problem, we could reuse the buffer (thus making the function non-reentrant), but I don't think that's worth the extra complexity. Using rpmatch(3) instead of a simple y/n test provides i18n to the response checking. We have a fall-back minimalistic implementation for systems that lack this function (e.g., musl libc). While we're at it, apply some other minor improvements to this file: - Remove comment saying which files use this function. That's likely to get outdated. And anyway, it's just a grep(1) away, so it doesn't really add any value. - Remove unnecessary casts to (void) that were used to verbosely ignore errors from stdio calls. They add clutter without really adding much value to the code (or I don't see it). - Remove comments from the function body. They make the function less readable. Instead, centralize the description of the function into a man-page-like comment before the function definition. This keeps the function body short and sweet. - Add '#include <stdbool.h>', which was missing. - Minor whitespace style changes (it doesn't hurt the diff at this point, since most of the affected lines were already touched by other changes, so I applied my preferred style :). Acked-by: Samanta Navarro <ferivoz@riseup.net> Cc: Serge Hallyn <serge@hallyn.com> Signed-off-by: Alejandro Colomar <alx@kernel.org> |
||
---|---|---|
.. | ||
.indent.pro | ||
addgrps.c | ||
age.c | ||
agetpass.c | ||
alloc.c | ||
audit_help.c | ||
basename.c | ||
bit.c | ||
btrfs.c | ||
chkname.c | ||
chkname.h | ||
chowndir.c | ||
chowntty.c | ||
cleanup_group.c | ||
cleanup_user.c | ||
cleanup.c | ||
console.c | ||
copydir.c | ||
csrand.c | ||
date_to_str.c | ||
entry.c | ||
env.c | ||
failure.c | ||
failure.h | ||
find_new_gid.c | ||
find_new_sub_gids.c | ||
find_new_sub_uids.c | ||
find_new_uid.c | ||
getdate.h | ||
getdate.y | ||
getgr_nam_gid.c | ||
getrange.c | ||
gettime.c | ||
hushed.c | ||
idmapping.c | ||
idmapping.h | ||
isexpired.c | ||
limits.c | ||
list.c | ||
log.c | ||
loginprompt.c | ||
mail.c | ||
Makefile.am | ||
mempcpy.c | ||
motd.c | ||
myname.c | ||
obscure.c | ||
pam_pass_non_interactive.c | ||
pam_pass.c | ||
prefix_flag.c | ||
pwd2spwd.c | ||
pwd_init.c | ||
pwdcheck.c | ||
remove_tree.c | ||
rlogin.c | ||
root_flag.c | ||
salt.c | ||
setugid.c | ||
setupenv.c | ||
shell.c | ||
stpecpy.c | ||
stpeprintf.c | ||
strtoday.c | ||
sub.c | ||
sulog.c | ||
ttytype.c | ||
tz.c | ||
ulimit.c | ||
user_busy.c | ||
utmp.c | ||
valid.c | ||
xgetgrgid.c | ||
xgetgrnam.c | ||
xgetpwnam.c | ||
xgetpwuid.c | ||
xgetspnam.c | ||
xgetXXbyYY.c | ||
yesno.c |