Skip to content

Commit 995667e

Browse files
authored
Merge pull request #4166 from tautschnig/goto-binary-versioning
Put current goto binary version in a single place
2 parents 8f8ae2b + fa80f58 commit 995667e

File tree

2 files changed

+14
-18
lines changed

2 files changed

+14
-18
lines changed

src/goto-programs/read_bin_goto_object.cpp

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ Date: June 2006
1919
#include <util/irep_serialization.h>
2020

2121
#include "goto_functions.h"
22+
#include "write_goto_binary.h"
2223

23-
/// read goto binary format v5
24+
/// read goto binary format
2425
/// \par parameters: input stream, symbol_table, functions
2526
/// \return true on error, false otherwise
26-
static bool read_bin_goto_object_v5(
27+
static bool read_bin_goto_object(
2728
std::istream &in,
2829
symbol_tablet &symbol_table,
2930
goto_functionst &functions,
@@ -218,23 +219,19 @@ bool read_bin_goto_object(
218219
{
219220
std::size_t version=irepconverter.read_gb_word(in);
220221

221-
switch(version)
222+
if(version < GOTO_BINARY_VERSION)
222223
{
223-
case 1:
224-
case 2:
225-
case 3:
226-
case 4:
227224
message.error() <<
228225
"The input was compiled with an old version of "
229226
"goto-cc; please recompile" << messaget::eom;
230227
return true;
231-
232-
case 5:
233-
return read_bin_goto_object_v5(
234-
in, symbol_table, functions, irepconverter);
235-
break;
236-
237-
default:
228+
}
229+
else if(version == GOTO_BINARY_VERSION)
230+
{
231+
return read_bin_goto_object(in, symbol_table, functions, irepconverter);
232+
}
233+
else
234+
{
238235
message.error() <<
239236
"The input was compiled with an unsupported version of "
240237
"goto-cc; please recompile" << messaget::eom;

src/goto-programs/write_goto_binary.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ Author: CM Wintersteiger
2121

2222
#include <goto-programs/goto_model.h>
2323

24-
/// Writes a goto program to disc, using goto binary format ver 5
25-
bool write_goto_binary_v5(
24+
/// Writes a goto program to disc, using goto binary format
25+
bool write_goto_binary(
2626
std::ostream &out,
2727
const symbol_tablet &symbol_table,
2828
const goto_functionst &goto_functions,
@@ -157,8 +157,7 @@ bool write_goto_binary(
157157
"unknown goto binary version " + std::to_string(version),
158158
"supported version = " + std::to_string(GOTO_BINARY_VERSION));
159159
else
160-
return write_goto_binary_v5(
161-
out, symbol_table, goto_functions, irepconverter);
160+
return write_goto_binary(out, symbol_table, goto_functions, irepconverter);
162161
}
163162

164163
/// Writes a goto program to disc

0 commit comments

Comments
 (0)