From daa1c63112bfea28613026b408eb412d9518bb9a Mon Sep 17 00:00:00 2001 From: Daniel Swanson Date: Sat, 20 Jul 2024 09:39:44 -0400 Subject: [PATCH] substr before calling stoi (closes #99) --- src/pattern.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pattern.cc b/src/pattern.cc index 441df57..d2a919d 100644 --- a/src/pattern.cc +++ b/src/pattern.cc @@ -468,7 +468,8 @@ PatternBuilder::write(FILE* output, int longest, vector> inpu if(s.compare(0, rule_sym_pre.size(), rule_sym_pre) != 0) { continue; } - const int rule_num = StringUtils::stoi(s.substr(rule_sym_pre.size())); + size_t pos = rule_sym_pre.size(); + const int rule_num = StringUtils::stoi(s.substr(pos, s.size()-pos-1)); transducer.setFinal(src); finals_rules.insert(make_pair(src, make_pair(rule_num, wgt))); }