Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpim-sw
cdo
Commits
0cb1e6c3
Commit
0cb1e6c3
authored
Dec 22, 2014
by
Uwe Schulzweida
Browse files
replace memcmp by cmpstrlen
parent
074ae375
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/cdo_int.h
View file @
0cb1e6c3
...
...
@@ -55,11 +55,11 @@ char *strdup(const char *s);
*/
#endif
#define cmpstr(s1, s2) (strncmp(s1, s2, strlen(s2)))
#define cmpstrlen(s1, s2, len) (strncmp(s1, s2, len = strlen(s2)))
/* sxxxYYYYMMDDhhmm0 */
#define DATE_LEN 31
/* YYYYMMDDhhmmss allocate DTLEN+1 !!!! */
#define SET_DATE(dtstr, date, time) (sprintf(dtstr, "%*d%*d", DATE_LEN-6, date, 6, time))
...
...
src/zaxis.c
View file @
0cb1e6c3
...
...
@@ -177,65 +177,65 @@ int zaxisFromFile(FILE *gfp, const char *dname)
pline
=
line
;
while
(
isspace
((
int
)
*
pline
)
)
pline
++
;
if
(
pline
[
0
]
==
'\0'
)
continue
;
if
(
mem
cmp
(
pline
,
"zaxistype"
,
9
)
==
0
||
mem
cmp
(
pline
,
"type"
,
4
)
==
0
)
if
(
cmp
strlen
(
pline
,
"zaxistype"
,
len
)
==
0
||
cmp
strlen
(
pline
,
"type"
,
len
)
==
0
)
{
if
(
*
pline
==
'z'
)
pline
=
skipSeparator
(
pline
+
9
);
else
pline
=
skipSeparator
(
pline
+
4
);
if
(
mem
cmp
(
pline
,
"pressure"
,
6
)
==
0
)
if
(
cmp
strlen
(
pline
,
"pressure"
,
len
)
==
0
)
zaxis
.
type
=
ZAXIS_PRESSURE
;
else
if
(
mem
cmp
(
pline
,
"hybrid_half"
,
11
)
==
0
)
else
if
(
cmp
strlen
(
pline
,
"hybrid_half"
,
len
)
==
0
)
zaxis
.
type
=
ZAXIS_HYBRID_HALF
;
else
if
(
mem
cmp
(
pline
,
"hybrid"
,
6
)
==
0
)
else
if
(
cmp
strlen
(
pline
,
"hybrid"
,
len
)
==
0
)
zaxis
.
type
=
ZAXIS_HYBRID
;
else
if
(
mem
cmp
(
pline
,
"height"
,
6
)
==
0
)
else
if
(
cmp
strlen
(
pline
,
"height"
,
len
)
==
0
)
zaxis
.
type
=
ZAXIS_HEIGHT
;
else
if
(
mem
cmp
(
pline
,
"depth below sea"
,
15
)
==
0
||
mem
cmp
(
pline
,
"depth_below_sea"
,
15
)
==
0
)
else
if
(
cmp
strlen
(
pline
,
"depth below sea"
,
len
)
==
0
||
cmp
strlen
(
pline
,
"depth_below_sea"
,
len
)
==
0
)
zaxis
.
type
=
ZAXIS_DEPTH_BELOW_SEA
;
else
if
(
mem
cmp
(
pline
,
"depth below land"
,
16
)
==
0
||
mem
cmp
(
pline
,
"depth_below_land"
,
16
)
==
0
)
else
if
(
cmp
strlen
(
pline
,
"depth below land"
,
len
)
==
0
||
cmp
strlen
(
pline
,
"depth_below_land"
,
len
)
==
0
)
zaxis
.
type
=
ZAXIS_DEPTH_BELOW_LAND
;
else
if
(
mem
cmp
(
pline
,
"isentropic"
,
10
)
==
0
)
else
if
(
cmp
strlen
(
pline
,
"isentropic"
,
len
)
==
0
)
zaxis
.
type
=
ZAXIS_ISENTROPIC
;
else
if
(
mem
cmp
(
pline
,
"surface"
,
7
)
==
0
)
else
if
(
cmp
strlen
(
pline
,
"surface"
,
len
)
==
0
)
zaxis
.
type
=
ZAXIS_SURFACE
;
else
if
(
mem
cmp
(
pline
,
"generic"
,
7
)
==
0
)
else
if
(
cmp
strlen
(
pline
,
"generic"
,
len
)
==
0
)
zaxis
.
type
=
ZAXIS_GENERIC
;
else
cdoAbort
(
"Invalid zaxisname : %s (zaxis description file: %s)"
,
pline
,
dname
);
}
else
if
(
mem
cmp
(
pline
,
"size"
,
4
)
==
0
)
else
if
(
cmp
strlen
(
pline
,
"size"
,
len
)
==
0
)
{
zaxis
.
size
=
atol
(
skipSeparator
(
pline
+
4
));
zaxis
.
size
=
atol
(
skipSeparator
(
pline
+
len
));
}
else
if
(
mem
cmp
(
pline
,
"vctsize"
,
7
)
==
0
)
else
if
(
cmp
strlen
(
pline
,
"vctsize"
,
len
)
==
0
)
{
zaxis
.
vctsize
=
atol
(
skipSeparator
(
pline
+
7
));
zaxis
.
vctsize
=
atol
(
skipSeparator
(
pline
+
len
));
}
else
if
(
mem
cmp
(
pline
,
"name"
,
4
)
==
0
)
else
if
(
cmp
strlen
(
pline
,
"name"
,
len
)
==
0
)
{
strcpy
(
zaxis
.
name
,
skipSeparator
(
pline
+
4
));
strcpy
(
zaxis
.
name
,
skipSeparator
(
pline
+
len
));
}
else
if
(
mem
cmp
(
pline
,
"longname"
,
8
)
==
0
)
else
if
(
cmp
strlen
(
pline
,
"longname"
,
len
)
==
0
)
{
strcpy
(
zaxis
.
longname
,
skipSeparator
(
pline
+
8
));
strcpy
(
zaxis
.
longname
,
skipSeparator
(
pline
+
len
));
}
else
if
(
mem
cmp
(
pline
,
"units"
,
5
)
==
0
)
else
if
(
cmp
strlen
(
pline
,
"units"
,
len
)
==
0
)
{
strcpy
(
zaxis
.
units
,
skipSeparator
(
pline
+
5
));
strcpy
(
zaxis
.
units
,
skipSeparator
(
pline
+
len
));
}
else
if
(
mem
cmp
(
pline
,
"levels"
,
6
)
==
0
)
else
if
(
cmp
strlen
(
pline
,
"levels"
,
len
)
==
0
)
{
int
i
;
double
flev
;
if
(
zaxis
.
size
>
0
)
{
pline
=
skipSeparator
(
pline
+
6
);
pline
=
skipSeparator
(
pline
+
len
);
zaxis
.
vals
=
(
double
*
)
malloc
(
zaxis
.
size
*
sizeof
(
double
));
for
(
i
=
0
;
i
<
zaxis
.
size
;
i
++
)
...
...
@@ -262,14 +262,14 @@ int zaxisFromFile(FILE *gfp, const char *dname)
cdoAbort
(
"size undefined (zaxis description file: %s)!"
,
dname
);
}
}
else
if
(
mem
cmp
(
pline
,
"vct"
,
3
)
==
0
)
else
if
(
cmp
strlen
(
pline
,
"vct"
,
len
)
==
0
)
{
int
i
;
double
flev
;
if
(
zaxis
.
vctsize
>
0
)
{
pline
=
skipSeparator
(
pline
+
3
);
pline
=
skipSeparator
(
pline
+
len
);
zaxis
.
vct
=
(
double
*
)
malloc
(
zaxis
.
vctsize
*
sizeof
(
double
));
for
(
i
=
0
;
i
<
zaxis
.
vctsize
;
i
++
)
...
...
@@ -296,14 +296,14 @@ int zaxisFromFile(FILE *gfp, const char *dname)
cdoAbort
(
"vctsize undefined (zaxis description file: %s)!"
,
dname
);
}
}
else
if
(
mem
cmp
(
pline
,
"lbounds"
,
7
)
==
0
)
else
if
(
cmp
strlen
(
pline
,
"lbounds"
,
len
)
==
0
)
{
int
i
;
double
flev
;
if
(
zaxis
.
size
>
0
)
{
pline
=
skipSeparator
(
pline
+
7
);
pline
=
skipSeparator
(
pline
+
len
);
zaxis
.
lbounds
=
(
double
*
)
malloc
(
zaxis
.
size
*
sizeof
(
double
));
for
(
i
=
0
;
i
<
zaxis
.
size
;
i
++
)
...
...
@@ -330,14 +330,14 @@ int zaxisFromFile(FILE *gfp, const char *dname)
cdoAbort
(
"size undefined (zaxis description file: %s)!"
,
dname
);
}
}
else
if
(
mem
cmp
(
pline
,
"ubounds"
,
7
)
==
0
)
else
if
(
cmp
strlen
(
pline
,
"ubounds"
,
len
)
==
0
)
{
int
i
;
double
flev
;
if
(
zaxis
.
size
>
0
)
{
pline
=
skipSeparator
(
pline
+
7
);
pline
=
skipSeparator
(
pline
+
len
);
zaxis
.
ubounds
=
(
double
*
)
malloc
(
zaxis
.
size
*
sizeof
(
double
));
for
(
i
=
0
;
i
<
zaxis
.
size
;
i
++
)
...
...
@@ -383,7 +383,7 @@ int zaxisFromName(const char *zaxisname)
zaxisInit
(
&
zaxis
);
pline
=
zaxisname
;
if
(
mem
cmp
(
pline
,
"surface"
,
7
)
==
0
)
/* surface */
if
(
cmp
str
(
pline
,
"surface"
)
==
0
)
/* surface */
{
zaxis
.
type
=
ZAXIS_SURFACE
;
zaxis
.
size
=
1
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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