File tree Expand file tree Collapse file tree 3 files changed +39
-0
lines changed
Expand file tree Collapse file tree 3 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -1626,6 +1626,7 @@ extern WORD* flint_ratfun_add(PHEAD WORD *, WORD *);
16261626extern int flint_ratfun_normalize (PHEAD WORD * );
16271627extern WORD * flint_rem (PHEAD WORD * , WORD * , const WORD );
16281628extern void flint_startup_init (void );
1629+ extern void flint_check_version (void );
16291630#endif
16301631
16311632extern void optimize_print_code (int );
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ extern "C" {
77#include " form3.h"
88}
99
10+ #include < sstream>
1011#include " flintinterface.h"
1112
1213
@@ -282,4 +283,38 @@ void flint_startup_init(void) {
282283}
283284/*
284285 #] flint_startup_init :
286+ #[ flint_check_version :
287+ */
288+
289+ /* *
290+ * Checks the FLINT library version at runtime.
291+ *
292+ * This function should be called at startup.
293+ * The program will terminate if a known buggy version of FLINT is detected.
294+ */
295+ void flint_check_version (void ) {
296+ bool ok = true ;
297+ std::stringstream ss (flint_version);
298+ int major, minor, patch;
299+ char dot1, dot2;
300+ if ( ss >> major >> dot1 >> minor >> dot2 >> patch ) {
301+ if ( dot1 != ' .' || dot2 != ' .' || major < 0 || minor < 0 || patch < 0 ) {
302+ ok = false ;
303+ }
304+ else if ( major * 10000 + minor * 100 + patch < 30200 ) {
305+ // flint < 3.2.0: https://github.com/form-dev/form/issues/679
306+ ok = false ;
307+ }
308+ }
309+ else {
310+ ok = false ;
311+ }
312+ if ( !ok ) {
313+ MesPrint (" Bad FLINT version detected at runtime: %s" ,flint_version);
314+ Terminate (-2 );
315+ }
316+ }
317+
318+ /*
319+ #] flint_check_version :
285320*/
Original file line number Diff line number Diff line change @@ -1739,6 +1739,9 @@ int main(int argc, char **argv)
17391739 Globalize (1 );
17401740#ifdef WITH_ALARM
17411741 if ( AM .TimeLimit > 0 ) alarm (AM .TimeLimit );
1742+ #endif
1743+ #ifdef WITHFLINT
1744+ flint_check_version ();
17421745#endif
17431746 TimeCPU (0 );
17441747 TimeChildren (0 );
You can’t perform that action at this time.
0 commit comments