Regexp::Regexp(const ucs4string& pattern, bool caseFold, bool isSingleLine) : pattern_(pattern), isErrorOccured_(false), errorMessage_(Object::Nil), irritants_(Object::Nil) { const ucs4char* p = pattern_.data(); int r = onig_new(®exp_, (const uint8_t*)p, (const uint8_t*)(p + pattern_.size()), (ONIG_OPTION_DEFAULT) | (caseFold ? ONIG_OPTION_IGNORECASE : 0) | (isSingleLine? ONIG_OPTION_SINGLELINE : 0), ONIG_ENCODING, ONIG_SYNTAX_RUBY, &einfo_); if (r != ONIG_NORMAL) { char errorMessageBuffer[ONIG_MAX_ERROR_MESSAGE_LEN]; onig_error_code_to_str((uint8_t*)errorMessageBuffer, r, &einfo_); isErrorOccured_ = true; errorMessage_ = errorMessageBuffer; irritants_ = L1(Object::makeString(pattern.data())); } }
void ucs4putstr(std::ostream& os, const ucs4string& ustr) { size_t bytes = ustr.size() * 4; os.write(reinterpret_cast<const char *>(ustr.data()), bytes); }