Comment

Comment by a1369209993

As written, it should be `s_hasdigit`, but it's actually wrong - it should be:

  int s_isnum(const char* s) {
    int result = (*s != '\0');
    while (*s != '\0') {
        if ((*s < '0') || ('9' < *s)) {
            result = 0;
        }
        s++;
    }
    return result;
  }
otherwise, it will choke on directories like `/proc/etc64/` or `/proc/net6/` if any such directory is added. (Plus other bits like early return, but that's not a correctness bug.)
parent a1369209993 3 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton