Hugh McMaster : regedit: Return a Unicode line from get_lineA().
Alexandre Julliard
julliard at winehq.org
Wed May 3 16:06:15 CDT 2017
Module: wine
Branch: master
Commit: 76b9e6c712bfa129afec746f4e986a5fbdedbd98
URL: http://source.winehq.org/git/wine.git/?a=commit;h=76b9e6c712bfa129afec746f4e986a5fbdedbd98
Author: Hugh McMaster <hugh.mcmaster at outlook.com>
Date: Wed May 3 11:28:26 2017 +0000
regedit: Return a Unicode line from get_lineA().
Signed-off-by: Hugh McMaster <hugh.mcmaster at outlook.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
programs/regedit/regproc.c | 35 +++++++++++++++++------------------
1 file changed, 17 insertions(+), 18 deletions(-)
diff --git a/programs/regedit/regproc.c b/programs/regedit/regproc.c
index 9740293..282800e 100644
--- a/programs/regedit/regproc.c
+++ b/programs/regedit/regproc.c
@@ -671,12 +671,15 @@ static enum reg_versions parse_file_header(WCHAR *s)
return REG_VERSION_INVALID;
}
-static char *get_lineA(FILE *fp)
+static WCHAR *get_lineA(FILE *fp)
{
+ static WCHAR *lineW;
static size_t size;
static char *buf, *next;
char *line;
+ HeapFree(GetProcessHeap(), 0, lineW);
+
if (!fp) goto cleanup;
if (!size)
@@ -707,7 +710,8 @@ static char *get_lineA(FILE *fp)
if (!(count = fread(buf + len, 1, size - len - 1, fp)))
{
next = NULL;
- return buf;
+ lineW = GetWideString(buf);
+ return lineW;
}
buf[len + count] = 0;
next = buf;
@@ -730,10 +734,12 @@ static char *get_lineA(FILE *fp)
line = next;
continue;
}
- return line;
+ lineW = GetWideString(line);
+ return lineW;
}
cleanup:
+ lineW = NULL;
if (size) HeapFree(GetProcessHeap(), 0, buf);
size = 0;
return NULL;
@@ -741,22 +747,19 @@ cleanup:
static BOOL processRegLinesA(FILE *fp, char *two_chars)
{
- char *line, *header;
- WCHAR *lineW;
+ WCHAR *line, *header;
int reg_version;
line = get_lineA(fp);
- header = HeapAlloc(GetProcessHeap(), 0, strlen(line) + 3);
+ header = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(line) + 3) * sizeof(WCHAR));
CHECK_ENOUGH_MEMORY(header);
- strcpy(header, two_chars);
- strcpy(header + 2, line);
+ header[0] = two_chars[0];
+ header[1] = two_chars[1];
+ lstrcpyW(header + 2, line);
- lineW = GetWideString(header);
+ reg_version = parse_file_header(header);
HeapFree(GetProcessHeap(), 0, header);
-
- reg_version = parse_file_header(lineW);
- HeapFree(GetProcessHeap(), 0, lineW);
if (reg_version == REG_VERSION_FUZZY || reg_version == REG_VERSION_INVALID)
{
get_lineA(NULL); /* Reset static variables */
@@ -765,14 +768,10 @@ static BOOL processRegLinesA(FILE *fp, char *two_chars)
while ((line = get_lineA(fp)))
{
- lineW = GetWideString(line);
-
if (reg_version == REG_VERSION_31)
- processRegEntry31(lineW);
+ processRegEntry31(line);
else
- processRegEntry(lineW, FALSE);
-
- HeapFree(GetProcessHeap(), 0, lineW);
+ processRegEntry(line, FALSE);
}
closeKey();
More information about the wine-cvs
mailing list