Commit 947a2ef7 authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Fix handling of empty argument lists in make_fint.c.

parent 5ceefe71
......@@ -4,6 +4,15 @@
This appendix provide a brief listing of the C language bindings of the
CDI library routines:
\section*{\tt \htmlref{cdiClearAdditionalKeys}{cdiClearAdditionalKeys}}
\begin{verbatim}
void cdiClearAdditionalKeys ();
\end{verbatim}
Clear the list of additional GRIB keys..
\section*{\tt \htmlref{cdiDefAdditionalKey}{cdiDefAdditionalKey}}
\begin{verbatim}
......@@ -685,7 +694,7 @@ Copy some entries of a variable list.
\section*{\tt \htmlref{vlistCreate}{vlistCreate}}
\begin{verbatim}
int vlistCreate (
int vlistCreate ();
\end{verbatim}
Create a variable list.
......
......@@ -4,6 +4,15 @@
This appendix provide a brief listing of the Fortran language bindings of the
CDI library routines:
\section*{\tt \htmlref{cdiClearAdditionalKeys}{cdiClearAdditionalKeys}}
\begin{verbatim}
SUBROUTINE cdiClearAdditionalKeys
\end{verbatim}
Clear the list of additional GRIB keys..
\section*{\tt \htmlref{cdiDefAdditionalKey}{cdiDefAdditionalKey}}
\begin{verbatim}
......@@ -687,7 +696,7 @@ Copy some entries of a variable list.
\section*{\tt \htmlref{vlistCreate}{vlistCreate}}
\begin{verbatim}
INTEGER FUNCTION vlistCreate (
INTEGER FUNCTION vlistCreate
\end{verbatim}
Create a variable list.
......
......@@ -1209,6 +1209,9 @@
! INTEGER forecast_type)
EXTERNAL vlistInqVarEnsemble
! cdiClearAdditionalKeys
EXTERNAL cdiClearAdditionalKeys
! cdiDefAdditionalKey
! (CHARACTER*(*) string)
EXTERNAL cdiDefAdditionalKey
......
......@@ -275,6 +275,7 @@ FCALLSCFUN3 (INT, vlistMergedLevel, VLISTMERGEDLEVEL, vlistmergedlevel, INT, INT
FCALLSCSUB5 (vlistDefVarEnsemble, VLISTDEFVARENSEMBLE, vlistdefvarensemble, INT, INT, INT, INT, INT)
FCALLSCFUN5 (INT, vlistInqVarEnsemble, VLISTINQVARENSEMBLE, vlistinqvarensemble, INT, INT, PINT, PINT, PINT)
FCALLSCSUB0 (cdiClearAdditionalKeys, CDICLEARADDITIONALKEYS, cdiclearadditionalkeys)
FCALLSCSUB1 (cdiDefAdditionalKey, CDIDEFADDITIONALKEY, cdidefadditionalkey, STRING)
FCALLSCSUB4 (vlistDefVarIntKey, VLISTDEFVARINTKEY, vlistdefvarintkey, INT, INT, STRING, INT)
FCALLSCSUB4 (vlistDefVarDblKey, VLISTDEFVARDBLKEY, vlistdefvardblkey, INT, INT, STRING, DOUBLE)
......
......@@ -10,7 +10,7 @@
//#include "config.h"
#define VERSION "1.6.1"
#define VERSION "1.6.1.1"
typedef struct
{
size_t naline;
......@@ -243,6 +243,12 @@ static void fortran_interface(char *fname, char *fnameinc, char *fnameint)
if (reCompile(&cppCondRE, cppCondREString, &line, &lineBufSize))
exit(EXIT_FAILURE);
}
regex_t emptyStringRE;
{
static const char emptyStringREString[] = "^"WS"*";
if (reCompile(&emptyStringRE, emptyStringREString, &line, &lineBufSize))
exit(EXIT_FAILURE);
}
/* fortran include */
fprintf(fpinc, "! This file was automatically generated, don't edit!\n");
......@@ -363,6 +369,15 @@ static void fortran_interface(char *fname, char *fnameinc, char *fnameint)
}
/* printf("funcargc = %d\n", funcargc);*/
/* test if argument list is actually empty */
if (funcargc == 1
&& !regexec(&emptyStringRE, line + funcargname[0].rm_so, 1,
reMatch, 0)
&& (funcargname[0].rm_so + reMatch[0].rm_eo
== funcargname[funcargc].rm_so - 1))
{
funcargc = 0;
}
{
size_t i;
for (i = 0; i < funcargc; ++i )
......@@ -544,7 +559,7 @@ static void fortran_interface(char *fname, char *fnameinc, char *fnameint)
}
strcat(xline, farg);
}
if ( funcargc ) strcat(xline, ");");
strcat(xline, ");");
cdoc[ncdoc].aline[cdoc[ncdoc].naline++] = strdup(xline);
cdoc[ncdoc].text = strdup(xdes);
......@@ -557,11 +572,12 @@ static void fortran_interface(char *fname, char *fnameinc, char *fnameint)
fdoc[nfdoc].fname = strdup(funcname);
if ( functype == ISVOID )
nch = sprintf(xline, "SUBROUTINE %s (", xname);
nch = sprintf(xline, "SUBROUTINE %s", xname);
else
nch = sprintf(xline, "%s FUNCTION %s (", funArgSym[functype].f77name, xname);
nch = sprintf(xline, "%s FUNCTION %s", funArgSym[functype].f77name, xname);
if ( (funcargc == 1 && funcargtype[0] == ISVOID) ) funcargc = 0;
if (funcargc) strcat(xline, " ("), nch += 2;
for (size_t i = 0; i < funcargc; i++ )
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment