Module: wine Branch: stable Commit: 67e1ee25a3cb0290fade9e252b40a44431cdf893 URL: http://source.winehq.org/git/wine.git/?a=commit;h=67e1ee25a3cb0290fade9e252b...
Author: Akihiro Sagawa sagawa.aki@gmail.com Date: Fri Mar 4 23:00:51 2011 +0900
regedit: Export a decent newline in Unicode format. (cherry picked from commit 3c6de3b3485e8ee3a622ef990c5b9042ad28e237)
---
programs/regedit/regproc.c | 25 ++++++++++++++----------- 1 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/programs/regedit/regproc.c b/programs/regedit/regproc.c index f210879..16931d6 100644 --- a/programs/regedit/regproc.c +++ b/programs/regedit/regproc.c @@ -23,6 +23,8 @@
#include <limits.h> #include <stdio.h> +#include <fcntl.h> +#include <io.h> #include <windows.h> #include <winnt.h> #include <winreg.h> @@ -970,9 +972,9 @@ static void REGPROC_export_binary(WCHAR **line_buf, DWORD *line_buf_size, DWORD const WCHAR *hex_prefix; const WCHAR hex[] = {'h','e','x',':',0}; WCHAR hex_buf[17]; - const WCHAR concat[] = {'\','\n',' ',' ',0}; + const WCHAR concat[] = {'\','\r','\n',' ',' ',0}; DWORD concat_prefix, concat_len; - const WCHAR newline[] = {'\n',0}; + const WCHAR newline[] = {'\r','\n',0}; CHAR* value_multibyte = NULL;
if (type == REG_BINARY) { @@ -1081,7 +1083,7 @@ static void export_hkey(FILE *file, HKEY key, DWORD i; BOOL more_data; LONG ret; - WCHAR key_format[] = {'\n','[','%','s',']','\n',0}; + WCHAR key_format[] = {'\r','\n','[','%','s',']','\r','\n',0};
/* get size information and resize the buffers if necessary */ if (RegQueryInfoKeyW(key, NULL, NULL, NULL, NULL, @@ -1151,7 +1153,7 @@ static void export_hkey(FILE *file, HKEY key, REGPROC_export_binary(line_buf, line_buf_size, &line_len, value_type, *val_buf, val_size1, unicode); } else { const WCHAR start[] = {'"',0}; - const WCHAR end[] = {'"','\n',0}; + const WCHAR end[] = {'"','\r','\n',0}; DWORD len;
len = lstrlenW(start); @@ -1172,7 +1174,7 @@ static void export_hkey(FILE *file, HKEY key,
case REG_DWORD: { - WCHAR format[] = {'d','w','o','r','d',':','%','0','8','x','\n',0}; + WCHAR format[] = {'d','w','o','r','d',':','%','0','8','x','\r','\n',0};
REGPROC_resize_char_buffer(line_buf, line_buf_size, line_len + 15); sprintfW(*line_buf + line_len, format, *((DWORD *)*val_buf)); @@ -1237,19 +1239,20 @@ static void export_hkey(FILE *file, HKEY key, }
/****************************************************************************** - * Open file for export. + * Open file in binary mode for export. */ static FILE *REGPROC_open_export_file(WCHAR *file_name, BOOL unicode) { FILE *file; WCHAR dash = '-';
- if (strncmpW(file_name,&dash,1)==0) + if (strncmpW(file_name,&dash,1)==0) { file=stdout; - else + _setmode(_fileno(file), _O_BINARY); + } else { CHAR* file_nameA = GetMultiByteString(file_name); - file = fopen(file_nameA, "w"); + file = fopen(file_nameA, "wb"); if (!file) { perror(""); fprintf(stderr,"%s: Can't open file "%s"\n", getAppName(), file_nameA); @@ -1261,12 +1264,12 @@ static FILE *REGPROC_open_export_file(WCHAR *file_name, BOOL unicode) if(unicode) { const BYTE unicode_seq[] = {0xff,0xfe}; - const WCHAR header[] = {'W','i','n','d','o','w','s',' ','R','e','g','i','s','t','r','y',' ','E','d','i','t','o','r',' ','V','e','r','s','i','o','n',' ','5','.','0','0','\n'}; + const WCHAR header[] = {'W','i','n','d','o','w','s',' ','R','e','g','i','s','t','r','y',' ','E','d','i','t','o','r',' ','V','e','r','s','i','o','n',' ','5','.','0','0','\r','\n'}; fwrite(unicode_seq, sizeof(BYTE), sizeof(unicode_seq)/sizeof(unicode_seq[0]), file); fwrite(header, sizeof(WCHAR), sizeof(header)/sizeof(header[0]), file); } else { - fputs("REGEDIT4\n", file); + fputs("REGEDIT4\r\n", file); }
return file;