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
libcdi
Commits
d976d55a
Commit
d976d55a
authored
Apr 07, 2016
by
Thomas Jahns
🤸
Browse files
Use table instead of conditionals.
parent
32a04d02
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/stream_cdf.c
View file @
d976d55a
...
...
@@ -766,21 +766,26 @@ void cdfDefForecastTimeUnits(char *unitstr, int timeunit)
static
void
cdfDefCalendar
(
int
fileID
,
int
ncvarid
,
int
calendar
)
{
size_t
len
;
char
calstr
[
80
];
calstr
[
0
]
=
0
;
if
(
calendar
==
CALENDAR_STANDARD
)
strcpy
(
calstr
,
"standard"
);
else
if
(
calendar
==
CALENDAR_PROLEPTIC
)
strcpy
(
calstr
,
"proleptic_gregorian"
);
else
if
(
calendar
==
CALENDAR_NONE
)
strcpy
(
calstr
,
"none"
);
else
if
(
calendar
==
CALENDAR_360DAYS
)
strcpy
(
calstr
,
"360_day"
);
else
if
(
calendar
==
CALENDAR_365DAYS
)
strcpy
(
calstr
,
"365_day"
);
else
if
(
calendar
==
CALENDAR_366DAYS
)
strcpy
(
calstr
,
"366_day"
);
len
=
strlen
(
calstr
);
if
(
len
)
cdf_put_att_text
(
fileID
,
ncvarid
,
"calendar"
,
len
,
calstr
);
size_t
len
=
0
;
const
char
*
calstr
;
static
const
struct
{
int
calCode
;
const
char
*
calStr
;
}
calTab
[]
=
{
{
CALENDAR_STANDARD
,
"standard"
},
{
CALENDAR_PROLEPTIC
,
"proleptic_gregorian"
},
{
CALENDAR_NONE
,
"none"
},
{
CALENDAR_360DAYS
,
"360_day"
},
{
CALENDAR_365DAYS
,
"365_day"
},
{
CALENDAR_366DAYS
,
"366_day"
},
};
enum
{
calTabSize
=
sizeof
calTab
/
sizeof
calTab
[
0
]
};
for
(
size_t
i
=
0
;
i
<
calTabSize
;
++
i
)
if
(
calTab
[
i
].
calCode
==
calendar
)
{
calstr
=
calTab
[
i
].
calStr
;
len
=
strlen
(
calstr
);
cdf_put_att_text
(
fileID
,
ncvarid
,
"calendar"
,
len
,
calstr
);
break
;
}
}
...
...
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