Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
a457ee0a
Commit
a457ee0a
authored
Jan 06, 2004
by
Peter Berg Larsen
Committed by
Alexandre Julliard
Jan 06, 2004
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
%[a-z] and %[z-a] are interpreted as equivalent to %[abcde...z].
Added some scanf tests.
parent
5d19e6c3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
6 deletions
+23
-6
scanf.h
dlls/msvcrt/scanf.h
+9
-5
scanf.c
dlls/msvcrt/tests/scanf.c
+14
-1
No files found.
dlls/msvcrt/scanf.h
View file @
a457ee0a
...
...
@@ -444,13 +444,17 @@ int _FUNCTION_ {
format
++
;
}
while
(
*
format
&&
(
*
format
!=
']'
))
{
/* According to:
* http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/html/_crt_scanf_width_specification.asp
* "Note that %[a-z] and %[z-a] are interpreted as equivalent to %[abcde...z]." */
if
((
*
format
==
'-'
)
&&
(
*
(
format
+
1
)
!=
']'
))
{
int
n
=
0
;
for
(;(
n
+
*
(
format
-
1
))
<
*
(
format
+
1
);
n
++
)
RtlSetBits
(
&
bitMask
,
n
+
*
(
format
-
1
),
1
);
if
((
*
(
format
-
1
))
<
*
(
format
+
1
))
RtlSetBits
(
&
bitMask
,
*
(
format
-
1
)
+
1
,
*
(
format
+
1
)
-
*
(
format
-
1
));
else
RtlSetBits
(
&
bitMask
,
*
(
format
+
1
)
,
*
(
format
-
1
)
-
*
(
format
+
1
));
format
++
;
}
RtlSetBits
(
&
bitMask
,
*
format
,
1
);
}
else
RtlSetBits
(
&
bitMask
,
*
format
,
1
);
format
++
;
}
/* read until char is not suitable */
...
...
dlls/msvcrt/tests/scanf.c
View file @
a457ee0a
...
...
@@ -57,19 +57,32 @@ static void test_sscanf( void )
ok
(
sscanf
(
buffer
,
format
,
&
result
)
==
1
,
"sscanf failed"
);
ok
(
result
==
12
,
"sscanf reads %x instead of %x"
,
result
,
12
);
/*Check float */
/*
Check float */
ret
=
sprintf
(
buffer
,
"%f %f"
,
res1
,
res2
);
ret
=
sscanf
(
buffer
,
"%f%f"
,
&
res11
,
&
res12
);
ok
(
(
res11
==
res1
)
&&
(
res12
==
res2
),
"Error reading floats"
);
/* check strings */
ret
=
sprintf
(
buffer
,
" %s"
,
pname
);
ret
=
sscanf
(
buffer
,
"%*c%[^
\n
]"
,
buffer1
);
ok
(
ret
==
1
,
"Error with format
\"
%s
\"
"
,
"%*c%[^
\n
]"
);
ok
(
strncmp
(
pname
,
buffer1
,
strlen
(
buffer1
))
==
0
,
"Error with
\"
%s
\"
\"
%s
\"
"
,
pname
,
buffer1
);
ret
=
sscanf
(
"abcefgdh"
,
"%*[a-cg-e]%c"
,
&
buffer
[
0
]);
ok
(
ret
==
1
,
"Error with format
\"
%s
\"
"
,
"%*[a-cg-e]%c"
);
ok
(
buffer
[
0
]
==
'd'
,
"Error with
\"
abcefgdh
\"
\"
%c
\"
"
,
buffer
[
0
]);
ret
=
sscanf
(
"abcefgdh"
,
"%*[a-cd-dg-e]%c"
,
&
buffer
[
0
]);
ok
(
ret
==
1
,
"Error with format
\"
%s
\"
"
,
"%*[a-cd-dg-e]%c"
);
ok
(
buffer
[
0
]
==
'h'
,
"Error with
\"
abcefgdh
\"
\"
%c
\"
"
,
buffer
[
0
]);
/* check digits */
ret
=
sprintf
(
buffer
,
"%d:%d:%d"
,
hour
,
min
,
sec
);
ret
=
sscanf
(
buffer
,
"%d%n"
,
&
number
,
&
number_so_far
);
ok
(
ret
==
1
,
"problem with format arg
\"
%%d%%n
\"
"
);
ok
(
number
==
hour
,
"Read wrong arg %d instead of %d"
,
number
,
hour
);
ok
(
number_so_far
==
2
,
"Read wrong arg for
\"
%%n
\"
%d instead of 2"
,
number_so_far
);
ret
=
sscanf
(
buffer
+
2
,
"%*c%n"
,
&
number_so_far
);
ok
(
ret
==
0
,
"problem with format arg
\"
%%*c%%n
\"
"
);
ok
(
number_so_far
==
1
,
"Read wrong arg for
\"
%%n
\"
%d instead of 2"
,
number_so_far
);
...
...
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