c = *ep++;
if (c)
{
- c -= '0';
- if (c > 9)
+ unsigned char d = c - '0';
+ if (d > 5)
+ value++;
+ else if (d == 5)
{
- return (speed_t) -1; /* Garbage after otherwise valid number */
- }
- else if (c > 5)
- {
- value++;
- }
- else if (c == 5)
- {
- while ((c = *ep++) == '0')
- ; /* Skip zeroes after .5 */
+ while ((c = *ep++) == '0'); /* Skip zeroes after .5 */
- if (c >= '1' && c <= '9')
- value++; /* Nonzero digit, round up */
+ if (c)
+ value++; /* Nonzero, round up */
else
value += (value & 1); /* Exactly in the middle, round even */
}
+
+ while (c_isdigit (c)) /* Skip remaining digits. */
+ c = *ep++;
+
+ if (c)
+ return (speed_t) -1; /* Garbage after otherwise valid number */
}
}
else if (c)
# so restrict tests here to invalid numbers
# We simulate unsupported numbers in a separate "LD_PRELOAD" test.
WRAP_9600="$(expr $ULONG_OFLOW - 9600)"
-for speed in 9600.. ++9600 -$WRAP_9600 --$WRAP_9600 0x2580 96E2; do
+for speed in 9599.. 9600.. 9600.5. 9600.50. 9600.0. ++9600 \
+ -$WRAP_9600 --$WRAP_9600 0x2580 96E2 9600,0 '9600.0 '; do
returns_ 1 stty ispeed "$speed" || fail=1
done