Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
asn1c
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
asn1c
Commits
4b4c146c
Commit
4b4c146c
authored
Jul 04, 2005
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ignoring non-normalized values
parent
398176b2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
6 deletions
+67
-6
skeletons/GeneralizedTime.c
skeletons/GeneralizedTime.c
+11
-6
skeletons/tests/check-GeneralizedTime.c
skeletons/tests/check-GeneralizedTime.c
+56
-0
No files found.
skeletons/GeneralizedTime.c
View file @
4b4c146c
...
@@ -559,18 +559,23 @@ asn_time2GT_frac(GeneralizedTime_t *opt_gt, const struct tm *tm, long frac_value
...
@@ -559,18 +559,23 @@ asn_time2GT_frac(GeneralizedTime_t *opt_gt, const struct tm *tm, long frac_value
/*
/*
* Deal with fractions.
* Deal with fractions.
*/
*/
if
(
frac_base
>=
10
&&
frac_value
>
0
)
{
if
(
frac_base
>=
10
&&
frac_value
>
0
/* 1001 ms? should ignore or adjust seconds */
&&
(
frac_value
/
frac_base
)
==
0
)
{
char
*
end
=
p
+
1
+
6
;
/* '.' + maximum 6 digits */
char
*
end
=
p
+
1
+
6
;
/* '.' + maximum 6 digits */
char
*
z
;
char
*
z
=
p
;
*
p
++
=
'.'
;
*
z
++
=
'.'
;
frac_value
%=
frac_base
;
do
{
do
{
int
digit
;
int
digit
;
frac_base
/=
10
;
frac_base
/=
10
;
digit
=
frac_value
/
frac_base
;
digit
=
frac_value
/
frac_base
;
frac_value
%=
frac_base
;
frac_value
%=
frac_base
;
*
p
++
=
digit
+
0x30
;
*
z
++
=
digit
+
0x30
;
}
while
(
frac_base
>=
10
&&
frac_value
>
0
&&
p
<
end
);
}
while
(
frac_base
>=
10
&&
frac_value
>
0
&&
z
<
end
);
for
(
z
=
p
-
1
;
*
z
==
0x30
;
--
z
);
/* Strip zeroes */
for
(
--
z
;
*
z
==
0x30
;
--
z
);
/* Strip zeroes */
p
=
z
+
(
*
z
!=
'.'
);
p
=
z
+
(
*
z
!=
'.'
);
size
=
p
-
buf
;
size
=
p
-
buf
;
}
}
...
...
skeletons/tests/check-GeneralizedTime.c
View file @
4b4c146c
...
@@ -83,11 +83,67 @@ recode(char *time_str, const char *expect) {
...
@@ -83,11 +83,67 @@ recode(char *time_str, const char *expect) {
FREEMEM
(
gt
.
buf
);
FREEMEM
(
gt
.
buf
);
}
}
static
void
check_fractions
()
{
GeneralizedTime_t
*
gt
=
0
;
struct
tm
tm
;
memset
(
&
tm
,
0
,
sizeof
tm
);
tm
.
tm_year
=
70
;
tm
.
tm_mday
=
1
;
gt
=
asn_time2GT_frac
(
gt
,
&
tm
,
-
1
,
-
1
,
1
);
assert
(
gt
);
printf
(
"[%s]
\n
"
,
gt
->
buf
);
assert
(
strcmp
((
char
*
)
gt
->
buf
,
"19700101000000Z"
)
==
0
);
gt
=
asn_time2GT_frac
(
gt
,
&
tm
,
0
,
0
,
1
);
assert
(
gt
);
printf
(
"[%s]
\n
"
,
gt
->
buf
);
assert
(
strcmp
((
char
*
)
gt
->
buf
,
"19700101000000Z"
)
==
0
);
gt
=
asn_time2GT_frac
(
gt
,
&
tm
,
0
,
-
1
,
1
);
assert
(
gt
);
printf
(
"[%s]
\n
"
,
gt
->
buf
);
assert
(
strcmp
((
char
*
)
gt
->
buf
,
"19700101000000Z"
)
==
0
);
gt
=
asn_time2GT_frac
(
gt
,
&
tm
,
-
1
,
0
,
1
);
assert
(
gt
);
printf
(
"[%s]
\n
"
,
gt
->
buf
);
assert
(
strcmp
((
char
*
)
gt
->
buf
,
"19700101000000Z"
)
==
0
);
gt
=
asn_time2GT_frac
(
gt
,
&
tm
,
10
,
0
,
1
);
assert
(
gt
);
printf
(
"[%s]
\n
"
,
gt
->
buf
);
assert
(
strcmp
((
char
*
)
gt
->
buf
,
"19700101000000Z"
)
==
0
);
/* Normalization should happen prior calling the _frac() */
gt
=
asn_time2GT_frac
(
gt
,
&
tm
,
55
,
10
,
1
);
assert
(
gt
);
printf
(
"[%s]
\n
"
,
gt
->
buf
);
assert
(
strcmp
((
char
*
)
gt
->
buf
,
"19700101000000Z"
)
==
0
);
gt
=
asn_time2GT_frac
(
gt
,
&
tm
,
10
,
20
,
1
);
assert
(
gt
);
printf
(
"[%s]
\n
"
,
gt
->
buf
);
assert
(
strcmp
((
char
*
)
gt
->
buf
,
"19700101000000.5Z"
)
==
0
);
gt
=
asn_time2GT_frac
(
gt
,
&
tm
,
-
10
,
20
,
1
);
assert
(
gt
);
printf
(
"[%s]
\n
"
,
gt
->
buf
);
assert
(
strcmp
((
char
*
)
gt
->
buf
,
"19700101000000Z"
)
==
0
);
FREEMEM
(
gt
->
buf
);
FREEMEM
(
gt
);
}
int
int
main
(
int
ac
,
char
**
av
)
{
main
(
int
ac
,
char
**
av
)
{
(
void
)
av
;
(
void
)
av
;
check_fractions
();
recognize
(
"200401250"
,
-
1
,
0
);
recognize
(
"200401250"
,
-
1
,
0
);
recognize
(
"2004012509300"
,
-
1
,
0
);
recognize
(
"2004012509300"
,
-
1
,
0
);
recognize
(
"20040125093000-"
,
-
1
,
0
);
recognize
(
"20040125093000-"
,
-
1
,
0
);
...
...
Write
Preview
Markdown
is supported
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