Skip to content

Commit

Permalink
Add RequireVersion() sfac call
Browse files Browse the repository at this point in the history
  • Loading branch information
fnevgeny committed Sep 27, 2021
1 parent 6e30265 commit ba2d282
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
6 changes: 6 additions & 0 deletions doc/sfaclang.tex
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ \subsection{Basic Configuration}
are not set, the standard values are used.
\end{fundesc}

\begin{fundesc}{RequireVersion}{v}
Ensure that \cFAC is {\em at least} of version \var{v}, with \var{v} in the
``x.y.z'' format, e.g., ``1.7.0''. This call should be the first in a script to
avoid unpleasant surprises.
\end{fundesc}

\begin{fundesc}{SetErrorOutput}{fn}
Redirect error and warning messages to a file. Two special destinations are
recognized, ``stderr'' and ``stdout''. Otherwise, \var{fn} is treated as a
Expand Down
41 changes: 41 additions & 0 deletions sfac/sfac.c
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,46 @@ static int PRefineRadial(int argc, char *argv[], int argt[],
return RefineRadial(cfac, maxfun, msglvl);
}

static int PRequireVersion(int argc, char *argv[], int argt[],
ARRAY *variables) {
int v, vsub1, vsub2, nv_req, nv_cur;
char *s, *tok;
int strict = 0;

if (argc != 1 || argt[0] != STRING ) {
return -1;
}

s = argv[0];

tok = strtok(s, ".");
if (!tok) {
return -1;
}
v = atoi(tok);

tok = strtok(NULL, ".");
if (!tok) {
return -1;
}
vsub1 = atoi(tok);

tok = strtok(NULL, ".");
if (!tok) {
return -1;
}
vsub2 = atoi(tok);

nv_req = 10000*v + 100*vsub1 + vsub2;
nv_cur = 10000*CFAC_VERSION + 100*CFAC_SUBVERSION + CFAC_SUBSUBVERSION;

if (nv_req > nv_cur || (strict && nv_req != nv_cur)) {
return -1;
}

return 0;
}

static int PPause(int argc, char *argv[], int argt[],
ARRAY *variables) {
char s[10];
Expand Down Expand Up @@ -2925,6 +2965,7 @@ static METHOD methods[] = {
{"RRTable", PRRTable},
{"RecStates", PRecStates},
{"RefineRadial", PRefineRadial},
{"RequireVersion", PRequireVersion},
{"SetAICut", PSetAICut},
{"SetAngZCut", PSetAngZCut},
{"SetAngZOptions", PSetAngZOptions},
Expand Down

0 comments on commit ba2d282

Please sign in to comment.