Alexander Nicolaysen Sørnes : regedit: Fix concat handling in unicode import.
Alexandre Julliard
julliard at winehq.org
Mon Jul 14 05:57:10 CDT 2008
Module: wine
Branch: master
Commit: 4ef4777630a45971fcf5cf12d9283565a10419fe
URL: http://source.winehq.org/git/wine.git/?a=commit;h=4ef4777630a45971fcf5cf12d9283565a10419fe
Author: Alexander Nicolaysen Sørnes <alex at thehandofagony.com>
Date: Sun Jul 13 13:58:40 2008 +0200
regedit: Fix concat handling in unicode import.
---
programs/regedit/regproc.c | 42 +++++++++++++++++++++++-------------------
1 files changed, 23 insertions(+), 19 deletions(-)
diff --git a/programs/regedit/regproc.c b/programs/regedit/regproc.c
index a716f3d..2b2daf1 100644
--- a/programs/regedit/regproc.c
+++ b/programs/regedit/regproc.c
@@ -704,7 +704,7 @@ void processRegLinesW(FILE *in)
{
WCHAR* buf = NULL; /* line read from input stream */
ULONG lineSize = REG_VAL_BUF_SIZE;
- size_t check = -1;
+ size_t CharsInBuf = -1;
WCHAR* s; /* The pointer into line for where the current fgets should read */
@@ -741,10 +741,10 @@ void processRegLinesW(FILE *in)
*/
size_to_get = (size_remaining > INT_MAX ? INT_MAX : size_remaining);
- check = fread(s, sizeof(WCHAR), size_to_get - 1, in);
- s[check] = 0;
+ CharsInBuf = fread(s, sizeof(WCHAR), size_to_get - 1, in);
+ s[CharsInBuf] = 0;
- if (check == 0) {
+ if (CharsInBuf == 0) {
if (ferror(in)) {
perror ("While reading input");
exit (IO_ERROR);
@@ -772,6 +772,25 @@ void processRegLinesW(FILE *in)
continue;
}
+ /* If there is a concatenating \\ then go around again */
+ if ((*(s_eol-1) == '\\') ||
+ (*(s_eol-1) == '\r' && *(s_eol-2) == '\\')) {
+ WCHAR* NextLine = s_eol;
+
+ while(*(NextLine+1) == ' ' || *(NextLine+1) == '\t')
+ NextLine++;
+
+ NextLine++;
+
+ if(*(s_eol-1) == '\r')
+ s_eol--;
+
+ MoveMemory(s_eol - 1, NextLine, (CharsInBuf - (NextLine - buf) + 1)*sizeof(WCHAR));
+ CharsInBuf -= NextLine - s_eol + 1;
+ s_eol = 0;
+ continue;
+ }
+
/* Remove any line feed. Leave s_eol on the \0 */
if (s_eol) {
*s_eol = '\0';
@@ -779,21 +798,6 @@ void processRegLinesW(FILE *in)
*(s_eol-1) = '\0';
}
- /* If there is a concatenating \\ then go around again */
- if (s_eol > buf && *(s_eol-1) == '\\') {
- WCHAR c[2];
- s = s_eol+1;
- /* The following error protection could be made more self-
- * correcting but I thought it not worth trying.
- */
- if(!fread(&c, sizeof(WCHAR), 2, in))
- break;
- if (feof(in) || c[0] != ' ' || c[1] != ' ')
- fprintf(stderr,"%s: ERROR - invalid continuation.\n",
- getAppName());
- continue;
- }
-
if(!s_eol)
break;
More information about the wine-cvs
mailing list