Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpim-sw
libcdi
Commits
6c38e1f0
Commit
6c38e1f0
authored
Dec 02, 2014
by
Thomas Jahns
🤸
Browse files
Add matching of multi-line doc-comments to make_fint.c.
parent
78fe5e14
Changes
3
Hide whitespace changes
Inline
Side-by-side
doc/pio/tex/c_quick_ref.tex
View file @
6c38e1f0
...
...
@@ -4,6 +4,16 @@
This appendix provide a brief listing of the C language bindings of the
CDI library routines:
\section*
{
\tt
\htmlref
{
cdiPioNoPostCommSetup
}{
cdiPioNoPostCommSetup
}}
\begin{verbatim}
void cdiPioNoPostCommSetup ();
\end{verbatim}
Dummy function to use as argument to pioInit
if no actions are necessary after I/O servers initialize communication.
\section*
{
\tt
\htmlref
{
pioInit
}{
pioInit
}}
\begin{verbatim}
...
...
doc/pio/tex/f_quick_ref.tex
View file @
6c38e1f0
...
...
@@ -4,6 +4,16 @@
This appendix provide a brief listing of the Fortran language bindings of the
CDI library routines:
\section*
{
\tt
\htmlref
{
cdiPioNoPostCommSetup
}{
cdiPioNoPostCommSetup
}}
\begin{verbatim}
SUBROUTINE cdiPioNoPostCommSetup
\end{verbatim}
Dummy function to use as argument to pioInit
if no actions are necessary after I/O servers initialize communication.
\section*
{
\tt
\htmlref
{
pioInit
}{
pioInit
}}
\begin{verbatim}
...
...
src/make_fint.c
View file @
6c38e1f0
...
...
@@ -208,6 +208,14 @@ symRegexCompile(size_t numSyms, struct symbol symList[],
static
void
build_header_name
(
const
char
*
fname
,
char
*
cppMacro
);
static
int
detectComment
(
char
**
line_
,
ssize_t
*
lineLen
,
size_t
*
lineBufSize
,
size_t
maxMatch
,
regmatch_t
reMatch
[],
char
*
xname
,
size_t
*
xnameLen
,
char
*
xdes
,
FILE
*
fpin
,
FILE
*
fpinc
,
FILE
*
fpint
);
static
regex_t
commentStartRE
,
commentEndRE
,
commentRE
,
docCommentRE
;
static
void
fortran_interface
(
char
*
fname
,
char
*
fnameinc
,
char
*
fnameint
,
const
char
*
doc_root
)
{
...
...
@@ -262,16 +270,26 @@ static void fortran_interface(char *fname, char *fnameinc, char *fnameint,
maxMatch
=
maxFunMatch
;
}
++
maxMatch
;
reMatch
=
(
regmatch_t
*
)
malloc
((
size_t
)
maxMatch
*
sizeof
(
reMatch
[
0
]));
/* compile comment regular expression */
regex_t
commentRE
;
reMatch
=
(
regmatch_t
*
)
malloc
((
size_t
)
maxMatch
*
sizeof
(
reMatch
[
0
]));
/* compile comment start regular expression */
{
static
const
char
commentStartREString
[]
=
"^"
WS
"*/
\\
*"
WS
"*(.*"
NWS
")"
WS
"*"
;
if
(
reCompile
(
&
commentStartRE
,
commentStartREString
,
&
line
,
&
lineBufSize
))
exit
(
EXIT_FAILURE
);
}
/* compile comment end regular expression */
{
static
const
char
commentEndREString
[]
=
"
\\
*/"
;
if
(
reCompile
(
&
commentEndRE
,
commentEndREString
,
&
line
,
&
lineBufSize
))
exit
(
EXIT_FAILURE
);
}
/* compile complete comment regular expression */
{
static
const
char
commentREString
[]
=
"^"
WS
"*/
\\
*"
WS
"*(.*"
NWS
")"
WS
"*
\\
*/"
;
if
(
reCompile
(
&
commentRE
,
commentREString
,
&
line
,
&
lineBufSize
))
exit
(
EXIT_FAILURE
);
}
/* compile documentation comment regular expression */
regex_t
docCommentRE
;
{
static
const
char
docCommentREString
[]
=
"^"
WS
"*/
\\
*"
WS
"*"
SYMRE
":"
WS
"*("
NWS
".*"
NWS
")"
WS
"*
\\
*/"
;
...
...
@@ -731,29 +749,11 @@ static void fortran_interface(char *fname, char *fnameinc, char *fnameint,
/* fortran include */
fputs
(
line
,
fpint
);
}
else
if
(
!
regexec
(
&
docCommentRE
,
line
,
maxMatch
,
reMatch
,
0
))
{
/* found documentation comment */
size_t
nameMatchLen
=
(
size_t
)(
reMatch
[
1
].
rm_eo
-
reMatch
[
1
].
rm_so
),
docMatchLen
=
(
size_t
)(
reMatch
[
2
].
rm_eo
-
reMatch
[
2
].
rm_so
);
memcpy
(
xname
,
line
+
reMatch
[
1
].
rm_so
,
nameMatchLen
);
xname
[
nameMatchLen
]
=
0
;
xnameLen
=
nameMatchLen
;
memcpy
(
xdes
,
line
+
reMatch
[
2
].
rm_so
,
docMatchLen
);
xdes
[
docMatchLen
]
=
0
;
printf
(
"Found documentation for
\"
%s
\"
:
\"
%s
\"\n
"
,
xname
,
xdes
);
}
else
if
(
!
regexec
(
&
commentRE
,
line
,
maxMatch
,
reMatch
,
0
))
{
size_t
commentLen
=
(
size_t
)(
reMatch
[
1
].
rm_eo
-
reMatch
[
1
].
rm_so
);
const
char
*
comment
=
line
+
reMatch
[
1
].
rm_so
;
/* fortran include */
fprintf
(
fpinc
,
"!
\n
! %.*s
\n
!
\n
"
,
(
int
)
commentLen
,
comment
);
/* fortran interface */
fprintf
(
fpint
,
"
\n
/* %.*s */
\n\n
"
,
(
int
)
commentLen
,
comment
);
}
else
if
(
detectComment
(
&
line
,
&
lineLen
,
&
lineBufSize
,
maxMatch
,
reMatch
,
xname
,
&
xnameLen
,
xdes
,
fpin
,
fpinc
,
fpint
))
;
else
{
if
(
lineLen
>
1
)
...
...
@@ -1052,6 +1052,102 @@ static int cfVoidFuncPrologue(FILE *outfp, size_t argNum)
return
retval
;
}
enum
{
FOUND_NOTHING
,
FOUND_COMMENT
,
FOUND_DOCCOMMENT
,
};
static
int
detectComment
(
char
**
line_
,
ssize_t
*
lineLen
,
size_t
*
lineBufSize
,
size_t
maxMatch
,
regmatch_t
reMatch
[],
char
*
xname
,
size_t
*
xnameLen
,
char
*
xdes
,
FILE
*
fpin
,
FILE
*
fpinc
,
FILE
*
fpint
)
{
char
*
restrict
line
=
*
line_
;
int
matchType
;
do
{
if
(
!
regexec
(
&
docCommentRE
,
line
,
maxMatch
,
reMatch
,
0
))
{
/* found documentation comment */
size_t
nameMatchLen
=
(
size_t
)(
reMatch
[
1
].
rm_eo
-
reMatch
[
1
].
rm_so
),
docMatchLen
=
(
size_t
)(
reMatch
[
2
].
rm_eo
-
reMatch
[
2
].
rm_so
);
memcpy
(
xname
,
line
+
reMatch
[
1
].
rm_so
,
nameMatchLen
);
xname
[
nameMatchLen
]
=
0
;
*
xnameLen
=
nameMatchLen
;
memcpy
(
xdes
,
line
+
reMatch
[
2
].
rm_so
,
docMatchLen
);
{
char
*
eol
=
xdes
;
while
((
eol
=
strchr
(
eol
,
'\n'
)))
{
++
eol
;
/* delete whitespace following newline */
size_t
squeezeLen
=
strspn
(
eol
,
"
\t
*"
);
char
*
startoftext
=
eol
+
squeezeLen
;
memmove
(
eol
,
startoftext
,
docMatchLen
-
(
size_t
)(
eol
-
xdes
));
docMatchLen
-=
squeezeLen
;
}
}
xdes
[
docMatchLen
]
=
0
;
printf
(
"Found documentation for
\"
%s
\"
:
\"
%s
\"\n
"
,
xname
,
xdes
);
matchType
=
FOUND_DOCCOMMENT
;
break
;
}
else
if
(
!
regexec
(
&
commentRE
,
line
,
maxMatch
,
reMatch
,
0
))
{
size_t
commentLen
=
(
size_t
)(
reMatch
[
1
].
rm_eo
-
reMatch
[
1
].
rm_so
);
char
*
comment
=
line
+
reMatch
[
1
].
rm_so
;
{
char
savedCommentEnd
=
comment
[
commentLen
];
comment
[
commentLen
]
=
'\0'
;
/* fortran include */
fputs
(
"!
\n
"
,
fpinc
);
char
*
cline
=
comment
;
do
{
cline
+=
strspn
(
cline
,
"
\t
*"
);
char
*
eol
=
strchr
(
cline
,
'\n'
);
if
(
!
eol
)
eol
=
comment
+
commentLen
;
size_t
lineLen
=
(
size_t
)(
eol
-
cline
);
fprintf
(
fpinc
,
"! %.*s
\n
"
,
(
int
)
lineLen
,
cline
);
cline
=
(
eol
!=
comment
+
commentLen
)
?
eol
+
1
:
NULL
;
}
while
(
cline
);
fputs
(
"!
\n
"
,
fpinc
);
comment
[
commentLen
]
=
savedCommentEnd
;
}
/* fortran interface */
fprintf
(
fpint
,
"
\n
/* %.*s */
\n\n
"
,
(
int
)
commentLen
,
comment
);
matchType
=
FOUND_COMMENT
;
break
;
}
/* found comment start, read further lines and retry */
else
if
(
!
regexec
(
&
commentStartRE
,
line
,
maxMatch
,
reMatch
,
0
))
{
int
foundCommentEnd
=
0
;
char
*
lineExtension
=
NULL
;
size_t
extSize
=
0
;
do
{
ssize_t
extLen
;
if
((
extLen
=
getline
(
&
lineExtension
,
&
extSize
,
fpin
))
<=
0
)
break
;
if
((
size_t
)(
*
lineLen
+
extLen
)
>=
*
lineBufSize
)
if
(
!
(
line
=
realloc
(
line
,
(
size_t
)(
*
lineLen
+
extLen
+
1
))))
exit
(
EXIT_FAILURE
);
memcpy
(
line
+
*
lineLen
,
lineExtension
,
(
size_t
)
extLen
+
1
);
*
lineLen
+=
extLen
;
foundCommentEnd
=
!
regexec
(
&
commentEndRE
,
lineExtension
,
maxMatch
,
reMatch
,
0
);
}
while
(
!
foundCommentEnd
);
}
else
/* found no comment at all */
break
;
}
while
(
1
);
*
line_
=
line
;
return
matchType
;
}
/*
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment