Source-Changes-D archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/bin/sleep



    Date:        Thu, 24 Jan 2019 16:18:49 +0100
    From:        Joerg Sonnenberger <joerg%bec.de@localhost>
    Message-ID:  <20190124151849.GA10743%britannica.bec.de@localhost>

  | This is overcomplicated and fragile, IMO. Can we just go back to the old
  | code and switch the strtod to strtod_l with LC_C_LOCALE? That solves the
  | input problem.

We could certainly do that, but while it is a little complicated, I do not
really think it is fragile.  Using a locale specific decimal radix in a
script is fragile - but the only way to avoid that is either to effectively
give up on non-C locales entirely for scripts, or drop all support for
fractional numbers as args to any command.

Note: the arg to "sleep" might come as ...
	echo -n "How many seconds do you want to sleep? "
	read secs
	sleep "${secs}"
(with some error checking).

I have no idea why sleep() was made to parse its arg in a locale
specific way, but that was done long long ago, and was (according
to the comments) done quite deliberately.

I think changing that decison (rather than just avoiding the problem,
as the current "fix" does) needs more discussion than a few comments
on the source-changes-d list.

kre

ps: "long long ago" means 1997 - this was added in version 1.10 of
sleep.c along with the comment explaining that it allows a locale
specific radix to be used.   1997 means this was in NetBSD 1.3 and
has been in all versions since.   Even if we were to change that for
NetBSD 9, I don't think such an alteration should be done in a point
release, so we will need to make something deal with the problem
for 8.1



Home | Main Index | Thread Index | Old Index