regedit: Return a Unicode line from get_lineA().

Signed-off-by: Hugh McMaster <hugh.mcmaster@outlook.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hugh McMaster 2017-05-03 11:28:26 +00:00 committed by Alexandre Julliard
parent 6b596ecf9e
commit 76b9e6c712
1 changed files with 17 additions and 18 deletions

View File

@ -671,12 +671,15 @@ static enum reg_versions parse_file_header(WCHAR *s)
return REG_VERSION_INVALID; return REG_VERSION_INVALID;
} }
static char *get_lineA(FILE *fp) static WCHAR *get_lineA(FILE *fp)
{ {
static WCHAR *lineW;
static size_t size; static size_t size;
static char *buf, *next; static char *buf, *next;
char *line; char *line;
HeapFree(GetProcessHeap(), 0, lineW);
if (!fp) goto cleanup; if (!fp) goto cleanup;
if (!size) if (!size)
@ -707,7 +710,8 @@ static char *get_lineA(FILE *fp)
if (!(count = fread(buf + len, 1, size - len - 1, fp))) if (!(count = fread(buf + len, 1, size - len - 1, fp)))
{ {
next = NULL; next = NULL;
return buf; lineW = GetWideString(buf);
return lineW;
} }
buf[len + count] = 0; buf[len + count] = 0;
next = buf; next = buf;
@ -730,10 +734,12 @@ static char *get_lineA(FILE *fp)
line = next; line = next;
continue; continue;
} }
return line; lineW = GetWideString(line);
return lineW;
} }
cleanup: cleanup:
lineW = NULL;
if (size) HeapFree(GetProcessHeap(), 0, buf); if (size) HeapFree(GetProcessHeap(), 0, buf);
size = 0; size = 0;
return NULL; return NULL;
@ -741,22 +747,19 @@ cleanup:
static BOOL processRegLinesA(FILE *fp, char *two_chars) static BOOL processRegLinesA(FILE *fp, char *two_chars)
{ {
char *line, *header; WCHAR *line, *header;
WCHAR *lineW;
int reg_version; int reg_version;
line = get_lineA(fp); line = get_lineA(fp);
header = HeapAlloc(GetProcessHeap(), 0, strlen(line) + 3); header = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(line) + 3) * sizeof(WCHAR));
CHECK_ENOUGH_MEMORY(header); CHECK_ENOUGH_MEMORY(header);
strcpy(header, two_chars); header[0] = two_chars[0];
strcpy(header + 2, line); header[1] = two_chars[1];
lstrcpyW(header + 2, line);
lineW = GetWideString(header); reg_version = parse_file_header(header);
HeapFree(GetProcessHeap(), 0, 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) if (reg_version == REG_VERSION_FUZZY || reg_version == REG_VERSION_INVALID)
{ {
get_lineA(NULL); /* Reset static variables */ get_lineA(NULL); /* Reset static variables */
@ -765,14 +768,10 @@ static BOOL processRegLinesA(FILE *fp, char *two_chars)
while ((line = get_lineA(fp))) while ((line = get_lineA(fp)))
{ {
lineW = GetWideString(line);
if (reg_version == REG_VERSION_31) if (reg_version == REG_VERSION_31)
processRegEntry31(lineW); processRegEntry31(line);
else else
processRegEntry(lineW, FALSE); processRegEntry(line, FALSE);
HeapFree(GetProcessHeap(), 0, lineW);
} }
closeKey(); closeKey();