Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libcdi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mpim-sw
libcdi
Commits
9971a8b2
Commit
9971a8b2
authored
12 years ago
by
Thomas Jahns
Browse files
Options
Downloads
Patches
Plain Diff
Put recurring code for regex compilation into function.
parent
5ba81982
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/make_fint.c
+34
-40
34 additions, 40 deletions
src/make_fint.c
with
34 additions
and
40 deletions
src/make_fint.c
+
34
−
40
View file @
9971a8b2
...
...
@@ -153,6 +153,9 @@ enum {
static
inline
size_t
compress_whitespace
(
size_t
len
,
char
str
[]);
static
int
reCompile
(
regex_t
*
restrict
RE
,
const
char
*
restrict
REstring
,
char
*
restrict
*
restrict
lineBuf
,
size_t
*
restrict
lineBufSize
);
static
size_t
symRegexCompile
(
size_t
numSyms
,
struct
symbol
symList
[],
char
**
line
,
size_t
*
lineBufSize
);
...
...
@@ -215,37 +218,17 @@ static void fortran_interface(char *fname, char *fnameinc, char *fnameint)
/* compile comment regular expression */
regex_t
commentRE
;
{
int
errcode
;
char
commentREString
[]
=
"^"
WS
"*/
\\
*"
WS
"*(.*"
NWS
")"
WS
"*
\\
*/"
;
if
((
errcode
=
regcomp
(
&
commentRE
,
commentREString
,
REG_EXTENDED
)))
{
line
=
realloc
(
line
,
lineBufSize
=
1024
);
if
(
line
)
{
regerror
(
errcode
,
&
commentRE
,
line
,
lineBufSize
);
fprintf
(
stderr
,
"Error compiling regular expression: %s: %s
\n
"
,
commentREString
,
line
);
exit
(
EXIT_FAILURE
);
}
}
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
;
{
int
errcode
;
char
docCommentREString
[]
=
"^"
WS
"*/
\\
*"
WS
"*"
SYMRE
":"
static
const
char
docCommentREString
[]
=
"^"
WS
"*/
\\
*"
WS
"*"
SYMRE
":"
WS
"*("
NWS
".*"
NWS
")"
WS
"*
\\
*/"
;
if
((
errcode
=
regcomp
(
&
docCommentRE
,
docCommentREString
,
REG_EXTENDED
)))
{
line
=
realloc
(
line
,
lineBufSize
=
1024
);
if
(
line
)
{
regerror
(
errcode
,
&
commentRE
,
line
,
lineBufSize
);
fprintf
(
stderr
,
"Error compiling regular expression: %s: %s
\n
"
,
docCommentREString
,
line
);
exit
(
EXIT_FAILURE
);
}
}
if
(
reCompile
(
&
docCommentRE
,
docCommentREString
,
&
line
,
&
lineBufSize
))
exit
(
EXIT_FAILURE
);
}
/* fortran include */
...
...
@@ -774,26 +757,37 @@ symRegexCompile(size_t numSyms, struct symbol symList[],
size_t
maxMatch
=
0
;
for
(
size_t
sym
=
0
;
sym
<
numSyms
;
++
sym
)
{
int
errcode
;
if
((
errcode
=
regcomp
(
&
symList
[
sym
].
preg
,
symList
[
sym
].
parseRE
,
REG_EXTENDED
)))
{
if
(
*
lineBufSize
<
REGEX_MAX_ERRSTRLEN
)
line
=
realloc
(
line
,
*
lineBufSize
=
REGEX_MAX_ERRSTRLEN
);
if
(
line
)
{
regerror
(
errcode
,
&
symList
[
sym
].
preg
,
*
line
,
*
lineBufSize
);
fprintf
(
stderr
,
"Error compiling regular expression: %s: %s
\n
"
,
symList
[
sym
].
parseRE
,
*
line
);
}
exit
(
EXIT_FAILURE
);
}
if
(
reCompile
(
&
symList
[
sym
].
preg
,
symList
[
sym
].
parseRE
,
line
,
lineBufSize
))
exit
(
EXIT_FAILURE
);
if
(
symList
[
sym
].
nameMatch
>
maxMatch
)
maxMatch
=
symList
[
sym
].
nameMatch
;
}
return
maxMatch
;
}
static
int
reCompile
(
regex_t
*
restrict
RE
,
const
char
*
restrict
REstring
,
char
*
restrict
*
restrict
lineBuf
,
size_t
*
restrict
lineBufSize
)
{
int
errcode
;
if
((
errcode
=
regcomp
(
RE
,
REstring
,
REG_EXTENDED
)))
{
char
*
restrict
line
;
size_t
resize
;
if
(
*
lineBufSize
<
REGEX_MAX_ERRSTRLEN
&&
(
line
=
realloc
(
*
lineBuf
,
resize
=
REGEX_MAX_ERRSTRLEN
)))
{
*
lineBuf
=
line
;
*
lineBufSize
=
resize
;
regerror
(
errcode
,
RE
,
line
,
*
lineBufSize
);
fprintf
(
stderr
,
"Error compiling regular expression: %s: %s
\n
"
,
REstring
,
*
lineBuf
);
}
}
return
errcode
;
}
/* emit conversion code for MPI_Comm argument */
static
int
cfMPICommConvert
(
FILE
*
outfp
,
const
char
*
argName
,
size_t
argNameLen
,
enum
conversionType
part
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment