Skip to content

Commit

Permalink
Revert breaking change from df5f7ad
Browse files Browse the repository at this point in the history
Also fix bug in Transducer::read which would not read in states if
they had no incoming or outgoing edges, leaving gaps
  • Loading branch information
mr-martian committed Aug 21, 2024
1 parent b248842 commit 5bc7fc5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
project(lttoolbox
VERSION 3.7.12
VERSION 3.7.13
LANGUAGES CXX C
)
set(VERSION ${PROJECT_VERSION})
Expand Down
7 changes: 3 additions & 4 deletions lttoolbox/string_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,9 @@ StringUtils::ftoa(double f)
int
StringUtils::stoi(const UString& str)
{
int ret, len;
int c = u_sscanf(str.c_str(), "%d%n", &ret, &len);
// apparently %n isn't counted when calculating the return value of u_sscanf
if (c != 1 || static_cast<size_t>(len) != str.size()) {
int ret;
int c = u_sscanf(str.c_str(), "%d", &ret);
if (c != 1) {
throw std::invalid_argument("unable to parse int");
}
return ret;
Expand Down
3 changes: 3 additions & 0 deletions lttoolbox/transducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,9 @@ Transducer::read(FILE *input, int const decalage)
{
int number_of_local_transitions = Compression::multibyte_read(input);
int tagbase = 0;
if (new_t.transitions.find(current_state) == new_t.transitions.end()) {
new_t.transitions[current_state].clear(); // force create
}
while(number_of_local_transitions > 0)
{
number_of_local_transitions--;
Expand Down

0 comments on commit 5bc7fc5

Please sign in to comment.