[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Minor correctness issue with l_str2d's use of ltolower
- From: Ahmed Charles <acharles@...>
- Date: Sat, 29 Aug 2020 13:27:11 +0000
ltolower could be enhanced with a check such as:
#define ltolower(c) check_exp((c) >= 'A' && (c) <= 'Z' || (c) >= 'a' && (c) <= 'z', ((c) | ('A' ^ 'a')))
Running the test suite with this reveals that the following code in l_str2d is incorrect:
const char *pmode = strpbrk(s, ".xXnN");
It should be:
const char *pmode = strpbrk(s, "xXnN");
Due to the following line calling ltolower:
int mode = pmode ? ltolower(cast_uchar(*pmode)) : 0;
Note: this doesn't change the code's behavior at all, because 0 is equivalent to '.' (or 46, which is the value returned by ltolower('.')) when doing the subsequent checks against mode. It's mostly just cause for confusion.
Thanks.