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
8d9eb707
Commit
8d9eb707
authored
Nov 20, 2022
by
Nikolay Sivov
Committed by
Alexandre Julliard
Nov 24, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32/profile: Trim spaces from section names on load.
Wine-Bug:
https://bugs.winehq.org/show_bug.cgi?id=53814
Signed-off-by:
Nikolay Sivov
<
nsivov@codeweavers.com
>
parent
1c84acd0
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
5 deletions
+27
-5
profile.c
dlls/kernel32/profile.c
+18
-4
profile.c
dlls/kernel32/tests/profile.c
+9
-1
No files found.
dlls/kernel32/profile.c
View file @
8d9eb707
...
@@ -292,6 +292,16 @@ static inline ENCODING PROFILE_DetectTextEncoding(const void * buffer, int * len
...
@@ -292,6 +292,16 @@ static inline ENCODING PROFILE_DetectTextEncoding(const void * buffer, int * len
return
ENCODING_ANSI
;
return
ENCODING_ANSI
;
}
}
static
void
profile_trim_spaces
(
WCHAR
**
start
,
WCHAR
**
end
)
{
WCHAR
*
s
=
*
start
,
*
e
=
*
end
;
while
(
s
<
e
&&
PROFILE_isspaceW
(
*
s
))
s
++
;
while
((
e
>
s
)
&&
PROFILE_isspaceW
(
e
[
-
1
]))
e
--
;
*
start
=
s
;
*
end
=
e
;
}
/***********************************************************************
/***********************************************************************
* PROFILE_Load
* PROFILE_Load
...
@@ -302,8 +312,8 @@ static PROFILESECTION *PROFILE_Load(HANDLE hFile, ENCODING * pEncoding)
...
@@ -302,8 +312,8 @@ static PROFILESECTION *PROFILE_Load(HANDLE hFile, ENCODING * pEncoding)
{
{
void
*
buffer_base
,
*
pBuffer
;
void
*
buffer_base
,
*
pBuffer
;
WCHAR
*
szFile
;
WCHAR
*
szFile
;
const
WCHAR
*
szLineStart
,
*
szLineEnd
;
WCHAR
*
szLineStart
,
*
szLineEnd
,
*
next_line
;
const
WCHAR
*
szValueStart
,
*
szEnd
,
*
next_line
;
const
WCHAR
*
szValueStart
,
*
szEnd
;
int
len
;
int
len
;
PROFILESECTION
*
section
,
*
first_section
;
PROFILESECTION
*
section
,
*
first_section
;
PROFILESECTION
**
next_section
;
PROFILESECTION
**
next_section
;
...
@@ -400,8 +410,7 @@ static PROFILESECTION *PROFILE_Load(HANDLE hFile, ENCODING * pEncoding)
...
@@ -400,8 +410,7 @@ static PROFILESECTION *PROFILE_Load(HANDLE hFile, ENCODING * pEncoding)
szLineEnd
=
next_line
;
szLineEnd
=
next_line
;
/* get rid of white space */
/* get rid of white space */
while
(
szLineStart
<
szLineEnd
&&
PROFILE_isspaceW
(
*
szLineStart
))
szLineStart
++
;
profile_trim_spaces
(
&
szLineStart
,
&
szLineEnd
);
while
((
szLineEnd
>
szLineStart
)
&&
PROFILE_isspaceW
(
szLineEnd
[
-
1
]))
szLineEnd
--
;
if
(
szLineStart
>=
szLineEnd
)
continue
;
if
(
szLineStart
>=
szLineEnd
)
continue
;
...
@@ -415,8 +424,13 @@ static PROFILESECTION *PROFILE_Load(HANDLE hFile, ENCODING * pEncoding)
...
@@ -415,8 +424,13 @@ static PROFILESECTION *PROFILE_Load(HANDLE hFile, ENCODING * pEncoding)
}
}
else
else
{
{
/* Skip brackets */
szLineStart
++
;
szLineStart
++
;
len
-=
2
;
len
-=
2
;
szLineEnd
=
szLineStart
+
len
;
profile_trim_spaces
(
&
szLineStart
,
&
szLineEnd
);
len
=
szLineEnd
-
szLineStart
;
/* no need to allocate +1 for NULL terminating character as
/* no need to allocate +1 for NULL terminating character as
* already included in structure */
* already included in structure */
if
(
!
(
section
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
*
section
)
+
len
*
sizeof
(
WCHAR
)
)))
if
(
!
(
section
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
*
section
)
+
len
*
sizeof
(
WCHAR
)
)))
...
...
dlls/kernel32/tests/profile.c
View file @
8d9eb707
...
@@ -80,6 +80,7 @@ static void test_profile_int(void)
...
@@ -80,6 +80,7 @@ static void test_profile_int(void)
{
SECTION
,
KEY
,
"B4294967297"
,
TESTFILE
,
1
,
0
},
{
SECTION
,
KEY
,
"B4294967297"
,
TESTFILE
,
1
,
0
},
};
};
int
i
,
num_test
=
ARRAY_SIZE
(
profileInt
);
int
i
,
num_test
=
ARRAY_SIZE
(
profileInt
);
char
section
[
64
];
UINT
res
;
UINT
res
;
DeleteFileA
(
TESTFILE
);
DeleteFileA
(
TESTFILE
);
...
@@ -93,6 +94,12 @@ static void test_profile_int(void)
...
@@ -93,6 +94,12 @@ static void test_profile_int(void)
profileInt
[
i
].
defaultVal
,
profileInt
[
i
].
iniFile
);
profileInt
[
i
].
defaultVal
,
profileInt
[
i
].
iniFile
);
ok
((
res
==
profileInt
[
i
].
result
),
"test<%02d>: ret<%010u> exp<%010u>
\n
"
,
ok
((
res
==
profileInt
[
i
].
result
),
"test<%02d>: ret<%010u> exp<%010u>
\n
"
,
i
,
res
,
profileInt
[
i
].
result
);
i
,
res
,
profileInt
[
i
].
result
);
sprintf
(
section
,
" %s "
,
profileInt
[
i
].
section
);
res
=
GetPrivateProfileIntA
(
profileInt
[
i
].
section
,
profileInt
[
i
].
key
,
profileInt
[
i
].
defaultVal
,
profileInt
[
i
].
iniFile
);
ok
((
res
==
profileInt
[
i
].
result
),
"test<%02d>: ret<%010u> exp<%010u>
\n
"
,
i
,
res
,
profileInt
[
i
].
result
);
}
}
DeleteFileA
(
TESTFILE
);
DeleteFileA
(
TESTFILE
);
...
@@ -270,7 +277,7 @@ static void test_profile_sections_names(void)
...
@@ -270,7 +277,7 @@ static void test_profile_sections_names(void)
DWORD
count
;
DWORD
count
;
char
buf
[
100
];
char
buf
[
100
];
WCHAR
bufW
[
100
];
WCHAR
bufW
[
100
];
static
const
char
content
[]
=
"[
section1
]
\r\n
[section2]
\r\n
[section3]
\r\n
"
;
static
const
char
content
[]
=
"[
section1
]
\r\n
[section2]
\r\n
[section3]
\r\n
"
;
static
const
char
testfile3
[]
=
".
\\
testwine3.ini"
;
static
const
char
testfile3
[]
=
".
\\
testwine3.ini"
;
static
const
WCHAR
testfile3W
[]
=
{
'.'
,
'\\'
,
't'
,
'e'
,
's'
,
't'
,
'w'
,
'i'
,
'n'
,
'e'
,
'3'
,
'.'
,
'i'
,
'n'
,
'i'
,
0
};
static
const
WCHAR
testfile3W
[]
=
{
'.'
,
'\\'
,
't'
,
'e'
,
's'
,
't'
,
'w'
,
'i'
,
'n'
,
'e'
,
'3'
,
'.'
,
'i'
,
'n'
,
'i'
,
0
};
static
const
WCHAR
not_here
[]
=
{
'.'
,
'\\'
,
'n'
,
'o'
,
't'
,
'_'
,
'h'
,
'e'
,
'r'
,
'e'
,
'.'
,
'i'
,
'n'
,
'i'
,
0
};
static
const
WCHAR
not_here
[]
=
{
'.'
,
'\\'
,
'n'
,
'o'
,
't'
,
'_'
,
'h'
,
'e'
,
'r'
,
'e'
,
'.'
,
'i'
,
'n'
,
'i'
,
0
};
...
@@ -288,6 +295,7 @@ static void test_profile_sections_names(void)
...
@@ -288,6 +295,7 @@ static void test_profile_sections_names(void)
ok
(
ret
==
27
,
"expected return size 27, got %d
\n
"
,
ret
);
ok
(
ret
==
27
,
"expected return size 27, got %d
\n
"
,
ret
);
ok
(
(
buf
[
ret
-
1
]
==
0
&&
buf
[
ret
]
==
0
),
ok
(
(
buf
[
ret
-
1
]
==
0
&&
buf
[
ret
]
==
0
),
"returned buffer not terminated with double-null
\n
"
);
"returned buffer not terminated with double-null
\n
"
);
ok
(
!
strcmp
(
buf
,
"section1"
),
"Unexpected content %s.
\n
"
,
debugstr_a
(
buf
));
/* Test with exactly fitting buffer */
/* Test with exactly fitting buffer */
memset
(
buf
,
0xc
,
sizeof
(
buf
));
memset
(
buf
,
0xc
,
sizeof
(
buf
));
...
...
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