Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
8f8ec2ad
Commit
8f8ec2ad
authored
Aug 19, 2005
by
Jason Edmeades
Committed by
Alexandre Julliard
Aug 19, 2005
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
_swab failed if src == dest, plus some testcases.
parent
c1cd0d22
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
3 deletions
+52
-3
string.c
dlls/msvcrt/string.c
+5
-3
string.c
dlls/msvcrt/tests/string.c
+47
-0
No files found.
dlls/msvcrt/string.c
View file @
8f8ec2ad
...
...
@@ -106,9 +106,11 @@ void MSVCRT__swab(char* src, char* dst, int len)
len
=
(
unsigned
)
len
>>
1
;
while
(
len
--
)
{
*
dst
++
=
src
[
1
];
*
dst
++
=
*
src
++
;
src
++
;
char
s0
=
src
[
0
];
char
s1
=
src
[
1
];
*
dst
++
=
s1
;
*
dst
++
=
s0
;
src
=
src
+
2
;
}
}
}
...
...
dlls/msvcrt/tests/string.c
View file @
8f8ec2ad
...
...
@@ -29,6 +29,50 @@ static int* (*pmemcmp)(void *, const void *, size_t n);
#define SETNOFAIL(x,y) x = (void*)GetProcAddress(hMsvcrt,y)
#define SET(x,y) SETNOFAIL(x,y); ok(x != NULL, "Export '%s' not found\n", y)
static
void
test_swab
(
void
)
{
char
original
[]
=
"BADCFEHGJILKNMPORQTSVUXWZY@#"
;
char
expected1
[]
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZ@#"
;
char
expected2
[]
=
"ABCDEFGHIJKLMNOPQRSTUVWX$"
;
char
expected3
[]
=
"$"
;
char
from
[
30
];
char
to
[
30
];
int
testsize
;
/* Test 1 - normal even case */
memset
(
to
,
'$'
,
sizeof
(
to
));
memset
(
from
,
'@'
,
sizeof
(
from
));
testsize
=
26
;
memcpy
(
from
,
original
,
testsize
);
_swab
(
from
,
to
,
testsize
);
ok
(
memcmp
(
to
,
expected1
,
testsize
)
==
0
,
"Testing even size %d returned '%*.*s'
\n
"
,
testsize
,
testsize
,
testsize
,
to
);
/* Test 2 - uneven case */
memset
(
to
,
'$'
,
sizeof
(
to
));
memset
(
from
,
'@'
,
sizeof
(
from
));
testsize
=
25
;
memcpy
(
from
,
original
,
testsize
);
_swab
(
from
,
to
,
testsize
);
ok
(
memcmp
(
to
,
expected2
,
testsize
)
==
0
,
"Testing odd size %d returned '%*.*s'
\n
"
,
testsize
,
testsize
,
testsize
,
to
);
/* Test 3 - from = to */
memset
(
to
,
'$'
,
sizeof
(
to
));
memset
(
from
,
'@'
,
sizeof
(
from
));
testsize
=
26
;
memcpy
(
to
,
original
,
testsize
);
_swab
(
to
,
to
,
testsize
);
ok
(
memcmp
(
to
,
expected1
,
testsize
)
==
0
,
"Testing overlapped size %d returned '%*.*s'
\n
"
,
testsize
,
testsize
,
testsize
,
to
);
/* Test 4 - 1 bytes */
memset
(
to
,
'$'
,
sizeof
(
to
));
memset
(
from
,
'@'
,
sizeof
(
from
));
testsize
=
1
;
memcpy
(
from
,
original
,
testsize
);
_swab
(
from
,
to
,
testsize
);
ok
(
memcmp
(
to
,
expected3
,
testsize
)
==
0
,
"Testing small size %d returned '%*.*s'
\n
"
,
testsize
,
testsize
,
testsize
,
to
);
}
START_TEST
(
string
)
{
...
...
@@ -48,4 +92,7 @@ START_TEST(string)
pmemcpy
((
char
*
)
mem
+
5
,
mem
,
nLen
+
1
);
ok
(
pmemcmp
((
char
*
)
mem
+
5
,
xilstring
,
nLen
)
==
0
,
"Got result %s
\n
"
,(
char
*
)
mem
+
5
);
/* Test _swab function */
test_swab
();
}
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