[lldb-dev] Can someone compile and run this on Linux?

Greg Clayton gclayton at apple.com
Tue Jan 20 15:37:12 PST 2015


The code below fails to match the string "a" to the regex "^a$" on MacOSX if both "REG_EXTENDED | REG_ENHANCED" are specified, but it will pass if just REG_ENHANCED is used. 

Can someone run this on linux to see if the code below fails as well on linux? I want to make sure it isn't just an old version of regex we have in our libc...



#include <stdio.h>
#include <stdint.h>
#include <regex.h>

#define DEFAULT_REG_FLAGS (REG_EXTENDED | REG_ENHANCED)

int main (int argc, char const *argv[], char const *envp[])
{
    regex_t re;
    const char *regex_input = "a";
    int err = regcomp (&re, "^a$", DEFAULT_REG_FLAGS);
    if (err == 0)
    {
        err = regexec (&re, regex_input, 0, NULL, DEFAULT_REG_FLAGS);
        if (err == 0)
        {
            puts("matched");
        }
        else
        {
            char error_str[2048];
            const size_t actual_error_str_size = regerror(err, &re, error_str, sizeof(error_str));
            puts(error_str);
        }
    }
    return 0;
}









More information about the lldb-dev mailing list