Skip to content

Commit b2e4252

Browse files
Simpler parse function
now defaults to 1s on \p with no numbers Co-Authored-By: Leifa <26681464+TrickyLeifa@users.noreply.github.com>
1 parent bf7c3fe commit b2e4252

1 file changed

Lines changed: 10 additions & 11 deletions

File tree

src/courtroom.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3515,21 +3515,20 @@ struct PauseInfo
35153515

35163516
static PauseInfo parse_pause_duration(const QString &text, int start_pos)
35173517
{
3518-
static const int max_digits = QString::number(10000).length();
3519-
static const QRegularExpression pause_regex(QString("^([1-9]\\d{0,%1})").arg(max_digits - 1));
3520-
QRegularExpressionMatch match = pause_regex.match(text.mid(start_pos));
3521-
if (!match.hasMatch())
3518+
int pos = start_pos;
3519+
while (pos < text.length() && text[pos].isDigit())
35223520
{
3523-
return {0, 0, false};
3521+
pos++;
35243522
}
3525-
bool ok = false;
3526-
int value = match.captured(1).toInt(&ok);
3527-
int length = match.capturedLength(0);
3528-
if (!ok || value < 1 || value > 10000)
3523+
3524+
if (pos == start_pos)
35293525
{
3530-
return {0, 0, false};
3526+
return {1000, 0, true};
35313527
}
3532-
return {value, length, true};
3528+
3529+
bool ok;
3530+
int value = qMin(10000, text.mid(start_pos, pos - start_pos).toInt(&ok));
3531+
return ok ? PauseInfo{value, pos - start_pos, true} : PauseInfo{0, 0, false};
35333532
}
35343533

35353534
QString Courtroom::filter_ic_text(QString p_text, bool html, int target_pos, int default_color)

0 commit comments

Comments
 (0)