Commit d1d3db41 authored by Francois Gouget's avatar Francois Gouget Committed by Alexandre Julliard

regedit: Simplify REGPROC_export_string().

parent 7f707b30
...@@ -892,49 +892,37 @@ static void REGPROC_resize_char_buffer(WCHAR **buffer, DWORD *len, DWORD require ...@@ -892,49 +892,37 @@ static void REGPROC_resize_char_buffer(WCHAR **buffer, DWORD *len, DWORD require
static void REGPROC_export_string(WCHAR **line_buf, DWORD *line_buf_size, DWORD *line_len, WCHAR *str) static void REGPROC_export_string(WCHAR **line_buf, DWORD *line_buf_size, DWORD *line_len, WCHAR *str)
{ {
DWORD len = lstrlenW(str); DWORD len = lstrlenW(str);
DWORD i; DWORD i, pos;
DWORD extra = 0; DWORD extra = 0;
REGPROC_resize_char_buffer(line_buf, line_buf_size, *line_len + len + 10); REGPROC_resize_char_buffer(line_buf, line_buf_size, *line_len + len + 10);
/* escaping characters */ /* escaping characters */
pos = *line_len;
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
WCHAR c = str[i]; WCHAR c = str[i];
switch (c) { switch (c) {
case '\\': case '\n':
{
const WCHAR escape[] = {'\\','\\'};
REGPROC_resize_char_buffer(line_buf, line_buf_size, *line_len + len + extra + 1);
memcpy(*line_buf + *line_len + i + extra, escape, 2 * sizeof(WCHAR));
extra++; extra++;
REGPROC_resize_char_buffer(line_buf, line_buf_size, *line_len + len + extra);
(*line_buf)[pos++] = '\\';
(*line_buf)[pos++] = 'n';
break; break;
}
case '"':
{
const WCHAR escape[] = {'\\','"'};
REGPROC_resize_char_buffer(line_buf, line_buf_size, *line_len + len + extra + 1); case '\\':
memcpy(*line_buf + *line_len + i + extra, escape, 2 * sizeof(WCHAR)); case '"':
extra++; extra++;
break; REGPROC_resize_char_buffer(line_buf, line_buf_size, *line_len + len + extra);
} (*line_buf)[pos++] = '\\';
case '\n': /* Fall through */
{
const WCHAR escape[] = {'\\','n'};
REGPROC_resize_char_buffer(line_buf, line_buf_size, *line_len + len + extra + 1);
memcpy(*line_buf + *line_len + i + extra, escape, 2 * sizeof(WCHAR));
extra++;
break;
}
default: default:
memcpy(*line_buf + *line_len + i + extra, &c, sizeof(WCHAR)); (*line_buf)[pos++] = c;
break; break;
} }
} }
*line_len += len + extra; (*line_buf)[pos] = '\0';
*(*line_buf + *line_len) = 0; *line_len = pos;
} }
/****************************************************************************** /******************************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment