15 tre_convert_pattern(const char *regex, size_t n, tre_char_t **w,
22 wregex = xmalloc(sizeof(tre_char_t) * (n + 1));
26 /* If the current locale uses the standard single byte encoding of
27 characters, we don't do a multibyte string conversion. If we did,
28 many applications which use the default locale would break since
29 the default "C" locale uses the 7-bit ASCII character set, and
30 all characters with the eighth bit set would be considered invalid. */
32 if (TRE_MB_CUR_MAX == 1)
33 #endif /* TRE_MULTIBYTE */
36 const unsigned char *str = (const unsigned char *)regex;
37 tre_char_t *wstr = wregex;
39 for (i = 0; i < n; i++)
47 tre_char_t *wcptr = wregex;
50 memset(&state, '\0', sizeof(state));
51 #endif /* HAVE_MBSTATE_T */
54 consumed = tre_mbrtowc(wcptr, regex, n, &state);
68 DPRINT(("mbrtowc: error %d: %s.\n", errno, strerror(errno)));
72 /* The last character wasn't complete. Let's not call it a
81 wlen = wcptr - wregex;
83 #endif /* TRE_MULTIBYTE */
88 #else /* !TRE_WCHAR */
90 *w = (tre_char_t * const *)regex;
94 #endif /* !TRE_WCHAR */
98 tre_free_pattern(tre_char_t *wregex)