• Rusty Russell's avatar
    str: provide checks for ctype.h char functions, and strstr and strchr functions. · ecea0736
    Rusty Russell authored
    In the former case, we were bitten by the fact that you don't pass a char
    to isalpha() et al: you pass an int.  This means on most platforms you want
    to do:
    
       if (isalpha((unsigned char)c)) ...
    
    Insane?  Yes, but I assure you I'm not making this up.
    
    Similarly, I've always wanted strstr, strchr and strrchr to return
    const char * when given a const char * argument to search, to avoid
    constness leak.
    
    In both cases, the actual versions from the headers may be macros, so
    we need to be very careful overriding them.  The result is that they
    become out-of-line functions which is unacceptable for general
    performance.
    
    So we only activate these when CCAN_STR_DEBUG is defined.
    
    ecea0736
str.h 3.66 KB