Alexander Scott-Johns : notepad: When opening a file, replace \0 characters with spaces, instead of truncating the file at the first \0.

Alexandre Julliard julliard at winehq.org
Mon Jul 6 09:33:58 CDT 2009


Module: wine
Branch: master
Commit: 32c066f12abbf3864ec75b5cb6e9fb08c288c50b
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=32c066f12abbf3864ec75b5cb6e9fb08c288c50b

Author: Alexander Scott-Johns <alexander.scott.johns at googlemail.com>
Date:   Fri Jul  3 01:04:00 2009 +0100

notepad: When opening a file, replace \0 characters with spaces, instead of truncating the file at the first \0.

---

 programs/notepad/dialog.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/programs/notepad/dialog.c b/programs/notepad/dialog.c
index eae0d30..5594069 100644
--- a/programs/notepad/dialog.c
+++ b/programs/notepad/dialog.c
@@ -346,6 +346,7 @@ void DoOpenFile(LPCWSTR szFileName, ENCODING enc)
     DWORD dwNumRead;
     int lenW;
     WCHAR* textW;
+    int i;
     WCHAR log[5];
 
     /* Close any files and prompt to save changes */
@@ -433,6 +434,12 @@ void DoOpenFile(LPCWSTR szFileName, ENCODING enc)
         }
     }
 
+    /* Replace '\0's with spaces. Other than creating a custom control that
+     * can deal with '\0' characters, it's the best that can be done.
+     */
+    for (i = 0; i < lenW; i++)
+        if (textW[i] == '\0')
+            textW[i] = ' ';
     textW[lenW] = '\0';
 
     if (lenW >= 1 && textW[0] == 0xfeff)




More information about the wine-cvs mailing list