Michael Stefaniuc : riched20: Use zero terminated wchar strings.

Alexandre Julliard julliard at winehq.org
Thu Nov 19 16:10:22 CST 2020


Module: wine
Branch: master
Commit: 80620171ecd6d948499aeda4c6ecf968534cd431
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=80620171ecd6d948499aeda4c6ecf968534cd431

Author: Michael Stefaniuc <mstefani at winehq.org>
Date:   Sun Nov 15 23:11:16 2020 +0100

riched20: Use zero terminated wchar strings.

Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/riched20/editor.c | 17 ++++++-----------
 dlls/riched20/writer.c |  4 +---
 2 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index ee392f6fa6a..d89735acc82 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -627,10 +627,9 @@ void ME_RTFParAttrHook(RTF_Info *info)
         else
         {
           ME_Cursor cursor;
-          WCHAR endl = '\r';
           cursor = info->editor->pCursors[0];
           if (cursor.nOffset || cursor.run->nCharOfs)
-            ME_InsertTextFromCursor(info->editor, 0, &endl, 1, info->style);
+            ME_InsertTextFromCursor(info->editor, 0, L"\r", 1, info->style);
           tableDef->row_start = table_insert_row_start( info->editor, info->editor->pCursors );
         }
 
@@ -1079,8 +1078,6 @@ void ME_RTFSpecialCharHook(RTF_Info *info)
       }
       else /* v1.0 - v3.0 */
       {
-        WCHAR endl = '\r';
-
         para = info->editor->pCursors[0].para;
         para->fmt.dxOffset = info->tableDef->gapH;
         para->fmt.dxStartIndent = info->tableDef->leftEdge;
@@ -1094,7 +1091,7 @@ void ME_RTFSpecialCharHook(RTF_Info *info)
         }
         para->fmt.cTabCount = min(tableDef->numCellsDefined, MAX_TAB_STOPS);
         if (!tableDef->numCellsDefined) para->fmt.wEffects &= ~PFE_TABLE;
-        ME_InsertTextFromCursor(info->editor, 0, &endl, 1, info->style);
+        ME_InsertTextFromCursor(info->editor, 0, L"\r", 1, info->style);
         tableDef->numCellsInserted = 0;
       }
       break;
@@ -2488,8 +2485,6 @@ static BOOL handle_enter(ME_TextEditor *editor)
 
     if (editor->styleFlags & ES_MULTILINE)
     {
-        static const WCHAR endl = '\r';
-        static const WCHAR endlv10[] = {'\r','\n'};
         ME_Cursor cursor = editor->pCursors[0];
         ME_Paragraph *para = cursor.para;
         int from, to;
@@ -2530,7 +2525,7 @@ static BOOL handle_enter(ME_TextEditor *editor)
                     editor->pCursors[0].para = para;
                     editor->pCursors[0].run = para_first_run( para );
                     editor->pCursors[1] = editor->pCursors[0];
-                    ME_InsertTextFromCursor( editor, 0, &endl, 1, editor->pCursors[0].run->style );
+                    ME_InsertTextFromCursor( editor, 0, L"\r", 1, editor->pCursors[0].run->style );
                     para = editor_first_para( editor );
                     editor_set_default_para_fmt( editor, &para->fmt );
                     para->nFlags = 0;
@@ -2579,7 +2574,7 @@ static BOOL handle_enter(ME_TextEditor *editor)
                             }
                             editor->pCursors[0].nOffset = 0;
                             editor->pCursors[1] = editor->pCursors[0];
-                            ME_InsertTextFromCursor( editor, 0, &endl, 1, editor->pCursors[0].run->style );
+                            ME_InsertTextFromCursor( editor, 0, L"\r", 1, editor->pCursors[0].run->style );
                         }
                         else
                         {
@@ -2611,9 +2606,9 @@ static BOOL handle_enter(ME_TextEditor *editor)
                 ME_InsertEndRowFromCursor(editor, 0);
             else
                 if (!editor->bEmulateVersion10)
-                    ME_InsertTextFromCursor(editor, 0, &endl, 1, eop_style);
+                    ME_InsertTextFromCursor(editor, 0, L"\r", 1, eop_style);
                 else
-                    ME_InsertTextFromCursor(editor, 0, endlv10, 2, eop_style);
+                    ME_InsertTextFromCursor(editor, 0, L"\r\n", 2, eop_style);
             ME_CommitCoalescingUndo(editor);
             SetCursor(NULL);
 
diff --git a/dlls/riched20/writer.c b/dlls/riched20/writer.c
index 49cbb0e021f..50eccfa714b 100644
--- a/dlls/riched20/writer.c
+++ b/dlls/riched20/writer.c
@@ -1139,11 +1139,9 @@ static BOOL ME_StreamOutText(ME_TextEditor *editor, ME_OutStream *pStream,
 
     if (!editor->bEmulateVersion10 && cursor.run->nFlags & MERF_ENDPARA)
     {
-      static const WCHAR szEOL[] = { '\r', '\n' };
-
       /* richedit 2.0 - all line breaks are \r\n */
       if (dwFormat & SF_UNICODE)
-        success = ME_StreamOutMove(pStream, (const char *)szEOL, sizeof(szEOL));
+        success = ME_StreamOutMove(pStream, (const char *)L"\r\n", 2 * sizeof(WCHAR));
       else
         success = ME_StreamOutMove(pStream, "\r\n", 2);
     } else {




More information about the wine-cvs mailing list