Demi Marie Obenour writes: > On 11/14/25 08:08, Alyssa Ross wrote: >> Demi Marie Obenour writes: >> >>> On 11/13/25 13:01, Alyssa Ross wrote: >>>> Demi Marie Obenour writes: >>>> >>>>> On 11/13/25 08:21, Alyssa Ross wrote: >>>>>> Demi Marie Obenour writes: >>>>>> >>>>>>> + if (entry->d_name[0] == '.') >>>>>>> + if (len == 1 || (len == 2 && entry->d_name[1] == '.')) >>>>>>> + continue; >>>>>>> + unsigned char c = (unsigned char)entry->d_name[0]; >>>>>>> + if (!((c >= 'A' && c <= 'Z') || >>>>>>> + (c >= 'a' && c <= 'z'))) >>>>>>> + errx(EXIT_FAILURE, "Filename must begin with an ASCII letter"); >>>>>> >>>>>> Would the comparison not be valid without the cast? >>>>> >>>>> It would be in this case, but the subsequent cast to int in the error >>>>> path assumes that the cast was done. Signed characters are much >>>>> trickier and casting to unsigned makes the code easier to reason about. >>>> >>>> Is it safe to assume 'A' etc. are representable and comparable as >>>> unsigned values? (I'm sure it is in practice, but I'd like it if I >>>> could be confident this is being done strictly correctly.) >>> >>> I don't know if the C standard requires it, but we assume it. >> >> Is it a safe assumption, at least on all Linux architectures? > > I believe this assumption is hard-coded into GCC and Clang, so it's > pretty safe. Cool, okay.