switch to coroutine execution model
This commit is contained in:
+5
-6
@@ -18,7 +18,7 @@ TextTranscoder::TextTranscoder(const char* to, const char* from)
|
||||
: ic(iconv_open(to, from)) {
|
||||
if (ic == this->INVALID_IC) {
|
||||
string error_str = phosg::string_for_error(errno);
|
||||
throw runtime_error(phosg::string_printf("failed to initialize %s -> %s text converter: %s", from, to, error_str.c_str()));
|
||||
throw runtime_error(std::format("failed to initialize {} -> {} text converter: {}", from, to, error_str));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ TextTranscoder::Result TextTranscoder::operator()(
|
||||
case EILSEQ: {
|
||||
string custom_result = this->on_untranslatable(&src, &src_bytes);
|
||||
if (custom_result.empty()) {
|
||||
throw runtime_error(phosg::string_printf("untranslatable character at position 0x%zX", bytes_read));
|
||||
throw runtime_error(std::format("untranslatable character at position 0x{:X}", bytes_read));
|
||||
} else if (custom_result.size() <= dest_bytes) {
|
||||
memcpy(dest, custom_result.data(), custom_result.size());
|
||||
dest = reinterpret_cast<char*>(dest) + custom_result.size();
|
||||
@@ -59,7 +59,7 @@ TextTranscoder::Result TextTranscoder::operator()(
|
||||
break;
|
||||
}
|
||||
case EINVAL:
|
||||
throw runtime_error(phosg::string_printf("incomplete multibyte sequence at position 0x%zX", bytes_read));
|
||||
throw runtime_error(std::format("incomplete multibyte sequence at position 0x{:X}", bytes_read));
|
||||
case E2BIG:
|
||||
if (!truncate_oversize_result) {
|
||||
throw runtime_error("string does not fit in buffer");
|
||||
@@ -109,13 +109,13 @@ string TextTranscoder::operator()(const void* src, size_t src_bytes) {
|
||||
case EILSEQ: {
|
||||
string custom_result = this->on_untranslatable(&src, &src_bytes);
|
||||
if (custom_result.empty()) {
|
||||
throw runtime_error(phosg::string_printf("untranslatable character at position %zu", bytes_read));
|
||||
throw runtime_error(std::format("untranslatable character at position {}", bytes_read));
|
||||
}
|
||||
blocks.emplace_back(std::move(custom_result));
|
||||
break;
|
||||
}
|
||||
case EINVAL:
|
||||
throw runtime_error(phosg::string_printf("incomplete multibyte sequence at position %zu", bytes_read));
|
||||
throw runtime_error(std::format("incomplete multibyte sequence at position {}", bytes_read));
|
||||
case E2BIG:
|
||||
break;
|
||||
default:
|
||||
@@ -457,7 +457,6 @@ void remove_color(phosg::StringWriter& w, const char* src, size_t max_input_char
|
||||
}
|
||||
src++;
|
||||
}
|
||||
w.put<char>(0);
|
||||
}
|
||||
|
||||
string remove_color(const string& s) {
|
||||
|
||||
Reference in New Issue
Block a user