Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Can someone explain to me why the matchstar function takes its first param as an integer? to me it should be a char.

    int matchstar(int c, char *regexp, char *text)
    {
        do {    /* a * matches zero or more instances */
            if (matchhere(regexp, text))
                return 1;
        } while (*text != '\0' && (*text++ == c || c == '.'));
        return 0;
    }


It doesn't seem to make sense in this context. One hypothesis is that it could have been done out of habit to write safer code: whether char is signed or unsigned is left to the implementation, whereas int is guaranteed to be signed.


The usual reason is to allow c to be EOF, but I don't see why anyone would in this case.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: